false
false

Contract Address Details

0x3558e707f29f589c99585B17bB217267B56807eD

Contract Name
StakingV1
Creator
0x34ccc8–1bb8ba at 0xfa29f5–2fed54
Balance
0 BTCC
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
30739616
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
StakingV1




Optimization enabled
true
Compiler version
v0.8.6+commit.11564f7e




Optimization runs
200
EVM Version
default




Verified at
2023-10-16T04:27:56.585830Z

contracts/StakingV1.sol

Sol2uml
new
// SPDX-License-Identifier: MIT

pragma solidity 0.8.6;

import {ERC721HolderUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import {EnumerableMapUpgradeable as EnumerableMap} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol";
import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {SafeMathUpgradeable as SafeMath} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC721Upgradeable as IERC721} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import {MathUpgradeable as Math} from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {INFTProperty} from "./interface/INFTProperty.sol";
import {IBFuel} from "./interface/IBFuel.sol";

contract StakingV1 is 
    ReentrancyGuardUpgradeable, 
    OwnableUpgradeable, 
    PausableUpgradeable, 
    ERC721HolderUpgradeable, 
    UUPSUpgradeable 
{
    using SafeMath for uint256;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    mapping(address => EnumerableMap.UintToAddressMap) private _minerOwners;

    struct NftStake {
        address staker;
        address nftAddr;
        uint256 minerId;
        uint256 hashRate;
        uint256 consumption;
        uint256 lastUpdateTime;
    }

    mapping(address => bool) public minerList;
    INFTProperty public property;

    /* ========== STATE VARIABLES ========== */
    // addreses
    IBFuel public bFuel;
    IERC721 public NFTMiner;

    uint256 private _totalHashRate;
    uint256 private _totalConsumption;

    address public fuelReceiver;
    uint256 public lastUpdateTime;
    uint256 public bFuelRate;
    uint256 public rewardRate;
    uint256 public consumptionRate;
    uint256 public periodFinish;
    uint256 public deductionCount;
    uint256 public rewardsDuration;
    uint256 public rewardPerHashRateStored;
    uint256 public consumptionPerHashRateStored;
    uint256 public BASE_DIVIDER;
    uint256 public FIRST_EPOCH_REWARDS;

    // User's reward amount
    mapping(address => uint256) public rewards;
    mapping(address => mapping(uint256 => NftStake)) public nftStakes;
    mapping(address => uint256) public consumptions;
    // user's computing power
    mapping(address => uint256) private _hashRateOf;
    // User consumption
    mapping(address => uint256) private _consumptionOf;
    // User consumption all
    mapping(address => uint256) private _consumptionAllOf;
    mapping(address => uint256) public userRewardPerHashRatePaid;
    mapping(address => uint256) public userConsumptionPerHashRatePaid;
    mapping(address => mapping(address => EnumerableSet.UintSet)) private _holderMiners;

    /* ========== CONSTRUCTOR ========== */

    constructor() {
        _disableInitializers();
    }

    receive() external payable {}

    modifier onlyValidMiner(address miner) {
        require(minerList[miner] == true, "E: miner is not valid");
        _;
    }

    function initialize(
        address _bFuelToken,
        address _property,
        uint256 _rewardsDuration
    ) external initializer {
        __ERC721Holder_init();
        __ReentrancyGuard_init();
        __Pausable_init();
        __Ownable_init();
        __UUPSUpgradeable_init();

        require(_rewardsDuration != 0, "rewardsDuration is zero");
        bFuel = IBFuel(_bFuelToken);
        property = INFTProperty(_property);
        rewardsDuration = _rewardsDuration;

        bFuelRate = 50;
        BASE_DIVIDER = 100;
        FIRST_EPOCH_REWARDS = 50 * 6 * 24 * 365 * 4 ether;
    }

    // Open mining pool
    function start() external payable onlyOwner {
        notifyRewardAmount(FIRST_EPOCH_REWARDS);
        emit Start(msg.sender);
    }

    // Initialize basic data
    function notifyRewardAmount(uint256 reward)
        private
        updateReward(address(0))
    {
        consumptionRate = uint256(1e18).div(3600);
        if (block.timestamp >= periodFinish) {
            rewardRate = reward.div(rewardsDuration);
        } else {
            uint256 remaining = periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(rewardRate);
            rewardRate = reward.add(leftover).div(rewardsDuration);
        }

        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp.add(rewardsDuration);
        emit RewardAdded(reward);
    }

    function lastTimeRewardApplicable() public view returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    // Reward per unit of token
    function rewardPerToken() public view returns (uint256) {
        if (_totalHashRate == 0) {
            return rewardPerHashRateStored;
        }

        return
            rewardPerHashRateStored.add(
                lastTimeRewardApplicable()
                    .sub(lastUpdateTime)
                    .mul(rewardRate)
                    .mul(1e18)
                    .div(_totalHashRate)
            );
    }

    function consumptionPerToken() public view returns (uint256) {
        if (_totalHashRate == 0) {
            return consumptionPerHashRateStored;
        }

        return
            consumptionPerHashRateStored.add(
                lastTimeRewardApplicable().sub(lastUpdateTime).mul(
                    consumptionRate
                )
            );
    }

    // Calculate earnings
    function earned(address _owner) public view returns (uint256) {
        return
            _hashRateOf[_owner]
                .mul(rewardPerToken().sub(userRewardPerHashRatePaid[_owner]))
                .div(1e18)
                .add(rewards[_owner]);
    }

    // Calculate consumption
    function consumption(address _owner) public view returns (uint256) {
        return
            _consumptionOf[_owner]
                .mul(
                    consumptionPerToken().sub(
                        userConsumptionPerHashRatePaid[_owner]
                    )
                )
                .add(consumptions[_owner]);
    }

    /**
     *    @notice nft deposit contract
     *    @param minerIds => array of nft ids
     */
    function batchStake(address[] calldata nftAddrs, uint256[] calldata minerIds) external {
        for (uint256 i = 0; i < minerIds.length; i++) {
            stake(nftAddrs[i], minerIds[i]);
        }
    }

    /**
     *    @notice nft deposit contract
     *    @param minerId => nft id
     */
    function stake(address nftAddr, uint256 minerId)
        public
        whenNotPaused
        onlyValidMiner(nftAddr)
        updateReward(msg.sender)
        nonReentrant
    {
        uint256 hashRate = property.getHashRate(nftAddr, minerId);
        require(hashRate != 0, "Staking: Id not exist");
        uint256 _consumption = property.getConsumption(nftAddr, minerId);
        require(_consumption != 0, "Staking: Id not exist");

        IERC721(nftAddr).safeTransferFrom(msg.sender, address(this), minerId);

        nftStakes[nftAddr][minerId] = NftStake({
            staker: msg.sender,
            nftAddr: nftAddr,
            minerId: minerId,
            hashRate: hashRate,
            consumption: _consumption,
            lastUpdateTime: block.timestamp
        });
        _holderMiners[nftAddr][msg.sender].add(minerId);
        _minerOwners[nftAddr].set(minerId, msg.sender);
        _totalHashRate = _totalHashRate.add(hashRate);
        _hashRateOf[msg.sender] = _hashRateOf[msg.sender].add(hashRate);
        _consumptionOf[msg.sender] = _consumptionOf[msg.sender].add(
            _consumption
        );
        emit MinerStaked(msg.sender, nftAddr, minerId);
    }

    /**
     *   @notice withdraw nft from contract
     */
    function batchWithdrawMiners(address[] calldata nftAddrs, uint256[] calldata minerIds) external {
        for (uint256 i = 0; i < minerIds.length; i++) {
            withdrawMiner(nftAddrs[i], minerIds[i]);
        }
    }

    /**
     *   @notice withdraw nft from contract
     */
    function withdrawAllMiners(address nftAddr) external {
        uint256 amount = minerAmountOf(nftAddr, msg.sender);
        for (uint256 i = 0; i < amount; i++) {
            withdrawMiner(nftAddr, minerOfOwnerByIndex(nftAddr, msg.sender, 0));
        }
    }

    /**
     *   @notice withdraw nft from contract
     */
    function withdrawMiner(address nftAddr, uint256 minerId)
        public
        updateReward(msg.sender)
        onlyValidMiner(nftAddr)
        checkDeduction
        nonReentrant
    {
        require(
            minerOwnerOf(nftAddr, minerId) == msg.sender,
            "withdraw of token that is not own"
        );
        NftStake memory nftStake = nftStakes[nftAddr][minerId];
        _totalHashRate = _totalHashRate.sub(nftStake.hashRate);
        _hashRateOf[msg.sender] = _hashRateOf[msg.sender].sub(
            nftStake.hashRate
        );

        _consumptionOf[msg.sender] = _consumptionOf[msg.sender].sub(
            nftStake.consumption
        );
        _holderMiners[nftAddr][msg.sender].remove(minerId);
        _minerOwners[nftAddr].set(minerId, address(0));

        delete nftStakes[nftAddr][minerId];

        IERC721(nftAddr).safeTransferFrom(address(this), msg.sender, minerId);
        emit MinerWithdrawn(msg.sender, nftAddr, minerId);
    }

    // Receive award
    function getReward()
        public
        nonReentrant
        updateReward(msg.sender)
        checkDeduction
    {
        uint256 reward = rewards[msg.sender];
        uint256 currentConsumption = consumptions[msg.sender];
        uint256 bFuelAmount = bFuel.balanceOf(msg.sender);
        require(
            bFuelAmount >= currentConsumption,
            "BFuel Insufficient balance"
        );
        _consumptionAllOf[msg.sender] = _consumptionAllOf[msg.sender].add(
            currentConsumption
        );
        _totalConsumption = _totalConsumption.add(currentConsumption);
        if (reward > 0) {
            uint256 burnAmount = currentConsumption.mul(bFuelRate).div(
                BASE_DIVIDER
            );
            bFuel.transferFrom(
                msg.sender,
                fuelReceiver,
                currentConsumption.sub(burnAmount)
            );
            //mFuel burn
            bFuel.transferFrom(msg.sender, address(this), burnAmount);
            bFuel.burn(burnAmount);

            rewards[msg.sender] = 0;
            consumptions[msg.sender] = 0;
            (bool success, ) = payable(msg.sender).call{value: reward}("");
            require(success, "E: reward transfer error");
            emit RewardPaid(msg.sender, reward);
        }
    }

     // Receive award
    function getExactReward(uint256 exactReward)
        public
        nonReentrant
        updateReward(msg.sender)
        checkDeduction
    {
        uint256 reward = rewards[msg.sender];
        uint256 currentConsumption = consumptions[msg.sender];
        uint256 bFuelAmount = bFuel.balanceOf(msg.sender);
        
        uint256 exactConsumption = exactReward.mul(currentConsumption).div(reward);
        require(
            bFuelAmount >= exactConsumption,
            "BFuel Insufficient balance"
        );
        require(
            reward >= exactReward,
            "E: exact reward exceed reward"
        );


        _consumptionAllOf[msg.sender] = _consumptionAllOf[msg.sender].add(
            exactConsumption
        );
        _totalConsumption = _totalConsumption.add(exactConsumption);
        if (reward > 0) {
            uint256 burnAmount = exactConsumption.mul(bFuelRate).div(
                BASE_DIVIDER
            );
            bFuel.transferFrom(
                msg.sender,
                fuelReceiver,
                exactConsumption.sub(burnAmount)
            );
            //mFuel burn
            bFuel.transferFrom(msg.sender, address(this), burnAmount);
            bFuel.burn(burnAmount);

            rewards[msg.sender] = reward.sub(exactReward);
            consumptions[msg.sender] = currentConsumption.sub(exactConsumption);
            (bool success, ) = payable(msg.sender).call{value: exactReward}("");
            require(success, "E: reward transfer error");
            emit RewardPaid(msg.sender, exactReward);
        }
    }

    // total hashrate
    function totalHashRate() external view returns (uint256) {
        return _totalHashRate;
    }

    // owner hashrate
    function hashRateOf(address _owner) external view returns (uint256) {
        return _hashRateOf[_owner];
    }

    // total consumption
    function totalConsumption() external view returns (uint256) {
        return _totalConsumption;
    }

    // owner consumption
    function consumptionOf(address _owner) external view returns (uint256) {
        return _consumptionOf[_owner];
    }

    // owner consumption all
    function consumptionAllOf(address _owner) external view returns (uint256) {
        return _consumptionAllOf[_owner];
    }

    function minerOwnerOf(address nftAddr, uint256 tokenId) private view returns (address) {
        return _minerOwners[nftAddr].get(tokenId, "query for nonexistent token");
    }

    function minerAmountOf(address nftAddr, address owner) public view returns (uint256) {
        require(
            owner != address(0),
            "Staking: balance query for the zero address"
        );
        return _holderMiners[nftAddr][owner].length();
    }

    function minerOfOwnerByIndex(address nftAddr, address owner, uint256 index)
        public
        view
        returns (uint256)
    {
        return _holderMiners[nftAddr][owner].at(index);
    }

    function setBFuelAddress(address _addr) external onlyOwner whenNotPaused {
        require(_addr != address(0), "address is zero");
        bFuel = IBFuel(_addr);
    }

    function setNFTStatus(address _addr, bool status) external onlyOwner whenNotPaused {
        require(_addr != address(0), "address is zero");
        minerList[_addr] = status;
    }

    function setProperty(address _addr) external onlyOwner whenNotPaused {
        require(_addr != address(0), "address is zero");
        property = INFTProperty(_addr);
    }

    function setBFuelRate(uint256 rate) external onlyOwner whenNotPaused {
        require(rate > 0, "rate is zero");
        bFuelRate = rate;
        emit SetBFuelRate(rate, msg.sender);
    }

    function setFuelReceiver(address _address)
        external
        onlyOwner
        whenNotPaused
    {
        require(_address != address(0), "address is zero");
        fuelReceiver = _address;
        emit SetFuelReceiver(_address, msg.sender);
    }

    function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
        require(
            block.timestamp > periodFinish,
            "Previous rewards period must be complete before changing the duration for the new period"
        );
        rewardsDuration = _rewardsDuration;
        emit RewardsDurationUpdated(rewardsDuration);
    }

    function getRewardForDuration() external view returns (uint256) {
        return rewardRate.mul(rewardsDuration);
    }

    function pause() public virtual onlyOwner {
        _pause();
        emit SetPause(msg.sender);
    }

    function unpause() public virtual onlyOwner {
        _unpause();
        emit SetUnPause(msg.sender);
    }

    // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
    function recover(address recipient)
        external
        onlyOwner
    {
        // Cannot recover the staking token or the rewards token
        require(
            recipient != address(0),
            "E: recipient address can'be 0"
        );
        uint256 balance = address(this).balance;
        (bool success, ) = payable(recipient).call{value: balance}("");
        require(success, "E: recover transfer error");
        emit Recovered(recipient, balance);
    }

    /* ========== MODIFIERS ========== */

    modifier updateReward(address owner) {
        rewardPerHashRateStored = rewardPerToken();
        consumptionPerHashRateStored = consumptionPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        if (owner != address(0)) {
            rewards[owner] = earned(owner);
            consumptions[owner] = consumption(owner);
            userRewardPerHashRatePaid[owner] = rewardPerHashRateStored;
            userConsumptionPerHashRatePaid[
                owner
            ] = consumptionPerHashRateStored;
        }
        _;
    }

    // todo periodFinish > 0
    modifier checkDeduction() {
        if (periodFinish != 0) {
            if (block.timestamp > periodFinish) {
                deductionCount = deductionCount.add(1);
                uint256 nextEpochRewards = FIRST_EPOCH_REWARDS;
                for (uint256 i = 1; i <= deductionCount; i++) {
                    nextEpochRewards = nextEpochRewards.div(2);
                }
                notifyRewardAmount(nextEpochRewards);
            }
        }
        _;
    }

    /// uups interface
    function _authorizeUpgrade(address newImplementation)
        internal
        override
        view
        onlyOwner
    { }


    /* ========== EVENTS ========== */

    event Start(address user);
    event SetPause(address _owner);
    event SetUnPause(address _owner);
    event RewardAdded(uint256 reward);
    event MinerStaked(address indexed user, address indexed nftAddr, uint256 id);
    event MinerWithdrawn(address indexed user, address indexed nftAddr, uint256 id);
    event RewardPaid(address indexed user, uint256 reward);
    event RewardsDurationUpdated(uint256 newDuration);
    event Recovered(address token, uint256 amount);
    event SetBFuelRate(uint256 rate, address user);
    event SetFuelReceiver(address recevier, address user);
}
        

