Token Digit Deposit

 

Overview ERC-721

Total Supply:
151 DIGI

Holders:
94 addresses

Transfers:
-

Loading
[ Download CSV Export  ] 
Loading
[ Download CSV Export  ] 
Loading

Click here to update the token ICO / general information
# Exchange Pair Price  24H Volume % Volume
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Reliquary

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 28 : Reliquary.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./ReliquaryEvents.sol";
import "./interfaces/IReliquary.sol";
import "./interfaces/IEmissionCurve.sol";
import "./interfaces/IRewarder.sol";
import "./interfaces/INFTDescriptor.sol";
import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "openzeppelin-contracts/contracts/utils/Multicall.sol";
import "openzeppelin-contracts/contracts/access/AccessControlEnumerable.sol";
import "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";

/**
 * @title Reliquary
 * @author Justin Bebis, Zokunei & the Byte Masons team
 *
 * @notice This system is designed to manage incentives for deposited assets such that
 * behaviors can be programmed on a per-pool basis using maturity levels. Stake in a
 * pool, also referred to as "position," is represented by means of an NFT called a
 * "Relic." Each position has a "maturity" which captures the age of the position.
 *
 * @notice Deposits are tracked by Relic ID instead of by user. This allows for
 * increased composability without affecting accounting logic too much, and users can
 * trade their Relics without withdrawing liquidity or affecting the position's maturity.
 */
