ETH Price: $3,361.96 (-2.63%)

Contract

0x176BD8035AB5DBA3d5893271F2b7E51085B06732
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MultiStakingManagerV2

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 10 : MultiStakingManagerV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

contract MultiStakingManagerV2 is
    Initializable,
    OwnableUpgradeable,
    PausableUpgradeable,
    ReentrancyGuardUpgradeable
{
    using SafeERC20Upgradeable for IERC20Upgradeable;

    struct Pool {
        bool initialized;
        uint256 tokensStaked;
        uint256 harvestedTokens;
        uint256 harvestedEth;
        uint256 lastRewardedBlock;
        uint256 accTokenRewardsPerShare;
        uint256 accEthRewardsPerShare;
        uint256 rewardTokensPerBlock;
        uint256 rewardEthPerBlock;
        uint256 lockTime;
        uint256 endBlock;
        bool updateStakedTime;
    }

    struct PoolStaker {
        uint256 amount;
        uint256 stakedTime;
        uint256 harvestedTokens;
        uint256 harvestedEth;
        uint256 rewardTokenDebt;
        uint256 rewardEthDebt;
    }

    IERC20Upgradeable public stakeToken;
    uint256 public tokensStaked;

    uint256 private constant REWARDS_PRECISION = 1e12;
    uint256 private nextPoolId;

    mapping(uint256 => Pool) public pools;
    mapping(uint256 => mapping(address => PoolStaker)) public poolStakers;

    event Deposit(
        uint256 indexed pool,
        address indexed user,
        uint256 amount,
        uint256 timestamp
    );
    event Withdraw(
        uint256 indexed pool,
        address indexed user,
        uint256 amount,
        uint256 timestamp
    );
    event HarvestRewards(
        uint256 indexed pool,
        address indexed user,
        address indexed token,
        uint256 amount,
        uint256 timestamp
    );

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    modifier verifyPools(uint256[] calldata _poolIds) {
        require(_poolIds.length > 0, "Must input at least one pool");
        for (uint256 i; i < _poolIds.length; i++) {
            uint256 i_poolId = _poolIds[i];
            require(pools[i_poolId].initialized, "Pool is uninitialized");
            for (uint256 x; x < _poolIds.length; x++)
                if (i_poolId == _poolIds[x])
                    require(i == x, "Duplicate pool inputs found");
        }
        _;
    }

    /**
     * @dev Receive ETH rewards
     */
    receive() external payable {}

    /**
     * @dev To pause staking
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev To unpause staking
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @dev Deposit tokens to the pool
     */
    function deposit(
        uint256[] calldata _poolIds,
        uint256[] calldata _amounts
    ) external whenNotPaused nonReentrant verifyPools(_poolIds) {
        require(_poolIds.length == _amounts.length, "Invalid parameters");
        for (uint256 i; i < _poolIds.length; i++) {
            uint256 _poolId = _poolIds[i];
            uint256 _amount = _amounts[i];
            require(
                block.number < pools[_poolId].endBlock,
                "Staking for this pool has ended"
            );
            require(_amount > 0, "Deposit amount can't be zero");
            _harvestRewardsAndSend(_poolId, msg.sender);
            _deposit(_poolId, msg.sender, _amount);
            stakeToken.safeTransferFrom(msg.sender, address(this), _amount);
        }
    }

    /**
     * @dev Harvest rewards and deposit them to the pool
     */
    function harvestAndDeposit(
        uint256[] calldata _poolIds
    ) external whenNotPaused nonReentrant verifyPools(_poolIds) {
        for (uint256 i; i < _poolIds.length; i++) {
            uint256 _poolId = _poolIds[i];
            require(
                block.number < pools[_poolId].endBlock,
                "Staking for this pool has ended"
            );
            uint256[2] memory _rewards = _harvestRewards(_poolId, msg.sender);
            if (_rewards[0] > 0) _deposit(_poolId, msg.sender, _rewards[0]);
            if (_rewards[1] > 0) _sendValue(payable(msg.sender), _rewards[1]);
        }
    }

    /**
     * @dev Deposit tokens to single pool
     */
    function _deposit(uint256 _poolId, address _user, uint256 _amount) private {
        Pool storage pool = pools[_poolId];
        PoolStaker storage staker = poolStakers[_poolId][_user];

        // Update current staker
        staker.amount += _amount;
        staker.rewardTokenDebt =
            (staker.amount * pool.accTokenRewardsPerShare) /
            REWARDS_PRECISION;
        staker.rewardEthDebt =
            (staker.amount * pool.accEthRewardsPerShare) /
            REWARDS_PRECISION;
        if (pool.updateStakedTime || staker.stakedTime == 0) {
            staker.stakedTime = block.timestamp;
        }

        // Update pool
        pool.tokensStaked += _amount;
        tokensStaked += _amount;

        // Emit deposit tokens event
        emit Deposit(_poolId, _user, _amount, block.timestamp);
    }

    /**
     * @dev Withdraw all tokens from existing pools
     */
    function withdraw(
        uint256[] calldata _poolIds
    ) external whenNotPaused nonReentrant verifyPools(_poolIds) {
        for (uint256 i; i < _poolIds.length; i++) {
            uint256 _poolId = _poolIds[i];
            Pool storage pool = pools[_poolId];
            PoolStaker memory staker = poolStakers[_poolId][msg.sender];
            require(
                block.number >= pool.endBlock ||
                    staker.stakedTime + pool.lockTime <= block.timestamp,
                "You are not allowed to withdraw before locked time"
            );
            require(staker.amount > 0, "Withdraw amount can't be zero");

            // Update pool stakers and aggregate rewards
            _harvestRewardsAndSend(_poolId, msg.sender);

            // Delete staker
            delete poolStakers[_poolId][msg.sender];

            // Update pool
            pool.tokensStaked -= staker.amount;
            tokensStaked -= staker.amount;

            // Emit withdraw tokens event
            emit Withdraw(_poolId, msg.sender, staker.amount, block.timestamp);
            stakeToken.safeTransfer(msg.sender, staker.amount);
        }
    }

    /**
     * @dev Harvest user rewards
     */
    function harvestRewards(
        uint256[] calldata _poolIds
    ) external whenNotPaused nonReentrant verifyPools(_poolIds) {
        for (uint256 i; i < _poolIds.length; i++)
            _harvestRewardsAndSend(_poolIds[i], msg.sender);
    }

    /**
     * @dev Harvest user's pool rewards and send
     */
    function _harvestRewardsAndSend(uint256 _poolId, address _user) private {
        uint256[2] memory _rewards = _harvestRewards(_poolId, _user);
        if (_rewards[0] > 0) stakeToken.safeTransfer(_user, _rewards[0]);
        if (_rewards[1] > 0) _sendValue(payable(_user), _rewards[1]);
    }

    /**
     * @dev Harvest user's pool rewards
     */
    function _harvestRewards(
        uint256 _poolId,
        address _user
    ) private returns (uint256[2] memory) {
        _updatePoolRewards(_poolId);
        Pool storage pool = pools[_poolId];
        PoolStaker storage staker = poolStakers[_poolId][_user];

        uint256 rewardTokensToHarvest = ((staker.amount *
            pool.accTokenRewardsPerShare) / REWARDS_PRECISION) -
            staker.rewardTokenDebt;
        if (rewardTokensToHarvest > 0) {
            pool.harvestedTokens += rewardTokensToHarvest;
            staker.harvestedTokens += rewardTokensToHarvest;
            staker.rewardTokenDebt =
                (staker.amount * pool.accTokenRewardsPerShare) /
                REWARDS_PRECISION;
            emit HarvestRewards(
                _poolId,
                _user,
                address(stakeToken),
                rewardTokensToHarvest,
                block.timestamp
            );
        }

        uint256 rewardEthToHarvest = ((staker.amount *
            pool.accEthRewardsPerShare) / REWARDS_PRECISION) -
            staker.rewardEthDebt;
        if (rewardEthToHarvest > 0) {
            pool.harvestedEth += rewardEthToHarvest;
            staker.harvestedEth += rewardEthToHarvest;
            staker.rewardEthDebt =
                (staker.amount * pool.accEthRewardsPerShare) /
                REWARDS_PRECISION;
            emit HarvestRewards(
                _poolId,
                _user,
                address(0),
                rewardEthToHarvest,
                block.timestamp
            );
        }

        return [rewardTokensToHarvest, rewardEthToHarvest];
    }

    /**
     * @dev Update pool's accRewardsPerShare and lastRewardedBlock
     */
    function _updatePoolRewards(uint256 _poolId) private {
        Pool storage pool = pools[_poolId];
        if (pool.tokensStaked == 0) {
            pool.lastRewardedBlock = block.number;
            return;
        }

        uint256 blocksSinceLastReward = block.number > pool.endBlock
            ? pool.endBlock - pool.lastRewardedBlock
            : block.number - pool.lastRewardedBlock;

        uint256 tokenRewards = blocksSinceLastReward *
            pool.rewardTokensPerBlock;
        pool.accTokenRewardsPerShare =
            pool.accTokenRewardsPerShare +
            ((tokenRewards * REWARDS_PRECISION) / pool.tokensStaked);

        uint256 ethRewards = blocksSinceLastReward * pool.rewardEthPerBlock;
        pool.accEthRewardsPerShare =
            pool.accEthRewardsPerShare +
            ((ethRewards * REWARDS_PRECISION) / pool.tokensStaked);

        pool.lastRewardedBlock = block.number > pool.endBlock
            ? pool.endBlock
            : block.number;
    }

    /**
     * @dev Send ether to recipient
     */
    function _sendValue(address payable _recipient, uint256 _amount) private {
        require(address(this).balance >= _amount, "Low balance");
        (bool success, ) = _recipient.call{value: _amount}("");
        require(success, "ETH payment failed");
    }

    /**
     * @dev To get the number of rewards that user can get
     */
    function getRewards(
        uint256[] calldata _poolIds,
        address _user
    ) public view verifyPools(_poolIds) returns (uint256[2] memory) {
        uint256[2] memory _rewards = [uint256(0), uint256(0)];

        for (uint256 i; i < _poolIds.length; i++) {
            uint256 _poolId = _poolIds[i];
            Pool memory pool = pools[_poolId];

            if (pool.tokensStaked > 0) {
                uint256 blocksSinceLastReward = block.number > pool.endBlock
                    ? pool.endBlock - pool.lastRewardedBlock
                    : block.number - pool.lastRewardedBlock;

                uint256 tokenRewards = blocksSinceLastReward *
                    pool.rewardTokensPerBlock;
                uint256 accTokenCalc = pool.accTokenRewardsPerShare +
                    ((tokenRewards * REWARDS_PRECISION) / pool.tokensStaked);

                uint256 ethRewards = blocksSinceLastReward *
                    pool.rewardEthPerBlock;
                uint256 accEthCalc = pool.accEthRewardsPerShare +
                    ((ethRewards * REWARDS_PRECISION) / pool.tokensStaked);

                PoolStaker memory staker = poolStakers[_poolId][_user];

                _rewards[0] +=
                    ((staker.amount * accTokenCalc) / REWARDS_PRECISION) -
                    staker.rewardTokenDebt;
                _rewards[1] +=
                    ((staker.amount * accEthCalc) / REWARDS_PRECISION) -
                    staker.rewardEthDebt;
            }
        }

        return _rewards;
    }

    /**
     * @dev To get the number of lifetime rewards harvested
     */
    function getHarvestedRewards(
        uint256[] calldata _poolIds
    ) public view verifyPools(_poolIds) returns (uint256[2] memory) {
        uint256[2] memory _rewards = [uint256(0), uint256(0)];

        for (uint256 i; i < _poolIds.length; i++) {
            Pool memory pool = pools[_poolIds[i]];
            _rewards[0] += pool.harvestedTokens;
            _rewards[1] += pool.harvestedEth;
        }

        return _rewards;
    }

    /**
     * @dev To create a new staking pool
     */
    function createPool(
        uint256 _tokenRate,
        uint256 _ethRate,
        uint256 _lockTime,
        uint256 _rewardBlocks,
        bool _updateStakedTime
    ) public onlyOwner {
        _createPool(
            _tokenRate,
            _ethRate,
            _lockTime,
            _rewardBlocks,
            _updateStakedTime
        );
    }

    function _createPool(
        uint256 _tokenRate,
        uint256 _ethRate,
        uint256 _lockTime,
        uint256 _rewardBlocks,
        bool _updateStakedTime
    ) private {
        Pool storage pool = pools[nextPoolId++];
        require(!pool.initialized, "Pool already initialized");
        pool.initialized = true;
        pool.rewardTokensPerBlock = _tokenRate;
        pool.rewardEthPerBlock = _ethRate;
        pool.lockTime = _lockTime;
        pool.endBlock = block.number + _rewardBlocks;
        pool.updateStakedTime = _updateStakedTime;
    }

    /**
     * @dev To update an existing staking pool
     */
    function updatePool(
        uint256 _poolId,
        uint256 _tokenRate,
        uint256 _ethRate,
        uint256 _lockTime,
        uint256 _endBlock,
        bool _updateStakedTime
    ) external onlyOwner {
        Pool storage pool = pools[_poolId];
        require(pool.initialized, "Pool is uninitialized");
        if (_tokenRate > 0) pool.rewardTokensPerBlock = _tokenRate;
        if (_ethRate > 0) pool.rewardEthPerBlock = _ethRate;
        if (_lockTime > 0) pool.lockTime = _lockTime;
        if (_endBlock > 0) pool.endBlock = _endBlock;
        pool.updateStakedTime = _updateStakedTime;
    }

    /**
     * @dev To update the underlying token
     */
    function setStakeToken(address _stakeToken) external onlyOwner {
        stakeToken = IERC20Upgradeable(_stakeToken);
    }
}