@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
          

@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

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

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

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

@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate that the this implementation remains valid after an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

contracts/interface/IBFuel.sol

// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.1.0
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/interfaces/IERC20.sol";

interface IBFuel is IERC20 {
    function burn(uint256 amount) external returns (bool);
}
          

contracts/interface/INFTProperty.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.6;

interface INFTProperty {
    function addProperty(address nftAddr, uint256 id, uint256[] calldata properties) external;

    function removeProperty(address nftAddr, uint256 id) external;

    function getHashRate(address nftAddr, uint256 id) external view returns (uint256 hashRate);

    function getConsumption(address nftAddr, uint256 id)
        external
        view
        returns (uint256 consumption);

    function getCreateTime(address nftAddr, uint256 id) external view returns (uint256 time);
}
          

@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

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

@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}
          

@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @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) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol

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

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

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

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

@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.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 IERC20Upgradeable {
    /**
     * @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);
}
          

@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must 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);
}
          

@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

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

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

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

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

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

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

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

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

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

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

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

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

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

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

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

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

@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableMap.sol)

pragma solidity ^0.8.0;

import "./EnumerableSetUpgradeable.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * The following map types are supported:
 *
 * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0
 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0
 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
 *
 * [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 EnumerableMap, you can either remove all elements one by one or create a fresh instance using an array of EnumerableMap.
 * ====
 */
library EnumerableMapUpgradeable {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSetUpgradeable.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        bytes32 value
    ) internal returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
        return map._keys.length();
    }

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        return value;
    }

    // UintToUintMap

    struct UintToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToUintMap storage map,
        uint256 key,
        uint256 value
    ) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (uint256(key), uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key)));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToUintMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key), errorMessage));
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToAddressMap storage map,
        uint256 key,
        address value
    ) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

    // AddressToUintMap

    struct AddressToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        AddressToUintMap storage map,
        address key,
        uint256 value
    ) internal returns (bool) {
        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(AddressToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (address(uint160(uint256(key))), uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }

    // Bytes32ToUintMap

    struct Bytes32ToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        Bytes32ToUintMap storage map,
        bytes32 key,
        uint256 value
    ) internal returns (bool) {
        return set(map._inner, key, bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (key, uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, key);
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
        return uint256(get(map._inner, key));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToUintMap storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, key, errorMessage));
    }
}
          