contract Reliquary is
    IReliquary,
    ERC721Burnable,
    ERC721Enumerable,
    AccessControlEnumerable,
    Multicall,
    ReentrancyGuard
{
    using SafeERC20 for IERC20;

    /// @dev Access control roles.
    bytes32 private constant OPERATOR = keccak256("OPERATOR");
    bytes32 private constant EMISSION_CURVE = keccak256("EMISSION_CURVE");

    /// @dev Indicates whether tokens are being added to, or removed from, a pool.
    enum Kind {
        DEPOSIT,
        WITHDRAW,
        OTHER
    }

    /// @dev Level of precision rewards are calculated to.
    uint private constant ACC_REWARD_PRECISION = 1e12;

    /// @dev Nonce to use for new relicId.
    uint private idNonce;

    /// @notice Address of the reward token contract.
    address public immutable rewardToken;
    /// @notice Address of each NFTDescriptor contract.
    address[] public nftDescriptor;
    /// @notice Address of EmissionCurve contract.
    address public emissionCurve;
    /// @notice Info of each Reliquary pool.
    PoolInfo[] private poolInfo;
    /// @notice Level system for each Reliquary pool.
    LevelInfo[] private levels;
    /// @notice Address of the LP token for each Reliquary pool.
    address[] public poolToken;
    /// @notice Address of IRewarder contract for each Reliquary pool.
    address[] public rewarder;

    /// @notice Info of each staked position.
    mapping(uint => PositionInfo) internal positionForId;

    /// @dev Total allocation points. Must be the sum of all allocation points in all pools.
    uint public totalAllocPoint;

    error NonExistentRelic();
    error BurningPrincipal();
    error BurningRewards();
    error RewardTokenAsPoolToken();
    error EmptyArray();
    error ArrayLengthMismatch();
    error NonZeroFirstMaturity();
    error UnsortedMaturityLevels();
    error ZeroTotalAllocPoint();
    error NonExistentPool();
    error ZeroAmount();
    error NotOwner();
    error DuplicateRelicIds();
    error RelicsNotOfSamePool();
    error MergingEmptyRelics();
    error MaxEmissionRateExceeded();
    error NotApprovedOrOwner();
    error PartialWithdrawalsDisabled();

    /**
     * @dev Constructs and initializes the contract.
     * @param _rewardToken The reward token contract address.
     * @param _emissionCurve The contract address for the EmissionCurve, which will return the emission rate.
     */
    constructor(address _rewardToken, address _emissionCurve, string memory name, string memory symbol)
        ERC721(name, symbol)
    {
        rewardToken = _rewardToken;
        emissionCurve = _emissionCurve;
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /// @notice Sets a new EmissionCurve for overall rewardToken emissions. Can only be called with the proper role.
    /// @param _emissionCurve The contract address for the EmissionCurve, which will return the base emission rate.
    function setEmissionCurve(address _emissionCurve) external override onlyRole(EMISSION_CURVE) {
        emissionCurve = _emissionCurve;
        emit ReliquaryEvents.LogSetEmissionCurve(_emissionCurve);
    }

    /**
     * @notice Add a new pool for the specified LP. Can only be called by an operator.
     * @param allocPoint The allocation points for the new pool.
     * @param _poolToken Address of the pooled ERC-20 token.
     * @param _rewarder Address of the rewarder delegate.
     * @param requiredMaturities Array of maturity (in seconds) required to achieve each level for this pool.
     * @param levelMultipliers The multipliers applied to the amount of `_poolToken` for each level within this pool.
     * @param name Name of pool to be displayed in NFT image.
     * @param _nftDescriptor The contract address for NFTDescriptor, which will return the token URI.
     * @param allowPartialWithdrawals Whether users can withdraw less than their entire position. A value of false
     * will also disable shift and split functionality. This is useful for adding pools with decreasing levelMultipliers.
     */
    function addPool(
        uint allocPoint,
        address _poolToken,
        address _rewarder,
        uint[] calldata requiredMaturities,
        uint[] calldata levelMultipliers,
        string memory name,
        address _nftDescriptor,
        bool allowPartialWithdrawals
    ) external override onlyRole(OPERATOR) {
        if (_poolToken == rewardToken) revert RewardTokenAsPoolToken();
        if (requiredMaturities.length == 0) revert EmptyArray();
        if (requiredMaturities.length != levelMultipliers.length) revert ArrayLengthMismatch();
        if (requiredMaturities[0] != 0) revert NonZeroFirstMaturity();
        if (requiredMaturities.length > 1) {
            uint highestMaturity;
            for (uint i = 1; i < requiredMaturities.length;) {
                if (requiredMaturities[i] <= highestMaturity) revert UnsortedMaturityLevels();
                highestMaturity = requiredMaturities[i];
                unchecked {
                    ++i;
                }
            }
        }

        for (uint i; i < poolLength();) {
            _updatePool(i);
            unchecked {
                ++i;
            }
        }

        uint totalAlloc = totalAllocPoint + allocPoint;
        if (totalAlloc == 0) revert ZeroTotalAllocPoint();
        totalAllocPoint = totalAlloc;
        poolToken.push(_poolToken);
        rewarder.push(_rewarder);
        nftDescriptor.push(_nftDescriptor);

        poolInfo.push(
            PoolInfo({
                allocPoint: allocPoint,
                lastRewardTime: block.timestamp,
                accRewardPerShare: 0,
                name: name,
                allowPartialWithdrawals: allowPartialWithdrawals
            })
        );
        levels.push(
            LevelInfo({
                requiredMaturities: requiredMaturities,
                multipliers: levelMultipliers,
                balance: new uint[](levelMultipliers.length)
            })
        );

        emit ReliquaryEvents.LogPoolAddition(
            (poolToken.length - 1), allocPoint, _poolToken, _rewarder, _nftDescriptor, allowPartialWithdrawals
        );
    }

    /**
     * @notice Modify the given pool's properties. Can only be called by an operator.
     * @param pid The index of the pool. See poolInfo.
     * @param allocPoint New AP of the pool.
     * @param _rewarder Address of the rewarder delegate.
     * @param name Name of pool to be displayed in NFT image.
     * @param _nftDescriptor The contract address for NFTDescriptor, which will return the token URI.
     * @param overwriteRewarder True if _rewarder should be set. Otherwise _rewarder is ignored.
     */
    function modifyPool(
        uint pid,
        uint allocPoint,
        address _rewarder,
        string calldata name,
        address _nftDescriptor,
        bool overwriteRewarder
    ) external override onlyRole(OPERATOR) {
        if (pid >= poolInfo.length) revert NonExistentPool();

        uint length = poolLength();
        for (uint i; i < length;) {
            _updatePool(i);
            unchecked {
                ++i;
            }
        }

        PoolInfo storage pool = poolInfo[pid];
        uint totalAlloc = totalAllocPoint + allocPoint - pool.allocPoint;
        if (totalAlloc == 0) revert ZeroTotalAllocPoint();
        totalAllocPoint = totalAlloc;
        pool.allocPoint = allocPoint;

        if (overwriteRewarder) {
            rewarder[pid] = _rewarder;
        }

        pool.name = name;
        nftDescriptor[pid] = _nftDescriptor;

        emit ReliquaryEvents.LogPoolModified(
            pid, allocPoint, overwriteRewarder ? _rewarder : rewarder[pid], _nftDescriptor
        );
    }

    /// @notice Update reward variables for all pools. Be careful of gas spending!
    /// @param pids Pool IDs of all to be updated. Make sure to update all active pools.
    function massUpdatePools(uint[] calldata pids) external override nonReentrant {
        for (uint i; i < pids.length;) {
            _updatePool(pids[i]);
            unchecked {
                ++i;
            }
        }
    }

    /// @notice Update reward variables of the given pool.
    /// @param pid The index of the pool. See poolInfo.
    function updatePool(uint pid) external override nonReentrant {
        _updatePool(pid);
    }

    /**
     * @notice Deposit pool tokens to Reliquary for reward token allocation.
     * @param amount Token amount to deposit.
     * @param relicId NFT ID of the position being deposited to.
     */
    function deposit(uint amount, uint relicId) external override nonReentrant {
        _requireApprovedOrOwner(relicId);
        _deposit(amount, relicId);
    }

    /**
     * @notice Withdraw pool tokens.
     * @param amount token amount to withdraw.
     * @param relicId NFT ID of the position being withdrawn.
     */
    function withdraw(uint amount, uint relicId) external override nonReentrant {
        if (amount == 0) revert ZeroAmount();
        _requireApprovedOrOwner(relicId);

        (uint poolId,) = _updatePosition(amount, relicId, Kind.WITHDRAW, address(0));

        IERC20(poolToken[poolId]).safeTransfer(msg.sender, amount);

        emit ReliquaryEvents.Withdraw(poolId, amount, msg.sender, relicId);
    }

    /**
     * @notice Harvest proceeds for transaction sender to owner of Relic `relicId`.
     * @param relicId NFT ID of the position being harvested.
     * @param harvestTo Address to send rewards to (zero address if harvest should not be performed).
     */
    function harvest(uint relicId, address harvestTo) external override nonReentrant {
        _requireApprovedOrOwner(relicId);

        (uint poolId, uint _pendingReward) = _updatePosition(0, relicId, Kind.OTHER, harvestTo);

        emit ReliquaryEvents.Harvest(poolId, _pendingReward, harvestTo, relicId);
    }

    /**
     * @notice Withdraw pool tokens and harvest proceeds for transaction sender to owner of Relic `relicId`.
     * @param amount token amount to withdraw.
     * @param relicId NFT ID of the position being withdrawn and harvested.
     * @param harvestTo Address to send rewards to (zero address if harvest should not be performed).
     */
    function withdrawAndHarvest(uint amount, uint relicId, address harvestTo) external override nonReentrant {
        if (amount == 0) revert ZeroAmount();
        _requireApprovedOrOwner(relicId);

        (uint poolId, uint _pendingReward) = _updatePosition(amount, relicId, Kind.WITHDRAW, harvestTo);

        IERC20(poolToken[poolId]).safeTransfer(msg.sender, amount);

        emit ReliquaryEvents.Withdraw(poolId, amount, msg.sender, relicId);
        emit ReliquaryEvents.Harvest(poolId, _pendingReward, harvestTo, relicId);
    }

    /**
     * @notice Withdraw without caring about rewards. EMERGENCY ONLY.
     * @param relicId NFT ID of the position to emergency withdraw from and burn.
     */
    function emergencyWithdraw(uint relicId) external override nonReentrant {
        address to = ownerOf(relicId);
        if (to != msg.sender) revert NotOwner();

        PositionInfo storage position = positionForId[relicId];
        uint amount = position.amount;
        uint poolId = position.poolId;

        levels[poolId].balance[position.level] -= amount;

        _burn(relicId);
        delete positionForId[relicId];

        IERC20(poolToken[poolId]).safeTransfer(to, amount);

        emit ReliquaryEvents.EmergencyWithdraw(poolId, amount, to, relicId);
    }

    /// @notice Update position without performing a deposit/withdraw/harvest.
    /// @param relicId The NFT ID of the position being updated.
    function updatePosition(uint relicId) external override nonReentrant {
        if (!_exists(relicId)) revert NonExistentRelic();
        _updatePosition(0, relicId, Kind.OTHER, address(0));
    }

    /// @notice Returns a PositionInfo object for the given relicId.
    function getPositionForId(uint relicId) external view override returns (PositionInfo memory position) {
        position = positionForId[relicId];
    }

    /// @notice Returns a PoolInfo object for pool ID `pid`.
    function getPoolInfo(uint pid) external view override returns (PoolInfo memory pool) {
        pool = poolInfo[pid];
    }

    /// @notice Returns a LevelInfo object for pool ID `pid`.
    function getLevelInfo(uint pid) external view override returns (LevelInfo memory levelInfo) {
        levelInfo = levels[pid];
    }

    /**
     * @notice View function to retrieve the relicIds, poolIds, and pendingReward for each Relic owned by an address.
     * @param owner Address of the owner to retrieve info for.
     * @return pendingRewards Array of PendingReward objects.
     */
    function pendingRewardsOfOwner(address owner)
        external
        view
        override
        returns (PendingReward[] memory pendingRewards)
    {
        uint balance = balanceOf(owner);
        pendingRewards = new PendingReward[](balance);
        for (uint i; i < balance;) {
            uint relicId = tokenOfOwnerByIndex(owner, i);
            pendingRewards[i] = PendingReward({
                relicId: relicId,
                poolId: positionForId[relicId].poolId,
                pendingReward: pendingReward(relicId)
            });
            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice View function to retrieve owned positions for an address.
     * @param owner Address of the owner to retrieve info for.
     * @return relicIds Each relicId owned by the given address.
     * @return positionInfos The PositionInfo object for each relicId.
     */
    function relicPositionsOfOwner(address owner)
        external
        view
        override
        returns (uint[] memory relicIds, PositionInfo[] memory positionInfos)
    {
        uint balance = balanceOf(owner);
        relicIds = new uint[](balance);
        positionInfos = new PositionInfo[](balance);
        for (uint i; i < balance;) {
            relicIds[i] = tokenOfOwnerByIndex(owner, i);
            positionInfos[i] = positionForId[relicIds[i]];
            unchecked {
                ++i;
            }
        }
    }

    /// @notice Returns whether `spender` is allowed to manage Relic `relicId`.
    function isApprovedOrOwner(address spender, uint relicId) external view override returns (bool) {
        return _isApprovedOrOwner(spender, relicId);
    }

    /**
     * @notice Create a new Relic NFT and deposit into this position.
     * @param to Address to mint the Relic to.
     * @param pid The index of the pool. See poolInfo.
     * @param amount Token amount to deposit.
     */
    function createRelicAndDeposit(address to, uint pid, uint amount)
        public
        virtual
        override
        nonReentrant
        returns (uint id)
    {
        if (pid >= poolInfo.length) revert NonExistentPool();
        id = _mint(to);
        PositionInfo storage position = positionForId[id];
        position.poolId = pid;
        _deposit(amount, id);
        emit ReliquaryEvents.CreateRelic(pid, to, id);
    }

    /**
     * @notice Split an owned Relic into a new one, while maintaining maturity.
     * @param fromId The NFT ID of the Relic to split from.
     * @param amount Amount to move from existing Relic into the new one.
     * @param to Address to mint the Relic to.
     * @return newId The NFT ID of the new Relic.
     */
    function split(uint fromId, uint amount, address to) public virtual override nonReentrant returns (uint newId) {
        if (amount == 0) revert ZeroAmount();
        _requireApprovedOrOwner(fromId);

        PositionInfo storage fromPosition = positionForId[fromId];
        uint poolId = fromPosition.poolId;
        if (!poolInfo[poolId].allowPartialWithdrawals) revert PartialWithdrawalsDisabled();

        uint fromAmount = fromPosition.amount;
        uint newFromAmount = fromAmount - amount;
        fromPosition.amount = newFromAmount;

        newId = _mint(to);
        PositionInfo storage newPosition = positionForId[newId];
        newPosition.amount = amount;
        newPosition.entry = fromPosition.entry;
        uint level = fromPosition.level;
        newPosition.level = level;
        newPosition.poolId = poolId;

        uint multiplier = _updatePool(poolId) * levels[poolId].multipliers[level];
        uint pendingFrom = fromAmount * multiplier / ACC_REWARD_PRECISION - fromPosition.rewardDebt;
        if (pendingFrom != 0) {
            fromPosition.rewardCredit += pendingFrom;
        }
        fromPosition.rewardDebt = newFromAmount * multiplier / ACC_REWARD_PRECISION;
        newPosition.rewardDebt = amount * multiplier / ACC_REWARD_PRECISION;

        emit ReliquaryEvents.CreateRelic(poolId, to, newId);
        emit ReliquaryEvents.Split(fromId, newId, amount);
    }

    struct LocalVariables_shift {
        uint fromAmount;
        uint poolId;
        uint toAmount;
        uint newFromAmount;
        uint newToAmount;
        uint fromLevel;
        uint oldToLevel;
        uint newToLevel;
        uint accRewardPerShare;
        uint fromMultiplier;
        uint pendingFrom;
        uint pendingTo;
    }

    /**
     * @notice Transfer amount from one Relic into another, updating maturity in the receiving Relic.
     * @param fromId The NFT ID of the Relic to transfer from.
     * @param toId The NFT ID of the Relic being transferred to.
     * @param amount The amount being transferred.
     */
    function shift(uint fromId, uint toId, uint amount) public virtual override nonReentrant {
        if (amount == 0) revert ZeroAmount();
        if (fromId == toId) revert DuplicateRelicIds();
        _requireApprovedOrOwner(fromId);
        _requireApprovedOrOwner(toId);

        LocalVariables_shift memory vars;
        PositionInfo storage fromPosition = positionForId[fromId];
        vars.poolId = fromPosition.poolId;
        if (!poolInfo[vars.poolId].allowPartialWithdrawals) revert PartialWithdrawalsDisabled();

        PositionInfo storage toPosition = positionForId[toId];
        if (vars.poolId != toPosition.poolId) revert RelicsNotOfSamePool();

        vars.fromAmount = fromPosition.amount;
        vars.toAmount = toPosition.amount;
        toPosition.entry = (vars.fromAmount * fromPosition.entry + vars.toAmount * toPosition.entry)
            / (vars.fromAmount + vars.toAmount);

        vars.newFromAmount = vars.fromAmount - amount;
        fromPosition.amount = vars.newFromAmount;

        vars.newToAmount = vars.toAmount + amount;
        toPosition.amount = vars.newToAmount;

        (vars.fromLevel, vars.oldToLevel, vars.newToLevel) =
            _shiftLevelBalances(fromId, toId, vars.poolId, amount, vars.toAmount, vars.newToAmount);

        vars.accRewardPerShare = _updatePool(vars.poolId);
        vars.fromMultiplier = vars.accRewardPerShare * levels[vars.poolId].multipliers[vars.fromLevel];
        vars.pendingFrom = vars.fromAmount * vars.fromMultiplier / ACC_REWARD_PRECISION - fromPosition.rewardDebt;
        if (vars.pendingFrom != 0) {
            fromPosition.rewardCredit += vars.pendingFrom;
        }
        vars.pendingTo = vars.toAmount * levels[vars.poolId].multipliers[vars.oldToLevel] * vars.accRewardPerShare
            / ACC_REWARD_PRECISION - toPosition.rewardDebt;
        if (vars.pendingTo != 0) {
            toPosition.rewardCredit += vars.pendingTo;
        }
        fromPosition.rewardDebt = vars.newFromAmount * vars.fromMultiplier / ACC_REWARD_PRECISION;
        toPosition.rewardDebt = vars.newToAmount * vars.accRewardPerShare
            * levels[vars.poolId].multipliers[vars.newToLevel] / ACC_REWARD_PRECISION;

        emit ReliquaryEvents.Shift(fromId, toId, amount);
    }

    /**
     * @notice Transfer entire position (including rewards) from one Relic into another, burning it
     * and updating maturity in the receiving Relic.
     * @param fromId The NFT ID of the Relic to transfer from.
     * @param toId The NFT ID of the Relic being transferred to.
     */
    function merge(uint fromId, uint toId) public virtual override nonReentrant {
        if (fromId == toId) revert DuplicateRelicIds();
        _requireApprovedOrOwner(fromId);
        _requireApprovedOrOwner(toId);

        PositionInfo storage fromPosition = positionForId[fromId];
        uint fromAmount = fromPosition.amount;

        uint poolId = fromPosition.poolId;
        PositionInfo storage toPosition = positionForId[toId];
        if (poolId != toPosition.poolId) revert RelicsNotOfSamePool();

        uint toAmount = toPosition.amount;
        uint newToAmount = toAmount + fromAmount;
        if (newToAmount == 0) revert MergingEmptyRelics();
        toPosition.entry = (fromAmount * fromPosition.entry + toAmount * toPosition.entry) / newToAmount;

        toPosition.amount = newToAmount;

        (uint fromLevel, uint oldToLevel, uint newToLevel) =
            _shiftLevelBalances(fromId, toId, poolId, fromAmount, toAmount, newToAmount);

        uint accRewardPerShare = _updatePool(poolId);
        uint pendingTo = accRewardPerShare
            * (fromAmount * levels[poolId].multipliers[fromLevel] + toAmount * levels[poolId].multipliers[oldToLevel])
            / ACC_REWARD_PRECISION + fromPosition.rewardCredit - fromPosition.rewardDebt - toPosition.rewardDebt;
        if (pendingTo != 0) {
            toPosition.rewardCredit += pendingTo;
        }
        toPosition.rewardDebt =
            newToAmount * accRewardPerShare * levels[poolId].multipliers[newToLevel] / ACC_REWARD_PRECISION;

        _burn(fromId);
        delete positionForId[fromId];

        emit ReliquaryEvents.Merge(fromId, toId, fromAmount);
    }

    /// @notice Burns the Relic with ID `tokenId`. Cannot be called if there is any principal or rewards in the Relic.
    function burn(uint tokenId) public virtual override(IReliquary, ERC721Burnable) {
        if (positionForId[tokenId].amount != 0) revert BurningPrincipal();
        if (pendingReward(tokenId) != 0) revert BurningRewards();
        super.burn(tokenId);
    }

    /**
     * @notice View function to see pending reward tokens on frontend.
     * @param relicId ID of the position.
     * @return pending reward amount for a given position owner.
     */
    function pendingReward(uint relicId) public view override returns (uint pending) {
        PositionInfo storage position = positionForId[relicId];
        uint poolId = position.poolId;
        PoolInfo storage pool = poolInfo[poolId];
        uint accRewardPerShare = pool.accRewardPerShare;
        uint lpSupply = _poolBalance(position.poolId);

        uint lastRewardTime = pool.lastRewardTime;
        uint secondsSinceReward = block.timestamp - lastRewardTime;
        if (secondsSinceReward != 0 && lpSupply != 0) {
            uint reward =
                secondsSinceReward * _baseEmissionsPerSecond(lastRewardTime) * pool.allocPoint / totalAllocPoint;
            accRewardPerShare += reward * ACC_REWARD_PRECISION / lpSupply;
        }

        uint leveledAmount = position.amount * levels[poolId].multipliers[position.level];
        pending = leveledAmount * accRewardPerShare / ACC_REWARD_PRECISION + position.rewardCredit - position.rewardDebt;
    }

    /**
     * @notice View function to see level of position if it were to be updated.
     * @param relicId ID of the position.
     * @return level Level for given position upon update.
     */
    function levelOnUpdate(uint relicId) public view override returns (uint level) {
        PositionInfo storage position = positionForId[relicId];
        LevelInfo storage levelInfo = levels[position.poolId];
        uint length = levelInfo.requiredMaturities.length;
        if (length == 1) {
            return 0;
        }

        uint maturity = block.timestamp - position.entry;
        for (level = length - 1; true;) {
            if (maturity >= levelInfo.requiredMaturities[level]) {
                break;
            }
            unchecked {
                --level;
            }
        }
    }

    /// @notice Returns the number of Reliquary pools.
    function poolLength() public view override returns (uint pools) {
        pools = poolInfo.length;
    }

    /**
     * @notice Returns the ERC721 tokenURI given by the pool's NFTDescriptor.
     * @dev Can be gas expensive if used in a transaction and the NFTDescriptor is complex.
     * @param tokenId The NFT ID of the Relic to get the tokenURI for.
     */
    function tokenURI(uint tokenId) public view override(ERC721) returns (string memory) {
        if (!_exists(tokenId)) revert NonExistentRelic();
        return INFTDescriptor(nftDescriptor[positionForId[tokenId].poolId]).constructTokenURI(tokenId);
    }

    /// @dev Implement ERC165 to return which interfaces this contract conforms to
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(IERC165, AccessControlEnumerable, ERC721, ERC721Enumerable)
        returns (bool)
    {
        return interfaceId == type(IReliquary).interfaceId || super.supportsInterface(interfaceId);
    }

    /// @dev Internal _updatePool function without nonReentrant modifier.
    function _updatePool(uint pid) internal returns (uint accRewardPerShare) {
        if (pid >= poolLength()) revert NonExistentPool();
        PoolInfo storage pool = poolInfo[pid];
        uint timestamp = block.timestamp;
        uint lastRewardTime = pool.lastRewardTime;
        uint secondsSinceReward = timestamp - lastRewardTime;

        accRewardPerShare = pool.accRewardPerShare;
        if (secondsSinceReward != 0) {
            uint lpSupply = _poolBalance(pid);

            if (lpSupply != 0) {
                uint reward =
                    secondsSinceReward * _baseEmissionsPerSecond(lastRewardTime) * pool.allocPoint / totalAllocPoint;
                accRewardPerShare += reward * ACC_REWARD_PRECISION / lpSupply;
                pool.accRewardPerShare = accRewardPerShare;
            }

            pool.lastRewardTime = timestamp;

            emit ReliquaryEvents.LogUpdatePool(pid, timestamp, lpSupply, accRewardPerShare);
        }
    }

    /// @dev Internal deposit function that assumes relicId is valid.
    function _deposit(uint amount, uint relicId) internal {
        if (amount == 0) revert ZeroAmount();

        (uint poolId,) = _updatePosition(amount, relicId, Kind.DEPOSIT, address(0));

        IERC20(poolToken[poolId]).safeTransferFrom(msg.sender, address(this), amount);

        emit ReliquaryEvents.Deposit(poolId, amount, ownerOf(relicId), relicId);
    }

    struct LocalVariables_updatePosition {
        uint accRewardPerShare;
        uint oldAmount;
        uint newAmount;
        uint oldLevel;
        uint newLevel;
        bool harvest;
    }

    /**
     * @dev Internal function called whenever a position's state needs to be modified.
     * @param amount Amount of poolToken to deposit/withdraw.
     * @param relicId The NFT ID of the position being updated.
     * @param kind Indicates whether tokens are being added to, or removed from, a pool.
     * @param harvestTo Address to send rewards to (zero address if harvest should not be performed).
     * @return poolId Pool ID of the given position.
     * @return _pendingReward Pending reward for given position owner.
     */
    function _updatePosition(uint amount, uint relicId, Kind kind, address harvestTo)
        internal
        returns (uint poolId, uint _pendingReward)
    {
        LocalVariables_updatePosition memory vars;
        PositionInfo storage position = positionForId[relicId];
        poolId = position.poolId;
        vars.accRewardPerShare = _updatePool(poolId);

        vars.oldAmount = position.amount;
        if (kind == Kind.DEPOSIT) {
            _updateEntry(amount, relicId);
            vars.newAmount = vars.oldAmount + amount;
            position.amount = vars.newAmount;
        } else if (kind == Kind.WITHDRAW) {
            if (amount != vars.oldAmount && !poolInfo[poolId].allowPartialWithdrawals) {
                revert PartialWithdrawalsDisabled();
            }
            vars.newAmount = vars.oldAmount - amount;
            position.amount = vars.newAmount;
        } else {
            vars.newAmount = vars.oldAmount;
        }

        vars.oldLevel = position.level;
        vars.newLevel = _updateLevel(relicId, vars.oldLevel);
        if (vars.oldLevel != vars.newLevel) {
            levels[poolId].balance[vars.oldLevel] -= vars.oldAmount;
            levels[poolId].balance[vars.newLevel] += vars.newAmount;
        } else if (kind == Kind.DEPOSIT) {
            levels[poolId].balance[vars.oldLevel] += amount;
        } else if (kind == Kind.WITHDRAW) {
            levels[poolId].balance[vars.oldLevel] -= amount;
        }

        _pendingReward = vars.oldAmount * levels[poolId].multipliers[vars.oldLevel] * vars.accRewardPerShare
            / ACC_REWARD_PRECISION - position.rewardDebt;
        position.rewardDebt =
            vars.newAmount * levels[poolId].multipliers[vars.newLevel] * vars.accRewardPerShare / ACC_REWARD_PRECISION;

        vars.harvest = harvestTo != address(0);
        if (!vars.harvest && _pendingReward != 0) {
            position.rewardCredit += _pendingReward;
        } else if (vars.harvest) {
            uint total = _pendingReward + position.rewardCredit;
            uint received = _receivedReward(total);
            position.rewardCredit = total - received;
            if (received != 0) {
                IERC20(rewardToken).safeTransfer(harvestTo, received);
                address _rewarder = rewarder[poolId];
                if (_rewarder != address(0)) {
                    IRewarder(_rewarder).onReward(relicId, received, harvestTo);
                }
            }
        }

        if (kind == Kind.DEPOSIT) {
            address _rewarder = rewarder[poolId];
            if (_rewarder != address(0)) {
                IRewarder(_rewarder).onDeposit(relicId, amount);
            }
        } else if (kind == Kind.WITHDRAW) {
            address _rewarder = rewarder[poolId];
            if (_rewarder != address(0)) {
                IRewarder(_rewarder).onWithdraw(relicId, amount);
            }
        }
    }

    /**
     * @notice Updates the user's entry time based on the weight of their deposit or withdrawal.
     * @param amount The amount of the deposit / withdrawal.
     * @param relicId The NFT ID of the position being updated.
     */
    function _updateEntry(uint amount, uint relicId) internal {
        PositionInfo storage position = positionForId[relicId];
        uint amountBefore = position.amount;
        if (amountBefore == 0) {
            position.entry = block.timestamp;
        } else {
            uint weight = _findWeight(amount, amountBefore);
            uint entryBefore = position.entry;
            uint maturity = block.timestamp - entryBefore;
            position.entry = entryBefore + maturity * weight / 1e12;
        }
    }

    /**
     * @notice Updates the position's level based on entry time.
     * @param relicId The NFT ID of the position being updated.
     * @param oldLevel Level of position before update.
     * @return newLevel Level of position after update.
     */
    function _updateLevel(uint relicId, uint oldLevel) internal returns (uint newLevel) {
        newLevel = levelOnUpdate(relicId);
        PositionInfo storage position = positionForId[relicId];
        if (oldLevel != newLevel) {
            position.level = newLevel;
            emit ReliquaryEvents.LevelChanged(relicId, newLevel);
        }
    }

    /// @dev Ensure the behavior of ERC721Enumerable _beforeTokenTransfer is preserved.
    function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) {
        ERC721Enumerable._beforeTokenTransfer(from, to, tokenId);
    }

    /**
     * @notice Calculate how much the owner will actually receive on harvest, given available reward tokens.
     * @param _pendingReward Amount of reward token owed.
     * @return received The minimum between amount owed and amount available.
     */
    function _receivedReward(uint _pendingReward) internal view returns (uint received) {
        uint available = IERC20(rewardToken).balanceOf(address(this));
        received = (available > _pendingReward) ? _pendingReward : available;
    }

    /// @notice Gets the base emission rate from external, upgradable contract.
    function _baseEmissionsPerSecond(uint lastRewardTime) internal view returns (uint rate) {
        rate = IEmissionCurve(emissionCurve).getRate(lastRewardTime);
        if (rate > 6e18) revert MaxEmissionRateExceeded();
    }

    /**
     * @notice returns The total deposits of the pool's token, weighted by maturity level allocation.
     * @param pid The index of the pool. See poolInfo.
     * @return total The amount of pool tokens held by the contract.
     */
    function _poolBalance(uint pid) internal view returns (uint total) {
        LevelInfo storage levelInfo = levels[pid];
        uint length = levelInfo.balance.length;
        for (uint i; i < length;) {
            total += levelInfo.balance[i] * levelInfo.multipliers[i];
            unchecked {
                ++i;
            }
        }
    }

    /// @notice Require the sender is either the owner of the Relic or approved to transfer it.
    /// @param relicId The NFT ID of the Relic.
    function _requireApprovedOrOwner(uint relicId) internal view {
        if (!_isApprovedOrOwner(msg.sender, relicId)) revert NotApprovedOrOwner();
    }

    /**
     * @notice Used in `_updateEntry` to find weights without any underflows or zero division problems.
     * @param addedValue New value being added.
     * @param oldValue Current amount of x.
     */
    function _findWeight(uint addedValue, uint oldValue) internal pure returns (uint weightNew) {
        if (oldValue < addedValue) {
            weightNew = 1e12 - oldValue * 1e12 / (addedValue + oldValue);
        } else if (addedValue < oldValue) {
            weightNew = addedValue * 1e12 / (addedValue + oldValue);
        } else {
            weightNew = 5e11;
        }
    }

    /// @dev Handle updating balances for each affected tranche when shifting and merging.
    function _shiftLevelBalances(uint fromId, uint toId, uint poolId, uint amount, uint toAmount, uint newToAmount)
        private
        returns (uint fromLevel, uint oldToLevel, uint newToLevel)
    {
        fromLevel = positionForId[fromId].level;
        oldToLevel = positionForId[toId].level;
        newToLevel = _updateLevel(toId, oldToLevel);
        if (fromLevel != newToLevel) {
            levels[poolId].balance[fromLevel] -= amount;
        }
        if (oldToLevel != newToLevel) {
            levels[poolId].balance[oldToLevel] -= toAmount;
        }
        if (fromLevel != newToLevel && oldToLevel != newToLevel) {
            levels[poolId].balance[newToLevel] += newToAmount;
        } else if (fromLevel != newToLevel) {
            levels[poolId].balance[newToLevel] += amount;
        } else if (oldToLevel != newToLevel) {
            levels[poolId].balance[newToLevel] += toAmount;
        }
    }

    /// @dev Increments the ID nonce and mints a new Relic to `to`.
    function _mint(address to) private returns (uint id) {
        id = ++idNonce;
        _safeMint(to, id);
    }
}

File 2 of 28 : ReliquaryEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library ReliquaryEvents {
    event CreateRelic(uint indexed pid, address indexed to, uint indexed relicId);
    event Deposit(uint indexed pid, uint amount, address indexed to, uint indexed relicId);
    event Withdraw(uint indexed pid, uint amount, address indexed to, uint indexed relicId);
    event EmergencyWithdraw(uint indexed pid, uint amount, address indexed to, uint indexed relicId);
    event Harvest(uint indexed pid, uint amount, address indexed to, uint indexed relicId);
    event LogPoolAddition(
        uint indexed pid,
        uint allocPoint,
        address indexed poolToken,
        address indexed rewarder,
        address nftDescriptor,
        bool allowPartialWithdrawals
    );
    event LogPoolModified(uint indexed pid, uint allocPoint, address indexed rewarder, address nftDescriptor);
    event LogUpdatePool(uint indexed pid, uint lastRewardTime, uint lpSupply, uint accRewardPerShare);
    event LogSetEmissionCurve(address indexed emissionCurveAddress);
    event LevelChanged(uint indexed relicId, uint newLevel);
    event Split(uint indexed fromId, uint indexed toId, uint amount);
    event Shift(uint indexed fromId, uint indexed toId, uint amount);
    event Merge(uint indexed fromId, uint indexed toId, uint amount);
}

File 3 of 28 : IEmissionCurve.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

interface IEmissionCurve {
    function getRate(uint lastRewardTime) external view returns (uint rate);
}

File 4 of 28 : INFTDescriptor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

interface INFTDescriptor {
    function constructTokenURI(uint relicId) external view returns (string memory);
}

File 5 of 28 : IReliquary.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

/**
 * @notice Info for each Reliquary position.
 * `amount` LP token amount the position owner has provided.
 * `rewardDebt` Amount of reward token accumalated before the position's entry or last harvest.
 * `rewardCredit` Amount of reward token owed to the user on next harvest.
 * `entry` Used to determine the maturity of the position.
 * `poolId` ID of the pool to which this position belongs.
 * `level` Index of this position's level within the pool's array of levels.
 */
struct PositionInfo {
    uint amount;
    uint rewardDebt;
    uint rewardCredit;
    uint entry; // position owner's relative entry into the pool.
    uint poolId; // ensures that a single Relic is only used for one pool.
    uint level;
}

/**
 * @notice Info of each Reliquary pool.
 * `accRewardPerShare` Accumulated reward tokens per share of pool (1 / 1e12).
 * `lastRewardTime` Last timestamp the accumulated reward was updated.
 * `allocPoint` Pool's individual allocation - ratio of the total allocation.
 * `name` Name of pool to be displayed in NFT image.
 * `allowPartialWithdrawals` Whether users can withdraw less than their entire position.
 *     A value of false will also disable shift and split functionality.
 */
struct PoolInfo {
    uint accRewardPerShare;
    uint lastRewardTime;
    uint allocPoint;
    string name;
    bool allowPartialWithdrawals;
}

/**
 * @notice Info for each level in a pool that determines how maturity is rewarded.
 * `requiredMaturities` The minimum maturity (in seconds) required to reach each Level.
 * `multipliers` Multiplier for each level applied to amount of incentivized token when calculating rewards in the pool.
 *     This is applied to both the numerator and denominator in the calculation such that the size of a user's position
 *     is effectively considered to be the actual number of tokens times the multiplier for their level.
 *     Also note that these multipliers do not affect the overall emission rate.
 * `balance` Total (actual) number of tokens deposited in positions at each level.
 */
struct LevelInfo {
    uint[] requiredMaturities;
    uint[] multipliers;
    uint[] balance;
}

/**
 * @notice Object representing pending rewards and related data for a position.
 * `relicId` The NFT ID of the given position.
 * `poolId` ID of the pool to which this position belongs.
 * `pendingReward` pending reward amount for a given position.
 */
struct PendingReward {
    uint relicId;
    uint poolId;
    uint pendingReward;
}

interface IReliquary is IERC721Enumerable {
    function setEmissionCurve(address _emissionCurve) external;
    function addPool(
        uint allocPoint,
        address _poolToken,
        address _rewarder,
        uint[] calldata requiredMaturity,
        uint[] calldata allocPoints,
        string memory name,
        address _nftDescriptor,
        bool allowPartialWithdrawals
    ) external;
    function modifyPool(
        uint pid,
        uint allocPoint,
        address _rewarder,
        string calldata name,
        address _nftDescriptor,
        bool overwriteRewarder
    ) external;
    function massUpdatePools(uint[] calldata pids) external;
    function updatePool(uint pid) external;
    function deposit(uint amount, uint relicId) external;
    function withdraw(uint amount, uint relicId) external;
    function harvest(uint relicId, address harvestTo) external;
    function withdrawAndHarvest(uint amount, uint relicId, address harvestTo) external;
    function emergencyWithdraw(uint relicId) external;
    function updatePosition(uint relicId) external;
    function getPositionForId(uint) external view returns (PositionInfo memory);
    function getPoolInfo(uint) external view returns (PoolInfo memory);
    function getLevelInfo(uint) external view returns (LevelInfo memory);
    function pendingRewardsOfOwner(address owner) external view returns (PendingReward[] memory pendingRewards);
    function relicPositionsOfOwner(address owner)
        external
        view
        returns (uint[] memory relicIds, PositionInfo[] memory positionInfos);
    function isApprovedOrOwner(address, uint) external view returns (bool);
    function createRelicAndDeposit(address to, uint pid, uint amount) external returns (uint id);
    function split(uint relicId, uint amount, address to) external returns (uint newId);
    function shift(uint fromId, uint toId, uint amount) external;
    function merge(uint fromId, uint toId) external;
    function burn(uint tokenId) external;
    function pendingReward(uint relicId) external view returns (uint pending);
    function levelOnUpdate(uint relicId) external view returns (uint level);
    function poolLength() external view returns (uint);

    function rewardToken() external view returns (address);
    function nftDescriptor(uint) external view returns (address);
    function emissionCurve() external view returns (address);
    function poolToken(uint) external view returns (address);
    function rewarder(uint) external view returns (address);
    function totalAllocPoint() external view returns (uint);
}

File 6 of 28 : IRewarder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

interface IRewarder {
    function onReward(uint relicId, uint rewardAmount, address to) external;

    function onDeposit(uint relicId, uint depositAmount) external;

    function onWithdraw(uint relicId, uint withdrawalAmount) external;

    function pendingTokens(uint relicId, uint rewardAmount) external view returns (address[] memory, uint[] memory);
}

File 7 of 28 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

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

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

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

File 12 of 28 : 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 13 of 28 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 14 of 28 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

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

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

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

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

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

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

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

        _afterTokenTransfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

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

        // Clear approvals
        delete _tokenApprovals[tokenId];

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

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

        _afterTokenTransfer(owner, address(0), tokenId);
    }

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

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

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

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

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

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

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

File 16 of 28 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: 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 17 of 28 : IERC721Receiver.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 IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 18 of 28 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.0;

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

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
        _burn(tokenId);
    }
}