File 2 of 10 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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;
}

File 3 of 10 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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]
 * ```solidity
 * 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.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    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.
     *
     * 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.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * 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.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    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.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 4 of 10 : 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;
}

File 5 of 10 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

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

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _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;
}

File 6 of 10 : IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 7 of 10 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}

File 8 of 10 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20PermitUpgradeable token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));
    }
}

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 10 : 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;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pool","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pool","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"HarvestRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pool","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenRate","type":"uint256"},{"internalType":"uint256","name":"_ethRate","type":"uint256"},{"internalType":"uint256","name":"_lockTime","type":"uint256"},{"internalType":"uint256","name":"_rewardBlocks","type":"uint256"},{"internalType":"bool","name":"_updateStakedTime","type":"bool"}],"name":"createPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"}],"name":"getHarvestedRewards","outputs":[{"internalType":"uint256[2]","name":"","type":"uint256[2]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"},{"internalType":"address","name":"_user","type":"address"}],"name":"getRewards","outputs":[{"internalType":"uint256[2]","name":"","type":"uint256[2]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"}],"name":"harvestAndDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"}],"name":"harvestRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"poolStakers","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"stakedTime","type":"uint256"},{"internalType":"uint256","name":"harvestedTokens","type":"uint256"},{"internalType":"uint256","name":"harvestedEth","type":"uint256"},{"internalType":"uint256","name":"rewardTokenDebt","type":"uint256"},{"internalType":"uint256","name":"rewardEthDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pools","outputs":[{"internalType":"bool","name":"initialized","type":"bool"},{"internalType":"uint256","name":"tokensStaked","type":"uint256"},{"internalType":"uint256","name":"harvestedTokens","type":"uint256"},{"internalType":"uint256","name":"harvestedEth","type":"uint256"},{"internalType":"uint256","name":"lastRewardedBlock","type":"uint256"},{"internalType":"uint256","name":"accTokenRewardsPerShare","type":"uint256"},{"internalType":"uint256","name":"accEthRewardsPerShare","type":"uint256"},{"internalType":"uint256","name":"rewardTokensPerBlock","type":"uint256"},{"internalType":"uint256","name":"rewardEthPerBlock","type":"uint256"},{"internalType":"uint256","name":"lockTime","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"bool","name":"updateStakedTime","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakeToken","type":"address"}],"name":"setStakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_tokenRate","type":"uint256"},{"internalType":"uint256","name":"_ethRate","type":"uint256"},{"internalType":"uint256","name":"_lockTime","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"bool","name":"_updateStakedTime","type":"bool"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_poolIds","type":"uint256[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61257780620000f36000396000f3fe6080604052600436106101185760003560e01c80638da5cb5b116100a0578063b798aaae11610064578063b798aaae146103b4578063cf7e58741461043c578063f223885a1461045c578063f2fde38b1461047c578063fb2f897a1461049c57600080fd5b80638da5cb5b14610256578063983d95ce1461027457806399a0331614610294578063a240e37a146102b8578063ac4afa38146102d857600080fd5b806351ed6a30116100e757806351ed6a30146101b15780635c975abb146101e9578063715018a61461020c5780638091fbac146102215780638456cb591461024157600080fd5b80630397d458146101245780632a456115146101465780633697da15146101665780633f4ba83a1461019c57600080fd5b3661011f57005b600080fd5b34801561013057600080fd5b5061014461013f3660046120da565b6104bc565b005b34801561015257600080fd5b50610144610161366004612148565b6104e6565b34801561017257600080fd5b50610186610181366004612148565b61063b565b604051610193919061218a565b60405180910390f35b3480156101a857600080fd5b5061014461085e565b3480156101bd57600080fd5b5060c9546101d1906001600160a01b031681565b6040516001600160a01b039091168152602001610193565b3480156101f557600080fd5b5060655460ff166040519015158152602001610193565b34801561021857600080fd5b50610144610870565b34801561022d57600080fd5b5061014461023c3660046121c9565b610882565b34801561024d57600080fd5b5061014461089e565b34801561026257600080fd5b506033546001600160a01b03166101d1565b34801561028057600080fd5b5061014461028f366004612148565b6108ae565b3480156102a057600080fd5b506102aa60ca5481565b604051908152602001610193565b3480156102c457600080fd5b506101446102d3366004612216565b610c02565b3480156102e457600080fd5b506103576102f336600461226b565b60cc60205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b909b015460ff9a8b169b999a98999798969795969495939492939192168c565b604080519c15158d5260208d019b909b52998b019890985260608a0196909652608089019490945260a088019290925260c087015260e0860152610100850152610120840152610140830152151561016082015261018001610193565b3480156103c057600080fd5b5061040f6103cf366004612284565b60cd602090815260009283526040808420909152908252902080546001820154600283015460038401546004850154600590950154939492939192909186565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610193565b34801561044857600080fd5b50610144610457366004612148565b610c8a565b34801561046857600080fd5b506101446104773660046122b0565b610e69565b34801561048857600080fd5b506101446104973660046120da565b6110f8565b3480156104a857600080fd5b506101866104b736600461231c565b611171565b6104c461153d565b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6104ee611597565b6104f66115dd565b81818061051e5760405162461bcd60e51b815260040161051590612370565b60405180910390fd5b60005b818110156105ea57600083838381811061053d5761053d6123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff1661057a5760405162461bcd60e51b8152600401610515906123bd565b60005b838110156105d557848482818110610597576105976123a7565b9050602002013582036105c3578083146105c35760405162461bcd60e51b8152600401610515906123ec565b806105cd81612439565b91505061057d565b505080806105e290612439565b915050610521565b5060005b8381101561062a5761061885858381811061060b5761060b6123a7565b9050602002013533611636565b8061062281612439565b9150506105ee565b5050506106376001609755565b5050565b6106436120a0565b8282806106625760405162461bcd60e51b815260040161051590612370565b60005b8181101561072e576000838383818110610681576106816123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166106be5760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610719578484828181106106db576106db6123a7565b905060200201358203610707578083146107075760405162461bcd60e51b8152600401610515906123ec565b8061071181612439565b9150506106c1565b5050808061072690612439565b915050610665565b50604080518082019091526000808252602082018190525b8581101561085457600060cc6000898985818110610766576107666123a7565b60209081029290920135835250818101929092526040908101600020815161018081018352815460ff9081161515825260018301549482019490945260028201549281018390526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b9091015490921615156101608301528451919250908490610824908390612452565b905250606081015160208401805161083d908390612452565b90525081905061084c81612439565b915050610746565b5095945050505050565b61086661153d565b61086e611683565b565b61087861153d565b61086e60006116d5565b61088a61153d565b6108978585858585611727565b5050505050565b6108a661153d565b61086e6117ed565b6108b6611597565b6108be6115dd565b8181806108dd5760405162461bcd60e51b815260040161051590612370565b60005b818110156109a95760008383838181106108fc576108fc6123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166109395760405162461bcd60e51b8152600401610515906123bd565b60005b8381101561099457848482818110610956576109566123a7565b905060200201358203610982578083146109825760405162461bcd60e51b8152600401610515906123ec565b8061098c81612439565b91505061093c565b505080806109a190612439565b9150506108e0565b5060005b8381101561062a5760008585838181106109c9576109c96123a7565b60209081029290920135600081815260cc8452604080822060cd8652818320338452865291819020815160c0810183528154815260018201549681019690965260028101549186019190915260038101546060860152600481015460808601526005015460a0850152600a81015491945092915043101580610a5e57504282600901548260200151610a5b9190612452565b11155b610ac55760405162461bcd60e51b815260206004820152603260248201527f596f7520617265206e6f7420616c6c6f77656420746f207769746864726177206044820152716265666f7265206c6f636b65642074696d6560701b6064820152608401610515565b8051610b135760405162461bcd60e51b815260206004820152601d60248201527f576974686472617720616d6f756e742063616e2774206265207a65726f0000006044820152606401610515565b610b1d8333611636565b600083815260cd602090815260408083203384529091528120818155600180820183905560028201839055600382018390556004820183905560059091018290558251908401805491929091610b74908490612465565b9091555050805160ca8054600090610b8d908490612465565b9091555050805160408051918252426020830152339185917fb0ecf14e184effded5473bba77dcfab32b094b77ac1fbb36beec2aef55587970910160405180910390a3805160c954610bec916001600160a01b0390911690339061182a565b5050508080610bfa90612439565b9150506109ad565b610c0a61153d565b600086815260cc60205260409020805460ff16610c395760405162461bcd60e51b8152600401610515906123bd565b8515610c4757600781018690555b8415610c5557600881018590555b8315610c6357600981018490555b8215610c7157600a81018390555b600b01805460ff19169115159190911790555050505050565b610c92611597565b610c9a6115dd565b818180610cb95760405162461bcd60e51b815260040161051590612370565b60005b81811015610d85576000838383818110610cd857610cd86123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff16610d155760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610d7057848482818110610d3257610d326123a7565b905060200201358203610d5e57808314610d5e5760405162461bcd60e51b8152600401610515906123ec565b80610d6881612439565b915050610d18565b50508080610d7d90612439565b915050610cbc565b5060005b8381101561062a576000858583818110610da557610da56123a7565b90506020020135905060cc6000828152602001908152602001600020600a01544310610e135760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e6720666f72207468697320706f6f6c2068617320656e646564006044820152606401610515565b6000610e1f823361188d565b805190915015610e38578051610e389083903390611aa7565b602081015115610e5457610e54338260015b6020020151611bd5565b50508080610e6190612439565b915050610d89565b610e71611597565b610e796115dd565b838380610e985760405162461bcd60e51b815260040161051590612370565b60005b81811015610f64576000838383818110610eb757610eb76123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff16610ef45760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610f4f57848482818110610f1157610f116123a7565b905060200201358203610f3d57808314610f3d5760405162461bcd60e51b8152600401610515906123ec565b80610f4781612439565b915050610ef7565b50508080610f5c90612439565b915050610e9b565b50848314610fa95760405162461bcd60e51b8152602060048201526012602482015271496e76616c696420706172616d657465727360701b6044820152606401610515565b60005b858110156110e5576000878783818110610fc857610fc86123a7565b9050602002013590506000868684818110610fe557610fe56123a7565b90506020020135905060cc6000838152602001908152602001600020600a015443106110535760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e6720666f72207468697320706f6f6c2068617320656e646564006044820152606401610515565b600081116110a35760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610515565b6110ad8233611636565b6110b8823383611aa7565b60c9546110d0906001600160a01b0316333084611cab565b505080806110dd90612439565b915050610fac565b5050506110f26001609755565b50505050565b61110061153d565b6001600160a01b0381166111655760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610515565b61116e816116d5565b50565b6111796120a0565b8383806111985760405162461bcd60e51b815260040161051590612370565b60005b818110156112645760008383838181106111b7576111b76123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166111f45760405162461bcd60e51b8152600401610515906123bd565b60005b8381101561124f57848482818110611211576112116123a7565b90506020020135820361123d5780831461123d5760405162461bcd60e51b8152600401610515906123ec565b8061124781612439565b9150506111f7565b5050808061125c90612439565b91505061119b565b50604080518082019091526000808252602082018190525b86811015611532576000888883818110611298576112986123a7565b60209081029290920135600081815260cc8452604090819020815161018081018352815460ff9081161515825260018301549682018790526002830154938201939093526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b9091015490911615156101608201529093509115905061151d576000816101400151431161136d5760808201516113689043612465565b611382565b81608001518261014001516113829190612465565b905060008260e00151826113969190612478565b90506000836020015164e8d4a51000836113b09190612478565b6113ba919061248f565b8460a001516113c99190612452565b90506000846101000151846113de9190612478565b90506000856020015164e8d4a51000836113f89190612478565b611402919061248f565b8660c001516114119190612452565b9050600060cd600089815260200190815260200160002060008f6001600160a01b03166001600160a01b031681526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815250509050806080015164e8d4a510008583600001516114af9190612478565b6114b9919061248f565b6114c39190612465565b8a518b906114d2908390612452565b90525060a0810151815164e8d4a51000906114ee908590612478565b6114f8919061248f565b6115029190612465565b60208b018051611513908390612452565b9052505050505050505b5050808061152a90612439565b91505061127c565b509695505050505050565b6033546001600160a01b0316331461086e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610515565b60655460ff161561086e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610515565b60026097540361162f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610515565b6002609755565b6000611642838361188d565b80519091501561166857805160c954611668916001600160a01b0390911690849061182a565b60208101511561167e5761167e82826001610e4a565b505050565b61168b611ce3565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60cb805460009160cc9183918261173d83612439565b9091555081526020810191909152604001600020805490915060ff16156117a65760405162461bcd60e51b815260206004820152601860248201527f506f6f6c20616c726561647920696e697469616c697a656400000000000000006044820152606401610515565b805460ff191660011781556007810186905560088101859055600981018490556117d08343612452565b600a820155600b01805460ff191691151591909117905550505050565b6117f5611597565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116b83390565b6040516001600160a01b03831660248201526044810182905261167e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611d2c565b6118956120a0565b61189e83611e01565b600083815260cc6020908152604080832060cd83528184206001600160a01b038716855290925282206004810154600583015482549394929364e8d4a51000916118e791612478565b6118f1919061248f565b6118fb9190612465565b905080156119aa57808360020160008282546119179190612452565b92505081905550808260020160008282546119329190612452565b90915550506005830154825464e8d4a510009161194e91612478565b611958919061248f565b600483015560c954604080518381524260208201526001600160a01b039283169288169189917fb212aab63d2cea75226d870069b6f234e2ef0a3b67015822945f80d6e29d4b90910160405180910390a45b6000826005015464e8d4a51000856006015485600001546119cb9190612478565b6119d5919061248f565b6119df9190612465565b90508015611a8a57808460030160008282546119fb9190612452565b9250508190555080836003016000828254611a169190612452565b90915550506006840154835464e8d4a5100091611a3291612478565b611a3c919061248f565b6005840155604080518281524260208201526000916001600160a01b038916918a917fb212aab63d2cea75226d870069b6f234e2ef0a3b67015822945f80d6e29d4b90910160405180910390a45b604080518082019091529182526020820152925050505b92915050565b600083815260cc6020908152604080832060cd83528184206001600160a01b0387168552909252822080549192909184918391611ae5908490612452565b90915550506005820154815464e8d4a5100091611b0191612478565b611b0b919061248f565b60048201556006820154815464e8d4a5100091611b2791612478565b611b31919061248f565b6005820155600b82015460ff1680611b4b57506001810154155b15611b57574260018201555b82826001016000828254611b6b9190612452565b925050819055508260ca6000828254611b849190612452565b9091555050604080518481524260208201526001600160a01b0386169187917fd36a2f67d06d285786f61a32b052b9ace6b0b7abef5177b54358abdc83a0b69b910160405180910390a35050505050565b80471015611c135760405162461bcd60e51b815260206004820152600b60248201526a4c6f772062616c616e636560a81b6044820152606401610515565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c60576040519150601f19603f3d011682016040523d82523d6000602084013e611c65565b606091505b505090508061167e5760405162461bcd60e51b8152602060048201526012602482015271115512081c185e5b595b9d0819985a5b195960721b6044820152606401610515565b6040516001600160a01b03808516602483015283166044820152606481018290526110f29085906323b872dd60e01b90608401611856565b60655460ff1661086e5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610515565b6000611d81826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f109092919063ffffffff16565b9050805160001480611da2575080806020019051810190611da291906124b1565b61167e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610515565b600081815260cc602052604081206001810154909103611e25574360049091015550565b600081600a01544311611e46576004820154611e419043612465565b611e5a565b816004015482600a0154611e5a9190612465565b90506000826007015482611e6e9190612478565b6001840154909150611e8564e8d4a5100083612478565b611e8f919061248f565b8360050154611e9e9190612452565b60058401556008830154600090611eb59084612478565b6001850154909150611ecc64e8d4a5100083612478565b611ed6919061248f565b8460060154611ee59190612452565b6006850155600a8401544311611efb5743611f01565b83600a01545b84600401819055505050505050565b6060611f1f8484600085611f27565b949350505050565b606082471015611f885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610515565b600080866001600160a01b03168587604051611fa491906124f2565b60006040518083038185875af1925050503d8060008114611fe1576040519150601f19603f3d011682016040523d82523d6000602084013e611fe6565b606091505b5091509150611ff787838387612002565b979650505050505050565b6060831561207157825160000361206a576001600160a01b0385163b61206a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610515565b5081611f1f565b611f1f83838151156120865781518083602001fd5b8060405162461bcd60e51b8152600401610515919061250e565b60405180604001604052806002906020820280368337509192915050565b80356001600160a01b03811681146120d557600080fd5b919050565b6000602082840312156120ec57600080fd5b6120f5826120be565b9392505050565b60008083601f84011261210e57600080fd5b50813567ffffffffffffffff81111561212657600080fd5b6020830191508360208260051b850101111561214157600080fd5b9250929050565b6000806020838503121561215b57600080fd5b823567ffffffffffffffff81111561217257600080fd5b61217e858286016120fc565b90969095509350505050565b60408101818360005b60028110156121b2578151835260209283019290910190600101612193565b50505092915050565b801515811461116e57600080fd5b600080600080600060a086880312156121e157600080fd5b853594506020860135935060408601359250606086013591506080860135612208816121bb565b809150509295509295909350565b60008060008060008060c0878903121561222f57600080fd5b863595506020870135945060408701359350606087013592506080870135915060a087013561225d816121bb565b809150509295509295509295565b60006020828403121561227d57600080fd5b5035919050565b6000806040838503121561229757600080fd5b823591506122a7602084016120be565b90509250929050565b600080600080604085870312156122c657600080fd5b843567ffffffffffffffff808211156122de57600080fd5b6122ea888389016120fc565b9096509450602087013591508082111561230357600080fd5b50612310878288016120fc565b95989497509550505050565b60008060006040848603121561233157600080fd5b833567ffffffffffffffff81111561234857600080fd5b612354868287016120fc565b90945092506123679050602085016120be565b90509250925092565b6020808252601c908201527f4d75737420696e707574206174206c65617374206f6e6520706f6f6c00000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b602080825260159082015274141bdbdb081a5cc81d5b9a5b9a5d1a585b1a5e9959605a1b604082015260600190565b6020808252601b908201527f4475706c696361746520706f6f6c20696e7075747320666f756e640000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006001820161244b5761244b612423565b5060010190565b80820180821115611aa157611aa1612423565b81810381811115611aa157611aa1612423565b8082028115828204841417611aa157611aa1612423565b6000826124ac57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156124c357600080fd5b81516120f5816121bb565b60005b838110156124e95781810151838201526020016124d1565b50506000910152565b600082516125048184602087016124ce565b9190910192915050565b602081526000825180602084015261252d8160408501602087016124ce565b601f01601f1916919091016040019291505056fea26469706673582212200664ea5806083281b7475e813a94a6467932d426b72fa90ca48f3e5e268e8bac64736f6c63430008130033

Deployed Bytecode

0x6080604052600436106101185760003560e01c80638da5cb5b116100a0578063b798aaae11610064578063b798aaae146103b4578063cf7e58741461043c578063f223885a1461045c578063f2fde38b1461047c578063fb2f897a1461049c57600080fd5b80638da5cb5b14610256578063983d95ce1461027457806399a0331614610294578063a240e37a146102b8578063ac4afa38146102d857600080fd5b806351ed6a30116100e757806351ed6a30146101b15780635c975abb146101e9578063715018a61461020c5780638091fbac146102215780638456cb591461024157600080fd5b80630397d458146101245780632a456115146101465780633697da15146101665780633f4ba83a1461019c57600080fd5b3661011f57005b600080fd5b34801561013057600080fd5b5061014461013f3660046120da565b6104bc565b005b34801561015257600080fd5b50610144610161366004612148565b6104e6565b34801561017257600080fd5b50610186610181366004612148565b61063b565b604051610193919061218a565b60405180910390f35b3480156101a857600080fd5b5061014461085e565b3480156101bd57600080fd5b5060c9546101d1906001600160a01b031681565b6040516001600160a01b039091168152602001610193565b3480156101f557600080fd5b5060655460ff166040519015158152602001610193565b34801561021857600080fd5b50610144610870565b34801561022d57600080fd5b5061014461023c3660046121c9565b610882565b34801561024d57600080fd5b5061014461089e565b34801561026257600080fd5b506033546001600160a01b03166101d1565b34801561028057600080fd5b5061014461028f366004612148565b6108ae565b3480156102a057600080fd5b506102aa60ca5481565b604051908152602001610193565b3480156102c457600080fd5b506101446102d3366004612216565b610c02565b3480156102e457600080fd5b506103576102f336600461226b565b60cc60205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b909b015460ff9a8b169b999a98999798969795969495939492939192168c565b604080519c15158d5260208d019b909b52998b019890985260608a0196909652608089019490945260a088019290925260c087015260e0860152610100850152610120840152610140830152151561016082015261018001610193565b3480156103c057600080fd5b5061040f6103cf366004612284565b60cd602090815260009283526040808420909152908252902080546001820154600283015460038401546004850154600590950154939492939192909186565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610193565b34801561044857600080fd5b50610144610457366004612148565b610c8a565b34801561046857600080fd5b506101446104773660046122b0565b610e69565b34801561048857600080fd5b506101446104973660046120da565b6110f8565b3480156104a857600080fd5b506101866104b736600461231c565b611171565b6104c461153d565b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6104ee611597565b6104f66115dd565b81818061051e5760405162461bcd60e51b815260040161051590612370565b60405180910390fd5b60005b818110156105ea57600083838381811061053d5761053d6123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff1661057a5760405162461bcd60e51b8152600401610515906123bd565b60005b838110156105d557848482818110610597576105976123a7565b9050602002013582036105c3578083146105c35760405162461bcd60e51b8152600401610515906123ec565b806105cd81612439565b91505061057d565b505080806105e290612439565b915050610521565b5060005b8381101561062a5761061885858381811061060b5761060b6123a7565b9050602002013533611636565b8061062281612439565b9150506105ee565b5050506106376001609755565b5050565b6106436120a0565b8282806106625760405162461bcd60e51b815260040161051590612370565b60005b8181101561072e576000838383818110610681576106816123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166106be5760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610719578484828181106106db576106db6123a7565b905060200201358203610707578083146107075760405162461bcd60e51b8152600401610515906123ec565b8061071181612439565b9150506106c1565b5050808061072690612439565b915050610665565b50604080518082019091526000808252602082018190525b8581101561085457600060cc6000898985818110610766576107666123a7565b60209081029290920135835250818101929092526040908101600020815161018081018352815460ff9081161515825260018301549482019490945260028201549281018390526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b9091015490921615156101608301528451919250908490610824908390612452565b905250606081015160208401805161083d908390612452565b90525081905061084c81612439565b915050610746565b5095945050505050565b61086661153d565b61086e611683565b565b61087861153d565b61086e60006116d5565b61088a61153d565b6108978585858585611727565b5050505050565b6108a661153d565b61086e6117ed565b6108b6611597565b6108be6115dd565b8181806108dd5760405162461bcd60e51b815260040161051590612370565b60005b818110156109a95760008383838181106108fc576108fc6123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166109395760405162461bcd60e51b8152600401610515906123bd565b60005b8381101561099457848482818110610956576109566123a7565b905060200201358203610982578083146109825760405162461bcd60e51b8152600401610515906123ec565b8061098c81612439565b91505061093c565b505080806109a190612439565b9150506108e0565b5060005b8381101561062a5760008585838181106109c9576109c96123a7565b60209081029290920135600081815260cc8452604080822060cd8652818320338452865291819020815160c0810183528154815260018201549681019690965260028101549186019190915260038101546060860152600481015460808601526005015460a0850152600a81015491945092915043101580610a5e57504282600901548260200151610a5b9190612452565b11155b610ac55760405162461bcd60e51b815260206004820152603260248201527f596f7520617265206e6f7420616c6c6f77656420746f207769746864726177206044820152716265666f7265206c6f636b65642074696d6560701b6064820152608401610515565b8051610b135760405162461bcd60e51b815260206004820152601d60248201527f576974686472617720616d6f756e742063616e2774206265207a65726f0000006044820152606401610515565b610b1d8333611636565b600083815260cd602090815260408083203384529091528120818155600180820183905560028201839055600382018390556004820183905560059091018290558251908401805491929091610b74908490612465565b9091555050805160ca8054600090610b8d908490612465565b9091555050805160408051918252426020830152339185917fb0ecf14e184effded5473bba77dcfab32b094b77ac1fbb36beec2aef55587970910160405180910390a3805160c954610bec916001600160a01b0390911690339061182a565b5050508080610bfa90612439565b9150506109ad565b610c0a61153d565b600086815260cc60205260409020805460ff16610c395760405162461bcd60e51b8152600401610515906123bd565b8515610c4757600781018690555b8415610c5557600881018590555b8315610c6357600981018490555b8215610c7157600a81018390555b600b01805460ff19169115159190911790555050505050565b610c92611597565b610c9a6115dd565b818180610cb95760405162461bcd60e51b815260040161051590612370565b60005b81811015610d85576000838383818110610cd857610cd86123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff16610d155760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610d7057848482818110610d3257610d326123a7565b905060200201358203610d5e57808314610d5e5760405162461bcd60e51b8152600401610515906123ec565b80610d6881612439565b915050610d18565b50508080610d7d90612439565b915050610cbc565b5060005b8381101561062a576000858583818110610da557610da56123a7565b90506020020135905060cc6000828152602001908152602001600020600a01544310610e135760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e6720666f72207468697320706f6f6c2068617320656e646564006044820152606401610515565b6000610e1f823361188d565b805190915015610e38578051610e389083903390611aa7565b602081015115610e5457610e54338260015b6020020151611bd5565b50508080610e6190612439565b915050610d89565b610e71611597565b610e796115dd565b838380610e985760405162461bcd60e51b815260040161051590612370565b60005b81811015610f64576000838383818110610eb757610eb76123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff16610ef45760405162461bcd60e51b8152600401610515906123bd565b60005b83811015610f4f57848482818110610f1157610f116123a7565b905060200201358203610f3d57808314610f3d5760405162461bcd60e51b8152600401610515906123ec565b80610f4781612439565b915050610ef7565b50508080610f5c90612439565b915050610e9b565b50848314610fa95760405162461bcd60e51b8152602060048201526012602482015271496e76616c696420706172616d657465727360701b6044820152606401610515565b60005b858110156110e5576000878783818110610fc857610fc86123a7565b9050602002013590506000868684818110610fe557610fe56123a7565b90506020020135905060cc6000838152602001908152602001600020600a015443106110535760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e6720666f72207468697320706f6f6c2068617320656e646564006044820152606401610515565b600081116110a35760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610515565b6110ad8233611636565b6110b8823383611aa7565b60c9546110d0906001600160a01b0316333084611cab565b505080806110dd90612439565b915050610fac565b5050506110f26001609755565b50505050565b61110061153d565b6001600160a01b0381166111655760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610515565b61116e816116d5565b50565b6111796120a0565b8383806111985760405162461bcd60e51b815260040161051590612370565b60005b818110156112645760008383838181106111b7576111b76123a7565b60209081029290920135600081815260cc9093526040909220549192505060ff166111f45760405162461bcd60e51b8152600401610515906123bd565b60005b8381101561124f57848482818110611211576112116123a7565b90506020020135820361123d5780831461123d5760405162461bcd60e51b8152600401610515906123ec565b8061124781612439565b9150506111f7565b5050808061125c90612439565b91505061119b565b50604080518082019091526000808252602082018190525b86811015611532576000888883818110611298576112986123a7565b60209081029290920135600081815260cc8452604090819020815161018081018352815460ff9081161515825260018301549682018790526002830154938201939093526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b9091015490911615156101608201529093509115905061151d576000816101400151431161136d5760808201516113689043612465565b611382565b81608001518261014001516113829190612465565b905060008260e00151826113969190612478565b90506000836020015164e8d4a51000836113b09190612478565b6113ba919061248f565b8460a001516113c99190612452565b90506000846101000151846113de9190612478565b90506000856020015164e8d4a51000836113f89190612478565b611402919061248f565b8660c001516114119190612452565b9050600060cd600089815260200190815260200160002060008f6001600160a01b03166001600160a01b031681526020019081526020016000206040518060c001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815250509050806080015164e8d4a510008583600001516114af9190612478565b6114b9919061248f565b6114c39190612465565b8a518b906114d2908390612452565b90525060a0810151815164e8d4a51000906114ee908590612478565b6114f8919061248f565b6115029190612465565b60208b018051611513908390612452565b9052505050505050505b5050808061152a90612439565b91505061127c565b509695505050505050565b6033546001600160a01b0316331461086e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610515565b60655460ff161561086e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610515565b60026097540361162f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610515565b6002609755565b6000611642838361188d565b80519091501561166857805160c954611668916001600160a01b0390911690849061182a565b60208101511561167e5761167e82826001610e4a565b505050565b61168b611ce3565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60cb805460009160cc9183918261173d83612439565b9091555081526020810191909152604001600020805490915060ff16156117a65760405162461bcd60e51b815260206004820152601860248201527f506f6f6c20616c726561647920696e697469616c697a656400000000000000006044820152606401610515565b805460ff191660011781556007810186905560088101859055600981018490556117d08343612452565b600a820155600b01805460ff191691151591909117905550505050565b6117f5611597565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116b83390565b6040516001600160a01b03831660248201526044810182905261167e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611d2c565b6118956120a0565b61189e83611e01565b600083815260cc6020908152604080832060cd83528184206001600160a01b038716855290925282206004810154600583015482549394929364e8d4a51000916118e791612478565b6118f1919061248f565b6118fb9190612465565b905080156119aa57808360020160008282546119179190612452565b92505081905550808260020160008282546119329190612452565b90915550506005830154825464e8d4a510009161194e91612478565b611958919061248f565b600483015560c954604080518381524260208201526001600160a01b039283169288169189917fb212aab63d2cea75226d870069b6f234e2ef0a3b67015822945f80d6e29d4b90910160405180910390a45b6000826005015464e8d4a51000856006015485600001546119cb9190612478565b6119d5919061248f565b6119df9190612465565b90508015611a8a57808460030160008282546119fb9190612452565b9250508190555080836003016000828254611a169190612452565b90915550506006840154835464e8d4a5100091611a3291612478565b611a3c919061248f565b6005840155604080518281524260208201526000916001600160a01b038916918a917fb212aab63d2cea75226d870069b6f234e2ef0a3b67015822945f80d6e29d4b90910160405180910390a45b604080518082019091529182526020820152925050505b92915050565b600083815260cc6020908152604080832060cd83528184206001600160a01b0387168552909252822080549192909184918391611ae5908490612452565b90915550506005820154815464e8d4a5100091611b0191612478565b611b0b919061248f565b60048201556006820154815464e8d4a5100091611b2791612478565b611b31919061248f565b6005820155600b82015460ff1680611b4b57506001810154155b15611b57574260018201555b82826001016000828254611b6b9190612452565b925050819055508260ca6000828254611b849190612452565b9091555050604080518481524260208201526001600160a01b0386169187917fd36a2f67d06d285786f61a32b052b9ace6b0b7abef5177b54358abdc83a0b69b910160405180910390a35050505050565b80471015611c135760405162461bcd60e51b815260206004820152600b60248201526a4c6f772062616c616e636560a81b6044820152606401610515565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c60576040519150601f19603f3d011682016040523d82523d6000602084013e611c65565b606091505b505090508061167e5760405162461bcd60e51b8152602060048201526012602482015271115512081c185e5b595b9d0819985a5b195960721b6044820152606401610515565b6040516001600160a01b03808516602483015283166044820152606481018290526110f29085906323b872dd60e01b90608401611856565b60655460ff1661086e5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610515565b6000611d81826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f109092919063ffffffff16565b9050805160001480611da2575080806020019051810190611da291906124b1565b61167e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610515565b600081815260cc602052604081206001810154909103611e25574360049091015550565b600081600a01544311611e46576004820154611e419043612465565b611e5a565b816004015482600a0154611e5a9190612465565b90506000826007015482611e6e9190612478565b6001840154909150611e8564e8d4a5100083612478565b611e8f919061248f565b8360050154611e9e9190612452565b60058401556008830154600090611eb59084612478565b6001850154909150611ecc64e8d4a5100083612478565b611ed6919061248f565b8460060154611ee59190612452565b6006850155600a8401544311611efb5743611f01565b83600a01545b84600401819055505050505050565b6060611f1f8484600085611f27565b949350505050565b606082471015611f885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610515565b600080866001600160a01b03168587604051611fa491906124f2565b60006040518083038185875af1925050503d8060008114611fe1576040519150601f19603f3d011682016040523d82523d6000602084013e611fe6565b606091505b5091509150611ff787838387612002565b979650505050505050565b6060831561207157825160000361206a576001600160a01b0385163b61206a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610515565b5081611f1f565b611f1f83838151156120865781518083602001fd5b8060405162461bcd60e51b8152600401610515919061250e565b60405180604001604052806002906020820280368337509192915050565b80356001600160a01b03811681146120d557600080fd5b919050565b6000602082840312156120ec57600080fd5b6120f5826120be565b9392505050565b60008083601f84011261210e57600080fd5b50813567ffffffffffffffff81111561212657600080fd5b6020830191508360208260051b850101111561214157600080fd5b9250929050565b6000806020838503121561215b57600080fd5b823567ffffffffffffffff81111561217257600080fd5b61217e858286016120fc565b90969095509350505050565b60408101818360005b60028110156121b2578151835260209283019290910190600101612193565b50505092915050565b801515811461116e57600080fd5b600080600080600060a086880312156121e157600080fd5b853594506020860135935060408601359250606086013591506080860135612208816121bb565b809150509295509295909350565b60008060008060008060c0878903121561222f57600080fd5b863595506020870135945060408701359350606087013592506080870135915060a087013561225d816121bb565b809150509295509295509295565b60006020828403121561227d57600080fd5b5035919050565b6000806040838503121561229757600080fd5b823591506122a7602084016120be565b90509250929050565b600080600080604085870312156122c657600080fd5b843567ffffffffffffffff808211156122de57600080fd5b6122ea888389016120fc565b9096509450602087013591508082111561230357600080fd5b50612310878288016120fc565b95989497509550505050565b60008060006040848603121561233157600080fd5b833567ffffffffffffffff81111561234857600080fd5b612354868287016120fc565b90945092506123679050602085016120be565b90509250925092565b6020808252601c908201527f4d75737420696e707574206174206c65617374206f6e6520706f6f6c00000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b602080825260159082015274141bdbdb081a5cc81d5b9a5b9a5d1a585b1a5e9959605a1b604082015260600190565b6020808252601b908201527f4475706c696361746520706f6f6c20696e7075747320666f756e640000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006001820161244b5761244b612423565b5060010190565b80820180821115611aa157611aa1612423565b81810381811115611aa157611aa1612423565b8082028115828204841417611aa157611aa1612423565b6000826124ac57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156124c357600080fd5b81516120f5816121bb565b60005b838110156124e95781810151838201526020016124d1565b50506000910152565b600082516125048184602087016124ce565b9190910192915050565b602081526000825180602084015261252d8160408501602087016124ce565b601f01601f1916919091016040019291505056fea26469706673582212200664ea5806083281b7475e813a94a6467932d426b72fa90ca48f3e5e268e8bac64736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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