@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.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 EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

@openzeppelin/contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";
          

@openzeppelin/contracts/token/ERC20/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);
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"MinerStaked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"nftAddr","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MinerWithdrawn","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"nftAddr","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Recovered","inputs":[{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardAdded","inputs":[{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsDurationUpdated","inputs":[{"type":"uint256","name":"newDuration","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SetBFuelRate","inputs":[{"type":"uint256","name":"rate","internalType":"uint256","indexed":false},{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetFuelReceiver","inputs":[{"type":"address","name":"recevier","internalType":"address","indexed":false},{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetPause","inputs":[{"type":"address","name":"_owner","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetUnPause","inputs":[{"type":"address","name":"_owner","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Start","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"BASE_DIVIDER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FIRST_EPOCH_REWARDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC721Upgradeable"}],"name":"NFTMiner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IBFuel"}],"name":"bFuel","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bFuelRate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchStake","inputs":[{"type":"address[]","name":"nftAddrs","internalType":"address[]"},{"type":"uint256[]","name":"minerIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchWithdrawMiners","inputs":[{"type":"address[]","name":"nftAddrs","internalType":"address[]"},{"type":"uint256[]","name":"minerIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumption","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionAllOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionPerHashRateStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptions","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"deductionCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"earned","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"fuelReceiver","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getExactReward","inputs":[{"type":"uint256","name":"exactReward","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getReward","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRewardForDuration","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"hashRateOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_bFuelToken","internalType":"address"},{"type":"address","name":"_property","internalType":"address"},{"type":"uint256","name":"_rewardsDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastTimeRewardApplicable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastUpdateTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minerAmountOf","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"minerList","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minerOfOwnerByIndex","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"staker","internalType":"address"},{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"},{"type":"uint256","name":"hashRate","internalType":"uint256"},{"type":"uint256","name":"consumption","internalType":"uint256"},{"type":"uint256","name":"lastUpdateTime","internalType":"uint256"}],"name":"nftStakes","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"periodFinish","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INFTProperty"}],"name":"property","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recover","inputs":[{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerHashRateStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewards","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsDuration","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBFuelAddress","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBFuelRate","inputs":[{"type":"uint256","name":"rate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFuelReceiver","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFTStatus","inputs":[{"type":"address","name":"_addr","internalType":"address"},{"type":"bool","name":"status","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProperty","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardsDuration","inputs":[{"type":"uint256","name":"_rewardsDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"start","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalConsumption","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalHashRate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userConsumptionPerHashRatePaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userRewardPerHashRatePaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawAllMiners","inputs":[{"type":"address","name":"nftAddr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawMiner","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x60a06040523060601b6080523480156200001857600080fd5b506200002362000029565b620000eb565b600054610100900460ff1615620000965760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e9576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60805160601c613ecd62000126600039600081816116c90152818161170901528181611d6301528181611da30152611e360152613ecd6000f3fe60806040526004361061039a5760003560e01c80636cf7f80e116101dc578063bb40501911610102578063cd3daf9d116100a0578063e671b61a1161006f578063e671b61a14610b23578063ebe2b12b14610b3a578063ee1f188414610b51578063f2fde38b14610b7157600080fd5b8063cd3daf9d14610a93578063d9d11b4d14610aa8578063da3b6b3514610ad6578063e30d80da14610aec57600080fd5b8063c722f719116100dc578063c722f71914610a26578063c8f33c9114610a46578063c9f9cc5214610a5d578063cc1a378f14610a7357600080fd5b8063bb405019146109de578063be36c1c1146109fe578063be9a655514610a1e57600080fd5b80638456cb591161017a578063a8cb026d11610149578063a8cb026d14610962578063a9a5a51d14610990578063ac294d8e146109a7578063adc9772e146109be57600080fd5b80638456cb59146108e15780638557b84a146108f65780638da5cb5b1461092d57806397a6a62b1461094b57600080fd5b8063760ff3c9116101b6578063760ff3c91461085e5780637b0a47ee1461089557806380faa57d146108ac57806382d7db3c146108c157600080fd5b80636cf7f80e14610809578063715018a61461082957806374fcbd411461083e57600080fd5b806331d1b220116102c1578063400f92111161025f57806352d1902d1161022e57806352d1902d1461071b5780635c975abb14610730578063633f7155146107485780636b950e641461076857600080fd5b8063400f92111461068657806341671ca1146106a65780634f1ef286146106e75780635242d76d146106fa57600080fd5b8063386a95251161029b578063386a9525146106245780633d18b9121461063b5780633d8c2d20146106505780633f4ba83a1461067157600080fd5b806331d1b220146105cd57806332b95a6f146105e45780633659cfe61461060457600080fd5b806314e44a9d116103395780631c1f78eb116103085780631c1f78eb146105555780631e492f511461056a5780631fff315d1461059857806320c18f30146105b857600080fd5b806314e44a9d14610497578063150b7a02146104d0578063176fd3f0146105145780631794bb3c1461053557600080fd5b80630cd865ec116103755780630cd865ec1461041e5780630d6f6f5d14610440578063139656cb14610460578063144441b41461047757600080fd5b80628cc262146103a657806305c1fec4146103d95780630700037d146103f057600080fd5b366103a157005b600080fd5b3480156103b257600080fd5b506103c66103c1366004613921565b610b91565b6040519081526020015b60405180910390f35b3480156103e557600080fd5b506103c66101715481565b3480156103fc57600080fd5b506103c661040b366004613921565b6101726020526000908152604090205481565b34801561042a57600080fd5b5061043e610439366004613921565b610c12565b005b34801561044c57600080fd5b5061043e61045b366004613b64565b610d5f565b34801561046c57600080fd5b506103c66101705481565b34801561048357600080fd5b5061043e610492366004613921565b6112eb565b3480156104a357600080fd5b50610166546104b8906001600160a01b031681565b6040516001600160a01b0390911681526020016103d0565b3480156104dc57600080fd5b506104fb6104eb3660046139ab565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016103d0565b34801561052057600080fd5b50610161546104b8906001600160a01b031681565b34801561054157600080fd5b5061043e61055036600461396f565b61137c565b34801561056157600080fd5b506103c6611551565b34801561057657600080fd5b506103c6610585366004613921565b6101786020526000908152604090205481565b3480156105a457600080fd5b506103c66105b336600461393c565b611571565b3480156105c457600080fd5b506103c6611613565b3480156105d957600080fd5b506103c661016c5481565b3480156105f057600080fd5b5061043e6105ff366004613ac2565b611652565b34801561061057600080fd5b5061043e61061f366004613921565b6116be565b34801561063057600080fd5b506103c661016d5481565b34801561064757600080fd5b5061043e61179e565b34801561065c57600080fd5b50610162546104b8906001600160a01b031681565b34801561067d57600080fd5b5061043e611cb0565b34801561069257600080fd5b5061043e6106a1366004613a13565b611cf6565b3480156106b257600080fd5b506106d76106c1366004613921565b6101606020526000908152604090205460ff1681565b60405190151581526020016103d0565b61043e6106f5366004613a4a565b611d58565b34801561070657600080fd5b50610163546104b8906001600160a01b031681565b34801561072757600080fd5b506103c6611e29565b34801561073c57600080fd5b5060975460ff166106d7565b34801561075457600080fd5b506103c6610763366004613921565b611edc565b34801561077457600080fd5b506107d1610783366004613a98565b6101736020908152600092835260408084209091529082529020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c0016103d0565b34801561081557600080fd5b5061043e610824366004613921565b611f37565b34801561083557600080fd5b5061043e611f90565b34801561084a57600080fd5b5061043e610859366004613921565b611fa4565b34801561086a57600080fd5b506103c6610879366004613921565b6001600160a01b03166000908152610175602052604090205490565b3480156108a157600080fd5b506103c66101695481565b3480156108b857600080fd5b506103c6611ffd565b3480156108cd57600080fd5b5061043e6108dc366004613a98565b61200c565b3480156108ed57600080fd5b5061043e612435565b34801561090257600080fd5b506103c6610911366004613921565b6001600160a01b03166000908152610176602052604090205490565b34801561093957600080fd5b506065546001600160a01b03166104b8565b34801561095757600080fd5b506103c66101685481565b34801561096e57600080fd5b506103c661097d366004613921565b6101746020526000908152604090205481565b34801561099c57600080fd5b506103c661016f5481565b3480156109b357600080fd5b506103c661016e5481565b3480156109ca57600080fd5b5061043e6109d9366004613a98565b612475565b3480156109ea57600080fd5b5061043e6109f9366004613b64565b6129d4565b348015610a0a57600080fd5b5061043e610a19366004613ac2565b612a5e565b61043e612ac3565b348015610a3257600080fd5b5061043e610a41366004613921565b612b07565b348015610a5257600080fd5b506103c66101675481565b348015610a6957600080fd5b50610165546103c6565b348015610a7f57600080fd5b5061043e610a8e366004613b64565b612b47565b348015610a9f57600080fd5b506103c6612c23565b348015610ab457600080fd5b506103c6610ac3366004613921565b6101796020526000908152604090205481565b348015610ae257600080fd5b50610164546103c6565b348015610af857600080fd5b506103c6610b07366004613921565b6001600160a01b03166000908152610177602052604090205490565b348015610b2f57600080fd5b506103c661016a5481565b348015610b4657600080fd5b506103c661016b5481565b348015610b5d57600080fd5b506103c6610b6c36600461396f565b612c6f565b348015610b7d57600080fd5b5061043e610b8c366004613921565b612ca9565b6001600160a01b03811660009081526101726020908152604080832054610178909252822054610c0c9190610c0690670de0b6b3a764000090610c0090610be090610bda612c23565b90612d1f565b6001600160a01b0388166000908152610175602052604090205490612d2b565b90612d37565b90612d43565b92915050565b610c1a612d4f565b6001600160a01b038116610c755760405162461bcd60e51b815260206004820152601d60248201527f453a20726563697069656e7420616464726573732063616e276265203000000060448201526064015b60405180910390fd5b60405147906000906001600160a01b0384169083908381818185875af1925050503d8060008114610cc2576040519150601f19603f3d011682016040523d82523d6000602084013e610cc7565b606091505b5050905080610d185760405162461bcd60e51b815260206004820152601960248201527f453a207265636f766572207472616e73666572206572726f72000000000000006044820152606401610c6c565b604080516001600160a01b0385168152602081018490527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a1505050565b60026001541415610d825760405162461bcd60e51b8152600401610c6c90613cfc565b600260015533610d90612c23565b61016e55610d9c611613565b61016f55610da8611ffd565b610167556001600160a01b03811615610e2357610dc481610b91565b6001600160a01b03821660009081526101726020526040902055610de781611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b5415610e865761016b54421115610e865761016c54610e46906001612d43565b61016c556101715460015b61016c548111610e7a57610e66826002612d37565b915080610e7281613dcf565b915050610e51565b50610e8481612da9565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b158015610eee57600080fd5b505afa158015610f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f269190613b4b565b90506000610f3884610c008886612d2b565b905080821015610f8a5760405162461bcd60e51b815260206004820152601a60248201527f424675656c20496e73756666696369656e742062616c616e63650000000000006044820152606401610c6c565b85841015610fda5760405162461bcd60e51b815260206004820152601d60248201527f453a2065786163742072657761726420657863656564207265776172640000006044820152606401610c6c565b3360009081526101776020526040902054610ff59082612d43565b3360009081526101776020526040902055610165546110149082612d43565b6101655583156112df57600061103d61017054610c006101685485612d2b90919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd913391166110678686612d1f565b6040518463ffffffff1660e01b815260040161108593929190613b99565b602060405180830381600087803b15801561109f57600080fd5b505af11580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d79190613b2e565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd9061110d90339030908690600401613b99565b602060405180830381600087803b15801561112757600080fd5b505af115801561113b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115f9190613b2e565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b1580156111a757600080fd5b505af11580156111bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111df9190613b2e565b506111ea8588612d1f565b33600090815261017260205260409020556112058483612d1f565b336000818152610174602052604080822093909355915189908381818185875af1925050503d8060008114611256576040519150601f19603f3d011682016040523d82523d6000602084013e61125b565b606091505b50509050806112a75760405162461bcd60e51b8152602060048201526018602482015277229d103932bbb0b932103a3930b739b332b91032b93937b960411b6044820152606401610c6c565b60405188815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b50506001805550505050565b6112f3612d4f565b6112fb612f17565b6001600160a01b0381166113215760405162461bcd60e51b8152600401610c6c90613c88565b61016680546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f725540d4066d55e571d1f3a39840626c921529b8df65b93b870c24df49e57eaa91015b60405180910390a150565b600054610100900460ff161580801561139c5750600054600160ff909116105b806113b65750303b1580156113b6575060005460ff166001145b6114195760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c6c565b6000805460ff19166001179055801561143c576000805461ff0019166101001790555b611444612f5d565b61144c612f84565b611454612fb3565b61145c612fe2565b611464612f5d565b816114b15760405162461bcd60e51b815260206004820152601760248201527f726577617264734475726174696f6e206973207a65726f0000000000000000006044820152606401610c6c565b61016280546001600160a01b038087166001600160a01b03199283161790925561016180549286169290911691909117905561016d8290556032610168556064610170556a08b200a96f8d058a00000061017155801561154b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b600061156c61016d5461016954612d2b90919063ffffffff16565b905090565b60006001600160a01b0382166115dd5760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e673a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610c6c565b6001600160a01b03808416600090815261017a6020908152604080832093861683529290522061160c90613011565b9392505050565b60006101645460001415611629575061016f5490565b61156c61164861016a5461164261016754610bda611ffd565b90612d2b565b61016f5490612d43565b60005b818110156116b7576116a585858381811061167257611672613e16565b90506020020160208101906116879190613921565b84848481811061169957611699613e16565b90506020020135612475565b806116af81613dcf565b915050611655565b5050505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156117075760405162461bcd60e51b8152600401610c6c90613bf0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611750600080516020613e51833981519152546001600160a01b031690565b6001600160a01b0316146117765760405162461bcd60e51b8152600401610c6c90613c3c565b61177f8161301b565b6040805160008082526020820190925261179b91839190613023565b50565b600260015414156117c15760405162461bcd60e51b8152600401610c6c90613cfc565b6002600155336117cf612c23565b61016e556117db611613565b61016f556117e7611ffd565b610167556001600160a01b038116156118625761180381610b91565b6001600160a01b0382166000908152610172602052604090205561182681611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b54156118c55761016b544211156118c55761016c54611885906001612d43565b61016c556101715460015b61016c5481116118b9576118a5826002612d37565b9150806118b181613dcf565b915050611890565b506118c381612da9565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b15801561192d57600080fd5b505afa158015611941573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119659190613b4b565b9050818110156119b75760405162461bcd60e51b815260206004820152601a60248201527f424675656c20496e73756666696369656e742062616c616e63650000000000006044820152606401610c6c565b33600090815261017760205260409020546119d29083612d43565b3360009081526101776020526040902055610165546119f19083612d43565b610165558215611ca6576000611a1a61017054610c006101685486612d2b90919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd91339116611a448786612d1f565b6040518463ffffffff1660e01b8152600401611a6293929190613b99565b602060405180830381600087803b158015611a7c57600080fd5b505af1158015611a90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab49190613b2e565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90611aea90339030908690600401613b99565b602060405180830381600087803b158015611b0457600080fd5b505af1158015611b18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3c9190613b2e565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b158015611b8457600080fd5b505af1158015611b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bbc9190613b2e565b50336000818152610172602090815260408083208390556101749091528082208290555190919086908381818185875af1925050503d8060008114611c1d576040519150601f19603f3d011682016040523d82523d6000602084013e611c22565b606091505b5050905080611c6e5760405162461bcd60e51b8152602060048201526018602482015277229d103932bbb0b932103a3930b739b332b91032b93937b960411b6044820152606401610c6c565b60405185815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b5050600180555050565b611cb8612d4f565b611cc061319d565b6040513381527f9f0682ebfbd7a5387c2fd5dce8c4a5022b7f8a7090392ac53f6416c63efa9c67906020015b60405180910390a1565b611cfe612d4f565b611d06612f17565b6001600160a01b038216611d2c5760405162461bcd60e51b8152600401610c6c90613c88565b6001600160a01b0391909116600090815261016060205260409020805460ff1916911515919091179055565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415611da15760405162461bcd60e51b8152600401610c6c90613bf0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611dea600080516020613e51833981519152546001600160a01b031690565b6001600160a01b031614611e105760405162461bcd60e51b8152600401610c6c90613c3c565b611e198261301b565b611e2582826001613023565b5050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611ec95760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c6c565b50600080516020613e5183398151915290565b6001600160a01b03811660009081526101746020908152604080832054610179909252822054610c0c9190610c0690611f1790610bda611613565b6001600160a01b0386166000908152610176602052604090205490612d2b565b611f3f612d4f565b611f47612f17565b6001600160a01b038116611f6d5760405162461bcd60e51b8152600401610c6c90613c88565b61016280546001600160a01b0319166001600160a01b0392909216919091179055565b611f98612d4f565b611fa260006131ea565b565b611fac612d4f565b611fb4612f17565b6001600160a01b038116611fda5760405162461bcd60e51b8152600401610c6c90613c88565b61016180546001600160a01b0319166001600160a01b0392909216919091179055565b600061156c4261016b5461323c565b33612015612c23565b61016e55612021611613565b61016f5561202d611ffd565b610167556001600160a01b038116156120a85761204981610b91565b6001600160a01b0382166000908152610172602052604090205561206c81611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b6001600160a01b03831660009081526101606020526040902054839060ff1615156001146121105760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c6c565b61016b54156121735761016b544211156121735761016c54612133906001612d43565b61016c556101715460015b61016c54811161216757612153826002612d37565b91508061215f81613dcf565b91505061213e565b5061217181612da9565b505b600260015414156121965760405162461bcd60e51b8152600401610c6c90613cfc565b6002600155336121a68585613252565b6001600160a01b0316146122065760405162461bcd60e51b815260206004820152602160248201527f7769746864726177206f6620746f6b656e2074686174206973206e6f74206f776044820152603760f91b6064820152608401610c6c565b6001600160a01b03808516600090815261017360209081526040808320878452825291829020825160c0810184528154851681526001820154909416918401919091526002810154918301919091526003810154606083018190526004820154608084015260059091015460a08301526101645461228391612d1f565b61016455606081015133600090815261017560205260409020546122a691612d1f565b33600090815261017560209081526040808320939093556080840151610176909152919020546122d591612d1f565b33600081815261017660209081526040808320949094556001600160a01b038916825261017a8152838220928252919091522061231290856132ac565b506001600160a01b038516600090815261015f602052604081206123379186906132b8565b506001600160a01b03851660008181526101736020908152604080832088845290915280822080546001600160a01b0319908116825560018201805490911690556002810183905560038101839055600480820184905560059091019290925551632142170760e11b81526342842e0e916123b891309133918a9101613b99565b600060405180830381600087803b1580156123d257600080fd5b505af11580156123e6573d6000803e3d6000fd5b50506040518681526001600160a01b03881692503391507f948747f71e0c7df022c400908551bb18008e76b080a45255da5d373bca5823e69060200160405180910390a3505060018055505050565b61243d612d4f565b6124456132ce565b6040513381527fcefccc61a219f93791fb6e4db09576ac77dc4e7edf2a73b47634321897eee98a90602001611cec565b61247d612f17565b6001600160a01b03821660009081526101606020526040902054829060ff1615156001146124e55760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c6c565b336124ee612c23565b61016e556124fa611613565b61016f55612506611ffd565b610167556001600160a01b038116156125815761252281610b91565b6001600160a01b0382166000908152610172602052604090205561254581611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b600260015414156125a45760405162461bcd60e51b8152600401610c6c90613cfc565b60026001556101615460405163a38b54a960e01b81526001600160a01b03868116600483015260248201869052600092169063a38b54a99060440160206040518083038186803b1580156125f757600080fd5b505afa15801561260b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262f9190613b4b565b9050806126765760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c6c565b6101615460405163d1e118c560e01b81526001600160a01b03878116600483015260248201879052600092169063d1e118c59060440160206040518083038186803b1580156126c457600080fd5b505afa1580156126d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126fc9190613b4b565b9050806127435760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c6c565b604051632142170760e11b81526001600160a01b038716906342842e0e9061277390339030908a90600401613b99565b600060405180830381600087803b15801561278d57600080fd5b505af11580156127a1573d6000803e3d6000fd5b505050506040518060c00160405280336001600160a01b03168152602001876001600160a01b03168152602001868152602001838152602001828152602001428152506101736000886001600160a01b03166001600160a01b03168152602001908152602001600020600087815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a082015181600501559050506128fb8561017a6000896001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b0316815260200190815260200160002061330b90919063ffffffff16565b506001600160a01b038616600090815261015f602052604090206129209086336132b8565b506101645461292f9083612d43565b61016455336000908152610175602052604090205461294e9083612d43565b3360009081526101756020908152604080832093909355610176905220546129769082612d43565b336000818152610176602090815260409182902093909355518781526001600160a01b038916927ff39659f2ff90ba8a58bd5ee61a35788fcab5766770b69e851a764d220db98e0d910160405180910390a350506001805550505050565b6129dc612d4f565b6129e4612f17565b60008111612a235760405162461bcd60e51b815260206004820152600c60248201526b72617465206973207a65726f60a01b6044820152606401610c6c565b610168819055604080518281523360208201527fced933e7b0edc2a2e41e6be78c54b8ae9d95e86592ebb76c357bb89df0d261719101611371565b60005b818110156116b757612ab1858583818110612a7e57612a7e613e16565b9050602002016020810190612a939190613921565b848484818110612aa557612aa5613e16565b9050602002013561200c565b80612abb81613dcf565b915050612a61565b612acb612d4f565b612ad761017154612da9565b6040513381527f84d0447ca38875fa61115673259a210915bc1dd53a3c112d6f0790f15956a96590602001611cec565b6000612b138233611571565b905060005b81811015612b4257612b30836108dc85336000612c6f565b80612b3a81613dcf565b915050612b18565b505050565b612b4f612d4f565b61016b544211612bed5760405162461bcd60e51b815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610c6c565b61016d8190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001611371565b60006101645460001415612c39575061016e5490565b61156c612c6561016454610c00670de0b6b3a76400006116426101695461164261016754610bda611ffd565b61016e5490612d43565b6001600160a01b03808416600090815261017a602090815260408083209386168352929052908120612ca19083613317565b949350505050565b612cb1612d4f565b6001600160a01b038116612d165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c6c565b61179b816131ea565b600061160c8284613d8c565b600061160c8284613d6d565b600061160c8284613d4b565b600061160c8284613d33565b6065546001600160a01b03163314611fa25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c6c565b6000612db3612c23565b61016e55612dbf611613565b61016f55612dcb611ffd565b610167556001600160a01b03811615612e4657612de781610b91565b6001600160a01b03821660009081526101726020526040902055612e0a81611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b612e5a670de0b6b3a7640000610e10612d37565b61016a5561016b544210612e805761016d54612e77908390612d37565b61016955612ec7565b61016b54600090612e919042612d1f565b90506000612eab6101695483612d2b90919063ffffffff16565b61016d54909150612ec090610c008684612d43565b6101695550505b4261016781905561016d54612edc9190612d43565b61016b556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050565b60975460ff1615611fa25760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c6c565b600054610100900460ff16611fa25760405162461bcd60e51b8152600401610c6c90613cb1565b600054610100900460ff16612fab5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613323565b600054610100900460ff16612fda5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613350565b600054610100900460ff166130095760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613383565b6000610c0c825490565b61179b612d4f565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561305657612b42836133b3565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561308f57600080fd5b505afa9250505080156130bf575060408051601f3d908101601f191682019092526130bc91810190613b4b565b60015b6131225760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c6c565b600080516020613e5183398151915281146131915760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c6c565b50612b4283838361344f565b6131a5613474565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001611cec565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081831061324b578161160c565b5090919050565b604080518082018252601b81527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006020808301919091526001600160a01b038516600090815261015f90915291822061160c9184906134bd565b600061160c83836134ca565b6000612ca184846001600160a01b0385166135bd565b6132d6612f17565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131d23390565b600061160c83836135da565b600061160c8383613629565b600054610100900460ff1661334a5760405162461bcd60e51b8152600401610c6c90613cb1565b60018055565b600054610100900460ff166133775760405162461bcd60e51b8152600401610c6c90613cb1565b6097805460ff19169055565b600054610100900460ff166133aa5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2336131ea565b6001600160a01b0381163b6134205760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c6c565b600080516020613e5183398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61345883613653565b6000825111806134655750805b15612b425761154b8383613693565b60975460ff16611fa25760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c6c565b6000612ca1848484613787565b600081815260018301602052604081205480156135b35760006134ee600183613d8c565b855490915060009061350290600190613d8c565b905081811461356757600086600001828154811061352257613522613e16565b906000526020600020015490508087600001848154811061354557613545613e16565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061357857613578613e00565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c0c565b6000915050610c0c565b60008281526002840160205260408120829055612ca1848461330b565b600081815260018301602052604081205461362157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c0c565b506000610c0c565b600082600001828154811061364057613640613e16565b9060005260206000200154905092915050565b61365c816133b3565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6136fb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c6c565b600080846001600160a01b0316846040516137169190613b7d565b600060405180830381855af49150503d8060008114613751576040519150601f19603f3d011682016040523d82523d6000602084013e613756565b606091505b509150915061377e8282604051806060016040528060278152602001613e71602791396137d3565b95945050505050565b6000828152600284016020526040812054801515806137ab57506137ab858561380c565b83906137ca5760405162461bcd60e51b8152600401610c6c9190613bbd565b50949350505050565b606083156137e257508161160c565b8251156137f25782518084602001fd5b8160405162461bcd60e51b8152600401610c6c9190613bbd565b600081815260018301602052604081205461160c90849084908490151584565b80356001600160a01b038116811461384357600080fd5b919050565b60008083601f84011261385a57600080fd5b50813567ffffffffffffffff81111561387257600080fd5b6020830191508360208260051b850101111561388d57600080fd5b9250929050565b600082601f8301126138a557600080fd5b813567ffffffffffffffff808211156138c0576138c0613e2c565b604051601f8301601f19908116603f011681019082821181831017156138e8576138e8613e2c565b8160405283815286602085880101111561390157600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561393357600080fd5b61160c8261382c565b6000806040838503121561394f57600080fd5b6139588361382c565b91506139666020840161382c565b90509250929050565b60008060006060848603121561398457600080fd5b61398d8461382c565b925061399b6020850161382c565b9150604084013590509250925092565b600080600080608085870312156139c157600080fd5b6139ca8561382c565b93506139d86020860161382c565b925060408501359150606085013567ffffffffffffffff8111156139fb57600080fd5b613a0787828801613894565b91505092959194509250565b60008060408385031215613a2657600080fd5b613a2f8361382c565b91506020830135613a3f81613e42565b809150509250929050565b60008060408385031215613a5d57600080fd5b613a668361382c565b9150602083013567ffffffffffffffff811115613a8257600080fd5b613a8e85828601613894565b9150509250929050565b60008060408385031215613aab57600080fd5b613ab48361382c565b946020939093013593505050565b60008060008060408587031215613ad857600080fd5b843567ffffffffffffffff80821115613af057600080fd5b613afc88838901613848565b90965094506020870135915080821115613b1557600080fd5b50613b2287828801613848565b95989497509550505050565b600060208284031215613b4057600080fd5b815161160c81613e42565b600060208284031215613b5d57600080fd5b5051919050565b600060208284031215613b7657600080fd5b5035919050565b60008251613b8f818460208701613da3565b9190910192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6020815260008251806020840152613bdc816040850160208701613da3565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252600f908201526e61646472657373206973207a65726f60881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115613d4657613d46613dea565b500190565b600082613d6857634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615613d8757613d87613dea565b500290565b600082821015613d9e57613d9e613dea565b500390565b60005b83811015613dbe578181015183820152602001613da6565b8381111561154b5750506000910152565b6000600019821415613de357613de3613dea565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461179b57600080fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122070637be83e84354e702867a571bfe45251bc593399777bd94051f54eca85691f64736f6c63430008060033

Deployed ByteCode

0x60806040526004361061039a5760003560e01c80636cf7f80e116101dc578063bb40501911610102578063cd3daf9d116100a0578063e671b61a1161006f578063e671b61a14610b23578063ebe2b12b14610b3a578063ee1f188414610b51578063f2fde38b14610b7157600080fd5b8063cd3daf9d14610a93578063d9d11b4d14610aa8578063da3b6b3514610ad6578063e30d80da14610aec57600080fd5b8063c722f719116100dc578063c722f71914610a26578063c8f33c9114610a46578063c9f9cc5214610a5d578063cc1a378f14610a7357600080fd5b8063bb405019146109de578063be36c1c1146109fe578063be9a655514610a1e57600080fd5b80638456cb591161017a578063a8cb026d11610149578063a8cb026d14610962578063a9a5a51d14610990578063ac294d8e146109a7578063adc9772e146109be57600080fd5b80638456cb59146108e15780638557b84a146108f65780638da5cb5b1461092d57806397a6a62b1461094b57600080fd5b8063760ff3c9116101b6578063760ff3c91461085e5780637b0a47ee1461089557806380faa57d146108ac57806382d7db3c146108c157600080fd5b80636cf7f80e14610809578063715018a61461082957806374fcbd411461083e57600080fd5b806331d1b220116102c1578063400f92111161025f57806352d1902d1161022e57806352d1902d1461071b5780635c975abb14610730578063633f7155146107485780636b950e641461076857600080fd5b8063400f92111461068657806341671ca1146106a65780634f1ef286146106e75780635242d76d146106fa57600080fd5b8063386a95251161029b578063386a9525146106245780633d18b9121461063b5780633d8c2d20146106505780633f4ba83a1461067157600080fd5b806331d1b220146105cd57806332b95a6f146105e45780633659cfe61461060457600080fd5b806314e44a9d116103395780631c1f78eb116103085780631c1f78eb146105555780631e492f511461056a5780631fff315d1461059857806320c18f30146105b857600080fd5b806314e44a9d14610497578063150b7a02146104d0578063176fd3f0146105145780631794bb3c1461053557600080fd5b80630cd865ec116103755780630cd865ec1461041e5780630d6f6f5d14610440578063139656cb14610460578063144441b41461047757600080fd5b80628cc262146103a657806305c1fec4146103d95780630700037d146103f057600080fd5b366103a157005b600080fd5b3480156103b257600080fd5b506103c66103c1366004613921565b610b91565b6040519081526020015b60405180910390f35b3480156103e557600080fd5b506103c66101715481565b3480156103fc57600080fd5b506103c661040b366004613921565b6101726020526000908152604090205481565b34801561042a57600080fd5b5061043e610439366004613921565b610c12565b005b34801561044c57600080fd5b5061043e61045b366004613b64565b610d5f565b34801561046c57600080fd5b506103c66101705481565b34801561048357600080fd5b5061043e610492366004613921565b6112eb565b3480156104a357600080fd5b50610166546104b8906001600160a01b031681565b6040516001600160a01b0390911681526020016103d0565b3480156104dc57600080fd5b506104fb6104eb3660046139ab565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016103d0565b34801561052057600080fd5b50610161546104b8906001600160a01b031681565b34801561054157600080fd5b5061043e61055036600461396f565b61137c565b34801561056157600080fd5b506103c6611551565b34801561057657600080fd5b506103c6610585366004613921565b6101786020526000908152604090205481565b3480156105a457600080fd5b506103c66105b336600461393c565b611571565b3480156105c457600080fd5b506103c6611613565b3480156105d957600080fd5b506103c661016c5481565b3480156105f057600080fd5b5061043e6105ff366004613ac2565b611652565b34801561061057600080fd5b5061043e61061f366004613921565b6116be565b34801561063057600080fd5b506103c661016d5481565b34801561064757600080fd5b5061043e61179e565b34801561065c57600080fd5b50610162546104b8906001600160a01b031681565b34801561067d57600080fd5b5061043e611cb0565b34801561069257600080fd5b5061043e6106a1366004613a13565b611cf6565b3480156106b257600080fd5b506106d76106c1366004613921565b6101606020526000908152604090205460ff1681565b60405190151581526020016103d0565b61043e6106f5366004613a4a565b611d58565b34801561070657600080fd5b50610163546104b8906001600160a01b031681565b34801561072757600080fd5b506103c6611e29565b34801561073c57600080fd5b5060975460ff166106d7565b34801561075457600080fd5b506103c6610763366004613921565b611edc565b34801561077457600080fd5b506107d1610783366004613a98565b6101736020908152600092835260408084209091529082529020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c0016103d0565b34801561081557600080fd5b5061043e610824366004613921565b611f37565b34801561083557600080fd5b5061043e611f90565b34801561084a57600080fd5b5061043e610859366004613921565b611fa4565b34801561086a57600080fd5b506103c6610879366004613921565b6001600160a01b03166000908152610175602052604090205490565b3480156108a157600080fd5b506103c66101695481565b3480156108b857600080fd5b506103c6611ffd565b3480156108cd57600080fd5b5061043e6108dc366004613a98565b61200c565b3480156108ed57600080fd5b5061043e612435565b34801561090257600080fd5b506103c6610911366004613921565b6001600160a01b03166000908152610176602052604090205490565b34801561093957600080fd5b506065546001600160a01b03166104b8565b34801561095757600080fd5b506103c66101685481565b34801561096e57600080fd5b506103c661097d366004613921565b6101746020526000908152604090205481565b34801561099c57600080fd5b506103c661016f5481565b3480156109b357600080fd5b506103c661016e5481565b3480156109ca57600080fd5b5061043e6109d9366004613a98565b612475565b3480156109ea57600080fd5b5061043e6109f9366004613b64565b6129d4565b348015610a0a57600080fd5b5061043e610a19366004613ac2565b612a5e565b61043e612ac3565b348015610a3257600080fd5b5061043e610a41366004613921565b612b07565b348015610a5257600080fd5b506103c66101675481565b348015610a6957600080fd5b50610165546103c6565b348015610a7f57600080fd5b5061043e610a8e366004613b64565b612b47565b348015610a9f57600080fd5b506103c6612c23565b348015610ab457600080fd5b506103c6610ac3366004613921565b6101796020526000908152604090205481565b348015610ae257600080fd5b50610164546103c6565b348015610af857600080fd5b506103c6610b07366004613921565b6001600160a01b03166000908152610177602052604090205490565b348015610b2f57600080fd5b506103c661016a5481565b348015610b4657600080fd5b506103c661016b5481565b348015610b5d57600080fd5b506103c6610b6c36600461396f565b612c6f565b348015610b7d57600080fd5b5061043e610b8c366004613921565b612ca9565b6001600160a01b03811660009081526101726020908152604080832054610178909252822054610c0c9190610c0690670de0b6b3a764000090610c0090610be090610bda612c23565b90612d1f565b6001600160a01b0388166000908152610175602052604090205490612d2b565b90612d37565b90612d43565b92915050565b610c1a612d4f565b6001600160a01b038116610c755760405162461bcd60e51b815260206004820152601d60248201527f453a20726563697069656e7420616464726573732063616e276265203000000060448201526064015b60405180910390fd5b60405147906000906001600160a01b0384169083908381818185875af1925050503d8060008114610cc2576040519150601f19603f3d011682016040523d82523d6000602084013e610cc7565b606091505b5050905080610d185760405162461bcd60e51b815260206004820152601960248201527f453a207265636f766572207472616e73666572206572726f72000000000000006044820152606401610c6c565b604080516001600160a01b0385168152602081018490527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a1505050565b60026001541415610d825760405162461bcd60e51b8152600401610c6c90613cfc565b600260015533610d90612c23565b61016e55610d9c611613565b61016f55610da8611ffd565b610167556001600160a01b03811615610e2357610dc481610b91565b6001600160a01b03821660009081526101726020526040902055610de781611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b5415610e865761016b54421115610e865761016c54610e46906001612d43565b61016c556101715460015b61016c548111610e7a57610e66826002612d37565b915080610e7281613dcf565b915050610e51565b50610e8481612da9565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b158015610eee57600080fd5b505afa158015610f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f269190613b4b565b90506000610f3884610c008886612d2b565b905080821015610f8a5760405162461bcd60e51b815260206004820152601a60248201527f424675656c20496e73756666696369656e742062616c616e63650000000000006044820152606401610c6c565b85841015610fda5760405162461bcd60e51b815260206004820152601d60248201527f453a2065786163742072657761726420657863656564207265776172640000006044820152606401610c6c565b3360009081526101776020526040902054610ff59082612d43565b3360009081526101776020526040902055610165546110149082612d43565b6101655583156112df57600061103d61017054610c006101685485612d2b90919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd913391166110678686612d1f565b6040518463ffffffff1660e01b815260040161108593929190613b99565b602060405180830381600087803b15801561109f57600080fd5b505af11580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d79190613b2e565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd9061110d90339030908690600401613b99565b602060405180830381600087803b15801561112757600080fd5b505af115801561113b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115f9190613b2e565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b1580156111a757600080fd5b505af11580156111bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111df9190613b2e565b506111ea8588612d1f565b33600090815261017260205260409020556112058483612d1f565b336000818152610174602052604080822093909355915189908381818185875af1925050503d8060008114611256576040519150601f19603f3d011682016040523d82523d6000602084013e61125b565b606091505b50509050806112a75760405162461bcd60e51b8152602060048201526018602482015277229d103932bbb0b932103a3930b739b332b91032b93937b960411b6044820152606401610c6c565b60405188815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b50506001805550505050565b6112f3612d4f565b6112fb612f17565b6001600160a01b0381166113215760405162461bcd60e51b8152600401610c6c90613c88565b61016680546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f725540d4066d55e571d1f3a39840626c921529b8df65b93b870c24df49e57eaa91015b60405180910390a150565b600054610100900460ff161580801561139c5750600054600160ff909116105b806113b65750303b1580156113b6575060005460ff166001145b6114195760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c6c565b6000805460ff19166001179055801561143c576000805461ff0019166101001790555b611444612f5d565b61144c612f84565b611454612fb3565b61145c612fe2565b611464612f5d565b816114b15760405162461bcd60e51b815260206004820152601760248201527f726577617264734475726174696f6e206973207a65726f0000000000000000006044820152606401610c6c565b61016280546001600160a01b038087166001600160a01b03199283161790925561016180549286169290911691909117905561016d8290556032610168556064610170556a08b200a96f8d058a00000061017155801561154b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b600061156c61016d5461016954612d2b90919063ffffffff16565b905090565b60006001600160a01b0382166115dd5760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e673a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610c6c565b6001600160a01b03808416600090815261017a6020908152604080832093861683529290522061160c90613011565b9392505050565b60006101645460001415611629575061016f5490565b61156c61164861016a5461164261016754610bda611ffd565b90612d2b565b61016f5490612d43565b60005b818110156116b7576116a585858381811061167257611672613e16565b90506020020160208101906116879190613921565b84848481811061169957611699613e16565b90506020020135612475565b806116af81613dcf565b915050611655565b5050505050565b306001600160a01b037f0000000000000000000000003558e707f29f589c99585b17bb217267b56807ed1614156117075760405162461bcd60e51b8152600401610c6c90613bf0565b7f0000000000000000000000003558e707f29f589c99585b17bb217267b56807ed6001600160a01b0316611750600080516020613e51833981519152546001600160a01b031690565b6001600160a01b0316146117765760405162461bcd60e51b8152600401610c6c90613c3c565b61177f8161301b565b6040805160008082526020820190925261179b91839190613023565b50565b600260015414156117c15760405162461bcd60e51b8152600401610c6c90613cfc565b6002600155336117cf612c23565b61016e556117db611613565b61016f556117e7611ffd565b610167556001600160a01b038116156118625761180381610b91565b6001600160a01b0382166000908152610172602052604090205561182681611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b54156118c55761016b544211156118c55761016c54611885906001612d43565b61016c556101715460015b61016c5481116118b9576118a5826002612d37565b9150806118b181613dcf565b915050611890565b506118c381612da9565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b15801561192d57600080fd5b505afa158015611941573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119659190613b4b565b9050818110156119b75760405162461bcd60e51b815260206004820152601a60248201527f424675656c20496e73756666696369656e742062616c616e63650000000000006044820152606401610c6c565b33600090815261017760205260409020546119d29083612d43565b3360009081526101776020526040902055610165546119f19083612d43565b610165558215611ca6576000611a1a61017054610c006101685486612d2b90919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd91339116611a448786612d1f565b6040518463ffffffff1660e01b8152600401611a6293929190613b99565b602060405180830381600087803b158015611a7c57600080fd5b505af1158015611a90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab49190613b2e565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90611aea90339030908690600401613b99565b602060405180830381600087803b158015611b0457600080fd5b505af1158015611b18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3c9190613b2e565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b158015611b8457600080fd5b505af1158015611b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bbc9190613b2e565b50336000818152610172602090815260408083208390556101749091528082208290555190919086908381818185875af1925050503d8060008114611c1d576040519150601f19603f3d011682016040523d82523d6000602084013e611c22565b606091505b5050905080611c6e5760405162461bcd60e51b8152602060048201526018602482015277229d103932bbb0b932103a3930b739b332b91032b93937b960411b6044820152606401610c6c565b60405185815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b5050600180555050565b611cb8612d4f565b611cc061319d565b6040513381527f9f0682ebfbd7a5387c2fd5dce8c4a5022b7f8a7090392ac53f6416c63efa9c67906020015b60405180910390a1565b611cfe612d4f565b611d06612f17565b6001600160a01b038216611d2c5760405162461bcd60e51b8152600401610c6c90613c88565b6001600160a01b0391909116600090815261016060205260409020805460ff1916911515919091179055565b306001600160a01b037f0000000000000000000000003558e707f29f589c99585b17bb217267b56807ed161415611da15760405162461bcd60e51b8152600401610c6c90613bf0565b7f0000000000000000000000003558e707f29f589c99585b17bb217267b56807ed6001600160a01b0316611dea600080516020613e51833981519152546001600160a01b031690565b6001600160a01b031614611e105760405162461bcd60e51b8152600401610c6c90613c3c565b611e198261301b565b611e2582826001613023565b5050565b6000306001600160a01b037f0000000000000000000000003558e707f29f589c99585b17bb217267b56807ed1614611ec95760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c6c565b50600080516020613e5183398151915290565b6001600160a01b03811660009081526101746020908152604080832054610179909252822054610c0c9190610c0690611f1790610bda611613565b6001600160a01b0386166000908152610176602052604090205490612d2b565b611f3f612d4f565b611f47612f17565b6001600160a01b038116611f6d5760405162461bcd60e51b8152600401610c6c90613c88565b61016280546001600160a01b0319166001600160a01b0392909216919091179055565b611f98612d4f565b611fa260006131ea565b565b611fac612d4f565b611fb4612f17565b6001600160a01b038116611fda5760405162461bcd60e51b8152600401610c6c90613c88565b61016180546001600160a01b0319166001600160a01b0392909216919091179055565b600061156c4261016b5461323c565b33612015612c23565b61016e55612021611613565b61016f5561202d611ffd565b610167556001600160a01b038116156120a85761204981610b91565b6001600160a01b0382166000908152610172602052604090205561206c81611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b6001600160a01b03831660009081526101606020526040902054839060ff1615156001146121105760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c6c565b61016b54156121735761016b544211156121735761016c54612133906001612d43565b61016c556101715460015b61016c54811161216757612153826002612d37565b91508061215f81613dcf565b91505061213e565b5061217181612da9565b505b600260015414156121965760405162461bcd60e51b8152600401610c6c90613cfc565b6002600155336121a68585613252565b6001600160a01b0316146122065760405162461bcd60e51b815260206004820152602160248201527f7769746864726177206f6620746f6b656e2074686174206973206e6f74206f776044820152603760f91b6064820152608401610c6c565b6001600160a01b03808516600090815261017360209081526040808320878452825291829020825160c0810184528154851681526001820154909416918401919091526002810154918301919091526003810154606083018190526004820154608084015260059091015460a08301526101645461228391612d1f565b61016455606081015133600090815261017560205260409020546122a691612d1f565b33600090815261017560209081526040808320939093556080840151610176909152919020546122d591612d1f565b33600081815261017660209081526040808320949094556001600160a01b038916825261017a8152838220928252919091522061231290856132ac565b506001600160a01b038516600090815261015f602052604081206123379186906132b8565b506001600160a01b03851660008181526101736020908152604080832088845290915280822080546001600160a01b0319908116825560018201805490911690556002810183905560038101839055600480820184905560059091019290925551632142170760e11b81526342842e0e916123b891309133918a9101613b99565b600060405180830381600087803b1580156123d257600080fd5b505af11580156123e6573d6000803e3d6000fd5b50506040518681526001600160a01b03881692503391507f948747f71e0c7df022c400908551bb18008e76b080a45255da5d373bca5823e69060200160405180910390a3505060018055505050565b61243d612d4f565b6124456132ce565b6040513381527fcefccc61a219f93791fb6e4db09576ac77dc4e7edf2a73b47634321897eee98a90602001611cec565b61247d612f17565b6001600160a01b03821660009081526101606020526040902054829060ff1615156001146124e55760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c6c565b336124ee612c23565b61016e556124fa611613565b61016f55612506611ffd565b610167556001600160a01b038116156125815761252281610b91565b6001600160a01b0382166000908152610172602052604090205561254581611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b600260015414156125a45760405162461bcd60e51b8152600401610c6c90613cfc565b60026001556101615460405163a38b54a960e01b81526001600160a01b03868116600483015260248201869052600092169063a38b54a99060440160206040518083038186803b1580156125f757600080fd5b505afa15801561260b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262f9190613b4b565b9050806126765760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c6c565b6101615460405163d1e118c560e01b81526001600160a01b03878116600483015260248201879052600092169063d1e118c59060440160206040518083038186803b1580156126c457600080fd5b505afa1580156126d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126fc9190613b4b565b9050806127435760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c6c565b604051632142170760e11b81526001600160a01b038716906342842e0e9061277390339030908a90600401613b99565b600060405180830381600087803b15801561278d57600080fd5b505af11580156127a1573d6000803e3d6000fd5b505050506040518060c00160405280336001600160a01b03168152602001876001600160a01b03168152602001868152602001838152602001828152602001428152506101736000886001600160a01b03166001600160a01b03168152602001908152602001600020600087815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a082015181600501559050506128fb8561017a6000896001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b0316815260200190815260200160002061330b90919063ffffffff16565b506001600160a01b038616600090815261015f602052604090206129209086336132b8565b506101645461292f9083612d43565b61016455336000908152610175602052604090205461294e9083612d43565b3360009081526101756020908152604080832093909355610176905220546129769082612d43565b336000818152610176602090815260409182902093909355518781526001600160a01b038916927ff39659f2ff90ba8a58bd5ee61a35788fcab5766770b69e851a764d220db98e0d910160405180910390a350506001805550505050565b6129dc612d4f565b6129e4612f17565b60008111612a235760405162461bcd60e51b815260206004820152600c60248201526b72617465206973207a65726f60a01b6044820152606401610c6c565b610168819055604080518281523360208201527fced933e7b0edc2a2e41e6be78c54b8ae9d95e86592ebb76c357bb89df0d261719101611371565b60005b818110156116b757612ab1858583818110612a7e57612a7e613e16565b9050602002016020810190612a939190613921565b848484818110612aa557612aa5613e16565b9050602002013561200c565b80612abb81613dcf565b915050612a61565b612acb612d4f565b612ad761017154612da9565b6040513381527f84d0447ca38875fa61115673259a210915bc1dd53a3c112d6f0790f15956a96590602001611cec565b6000612b138233611571565b905060005b81811015612b4257612b30836108dc85336000612c6f565b80612b3a81613dcf565b915050612b18565b505050565b612b4f612d4f565b61016b544211612bed5760405162461bcd60e51b815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610c6c565b61016d8190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001611371565b60006101645460001415612c39575061016e5490565b61156c612c6561016454610c00670de0b6b3a76400006116426101695461164261016754610bda611ffd565b61016e5490612d43565b6001600160a01b03808416600090815261017a602090815260408083209386168352929052908120612ca19083613317565b949350505050565b612cb1612d4f565b6001600160a01b038116612d165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c6c565b61179b816131ea565b600061160c8284613d8c565b600061160c8284613d6d565b600061160c8284613d4b565b600061160c8284613d33565b6065546001600160a01b03163314611fa25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c6c565b6000612db3612c23565b61016e55612dbf611613565b61016f55612dcb611ffd565b610167556001600160a01b03811615612e4657612de781610b91565b6001600160a01b03821660009081526101726020526040902055612e0a81611edc565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b612e5a670de0b6b3a7640000610e10612d37565b61016a5561016b544210612e805761016d54612e77908390612d37565b61016955612ec7565b61016b54600090612e919042612d1f565b90506000612eab6101695483612d2b90919063ffffffff16565b61016d54909150612ec090610c008684612d43565b6101695550505b4261016781905561016d54612edc9190612d43565b61016b556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050565b60975460ff1615611fa25760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c6c565b600054610100900460ff16611fa25760405162461bcd60e51b8152600401610c6c90613cb1565b600054610100900460ff16612fab5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613323565b600054610100900460ff16612fda5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613350565b600054610100900460ff166130095760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2613383565b6000610c0c825490565b61179b612d4f565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561305657612b42836133b3565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561308f57600080fd5b505afa9250505080156130bf575060408051601f3d908101601f191682019092526130bc91810190613b4b565b60015b6131225760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c6c565b600080516020613e5183398151915281146131915760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c6c565b50612b4283838361344f565b6131a5613474565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001611cec565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081831061324b578161160c565b5090919050565b604080518082018252601b81527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006020808301919091526001600160a01b038516600090815261015f90915291822061160c9184906134bd565b600061160c83836134ca565b6000612ca184846001600160a01b0385166135bd565b6132d6612f17565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131d23390565b600061160c83836135da565b600061160c8383613629565b600054610100900460ff1661334a5760405162461bcd60e51b8152600401610c6c90613cb1565b60018055565b600054610100900460ff166133775760405162461bcd60e51b8152600401610c6c90613cb1565b6097805460ff19169055565b600054610100900460ff166133aa5760405162461bcd60e51b8152600401610c6c90613cb1565b611fa2336131ea565b6001600160a01b0381163b6134205760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c6c565b600080516020613e5183398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61345883613653565b6000825111806134655750805b15612b425761154b8383613693565b60975460ff16611fa25760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c6c565b6000612ca1848484613787565b600081815260018301602052604081205480156135b35760006134ee600183613d8c565b855490915060009061350290600190613d8c565b905081811461356757600086600001828154811061352257613522613e16565b906000526020600020015490508087600001848154811061354557613545613e16565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061357857613578613e00565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c0c565b6000915050610c0c565b60008281526002840160205260408120829055612ca1848461330b565b600081815260018301602052604081205461362157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c0c565b506000610c0c565b600082600001828154811061364057613640613e16565b9060005260206000200154905092915050565b61365c816133b3565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6136fb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c6c565b600080846001600160a01b0316846040516137169190613b7d565b600060405180830381855af49150503d8060008114613751576040519150601f19603f3d011682016040523d82523d6000602084013e613756565b606091505b509150915061377e8282604051806060016040528060278152602001613e71602791396137d3565b95945050505050565b6000828152600284016020526040812054801515806137ab57506137ab858561380c565b83906137ca5760405162461bcd60e51b8152600401610c6c9190613bbd565b50949350505050565b606083156137e257508161160c565b8251156137f25782518084602001fd5b8160405162461bcd60e51b8152600401610c6c9190613bbd565b600081815260018301602052604081205461160c90849084908490151584565b80356001600160a01b038116811461384357600080fd5b919050565b60008083601f84011261385a57600080fd5b50813567ffffffffffffffff81111561387257600080fd5b6020830191508360208260051b850101111561388d57600080fd5b9250929050565b600082601f8301126138a557600080fd5b813567ffffffffffffffff808211156138c0576138c0613e2c565b604051601f8301601f19908116603f011681019082821181831017156138e8576138e8613e2c565b8160405283815286602085880101111561390157600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561393357600080fd5b61160c8261382c565b6000806040838503121561394f57600080fd5b6139588361382c565b91506139666020840161382c565b90509250929050565b60008060006060848603121561398457600080fd5b61398d8461382c565b925061399b6020850161382c565b9150604084013590509250925092565b600080600080608085870312156139c157600080fd5b6139ca8561382c565b93506139d86020860161382c565b925060408501359150606085013567ffffffffffffffff8111156139fb57600080fd5b613a0787828801613894565b91505092959194509250565b60008060408385031215613a2657600080fd5b613a2f8361382c565b91506020830135613a3f81613e42565b809150509250929050565b60008060408385031215613a5d57600080fd5b613a668361382c565b9150602083013567ffffffffffffffff811115613a8257600080fd5b613a8e85828601613894565b9150509250929050565b60008060408385031215613aab57600080fd5b613ab48361382c565b946020939093013593505050565b60008060008060408587031215613ad857600080fd5b843567ffffffffffffffff80821115613af057600080fd5b613afc88838901613848565b90965094506020870135915080821115613b1557600080fd5b50613b2287828801613848565b95989497509550505050565b600060208284031215613b4057600080fd5b815161160c81613e42565b600060208284031215613b5d57600080fd5b5051919050565b600060208284031215613b7657600080fd5b5035919050565b60008251613b8f818460208701613da3565b9190910192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6020815260008251806020840152613bdc816040850160208701613da3565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252600f908201526e61646472657373206973207a65726f60881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115613d4657613d46613dea565b500190565b600082613d6857634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615613d8757613d87613dea565b500290565b600082821015613d9e57613d9e613dea565b500390565b60005b83811015613dbe578181015183820152602001613da6565b8381111561154b5750506000910152565b6000600019821415613de357613de3613dea565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461179b57600080fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122070637be83e84354e702867a571bfe45251bc593399777bd94051f54eca85691f64736f6c63430008060033