File 19 of 28 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 20 of 28 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 21 of 28 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 22 of 28 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

File 24 of 28 : Multicall.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)

pragma solidity ^0.8.0;

import "./Address.sol";

/**
 * @dev Provides a function to batch together multiple calls in a single external call.
 *
 * _Available since v4.1._
 */
abstract contract Multicall {
    /**
     * @dev Receives and executes a batch of function calls on this contract.
     */
    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }
}

File 25 of 28 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // 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);
    }

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 28 of 28 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

    /**
     * @dev Returns the number of values 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;

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

        return result;
    }
}

Settings
{
  "remappings": [
    "base64/=lib/base64/",
    "ds-test/=lib/solmate/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/solmate/src/",
    "v2-core/=lib/v2-core/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_emissionCurve","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"BurningPrincipal","type":"error"},{"inputs":[],"name":"BurningRewards","type":"error"},{"inputs":[],"name":"DuplicateRelicIds","type":"error"},{"inputs":[],"name":"EmptyArray","type":"error"},{"inputs":[],"name":"MaxEmissionRateExceeded","type":"error"},{"inputs":[],"name":"MergingEmptyRelics","type":"error"},{"inputs":[],"name":"NonExistentPool","type":"error"},{"inputs":[],"name":"NonExistentRelic","type":"error"},{"inputs":[],"name":"NonZeroFirstMaturity","type":"error"},{"inputs":[],"name":"NotApprovedOrOwner","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"PartialWithdrawalsDisabled","type":"error"},{"inputs":[],"name":"RelicsNotOfSamePool","type":"error"},{"inputs":[],"name":"RewardTokenAsPoolToken","type":"error"},{"inputs":[],"name":"UnsortedMaturityLevels","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"inputs":[],"name":"ZeroTotalAllocPoint","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"address","name":"_poolToken","type":"address"},{"internalType":"address","name":"_rewarder","type":"address"},{"internalType":"uint256[]","name":"requiredMaturities","type":"uint256[]"},{"internalType":"uint256[]","name":"levelMultipliers","type":"uint256[]"},{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"_nftDescriptor","type":"address"},{"internalType":"bool","name":"allowPartialWithdrawals","type":"bool"}],"name":"addPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"createRelicAndDeposit","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emissionCurve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"getLevelInfo","outputs":[{"components":[{"internalType":"uint256[]","name":"requiredMaturities","type":"uint256[]"},{"internalType":"uint256[]","name":"multipliers","type":"uint256[]"},{"internalType":"uint256[]","name":"balance","type":"uint256[]"}],"internalType":"struct LevelInfo","name":"levelInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"getPoolInfo","outputs":[{"components":[{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"allowPartialWithdrawals","type":"bool"}],"internalType":"struct PoolInfo","name":"pool","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"getPositionForId","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"rewardCredit","type":"uint256"},{"internalType":"uint256","name":"entry","type":"uint256"},{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"level","type":"uint256"}],"internalType":"struct PositionInfo","name":"position","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"},{"internalType":"address","name":"harvestTo","type":"address"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"levelOnUpdate","outputs":[{"internalType":"uint256","name":"level","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"pids","type":"uint256[]"}],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromId","type":"uint256"},{"internalType":"uint256","name":"toId","type":"uint256"}],"name":"merge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"address","name":"_rewarder","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"_nftDescriptor","type":"address"},{"internalType":"bool","name":"overwriteRewarder","type":"bool"}],"name":"modifyPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftDescriptor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"pendingReward","outputs":[{"internalType":"uint256","name":"pending","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"pendingRewardsOfOwner","outputs":[{"components":[{"internalType":"uint256","name":"relicId","type":"uint256"},{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"pendingReward","type":"uint256"}],"internalType":"struct PendingReward[]","name":"pendingRewards","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"pools","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"relicPositionsOfOwner","outputs":[{"internalType":"uint256[]","name":"relicIds","type":"uint256[]"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"rewardCredit","type":"uint256"},{"internalType":"uint256","name":"entry","type":"uint256"},{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"level","type":"uint256"}],"internalType":"struct PositionInfo[]","name":"positionInfos","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_emissionCurve","type":"address"}],"name":"setEmissionCurve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromId","type":"uint256"},{"internalType":"uint256","name":"toId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"shift","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"split","outputs":[{"internalType":"uint256","name":"newId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"updatePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"relicId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"relicId","type":"uint256"},{"internalType":"address","name":"harvestTo","type":"address"}],"name":"withdrawAndHarvest","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b506040516200629b3803806200629b8339810160408190526200003491620002d3565b81816000620000448382620003f1565b506001620000538282620003f1565b50506001600c55506001600160a01b03848116608052600f80546001600160a01b0319169185169190911790556200008d60003362000097565b50505050620004bd565b620000ae8282620000da60201b62002dc01760201c565b6000828152600b60209081526040909120620000d591839062002e466200017f821b17901c565b505050565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff166200017b576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200013a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600062000196836001600160a01b0384166200019f565b90505b92915050565b6000818152600183016020526040812054620001e85750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000199565b50600062000199565b80516001600160a01b03811681146200020957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200023657600080fd5b81516001600160401b03808211156200025357620002536200020e565b604051601f8301601f19908116603f011681019082821181831017156200027e576200027e6200020e565b816040528381526020925086838588010111156200029b57600080fd5b600091505b83821015620002bf5785820183015181830184015290820190620002a0565b600093810190920192909252949350505050565b60008060008060808587031215620002ea57600080fd5b620002f585620001f1565b93506200030560208601620001f1565b60408601519093506001600160401b03808211156200032357600080fd5b620003318883890162000224565b935060608701519150808211156200034857600080fd5b50620003578782880162000224565b91505092959194509250565b600181811c908216806200037857607f821691505b6020821081036200039957634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620000d557600081815260208120601f850160051c81016020861015620003c85750805b601f850160051c820191505b81811015620003e957828155600101620003d4565b505050505050565b81516001600160401b038111156200040d576200040d6200020e565b62000425816200041e845462000363565b846200039f565b602080601f8311600181146200045d5760008415620004445750858301515b600019600386901b1c1916600185901b178555620003e9565b600085815260208120601f198616915b828110156200048e578886015182559484019460019091019084016200046d565b5085821015620004ad5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051615dad620004ee6000396000818161077b015281816117e2015281816133f001526141a00152615dad6000f3fe608060405234801561001057600080fd5b50600436106102f85760003560e01c80636e7d401911610193578063b88d4fde116100e4578063d1abb90711610092578063d1abb907146106f7578063d1c2babb1461070a578063d547741f1461071d578063e2bbb15814610730578063e48dc13514610743578063e985e9c514610763578063f7c618c11461077657600080fd5b8063b88d4fde14610657578063b9be8cd51461066a578063bd75fd6c1461067d578063c346253d1461069d578063c87b56dd146106b0578063ca15c873146106c3578063d14d0a1a146106d657600080fd5b806391d148541161014157806391d14854146105db57806395d89b41146105ee5780639a67759b146105f6578063a217fddf14610609578063a22cb46514610611578063a6443e1e14610624578063ac9650d81461063757600080fd5b80636e7d4019146105565780636ecbae3f1461056957806370a082311461057c5780637747dd811461058f578063778b9a07146105a25780638d74c2bf146105b55780639010d07c146105c857600080fd5b80632f2ff15d1161024d578063441a3e70116101fb578063441a3e70146104d15780634f6ccce7146104e457806351eb05a6146104f75780635312ea8e1461050a57806357a5b58c1461051d5780636352211e146105305780636705fcf31461054357600080fd5b80632f2ff15d1461043f5780632f380b35146104525780632f745c591461047257806336568abe1461048557806342842e0e1461049857806342966c68146104ab578063430c2081146104be57600080fd5b806312f7086c116102aa57806312f7086c146103bf57806317caf6f1146103d257806318160ddd146103db57806318fccc76146103e3578063215e83eb146103f657806323b872dd14610409578063248a9ca31461041c57600080fd5b806301ffc9a7146102fd578063030101db1461032557806306fdde0314610345578063081812fc1461035a578063081e3eda14610385578063095ea7b31461039757806309f1c80a146103ac575b600080fd5b61031061030b366004614f39565b61079d565b60405190151581526020015b60405180910390f35b610338610333366004614f56565b6107c8565b60405161031c9190614faa565b61034d610927565b60405161031c919061505b565b61036d610368366004614f56565b6109b9565b6040516001600160a01b03909116815260200161031c565b6010545b60405190815260200161031c565b6103aa6103a5366004615085565b6109e0565b005b6103aa6103ba366004614f56565b610afa565b6103896103cd366004614f56565b610b46565b61038960155481565b600854610389565b6103aa6103f13660046150af565b610cbb565b61036d610404366004614f56565b610d36565b6103aa6104173660046150db565b610d60565b61038961042a366004614f56565b6000908152600a602052604090206001015490565b6103aa61044d3660046150af565b610d92565b610465610460366004614f56565b610db7565b60405161031c9190615117565b610389610480366004615085565b610ede565b6103aa6104933660046150af565b610f74565b6103aa6104a63660046150db565b610fee565b6103aa6104b9366004614f56565b611009565b6103106104cc366004615085565b611066565b6103aa6104df366004615169565b611079565b6103896104f2366004614f56565b611142565b6103aa610505366004614f56565b6111d5565b6103aa610518366004614f56565b6111f1565b6103aa61052b3660046151d6565b61134a565b61036d61053e366004614f56565b611392565b610389610551366004615217565b6113c7565b61036d610564366004614f56565b611461565b6103aa61057736600461524a565b611471565b61038961058a36600461524a565b6114e6565b61038961059d366004615265565b61156c565b6103aa6105b036600461537e565b6117b6565b6103aa6105c336600461545d565b611ca3565b61036d6105d6366004615169565b611ebe565b6103106105e93660046150af565b611ed6565b61034d611f01565b600f5461036d906001600160a01b031681565b610389600081565b6103aa61061f366004615514565b611f10565b610389610632366004614f56565b611f1b565b61064a6106453660046151d6565b611fca565b60405161031c919061554b565b6103aa6106653660046155ad565b6120be565b6103aa610678366004615628565b6120f6565b61069061068b36600461524a565b612574565b60405161031c9190615654565b61036d6106ab366004614f56565b612672565b61034d6106be366004614f56565b612682565b6103896106d1366004614f56565b61274b565b6106e96106e436600461524a565b612762565b60405161031c9291906156e7565b6103aa610705366004615265565b6128dc565b6103aa610718366004615169565b6129d0565b6103aa61072b3660046150af565b612ce7565b6103aa61073e366004615169565b612d0c565b610756610751366004614f56565b612d31565b60405161031c919061576c565b61031061077136600461577a565b612d92565b61036d7f000000000000000000000000000000000000000000000000000000000000000081565b60006001600160e01b03198216630c39233960e21b14806107c257506107c282612e5b565b92915050565b6107ec60405180606001604052806060815260200160608152602001606081525090565b601182815481106107ff576107ff6157a4565b90600052602060002090600302016040518060600160405290816000820180548060200260200160405190810160405280929190818152602001828054801561086757602002820191906000526020600020905b815481526020019060010190808311610853575b50505050508152602001600182018054806020026020016040519081016040528092919081815260200182805480156108bf57602002820191906000526020600020905b8154815260200190600101908083116108ab575b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561091757602002820191906000526020600020905b815481526020019060010190808311610903575b5050505050815250509050919050565b606060008054610936906157ba565b80601f0160208091040260200160405190810160405280929190818152602001828054610962906157ba565b80156109af5780601f10610984576101008083540402835291602001916109af565b820191906000526020600020905b81548152906001019060200180831161099257829003601f168201915b5050505050905090565b60006109c482612e80565b506000908152600460205260409020546001600160a01b031690565b60006109eb82611392565b9050806001600160a01b0316836001600160a01b031603610a5d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a795750610a798133612d92565b610aeb5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610a54565b610af58383612ea5565b505050565b610b02612f13565b610b0b81612f6c565b610b2857604051631d1286b560e31b815260040160405180910390fd5b610b3760008260026000612f89565b5050610b436001600c55565b50565b600081815260146020526040812060048101546010805484919083908110610b7057610b706157a4565b906000526020600020906005020190506000816000015490506000610b988560040154613625565b60018401549091506000610bac824261580a565b90508015801590610bbc57508215155b15610c1c5760006015548660020154610bd4856136c3565b610bde908561581d565b610be8919061581d565b610bf29190615834565b905083610c0464e8d4a510008361581d565b610c0e9190615834565b610c189086615856565b9450505b600060118781548110610c3157610c316157a4565b9060005260206000209060030201600101886005015481548110610c5757610c576157a4565b90600052602060002001548860000154610c71919061581d565b90508760010154886002015464e8d4a510008784610c8f919061581d565b610c999190615834565b610ca39190615856565b610cad919061580a565b9a9950505050505050505050565b610cc3612f13565b610ccc82613761565b600080610cdd600085600286612f89565b9150915083836001600160a01b0316837f614253edaf5943287293d855afffbb1f5f0403c51c84143aceaf27a50727b2fc84604051610d1e91815260200190565b60405180910390a45050610d326001600c55565b5050565b600e8181548110610d4657600080fd5b6000918252602090912001546001600160a01b0316905081565b610d6b335b82613788565b610d875760405162461bcd60e51b8152600401610a5490615869565b610af58383836137e7565b6000828152600a6020526040902060010154610dad8161398b565b610af58383613995565b610deb6040518060a00160405280600081526020016000815260200160008152602001606081526020016000151581525090565b60108281548110610dfe57610dfe6157a4565b90600052602060002090600502016040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382018054610e45906157ba565b80601f0160208091040260200160405190810160405280929190818152602001828054610e71906157ba565b8015610ebe5780601f10610e9357610100808354040283529160200191610ebe565b820191906000526020600020905b815481529060010190602001808311610ea157829003601f168201915b50505091835250506004919091015460ff16151560209091015292915050565b6000610ee9836114e6565b8210610f4b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a54565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6001600160a01b0381163314610fe45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a54565b610d3282826139b7565b610af5838383604051806020016040528060008152506120be565b600081815260146020526040902054156110365760405163f25a119760e01b815260040160405180910390fd5b61103f81610b46565b1561105d5760405163faaea8f160e01b815260040160405180910390fd5b610b43816139d9565b60006110728383613788565b9392505050565b611081612f13565b816000036110a257604051631f2a200560e01b815260040160405180910390fd5b6110ab81613761565b60006110bb838360016000612f89565b5090506110f23384601284815481106110d6576110d66157a4565b6000918252602090912001546001600160a01b03169190613a07565b81336001600160a01b0316827f191a58d19a6a9b76e2e91bdc04ecbe7553dc094a5ad7af78175a0d9f884e264a8660405161112f91815260200190565b60405180910390a450610d326001600c55565b600061114d60085490565b82106111b05760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a54565b600882815481106111c3576111c36157a4565b90600052602060002001549050919050565b6111dd612f13565b6111e681613a6a565b50610b436001600c55565b6111f9612f13565b600061120482611392565b90506001600160a01b038116331461122f576040516330cd747160e01b815260040160405180910390fd5b600082815260146020526040902080546004820154601180548391908390811061125b5761125b6157a4565b9060005260206000209060030201600201846005015481548110611281576112816157a4565b90600052602060002001600082825461129a919061580a565b909155506112a9905085613b9e565b60008581526014602052604081208181556001810182905560028101829055600381018290556004810182905560050155601280546112f7918691859190859081106110d6576110d66157a4565b84846001600160a01b0316827f6aaee64d11e8979fa392cd6388058c820f43709933f6a297e6e1005dddca62d68560405161133491815260200190565b60405180910390a450505050610b436001600c55565b611352612f13565b60005b818110156113875761137e838383818110611372576113726157a4565b90506020020135613a6a565b50600101611355565b50610d326001600c55565b6000818152600260205260408120546001600160a01b0316806107c25760405162461bcd60e51b8152600401610a54906158b6565b60006113d1612f13565b60105483106113f35760405163904e0f5960e01b815260040160405180910390fd5b6113fc84613c42565b60008181526014602052604090206004810185905590915061141e8383613c64565b81856001600160a01b0316857fb1ef6f1c5fca9fc83b81f6c18e6269a7942f041cadd830c353bb90f8680a3d4d60405160405180910390a4506110726001600c55565b60128181548110610d4657600080fd5b7ff0df1ecf66245243e1fe66eca783e2b1f173c34d37828b8788a74623e9a73e0261149b8161398b565b600f80546001600160a01b0319166001600160a01b0384169081179091556040517f097cb0b4d8d03c9f5f6d24fdb4d1c0764243aab030e9e385b0295badfe7a73e290600090a25050565b60006001600160a01b0382166115505760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610a54565b506001600160a01b031660009081526003602052604090205490565b6000611576612f13565b8260000361159757604051631f2a200560e01b815260040160405180910390fd5b6115a084613761565b6000848152601460205260409020600481015460108054829081106115c7576115c76157a4565b600091825260209091206004600590920201015460ff166115fb57604051635ea3f5c160e01b815260040160405180910390fd5b81546000611609878361580a565b808555905061161786613c42565b600081815260146020526040812089815560038088015490820155600580880154908201819055600482018790556011805494995091939092919087908110611662576116626157a4565b90600052602060002090600302016001018281548110611684576116846157a4565b906000526020600020015461169887613a6a565b6116a2919061581d565b90506000876001015464e8d4a5100083886116bd919061581d565b6116c79190615834565b6116d1919061580a565b905080156116f357808860020160008282546116ed9190615856565b90915550505b64e8d4a51000611703838761581d565b61170d9190615834565b600189015564e8d4a51000611722838d61581d565b61172c9190615834565b600185015560405189906001600160a01b038c169089907fb1ef6f1c5fca9fc83b81f6c18e6269a7942f041cadd830c353bb90f8680a3d4d90600090a4888c7fcf0974dfd867840133a0d4b02f1672f24017796fb8892d1e0d587692e4da90ab8d60405161179c91815260200190565b60405180910390a350505050505050506110726001600c55565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c6117e08161398b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a6001600160a01b0316036118325760405163c982c8c360e01b815260040160405180910390fd5b60008790036118545760405163521299a960e01b815260040160405180910390fd5b8685146118745760405163512509d360e11b815260040160405180910390fd5b87876000818110611887576118876157a4565b905060200201356000146118ae576040516369afe63f60e11b815260040160405180910390fd5b600187111561192457600060015b8881101561192157818a8a838181106118d7576118d76157a4565b90506020020135116118fc576040516367c462f760e01b815260040160405180910390fd5b89898281811061190e5761190e6157a4565b60200291909101359250506001016118bc565b50505b60005b6010548110156119435761193a81613a6a565b50600101611927565b5060008b6015546119549190615856565b90508060000361197757604051632ae6f6af60e11b815260040160405180910390fd5b8060158190555060128b9080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b0316021790555060138a9080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e849080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b0316021790555060106040518060a00160405280600081526020014281526020018e815260200187815260200185151581525090806001815401808255809150506001900390600052602060002090600502016000909190919091506000820151816000015560208201518160010155604082015181600201556060820151816003019081611ae1919061594b565b50608091820151600491909101805460ff19169115159190911790556040805160208b028082018401909252606081018b8152601193919283928e918e918291908601908490808284376000920191909152505050908252506040805160208b810282810182019093528b82529283019290918c918c918291850190849080828437600092019190915250505090825250602001886001600160401b03811115611b8d57611b8d61529a565b604051908082528060200260200182016040528015611bb6578160200160208202803683370190505b50905281546001810183556000928352602092839020825180519394600390930290910192611be89284920190614e8d565b506020828101518051611c019260018501920190614e8d565b5060408201518051611c1d916002840191602090910190614e8d565b50506012546001600160a01b03808d1692508d1690611c3e9060019061580a565b7f1af8063b2ec9698905896368410dddf34d4ef5f8fb21ddd995a7b43f69ae10678f8888604051611c8d939291909283526001600160a01b039190911660208301521515604082015260600190565b60405180910390a4505050505050505050505050565b7f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c611ccd8161398b565b6010548810611cef5760405163904e0f5960e01b815260040160405180910390fd5b6000611cfa60105490565b905060005b81811015611d1957611d1081613a6a565b50600101611cff565b50600060108a81548110611d2f57611d2f6157a4565b90600052602060002090600502019050600081600201548a601554611d549190615856565b611d5e919061580a565b905080600003611d8157604051632ae6f6af60e11b815260040160405180910390fd5b6015819055600282018a90558415611dd6578860138c81548110611da757611da76157a4565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60038201611de5888a83615a04565b5085600e8c81548110611dfa57611dfa6157a4565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555084611e5a5760138b81548110611e4057611e406157a4565b6000918252602090912001546001600160a01b0316611e5c565b885b6001600160a01b03168b7ffa4328c2a1268b2b661914d91df191c5271c699ddc97ccedda086c6d25b099f98c89604051611ea99291909182526001600160a01b0316602082015260400190565b60405180910390a35050505050505050505050565b6000828152600b602052604081206110729083613d1f565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060018054610936906157ba565b610d32338383613d2b565b60008181526014602052604081206004810154601180548492908110611f4357611f436157a4565b6000918252602090912060039091020180549091506001819003611f6c57506000949350505050565b6000836003015442611f7e919061580a565b9050611f8b60018361580a565b94505b826000018581548110611fa357611fa36157a4565b9060005260206000200154811015611fc15760001990940193611f8e565b50505050919050565b6060816001600160401b03811115611fe457611fe461529a565b60405190808252806020026020018201604052801561201757816020015b60608152602001906001900390816120025790505b50905060005b828110156120b7576120873085858481811061203b5761203b6157a4565b905060200281019061204d9190615abe565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613df592505050565b828281518110612099576120996157a4565b602002602001018190525080806120af90615b04565b91505061201d565b5092915050565b6120c83383613788565b6120e45760405162461bcd60e51b8152600401610a5490615869565b6120f084848484613e1a565b50505050565b6120fe612f13565b8060000361211f57604051631f2a200560e01b815260040160405180910390fd5b81830361213f57604051634cce529560e11b815260040160405180910390fd5b61214883613761565b61215182613761565b6121b56040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60008481526014602090815260409091206004810154918301829052601080549192909181106121e7576121e76157a4565b600091825260209091206004600590920201015460ff1661221b57604051635ea3f5c160e01b815260040160405180910390fd5b600084815260146020908152604090912060048101549184015190911461225557604051634f13191b60e01b815260040160405180910390fd5b815480845281546040850181905261226c91615856565b81600301548460400151612280919061581d565b60038401548551612291919061581d565b61229b9190615856565b6122a59190615834565b600382015582516122b790859061580a565b60608401819052825560408301516122d0908590615856565b60808401819052808255602084015160408501516122f692899289929091899190613e4d565b60e086015260c085015260a0840152602083015161231390613a6a565b6101008401526020830151601180549091908110612333576123336157a4565b90600052602060002090600302016001018360a0015181548110612359576123596157a4565b9060005260206000200154836101000151612374919061581d565b610120840181905260018301548451909164e8d4a5100091612396919061581d565b6123a09190615834565b6123aa919061580a565b6101408401819052156123d6578261014001518260020160008282546123d09190615856565b90915550505b806001015464e8d4a5100084610100015160118660200151815481106123fe576123fe6157a4565b90600052602060002090600302016001018660c0015181548110612424576124246157a4565b9060005260206000200154866040015161243e919061581d565b612448919061581d565b6124529190615834565b61245c919061580a565b610160840181905215612488578261016001518160020160008282546124829190615856565b90915550505b64e8d4a5100083610120015184606001516124a3919061581d565b6124ad9190615834565b600183015560208301516011805464e8d4a51000929081106124d1576124d16157a4565b90600052602060002090600302016001018460e00151815481106124f7576124f76157a4565b90600052602060002001548461010001518560800151612517919061581d565b612521919061581d565b61252b9190615834565b6001820155604051848152859087907fda2a03409498a5fe8db3da030754afa618bc2228c0517ec5fa8c9b052979e9ea9060200160405180910390a3505050610af56001600c55565b60606000612581836114e6565b9050806001600160401b0381111561259b5761259b61529a565b6040519080825280602002602001820160405280156125f057816020015b6125dd60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816125b95790505b50915060005b8181101561266b57600061260a8583610ede565b905060405180606001604052808281526020016014600084815260200190815260200160002060040154815260200161264283610b46565b815250848381518110612657576126576157a4565b6020908102919091010152506001016125f6565b5050919050565b60138181548110610d4657600080fd5b606061268d82612f6c565b6126aa57604051631d1286b560e31b815260040160405180910390fd5b600082815260146020526040902060040154600e805490919081106126d1576126d16157a4565b6000918252602090912001546040516344a5a61760e11b8152600481018490526001600160a01b039091169063894b4c2e90602401600060405180830381865afa158015612723573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107c29190810190615b1d565b6000818152600b602052604081206107c290614022565b6060806000612770846114e6565b9050806001600160401b0381111561278a5761278a61529a565b6040519080825280602002602001820160405280156127b3578160200160208202803683370190505b509250806001600160401b038111156127ce576127ce61529a565b60405190808252806020026020018201604052801561280757816020015b6127f4614ed8565b8152602001906001900390816127ec5790505b50915060005b818110156128d55761281f8582610ede565b848281518110612831576128316157a4565b60200260200101818152505060146000858381518110612853576128536157a4565b602002602001015181526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815250508382815181106128c2576128c26157a4565b602090810291909101015260010161280d565b5050915091565b6128e4612f13565b8260000361290557604051631f2a200560e01b815260040160405180910390fd5b61290e82613761565b60008061291e8585600186612f89565b9150915061293a3386601285815481106110d6576110d66157a4565b83336001600160a01b0316837f191a58d19a6a9b76e2e91bdc04ecbe7553dc094a5ad7af78175a0d9f884e264a8860405161297791815260200190565b60405180910390a483836001600160a01b0316837f614253edaf5943287293d855afffbb1f5f0403c51c84143aceaf27a50727b2fc846040516129bc91815260200190565b60405180910390a45050610af56001600c55565b6129d8612f13565b8082036129f857604051634cce529560e11b815260040160405180910390fd5b612a0182613761565b612a0a81613761565b6000828152601460205260408082208054600480830154868652939094209384015491939092918214612a5057604051634f13191b60e01b815260040160405180910390fd5b80546000612a5e8583615856565b905080600003612a8157604051636677a12d60e11b815260040160405180910390fd5b80836003015483612a92919061581d565b6003880154612aa1908861581d565b612aab9190615856565b612ab59190615834565b600384015580835560008080612acf8b8b898b8989613e4d565b9250925092506000612ae088613a6a565b9050600087600101548b600101548c6002015464e8d4a5100060118d81548110612b0c57612b0c6157a4565b90600052602060002090600302016001018881548110612b2e57612b2e6157a4565b90600052602060002001548b612b44919061581d565b60118e81548110612b5757612b576157a4565b90600052602060002090600302016001018a81548110612b7957612b796157a4565b90600052602060002001548f612b8f919061581d565b612b999190615856565b612ba3908761581d565b612bad9190615834565b612bb79190615856565b612bc1919061580a565b612bcb919061580a565b90508015612bed5780886002016000828254612be79190615856565b90915550505b64e8d4a5100060118a81548110612c0657612c066157a4565b90600052602060002090600302016001018481548110612c2857612c286157a4565b90600052602060002001548388612c3f919061581d565b612c49919061581d565b612c539190615834565b6001890155612c618d613b9e565b60008d8152601460205260408082208281556001810183905560028101839055600381018390556004810183905560050191909155518c908e907f285dbc28e663286c77e3cd79d1cf1525744b4dfe015f41295fe5ae2858880bdf90612cca908e815260200190565b60405180910390a35050505050505050505050610d326001600c55565b6000828152600a6020526040902060010154612d028161398b565b610af583836139b7565b612d14612f13565b612d1d81613761565b612d278282613c64565b610d326001600c55565b612d39614ed8565b50600090815260146020908152604091829020825160c08101845281548152600182015492810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b612dca8282611ed6565b610d32576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612e023390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611072836001600160a01b03841661402c565b60006001600160e01b03198216635a05180f60e01b14806107c257506107c28261407b565b612e8981612f6c565b610b435760405162461bcd60e51b8152600401610a54906158b6565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612eda82611392565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6002600c5403612f655760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a54565b6002600c55565b6000908152600260205260409020546001600160a01b0316151590565b600080612fc76040518060c0016040528060008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b600086815260146020526040902060048101549350612fe584613a6a565b825280546020830152600086600281111561300257613002615b8a565b0361302f5761301188886140a0565b8782602001516130219190615856565b6040830181905281556130bc565b600186600281111561304357613043615b8a565b036130b1578160200151881415801561308357506010848154811061306a5761306a6157a4565b600091825260209091206004600590920201015460ff16155b156130a157604051635ea3f5c160e01b815260040160405180910390fd5b878260200151613021919061580a565b602082015160408301525b6005810154606083018190526130d3908890614118565b608083018190526060830151146131a3578160200151601185815481106130fc576130fc6157a4565b9060005260206000209060030201600201836060015181548110613122576131226157a4565b90600052602060002001600082825461313b919061580a565b909155505060408201516011805486908110613159576131596157a4565b906000526020600020906003020160020183608001518154811061317f5761317f6157a4565b9060005260206000200160008282546131989190615856565b909155506132689050565b60008660028111156131b7576131b7615b8a565b036131f65787601185815481106131d0576131d06157a4565b906000526020600020906003020160020183606001518154811061317f5761317f6157a4565b600186600281111561320a5761320a615b8a565b03613268578760118581548110613223576132236157a4565b9060005260206000209060030201600201836060015181548110613249576132496157a4565b906000526020600020016000828254613262919061580a565b90915550505b806001015464e8d4a5100083600001516011878154811061328b5761328b6157a4565b90600052602060002090600302016001018560600151815481106132b1576132b16157a4565b906000526020600020015485602001516132cb919061581d565b6132d5919061581d565b6132df9190615834565b6132e9919061580a565b925064e8d4a51000826000015160118681548110613309576133096157a4565b906000526020600020906003020160010184608001518154811061332f5761332f6157a4565b90600052602060002001548460400151613349919061581d565b613353919061581d565b61335d9190615834565b60018201556001600160a01b03851615801560a0840181905261337f57508215155b156133a357828160020160008282546133989190615856565b909155506134b89050565b8160a00151156134b85760008160020154846133bf9190615856565b905060006133cc8261417e565b90506133d8818361580a565b600284015580156134b5576134176001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168883613a07565b60006013878154811061342c5761342c6157a4565b6000918252602090912001546001600160a01b0316905080156134b35760405163014a362160e71b8152600481018b9052602481018390526001600160a01b03898116604483015282169063a51b108090606401600060405180830381600087803b15801561349a57600080fd5b505af11580156134ae573d6000803e3d6000fd5b505050505b505b50505b60008660028111156134cc576134cc615b8a565b0361356b576000601385815481106134e6576134e66157a4565b6000918252602090912001546001600160a01b031690508015613565576040516303004b4760e01b815260048101899052602481018a90526001600160a01b038216906303004b4790604401600060405180830381600087803b15801561354c57600080fd5b505af1158015613560573d6000803e3d6000fd5b505050505b5061361a565b600186600281111561357f5761357f615b8a565b0361361a57600060138581548110613599576135996157a4565b6000918252602090912001546001600160a01b031690508015613618576040516305f7936f60e51b815260048101899052602481018a90526001600160a01b0382169063bef26de090604401600060405180830381600087803b1580156135ff57600080fd5b505af1158015613613573d6000803e3d6000fd5b505050505b505b505094509492505050565b6000806011838154811061363b5761363b6157a4565b600091825260208220600260039092020190810154909250905b818110156136bb57826001018181548110613672576136726157a4565b9060005260206000200154836002018281548110613692576136926157a4565b90600052602060002001546136a7919061581d565b6136b19085615856565b9350600101613655565b505050919050565b600f546040516315dd902560e21b8152600481018390526000916001600160a01b031690635776409490602401602060405180830381865afa15801561370d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137319190615ba0565b90506753444835ec58000081111561375c57604051632dfc35e960e21b815260040160405180910390fd5b919050565b61376b3382613788565b610b435760405163390cdd9b60e21b815260040160405180910390fd5b60008061379483611392565b9050806001600160a01b0316846001600160a01b031614806137bb57506137bb8185612d92565b806137df5750836001600160a01b03166137d4846109b9565b6001600160a01b0316145b949350505050565b826001600160a01b03166137fa82611392565b6001600160a01b03161461385e5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610a54565b6001600160a01b0382166138c05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a54565b6138cb838383614221565b600081815260046020908152604080832080546001600160a01b03191690556001600160a01b03861683526003909152812080546001929061390e90849061580a565b90915550506001600160a01b038216600090815260036020526040812080546001929061393c908490615856565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038681169182179092559151849391871691600080516020615d5883398151915291a4505050565b610b43813361422c565b61399f8282612dc0565b6000828152600b60205260409020610af59082612e46565b6139c18282614285565b6000828152600b60205260409020610af590826142ec565b6139e233610d65565b6139fe5760405162461bcd60e51b8152600401610a5490615869565b610b4381613b9e565b6040516001600160a01b038316602482015260448101829052610af590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614301565b6000613a7560105490565b8210613a945760405163904e0f5960e01b815260040160405180910390fd5b600060108381548110613aa957613aa96157a4565b6000918252602082206001600590920201908101549092504291613acd828461580a565b8454955090508015611fc1576000613ae487613625565b90508015613b4a5760006015548660020154613aff866136c3565b613b09908661581d565b613b13919061581d565b613b1d9190615834565b905081613b2f64e8d4a510008361581d565b613b399190615834565b613b439088615856565b8087559650505b60018501849055604080518581526020810183905290810187905287907fcb7325664a4a3b7c7223eefc492a97ca4fdf94d46884621e5a8fae5a04b2b9d29060600160405180910390a25050505050919050565b6000613ba982611392565b9050613bb781600084614221565b600082815260046020908152604080832080546001600160a01b03191690556001600160a01b038416835260039091528120805460019290613bfa90849061580a565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b03841690600080516020615d58833981519152908390a45050565b6000600d60008154613c5390615b04565b9182905550905061375c82826143d3565b81600003613c8557604051631f2a200560e01b815260040160405180910390fd5b6000613c948383600080612f89565b509050613ccd33308560128581548110613cb057613cb06157a4565b6000918252602090912001546001600160a01b03169291906143ed565b81613cd783611392565b6001600160a01b0316827f9a2a1e97e6d641080089aafc36750cfdef4c79f8b3ace6fa4c384fa2f047695986604051613d1291815260200190565b60405180910390a4505050565b60006110728383614425565b816001600160a01b0316836001600160a01b031603613d885760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610a54565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60606110728383604051806060016040528060278152602001615d316027913961444f565b613e258484846137e7565b613e31848484846144c7565b6120f05760405162461bcd60e51b8152600401610a5490615bb9565b60008681526014602052604080822060059081015488845291832001549091613e768883614118565b9050808314613ed4578560118881548110613e9357613e936157a4565b90600052602060002090600302016002018481548110613eb557613eb56157a4565b906000526020600020016000828254613ece919061580a565b90915550505b808214613f30578460118881548110613eef57613eef6157a4565b90600052602060002090600302016002018381548110613f1157613f116157a4565b906000526020600020016000828254613f2a919061580a565b90915550505b808314158015613f405750808214155b15613f9f578360118881548110613f5957613f596157a4565b90600052602060002090600302016002018281548110613f7b57613f7b6157a4565b906000526020600020016000828254613f949190615856565b909155506140169050565b808314613fba578560118881548110613f5957613f596157a4565b808214614016578460118881548110613fd557613fd56157a4565b90600052602060002090600302016002018281548110613ff757613ff76157a4565b9060005260206000200160008282546140109190615856565b90915550505b96509650969350505050565b60006107c2825490565b6000818152600183016020526040812054614073575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556107c2565b5060006107c2565b60006001600160e01b03198216637965db0b60e01b14806107c257506107c2826145c8565b6000818152601460205260408120805490918190036140c4574260038301556120f0565b60006140d085836145ed565b600384015490915060006140e4824261580a565b905064e8d4a510006140f6848361581d565b6141009190615834565b61410a9083615856565b600386015550505050505050565b600061412383611f1b565b60008481526014602052604090209091508282146120b7576005810182905560405182815284907f8bdaee675270281b7bc2d5b9ced20517ecf5ce96158973ef78072a7bc1491b449060200160405180910390a25092915050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156141e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061420b9190615ba0565b905082811161421a5780611072565b5090919050565b610af5838383614668565b6142368282611ed6565b610d325761424381614720565b61424e836020614732565b60405160200161425f929190615c0b565b60408051601f198184030181529082905262461bcd60e51b8252610a549160040161505b565b61428f8282611ed6565b15610d32576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611072836001600160a01b0384166148cd565b6000614356826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166149c09092919063ffffffff16565b805190915015610af557808060200190518101906143749190615c7a565b610af55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a54565b610d328282604051806020016040528060008152506149cf565b6040516001600160a01b03808516602483015283166044820152606481018290526120f09085906323b872dd60e01b90608401613a33565b600082600001828154811061443c5761443c6157a4565b9060005260206000200154905092915050565b6060600080856001600160a01b03168560405161446c9190615c97565b600060405180830381855af49150503d80600081146144a7576040519150601f19603f3d011682016040523d82523d6000602084013e6144ac565b606091505b50915091506144bd86838387614a02565b9695505050505050565b60006001600160a01b0384163b156145bd57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061450b903390899088908890600401615cb3565b6020604051808303816000875af1925050508015614546575060408051601f3d908101601f1916820190925261454391810190615ce6565b60015b6145a3573d808015614574576040519150601f19603f3d011682016040523d82523d6000602084013e614579565b606091505b50805160000361459b5760405162461bcd60e51b8152600401610a5490615bb9565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506137df565b506001949350505050565b60006001600160e01b0319821663780e9d6360e01b14806107c257506107c282614a7b565b600082821015614630576146018284615856565b6146108364e8d4a5100061581d565b61461a9190615834565b6146299064e8d4a5100061580a565b90506107c2565b8183101561465b576146428284615856565b6146518464e8d4a5100061581d565b6146299190615834565b5064746a52880092915050565b6001600160a01b0383166146c3576146be81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6146e6565b816001600160a01b0316836001600160a01b0316146146e6576146e68382614acb565b6001600160a01b0382166146fd57610af581614b68565b826001600160a01b0316826001600160a01b031614610af557610af58282614c17565b60606107c26001600160a01b03831660145b6060600061474183600261581d565b61474c906002615856565b6001600160401b038111156147635761476361529a565b6040519080825280601f01601f19166020018201604052801561478d576020820181803683370190505b509050600360fc1b816000815181106147a8576147a86157a4565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106147d7576147d76157a4565b60200101906001600160f81b031916908160001a90535060006147fb84600261581d565b614806906001615856565b90505b600181111561487e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061483a5761483a6157a4565b1a60f81b828281518110614850576148506157a4565b60200101906001600160f81b031916908160001a90535060049490941c9361487781615d03565b9050614809565b5083156110725760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a54565b600081815260018301602052604081205480156149b65760006148f160018361580a565b85549091506000906149059060019061580a565b905081811461496a576000866000018281548110614925576149256157a4565b9060005260206000200154905080876000018481548110614948576149486157a4565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061497b5761497b615d1a565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506107c2565b60009150506107c2565b60606137df8484600085614c5b565b6149d98383614d36565b6149e660008484846144c7565b610af55760405162461bcd60e51b8152600401610a5490615bb9565b60608315614a71578251600003614a6a576001600160a01b0385163b614a6a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a54565b50816137df565b6137df8383614e63565b60006001600160e01b031982166380ac58cd60e01b1480614aac57506001600160e01b03198216635b5e139f60e01b145b806107c257506301ffc9a760e01b6001600160e01b03198316146107c2565b60006001614ad8846114e6565b614ae2919061580a565b600083815260076020526040902054909150808214614b35576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090614b7a9060019061580a565b60008381526009602052604081205460088054939450909284908110614ba257614ba26157a4565b906000526020600020015490508060088381548110614bc357614bc36157a4565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480614bfb57614bfb615d1a565b6001900381819060005260206000200160009055905550505050565b6000614c22836114e6565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b606082471015614cbc5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a54565b600080866001600160a01b03168587604051614cd89190615c97565b60006040518083038185875af1925050503d8060008114614d15576040519150601f19603f3d011682016040523d82523d6000602084013e614d1a565b606091505b5091509150614d2b87838387614a02565b979650505050505050565b6001600160a01b038216614d8c5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a54565b614d9581612f6c565b15614de25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a54565b614dee60008383614221565b6001600160a01b0382166000908152600360205260408120805460019290614e17908490615856565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020615d58833981519152908290a45050565b815115614e735781518083602001fd5b8060405162461bcd60e51b8152600401610a54919061505b565b828054828255906000526020600020908101928215614ec8579160200282015b82811115614ec8578251825591602001919060010190614ead565b50614ed4929150614f0e565b5090565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b5b80821115614ed45760008155600101614f0f565b6001600160e01b031981168114610b4357600080fd5b600060208284031215614f4b57600080fd5b813561107281614f23565b600060208284031215614f6857600080fd5b5035919050565b600081518084526020808501945080840160005b83811015614f9f57815187529582019590820190600101614f83565b509495945050505050565b602081526000825160606020840152614fc66080840182614f6f565b90506020840151601f1980858403016040860152614fe48383614f6f565b92506040860151915080858403016060860152506150028282614f6f565b95945050505050565b60005b8381101561502657818101518382015260200161500e565b50506000910152565b6000815180845261504781602086016020860161500b565b601f01601f19169290920160200192915050565b602081526000611072602083018461502f565b80356001600160a01b038116811461375c57600080fd5b6000806040838503121561509857600080fd5b6150a18361506e565b946020939093013593505050565b600080604083850312156150c257600080fd5b823591506150d26020840161506e565b90509250929050565b6000806000606084860312156150f057600080fd5b6150f98461506e565b92506151076020850161506e565b9150604084013590509250925092565b602081528151602082015260208201516040820152604082015160608201526000606083015160a0608084015261515160c084018261502f565b90506080840151151560a08401528091505092915050565b6000806040838503121561517c57600080fd5b50508035926020909101359150565b60008083601f84011261519d57600080fd5b5081356001600160401b038111156151b457600080fd5b6020830191508360208260051b85010111156151cf57600080fd5b9250929050565b600080602083850312156151e957600080fd5b82356001600160401b038111156151ff57600080fd5b61520b8582860161518b565b90969095509350505050565b60008060006060848603121561522c57600080fd5b6152358461506e565b95602085013595506040909401359392505050565b60006020828403121561525c57600080fd5b6110728261506e565b60008060006060848603121561527a57600080fd5b83359250602084013591506152916040850161506e565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156152d8576152d861529a565b604052919050565b60006001600160401b038211156152f9576152f961529a565b50601f01601f191660200190565b600061531a615315846152e0565b6152b0565b905082815283838301111561532e57600080fd5b828260208301376000602084830101529392505050565b600082601f83011261535657600080fd5b61107283833560208501615307565b8015158114610b4357600080fd5b803561375c81615365565b6000806000806000806000806000806101008b8d03121561539e57600080fd5b8a3599506153ae60208c0161506e565b98506153bc60408c0161506e565b975060608b01356001600160401b03808211156153d857600080fd5b6153e48e838f0161518b565b909950975060808d01359150808211156153fd57600080fd5b6154098e838f0161518b565b909750955060a08d013591508082111561542257600080fd5b5061542f8d828e01615345565b93505061543e60c08c0161506e565b915061544c60e08c01615373565b90509295989b9194979a5092959850565b600080600080600080600060c0888a03121561547857600080fd5b873596506020880135955061548f6040890161506e565b945060608801356001600160401b03808211156154ab57600080fd5b818a0191508a601f8301126154bf57600080fd5b8135818111156154ce57600080fd5b8b60208285010111156154e057600080fd5b6020830196508095505050506154f86080890161506e565b915061550660a08901615373565b905092959891949750929550565b6000806040838503121561552757600080fd5b6155308361506e565b9150602083013561554081615365565b809150509250929050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156155a057603f1988860301845261558e85835161502f565b94509285019290850190600101615572565b5092979650505050505050565b600080600080608085870312156155c357600080fd5b6155cc8561506e565b93506155da6020860161506e565b92506040850135915060608501356001600160401b038111156155fc57600080fd5b8501601f8101871361560d57600080fd5b61561c87823560208401615307565b91505092959194509250565b60008060006060848603121561563d57600080fd5b505081359360208301359350604090920135919050565b602080825282518282018190526000919060409081850190868401855b828110156156a05781518051855286810151878601528501518585015260609093019290850190600101615671565b5091979650505050505050565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a08301525050565b604080825283519082018190526000906020906060840190828701845b8281101561572057815184529284019290840190600101615704565b5050508381038285015284518082528583019183019060005b8181101561575f5761574c8385516156ad565b9284019260c09290920191600101615739565b5090979650505050505050565b60c081016107c282846156ad565b6000806040838503121561578d57600080fd5b6157968361506e565b91506150d26020840161506e565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806157ce57607f821691505b6020821081036157ee57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156107c2576107c26157f4565b80820281158282048414176107c2576107c26157f4565b60008261585157634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156107c2576107c26157f4565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b601f821115610af557600081815260208120601f850160051c8101602086101561590f5750805b601f850160051c820191505b8181101561592e5782815560010161591b565b505050505050565b600019600383901b1c191660019190911b1790565b81516001600160401b038111156159645761596461529a565b6159788161597284546157ba565b846158e8565b602080601f8311600181146159a757600084156159955750858301515b61599f8582615936565b86555061592e565b600085815260208120601f198616915b828110156159d6578886015182559484019460019091019084016159b7565b50858210156159f45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6001600160401b03831115615a1b57615a1b61529a565b615a2f83615a2983546157ba565b836158e8565b6000601f841160018114615a5d5760008515615a4b5750838201355b615a558682615936565b845550615ab7565b600083815260209020601f19861690835b82811015615a8e5786850135825560209485019460019092019101615a6e565b5086821015615aab5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6000808335601e19843603018112615ad557600080fd5b8301803591506001600160401b03821115615aef57600080fd5b6020019150368190038213156151cf57600080fd5b600060018201615b1657615b166157f4565b5060010190565b600060208284031215615b2f57600080fd5b81516001600160401b03811115615b4557600080fd5b8201601f81018413615b5657600080fd5b8051615b64615315826152e0565b818152856020838501011115615b7957600080fd5b61500282602083016020860161500b565b634e487b7160e01b600052602160045260246000fd5b600060208284031215615bb257600080fd5b5051919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615c3d81601785016020880161500b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615c6e81602884016020880161500b565b01602801949350505050565b600060208284031215615c8c57600080fd5b815161107281615365565b60008251615ca981846020870161500b565b9190910192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906144bd9083018461502f565b600060208284031215615cf857600080fd5b815161107281614f23565b600081615d1257615d126157f4565b506000190190565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220d3a6fcb430175e3d92bcc9c3eb71481ffe8fa2603a851f79252d82f2a040dd2164736f6c6343000811003300000000000000000000000021ada0d2ac28c3a5fa3cd2ee30882da8812279b60000000000000000000000009154aebb61174774f691d8d8c99576971e6bbfd8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000d4469676974204465706f7369740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044449474900000000000000000000000000000000000000000000000000000000

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

00000000000000000000000021ada0d2ac28c3a5fa3cd2ee30882da8812279b60000000000000000000000009154aebb61174774f691d8d8c99576971e6bbfd8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000d4469676974204465706f7369740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044449474900000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _rewardToken (address): 0x21ada0d2ac28c3a5fa3cd2ee30882da8812279b6
Arg [1] : _emissionCurve (address): 0x9154aebb61174774f691d8d8c99576971e6bbfd8
Arg [2] : name (string): Digit Deposit
Arg [3] : symbol (string): DIGI

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000021ada0d2ac28c3a5fa3cd2ee30882da8812279b6
Arg [1] : 0000000000000000000000009154aebb61174774f691d8d8c99576971e6bbfd8
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [4] : 000000000000000000000000000000000000000000000000000000000000000d
Arg [5] : 4469676974204465706f73697400000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [7] : 4449474900000000000000000000000000000000000000000000000000000000


Loading