ETH Price: $3,426.22 (+3.81%)

Contract

0x7d85C0905a6E1Ab5837a0b57cD94A419d3a77523
 
Transaction Hash
Method
Block
From
To
Withdraw212520472024-11-23 17:51:114 mins ago1732384271IN
0x7d85C090...9d3a77523
0 ETH0.0024163716.04986746
Deposit212513882024-11-23 15:38:592 hrs ago1732376339IN
0x7d85C090...9d3a77523
0 ETH0.0037166720.79003673
Withdraw212511512024-11-23 14:51:353 hrs ago1732373495IN
0x7d85C090...9d3a77523
0 ETH0.004297422.55453746
Withdraw212509252024-11-23 14:05:233 hrs ago1732370723IN
0x7d85C090...9d3a77523
0 ETH0.0029009118.12083903
Withdraw212506132024-11-23 13:02:474 hrs ago1732366967IN
0x7d85C090...9d3a77523
0 ETH0.0018602114.97273038
Harvest212506102024-11-23 13:02:114 hrs ago1732366931IN
0x7d85C090...9d3a77523
0 ETH0.0018073914.11796204
Deposit212497812024-11-23 10:15:477 hrs ago1732356947IN
0x7d85C090...9d3a77523
0 ETH0.002055111.36089548
Deposit212496872024-11-23 9:56:597 hrs ago1732355819IN
0x7d85C090...9d3a77523
0 ETH0.001591810.32223844
Deposit212495122024-11-23 9:21:598 hrs ago1732353719IN
0x7d85C090...9d3a77523
0 ETH0.0020464211.44789784
Deposit212494122024-11-23 9:01:598 hrs ago1732352519IN
0x7d85C090...9d3a77523
0 ETH0.0020986512.81380429
Deposit212493522024-11-23 8:49:599 hrs ago1732351799IN
0x7d85C090...9d3a77523
0 ETH0.0017282711.36350853
Deposit212492772024-11-23 8:34:599 hrs ago1732350899IN
0x7d85C090...9d3a77523
0 ETH0.0024306513.59733103
Deposit212492662024-11-23 8:32:479 hrs ago1732350767IN
0x7d85C090...9d3a77523
0 ETH0.0024508113.54932185
Deposit212491912024-11-23 8:17:479 hrs ago1732349867IN
0x7d85C090...9d3a77523
0 ETH0.0020075411.23040169
Deposit212488172024-11-23 7:02:3510 hrs ago1732345355IN
0x7d85C090...9d3a77523
0 ETH0.0019825710.96067192
Deposit212487152024-11-23 6:42:1111 hrs ago1732344131IN
0x7d85C090...9d3a77523
0 ETH0.0017539.80647178
Deposit212484642024-11-23 5:51:5912 hrs ago1732341119IN
0x7d85C090...9d3a77523
0 ETH0.0018260610.21657176
Deposit212475192024-11-23 2:42:1115 hrs ago1732329731IN
0x7d85C090...9d3a77523
0 ETH0.0023084212.91356191
Deposit212465232024-11-22 23:22:2318 hrs ago1732317743IN
0x7d85C090...9d3a77523
0 ETH0.0024105513.48575879
Withdraw212463862024-11-22 22:54:4719 hrs ago1732316087IN
0x7d85C090...9d3a77523
0 ETH0.0020519115.37547981
Deposit212457342024-11-22 20:43:5921 hrs ago1732308239IN
0x7d85C090...9d3a77523
0 ETH0.0017344511.40412943
Deposit212457292024-11-22 20:42:5921 hrs ago1732308179IN
0x7d85C090...9d3a77523
0 ETH0.0020823511.64889284
Withdraw212454542024-11-22 19:47:4722 hrs ago1732304867IN
0x7d85C090...9d3a77523
0 ETH0.0014474310.84595447
Deposit212452152024-11-22 18:59:5922 hrs ago1732301999IN
0x7d85C090...9d3a77523
0 ETH0.0023316615.33081937
Deposit212452072024-11-22 18:58:2322 hrs ago1732301903IN
0x7d85C090...9d3a77523
0 ETH0.0025394915.5043195
View all transactions

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
177116942023-07-17 8:08:59495 days ago1689581339  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FarmingRange

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 11 : FarmingRange.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

// contracts
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

// libraries
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// interfaces
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "./interfaces/IFarmingRange.sol";

/**
 * @title FarmingRange
 * @notice Farming Range allows users to stake LP Tokens to receive various rewards
 * @custom:from Contract taken from the alpaca protocol, adapted to version 0.8.17 and modified with more functions
 * @custom:url https://github.com/alpaca-finance/bsc-alpaca-contract/blob/main/solidity/contracts/6.12/GrazingRange.sol
 */
contract FarmingRange is IFarmingRange, Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    mapping(uint256 => RewardInfo[]) public campaignRewardInfo;

    CampaignInfo[] public campaignInfo;
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;

    uint256 public rewardInfoLimit;
    address public immutable rewardManager;

    constructor(address _rewardManager) {
        rewardInfoLimit = 52;
        require(_rewardManager != address(0), "FarmingRange::constructor::Reward manager is not defined");
        rewardManager = _rewardManager;
    }

    /// @inheritdoc IFarmingRange
    function setRewardInfoLimit(uint256 _updatedRewardInfoLimit) external onlyOwner {
        rewardInfoLimit = _updatedRewardInfoLimit;
        emit SetRewardInfoLimit(rewardInfoLimit);
    }

    /// @inheritdoc IFarmingRange
    function addCampaignInfo(
        IERC20 _stakingToken,
        IERC20 _rewardToken,
        uint256 _startBlock
    ) external virtual onlyOwner {
        require(_startBlock > block.number, "FarmingRange::addCampaignInfo::Start block should be in the future");
        campaignInfo.push(
            CampaignInfo({
                stakingToken: _stakingToken,
                rewardToken: _rewardToken,
                startBlock: _startBlock,
                lastRewardBlock: _startBlock,
                accRewardPerShare: 0,
                totalStaked: 0,
                totalRewards: 0
            })
        );
        emit AddCampaignInfo(campaignInfo.length - 1, _stakingToken, _rewardToken, _startBlock);
    }

    /// @inheritdoc IFarmingRange
    function addRewardInfo(
        uint256 _campaignID,
        uint256 _endBlock,
        uint256 _rewardPerBlock
    ) public virtual onlyOwner nonReentrant {
        RewardInfo[] storage rewardInfo = campaignRewardInfo[_campaignID];
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        require(
            rewardInfo.length < rewardInfoLimit,
            "FarmingRange::addRewardInfo::reward info length exceeds the limit"
        );
        require(
            rewardInfo.length == 0 || rewardInfo[rewardInfo.length - 1].endBlock >= block.number,
            "FarmingRange::addRewardInfo::reward period ended"
        );
        require(
            rewardInfo.length == 0 || rewardInfo[rewardInfo.length - 1].endBlock < _endBlock,
            "FarmingRange::addRewardInfo::bad new endblock"
        );
        uint256 _startBlock = rewardInfo.length == 0 ? campaign.startBlock : rewardInfo[rewardInfo.length - 1].endBlock;
        uint256 _blockRange = _endBlock - _startBlock;
        uint256 _totalRewards = _rewardPerBlock * _blockRange;
        campaign.totalRewards = campaign.totalRewards + _totalRewards;
        rewardInfo.push(RewardInfo({ endBlock: _endBlock, rewardPerBlock: _rewardPerBlock }));
        _transferFromWithAllowance(campaign.rewardToken, _totalRewards, _campaignID);
        emit AddRewardInfo(_campaignID, rewardInfo.length - 1, _endBlock, _rewardPerBlock);
    }

    /// @inheritdoc IFarmingRange
    function addRewardInfoMultiple(
        uint256 _campaignID,
        uint256[] calldata _endBlock,
        uint256[] calldata _rewardPerBlock
    ) external onlyOwner {
        require(_endBlock.length == _rewardPerBlock.length, "FarmingRange::addRewardMultiple::wrong parameters length");
        for (uint256 _i; _i != _endBlock.length; ) {
            addRewardInfo(_campaignID, _endBlock[_i], _rewardPerBlock[_i]);
            unchecked {
                ++_i;
            }
        }
    }

    /// @inheritdoc IFarmingRange
    function updateRewardInfo(
        uint256 _campaignID,
        uint256 _rewardIndex,
        uint256 _endBlock,
        uint256 _rewardPerBlock
    ) public virtual onlyOwner nonReentrant {
        RewardInfo[] storage rewardInfo = campaignRewardInfo[_campaignID];
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        RewardInfo storage selectedRewardInfo = rewardInfo[_rewardIndex];
        uint256 _previousEndBlock = selectedRewardInfo.endBlock;
        _updateCampaign(_campaignID);
        require(_previousEndBlock >= block.number, "FarmingRange::updateRewardInfo::reward period ended");
        if (_rewardIndex != 0) {
            require(
                rewardInfo[_rewardIndex - 1].endBlock < _endBlock,
                "FarmingRange::updateRewardInfo::bad new endblock"
            );
        }
        if (rewardInfo.length > _rewardIndex + 1) {
            require(
                _endBlock < rewardInfo[_rewardIndex + 1].endBlock,
                "FarmingRange::updateRewardInfo::reward period end is in next range"
            );
        }
        (bool _refund, uint256 _diff) = _updateRewardsDiff(
            _rewardIndex,
            _endBlock,
            _rewardPerBlock,
            rewardInfo,
            campaign,
            selectedRewardInfo
        );
        if (!_refund && _diff != 0) {
            _transferFromWithAllowance(campaign.rewardToken, _diff, _campaignID);
        }
        // If _endblock is changed, and if we have another range after the updated one,
        // we need to update rewardPerBlock to distribute on the next new range or we could run out of tokens
        if (_endBlock != _previousEndBlock && rewardInfo.length - 1 > _rewardIndex) {
            RewardInfo storage nextRewardInfo = rewardInfo[_rewardIndex + 1];
            uint256 _nextRewardInfoEndBlock = nextRewardInfo.endBlock;
            uint256 _initialBlockRange = _nextRewardInfoEndBlock - _previousEndBlock;
            uint256 _nextBlockRange = _nextRewardInfoEndBlock - _endBlock;
            uint256 _currentRewardPerBlock = nextRewardInfo.rewardPerBlock;
            uint256 _initialNextTotal = _initialBlockRange * _currentRewardPerBlock;
            _currentRewardPerBlock = (_currentRewardPerBlock * _initialBlockRange) / _nextBlockRange;
            uint256 _nextTotal = _nextBlockRange * _currentRewardPerBlock;
            nextRewardInfo.rewardPerBlock = _currentRewardPerBlock;
            if (_nextTotal < _initialNextTotal) {
                campaign.rewardToken.safeTransfer(rewardManager, _initialNextTotal - _nextTotal);
                campaign.totalRewards -= _initialNextTotal - _nextTotal;
            }
        }
        // UPDATE total
        campaign.totalRewards = _refund ? campaign.totalRewards - _diff : campaign.totalRewards + _diff;
        selectedRewardInfo.endBlock = _endBlock;
        selectedRewardInfo.rewardPerBlock = _rewardPerBlock;
        emit UpdateRewardInfo(_campaignID, _rewardIndex, _endBlock, _rewardPerBlock);
    }

    /// @inheritdoc IFarmingRange
    function updateRewardMultiple(
        uint256 _campaignID,
        uint256[] memory _rewardIndex,
        uint256[] memory _endBlock,
        uint256[] memory _rewardPerBlock
    ) public onlyOwner {
        require(
            _rewardIndex.length == _endBlock.length && _rewardIndex.length == _rewardPerBlock.length,
            "FarmingRange::updateRewardMultiple::wrong parameters length"
        );
        for (uint256 _i; _i != _rewardIndex.length; ) {
            updateRewardInfo(_campaignID, _rewardIndex[_i], _endBlock[_i], _rewardPerBlock[_i]);
            unchecked {
                ++_i;
            }
        }
    }

    /// @inheritdoc IFarmingRange
    function updateCampaignsRewards(
        uint256[] calldata _campaignID,
        uint256[][] calldata _rewardIndex,
        uint256[][] calldata _endBlock,
        uint256[][] calldata _rewardPerBlock
    ) external onlyOwner {
        require(
            _campaignID.length == _rewardIndex.length &&
                _rewardIndex.length == _endBlock.length &&
                _rewardIndex.length == _rewardPerBlock.length,
            "FarmingRange::updateCampaignsRewards::wrong rewardInfo length"
        );
        for (uint256 _i; _i != _campaignID.length; ) {
            updateRewardMultiple(_campaignID[_i], _rewardIndex[_i], _endBlock[_i], _rewardPerBlock[_i]);
            unchecked {
                ++_i;
            }
        }
    }

    /// @inheritdoc IFarmingRange
    function removeLastRewardInfo(uint256 _campaignID) external virtual onlyOwner {
        RewardInfo[] storage rewardInfo = campaignRewardInfo[_campaignID];
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        uint256 _rewardInfoLength = rewardInfo.length;
        require(_rewardInfoLength != 0, "FarmingRange::updateCampaignsRewards::no rewardInfoLen");
        RewardInfo storage lastRewardInfo = rewardInfo[_rewardInfoLength - 1];
        uint256 _lastRewardInfoEndBlock = lastRewardInfo.endBlock;
        require(_lastRewardInfoEndBlock > block.number, "FarmingRange::removeLastRewardInfo::reward period ended");
        _updateCampaign(_campaignID);
        if (lastRewardInfo.rewardPerBlock != 0) {
            (bool _refund, uint256 _diff) = _updateRewardsDiff(
                _rewardInfoLength - 1,
                _lastRewardInfoEndBlock,
                0,
                rewardInfo,
                campaign,
                lastRewardInfo
            );
            if (_refund) {
                campaign.totalRewards = campaign.totalRewards - _diff;
            }
        }
        rewardInfo.pop();
        emit RemoveRewardInfo(_campaignID, _rewardInfoLength - 1);
    }

    /// @inheritdoc IFarmingRange
    function rewardInfoLen(uint256 _campaignID) external view returns (uint256) {
        return campaignRewardInfo[_campaignID].length;
    }

    /// @inheritdoc IFarmingRange
    function campaignInfoLen() external view returns (uint256) {
        return campaignInfo.length;
    }

    /// @inheritdoc IFarmingRange
    function currentEndBlock(uint256 _campaignID) external view virtual returns (uint256) {
        return _endBlockOf(_campaignID, block.number);
    }

    /// @inheritdoc IFarmingRange
    function currentRewardPerBlock(uint256 _campaignID) external view virtual returns (uint256) {
        return _rewardPerBlockOf(_campaignID, block.number);
    }

    /// @inheritdoc IFarmingRange
    function getMultiplier(uint256 _from, uint256 _to, uint256 _endBlock) public pure returns (uint256) {
        if ((_from >= _endBlock) || (_from > _to)) {
            return 0;
        }
        if (_to <= _endBlock) {
            return _to - _from;
        }
        return _endBlock - _from;
    }

    /// @inheritdoc IFarmingRange
    function pendingReward(uint256 _campaignID, address _user) external view returns (uint256) {
        return
            _pendingReward(_campaignID, userInfo[_campaignID][_user].amount, userInfo[_campaignID][_user].rewardDebt);
    }

    /// @inheritdoc IFarmingRange
    function updateCampaign(uint256 _campaignID) external nonReentrant {
        _updateCampaign(_campaignID);
    }

    /// @inheritdoc IFarmingRange
    function massUpdateCampaigns() external nonReentrant {
        uint256 _length = campaignInfo.length;
        for (uint256 _i; _i != _length; ) {
            _updateCampaign(_i);
            unchecked {
                ++_i;
            }
        }
    }

    /// @inheritdoc IFarmingRange
    function deposit(uint256 _campaignID, uint256 _amount) public nonReentrant {
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        UserInfo storage user = userInfo[_campaignID][msg.sender];
        _updateCampaign(_campaignID);
        if (user.amount != 0) {
            uint256 _pending = (user.amount * campaign.accRewardPerShare) / 1e20 - user.rewardDebt;
            if (_pending != 0) {
                campaign.rewardToken.safeTransfer(address(msg.sender), _pending);
            }
        }
        if (_amount != 0) {
            user.amount = user.amount + _amount;
            campaign.totalStaked = campaign.totalStaked + _amount;
            campaign.stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
        }
        user.rewardDebt = (user.amount * campaign.accRewardPerShare) / (1e20);
        emit Deposit(msg.sender, _amount, _campaignID);
    }

    /// @inheritdoc IFarmingRange
    function depositWithPermit(
        uint256 _campaignID,
        uint256 _amount,
        bool _approveMax,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external {
        SafeERC20.safePermit(
            IERC20Permit(address(campaignInfo[_campaignID].stakingToken)),
            msg.sender,
            address(this),
            _approveMax ? type(uint256).max : _amount,
            _deadline,
            _v,
            _r,
            _s
        );

        deposit(_campaignID, _amount);
    }

    /// @inheritdoc IFarmingRange
    function withdraw(uint256 _campaignID, uint256 _amount) external nonReentrant {
        _withdraw(_campaignID, _amount);
    }

    /// @inheritdoc IFarmingRange
    function harvest(uint256[] calldata _campaignIDs) external nonReentrant {
        for (uint256 _i; _i != _campaignIDs.length; ) {
            _withdraw(_campaignIDs[_i], 0);
            unchecked {
                ++_i;
            }
        }
    }

    /// @inheritdoc IFarmingRange
    function emergencyWithdraw(uint256 _campaignID) external nonReentrant {
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        UserInfo storage user = userInfo[_campaignID][msg.sender];
        uint256 _amount = user.amount;
        campaign.totalStaked = campaign.totalStaked - _amount;
        user.amount = 0;
        user.rewardDebt = 0;
        campaign.stakingToken.safeTransfer(msg.sender, _amount);
        emit EmergencyWithdraw(msg.sender, _amount, _campaignID);
    }

    /**
     * @notice function to trick the compilator to use safeTransferFrom in try catch
     * @param _token token to interact with
     * @param _from address who own token
     * @param _to address to transfer token
     * @param _amount quantity to be transferred
     */
    function attemptTransfer(IERC20 _token, address _from, address _to, uint256 _amount) external {
        require(msg.sender == address(this), "FarmingRange::attemptTransfer::Sender not farming"); // this function should be called only by this contract
        _token.safeTransferFrom(_from, _to, _amount);
    }

    /**
     * @notice return the endblock of the phase that contains _blockNumber
     * @param _campaignID the campaign id of the phases to check
     * @param _blockNumber the block number to check
     * @return the endblock of the phase that contains _blockNumber
     */
    function _endBlockOf(uint256 _campaignID, uint256 _blockNumber) internal view returns (uint256) {
        RewardInfo[] memory rewardInfo = campaignRewardInfo[_campaignID];
        uint256 _len = rewardInfo.length;
        if (_len == 0) {
            return 0;
        }
        for (uint256 _i; _i != _len; ) {
            if (_blockNumber <= rewardInfo[_i].endBlock) {
                return rewardInfo[_i].endBlock;
            }
            unchecked {
                ++_i;
            }
        }
        /// @dev when couldn't find any reward info, it means that _blockNumber exceed endblock
        /// so return the latest reward info.
        return rewardInfo[_len - 1].endBlock;
    }

    /**
     * @notice return the rewardPerBlock of the phase that contains _blockNumber
     * @param _campaignID the campaign id of the phases to check
     * @param _blockNumber the block number to check
     * @return the rewardPerBlock of the phase that contains _blockNumber
     */
    function _rewardPerBlockOf(uint256 _campaignID, uint256 _blockNumber) internal view returns (uint256) {
        RewardInfo[] memory rewardInfo = campaignRewardInfo[_campaignID];
        uint256 _len = rewardInfo.length;
        if (_len == 0) {
            return 0;
        }
        for (uint256 _i; _i != _len; ) {
            if (_blockNumber <= rewardInfo[_i].endBlock) {
                return rewardInfo[_i].rewardPerBlock;
            }
            unchecked {
                ++_i;
            }
        }
        /// @dev when couldn't find any reward info, it means that timestamp exceed endblock
        /// so return 0
        return 0;
    }

    /**
     * @notice in case of reward update, return reward diff and refund user if needed
     * @param _rewardIndex the number of the phase to update
     * @param _endBlock new endblock of the phase
     * @param _rewardPerBlock new rewardPerBlock of the phase
     * @param rewardInfo pointer on the array of rewardInfo in storage
     * @param campaign pointer on the campaign in storage
     * @param selectedRewardInfo pointer on the selectedRewardInfo in storage
     * @return refund_ boolean, true if user got refund
     * @return diff_ the reward difference
     */
    function _updateRewardsDiff(
        uint256 _rewardIndex,
        uint256 _endBlock,
        uint256 _rewardPerBlock,
        RewardInfo[] storage rewardInfo,
        CampaignInfo storage campaign,
        RewardInfo storage selectedRewardInfo
    ) internal virtual returns (bool refund_, uint256 diff_) {
        uint256 _previousStartBlock = _rewardIndex == 0 ? campaign.startBlock : rewardInfo[_rewardIndex - 1].endBlock;
        uint256 _newStartBlock = block.number > _previousStartBlock ? block.number : _previousStartBlock;
        uint256 _previousBlockRange = selectedRewardInfo.endBlock - _previousStartBlock;
        uint256 _newBlockRange = _endBlock - _newStartBlock;
        uint256 _selectedRewardPerBlock = selectedRewardInfo.rewardPerBlock;
        uint256 _accumulatedRewards = (_newStartBlock - _previousStartBlock) * _selectedRewardPerBlock;
        uint256 _previousTotalRewards = _selectedRewardPerBlock * _previousBlockRange;
        uint256 _totalRewards = _rewardPerBlock * _newBlockRange;
        refund_ = _previousTotalRewards > _totalRewards + _accumulatedRewards;
        diff_ = refund_
            ? _previousTotalRewards - _totalRewards - _accumulatedRewards
            : _totalRewards + _accumulatedRewards - _previousTotalRewards;
        if (refund_) {
            campaign.rewardToken.safeTransfer(rewardManager, diff_);
        }
    }

    /**
     * @notice transfer tokens from rewardManger to this contract.
     * @param _rewardToken to reward token to be transferred from the rewardManager to this contract
     * @param _amount qty to be transferred
     * @param _campaignID id of the campaign so the rewardManager can fetch the rewardToken address to transfer
     *
     * @dev in case of fail, not enough allowance is considered to be the reason, so we call resetAllowance(uint256) on
     * the reward manager (which will reset allowance to uint256.max) and we try again to transfer
     */
    function _transferFromWithAllowance(IERC20 _rewardToken, uint256 _amount, uint256 _campaignID) internal {
        try this.attemptTransfer(_rewardToken, rewardManager, address(this), _amount) {} catch {
            rewardManager.call(abi.encodeWithSignature("resetAllowance(uint256)", _campaignID));
            _rewardToken.safeTransferFrom(rewardManager, address(this), _amount);
        }
    }

    /**
     * @notice View function to retrieve pending Reward.
     * @param _campaignID pending reward of campaign id
     * @param _amount qty of staked token
     * @param _rewardDebt user info rewardDebt
     * @return pending rewards
     */
    function _pendingReward(
        uint256 _campaignID,
        uint256 _amount,
        uint256 _rewardDebt
    ) internal view virtual returns (uint256) {
        CampaignInfo memory _campaign = campaignInfo[_campaignID];
        RewardInfo[] memory _rewardInfo = campaignRewardInfo[_campaignID];
        uint256 _accRewardPerShare = _campaign.accRewardPerShare;

        if (block.number > _campaign.lastRewardBlock && _campaign.totalStaked != 0) {
            uint256 _cursor = _campaign.lastRewardBlock;
            for (uint256 _i; _i != _rewardInfo.length; ) {
                uint256 _multiplier = getMultiplier(_cursor, block.number, _rewardInfo[_i].endBlock);
                if (_multiplier != 0) {
                    _cursor = _rewardInfo[_i].endBlock;
                    _accRewardPerShare =
                        _accRewardPerShare +
                        ((_multiplier * _rewardInfo[_i].rewardPerBlock * 1e20) / _campaign.totalStaked);
                }
                unchecked {
                    ++_i;
                }
            }
        }
        return ((_amount * _accRewardPerShare) / 1e20) - _rewardDebt;
    }

    /**
     * @notice Update reward variables of the given campaign to be up-to-date.
     *         NOTE: All rewards relating to periods devoid of any depositors are sent back to the reward manager.
     * @param _campaignID campaign id
     */
    function _updateCampaign(uint256 _campaignID) internal virtual {
        require(campaignInfo.length > _campaignID, "FarmingRange::_updateCampaign::Campaign id not valid");
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        RewardInfo[] memory _rewardInfo = campaignRewardInfo[_campaignID];
        if (block.number <= campaign.lastRewardBlock) {
            return;
        }
        if (campaign.totalStaked == 0) {
            uint256 _amount;
            for (uint256 _i; _i != _rewardInfo.length; ) {
                if (_rewardInfo[_i].endBlock >= campaign.lastRewardBlock) {
                    uint256 _startBlock = _i != 0 ? _rewardInfo[_i - 1].endBlock : campaign.lastRewardBlock;
                    bool _lastRewardInfo = _rewardInfo[_i].endBlock > block.number;
                    uint256 _blockRange = (_lastRewardInfo ? block.number : _rewardInfo[_i].endBlock) -
                        (_startBlock > campaign.lastRewardBlock ? _startBlock : campaign.lastRewardBlock);
                    _amount += _rewardInfo[_i].rewardPerBlock * _blockRange;
                    if (_lastRewardInfo) {
                        break;
                    }
                }
                unchecked {
                    ++_i;
                }
            }

            if (_amount != 0) {
                campaign.rewardToken.safeTransfer(rewardManager, _amount);
            }

            campaign.lastRewardBlock = block.number;

            return;
        }
        /// @dev for each reward info
        for (uint256 _i; _i != _rewardInfo.length; ) {
            // @dev get multiplier based on current Block and rewardInfo's end block
            // multiplier will be a range of either (current block - campaign.lastRewardBlock)
            // or (reward info's endblock - campaign.lastRewardBlock) or 0
            uint256 _multiplier = getMultiplier(campaign.lastRewardBlock, block.number, _rewardInfo[_i].endBlock);
            if (_multiplier != 0) {
                // @dev if currentBlock exceed end block, use end block as the last reward block
                // so that for the next iteration, previous endBlock will be used as the last reward block
                if (block.number > _rewardInfo[_i].endBlock) {
                    campaign.lastRewardBlock = _rewardInfo[_i].endBlock;
                } else {
                    campaign.lastRewardBlock = block.number;
                }
                campaign.accRewardPerShare =
                    campaign.accRewardPerShare +
                    ((_multiplier * _rewardInfo[_i].rewardPerBlock * 1e20) / campaign.totalStaked);
            }
            unchecked {
                ++_i;
            }
        }
    }

    /**
     * @notice Withdraw staking token in a campaign. Also withdraw the current pending reward
     * @param _campaignID campaign id
     * @param _amount amount to withdraw
     */
    function _withdraw(uint256 _campaignID, uint256 _amount) internal {
        CampaignInfo storage campaign = campaignInfo[_campaignID];
        UserInfo storage user = userInfo[_campaignID][msg.sender];
        require(user.amount >= _amount, "FarmingRange::withdraw::bad withdraw amount");
        _updateCampaign(_campaignID);
        uint256 _pending = (user.amount * campaign.accRewardPerShare) / 1e20 - user.rewardDebt;
        if (_pending != 0) {
            campaign.rewardToken.safeTransfer(msg.sender, _pending);
        }
        if (_amount != 0) {
            user.amount = user.amount - _amount;
            campaign.totalStaked = campaign.totalStaked - _amount;
            campaign.stakingToken.safeTransfer(msg.sender, _amount);
        }
        user.rewardDebt = (user.amount * campaign.accRewardPerShare) / 1e20;

        emit Withdraw(msg.sender, _amount, _campaignID);
    }
}

File 2 of 11 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 4 of 11 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _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;
    }
}

File 5 of 11 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

// EIP-2612 is Final as of 2022-11-01. This file is deprecated.

import "./IERC20Permit.sol";

File 6 of 11 : IERC20Permit.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 IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

File 7 of 11 : IERC20.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 IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    /**
     * @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(IERC20 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(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @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(IERC20 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(IERC20 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. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    function forceApprove(IERC20 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(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        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(IERC20 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))) && Address.isContract(address(token));
    }
}

File 9 of 11 : Address.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 Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * 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 11 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 11 of 11 : IFarmingRange.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

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

interface IFarmingRange {
    /**
     * @notice Info of each user.
     * @param amount How many Staking tokens the user has provided.
     * @param rewardDebt We do some fancy math here. Basically, any point in time, the amount of reward
     *  entitled to a user but is pending to be distributed is:
     *
     *    pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
     *
     *  Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
     *    1. The pool's `accRewardPerShare` (and `lastRewardBlock`) gets updated.
     *    2. User receives the pending reward sent to his/her address.
     *    3. User's `amount` gets updated.
     *    4. User's `rewardDebt` gets updated.
     *
     * from: https://github.com/jazz-defi/contracts/blob/master/MasterChefV2.sol
     */
    struct UserInfo {
        uint256 amount;
        uint256 rewardDebt;
    }

    /**
     * @notice Info of each reward distribution campaign.
     * @param stakingToken address of Staking token contract.
     * @param rewardToken address of Reward token contract
     * @param startBlock start block of the campaign
     * @param lastRewardBlock last block number that Reward Token distribution occurs.
     * @param accRewardPerShare accumulated Reward Token per share, times 1e20.
     * @param totalStaked total staked amount each campaign's stake token, typically,
     * @param totalRewards total amount of reward to be distributed until the end of the last phase
     *
     * @dev each campaign has the same stake token, so no need to track it separetely
     */
    struct CampaignInfo {
        IERC20 stakingToken;
        IERC20 rewardToken;
        uint256 startBlock;
        uint256 lastRewardBlock;
        uint256 accRewardPerShare;
        uint256 totalStaked;
        uint256 totalRewards;
    }

    /**
     * @notice Info about a reward-phase
     * @param endBlock block number of the end of the phase
     * @param rewardPerBlock amount of reward to be distributed per block in this phase
     */
    struct RewardInfo {
        uint256 endBlock;
        uint256 rewardPerBlock;
    }

    /**
     * @notice emitted at each deposit
     * @param user address that deposit its funds
     * @param amount amount deposited
     * @param campaign campaingId on which the user has deposited funds
     */
    event Deposit(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each withdraw
     * @param user address that withdrawn its funds
     * @param amount amount withdrawn
     * @param campaign campaingId on which the user has withdrawn funds
     */
    event Withdraw(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each emergency withdraw
     * @param user address that emergency-withdrawn its funds
     * @param amount amount emergency-withdrawn
     * @param campaign campaingId on which the user has emergency-withdrawn funds
     */
    event EmergencyWithdraw(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each campaign added
     * @param campaignID new campaign id
     * @param stakingToken token address to be staked in this campaign
     * @param rewardToken token address of the rewards in this campaign
     * @param startBlock starting block of this campaign
     */
    event AddCampaignInfo(uint256 indexed campaignID, IERC20 stakingToken, IERC20 rewardToken, uint256 startBlock);

    /**
     * @notice emitted at each phase of reward added
     * @param campaignID campaign id on which rewards were added
     * @param phase number of the new phase added (latest at the moment of add)
     * @param endBlock number of the block that the phase stops (phase starts at the endblock of the previous phase's
     * endblock, and if it's the phase 0, it start at the startBlock of the campaign struct)
     * @param rewardPerBlock amount of reward distributed per block in this phase
     */
    event AddRewardInfo(uint256 indexed campaignID, uint256 indexed phase, uint256 endBlock, uint256 rewardPerBlock);

    /**
     * @notice emitted when a reward phase is updated
     * @param campaignID campaign id on which the rewards-phase is updated
     * @param phase id of phase updated
     * @param endBlock new endblock of the phase
     * @param rewardPerBlock new rewardPerBlock of the phase
     */
    event UpdateRewardInfo(uint256 indexed campaignID, uint256 indexed phase, uint256 endBlock, uint256 rewardPerBlock);

    /**
     * @notice emitted when a reward phase is removed
     * @param campaignID campaign id on which the rewards-phase is removed
     * @param phase id of phase removed (only the latest phase can be removed)
     */
    event RemoveRewardInfo(uint256 indexed campaignID, uint256 indexed phase);

    /**
     * @notice emitted when the rewardInfoLimit is updated
     * @param rewardInfoLimit new max phase amount per campaign
     */
    event SetRewardInfoLimit(uint256 rewardInfoLimit);

    /**
     * @notice set new reward info limit, defining how many phases are allowed
     * @param _updatedRewardInfoLimit new reward info limit
     */
    function setRewardInfoLimit(uint256 _updatedRewardInfoLimit) external;

    /**
     * @notice reward campaign, one campaign represent a pair of staking and reward token,
     * last reward Block and acc reward Per Share
     * @param _stakingToken staking token address
     * @param _rewardToken reward token address
     * @param _startBlock block number when the campaign will start
     */
    function addCampaignInfo(IERC20 _stakingToken, IERC20 _rewardToken, uint256 _startBlock) external;

    /**
     * @notice add a new reward info, when a new reward info is added, the reward
     * & its end block will be extended by the newly pushed reward info.
     * @param _campaignID id of the campaign
     * @param _endBlock end block of this reward info
     * @param _rewardPerBlock reward per block to distribute until the end
     */
    function addRewardInfo(uint256 _campaignID, uint256 _endBlock, uint256 _rewardPerBlock) external;

    /**
     * @notice add multiple reward Info into a campaign in one tx.
     * @param _campaignID id of the campaign
     * @param _endBlock array of end blocks
     * @param _rewardPerBlock array of reward per block
     */
    function addRewardInfoMultiple(
        uint256 _campaignID,
        uint256[] calldata _endBlock,
        uint256[] calldata _rewardPerBlock
    ) external;

    /**
     * @notice update one campaign reward info for a specified range index.
     * @param _campaignID id of the campaign
     * @param _rewardIndex index of the reward info
     * @param _endBlock end block of this reward info
     * @param _rewardPerBlock reward per block to distribute until the end
     */
    function updateRewardInfo(
        uint256 _campaignID,
        uint256 _rewardIndex,
        uint256 _endBlock,
        uint256 _rewardPerBlock
    ) external;

    /**
     * @notice update multiple campaign rewards info for all range index.
     * @param _campaignID id of the campaign
     * @param _rewardIndex array of reward info index
     * @param _endBlock array of end block
     * @param _rewardPerBlock array of rewardPerBlock
     */
    function updateRewardMultiple(
        uint256 _campaignID,
        uint256[] memory _rewardIndex,
        uint256[] memory _endBlock,
        uint256[] memory _rewardPerBlock
    ) external;

    /**
     * @notice update multiple campaigns and rewards info for all range index.
     * @param _campaignID array of campaign id
     * @param _rewardIndex multi dimensional array of reward info index
     * @param _endBlock multi dimensional array of end block
     * @param _rewardPerBlock multi dimensional array of rewardPerBlock
     */
    function updateCampaignsRewards(
        uint256[] calldata _campaignID,
        uint256[][] calldata _rewardIndex,
        uint256[][] calldata _endBlock,
        uint256[][] calldata _rewardPerBlock
    ) external;

    /**
     * @notice remove last reward info for specified campaign.
     * @param _campaignID campaign id
     */
    function removeLastRewardInfo(uint256 _campaignID) external;

    /**
     * @notice return the entries amount of reward info for one campaign.
     * @param _campaignID campaign id
     * @return reward info quantity
     */
    function rewardInfoLen(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice return the number of campaigns.
     * @return campaign quantity
     */
    function campaignInfoLen() external view returns (uint256);

    /**
     * @notice return the end block of the current reward info for a given campaign.
     * @param _campaignID campaign id
     * @return reward info end block number
     */
    function currentEndBlock(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice return the reward per block of the current reward info for a given campaign.
     * @param _campaignID campaign id
     * @return current reward per block
     */
    function currentRewardPerBlock(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice Return reward multiplier over the given _from to _to block.
     * Reward multiplier is the amount of blocks between from and to
     * @param _from start block number
     * @param _to end block number
     * @param _endBlock end block number of the reward info
     * @return block distance
     */
    function getMultiplier(uint256 _from, uint256 _to, uint256 _endBlock) external returns (uint256);

    /**
     * @notice View function to retrieve pending Reward.
     * @param _campaignID pending reward of campaign id
     * @param _user address to retrieve pending reward
     * @return current pending reward
     */
    function pendingReward(uint256 _campaignID, address _user) external view returns (uint256);

    /**
     * @notice Update reward variables of the given campaign to be up-to-date.
     * @param _campaignID campaign id
     */
    function updateCampaign(uint256 _campaignID) external;

    /**
     * @notice Update reward variables for all campaigns. gas spending is HIGH in this method call, BE CAREFUL.
     */
    function massUpdateCampaigns() external;

    /**
     * @notice Deposit staking token in a campaign.
     * @param _campaignID campaign id
     * @param _amount amount to deposit
     */
    function deposit(uint256 _campaignID, uint256 _amount) external;

    /**
     * @notice Deposit staking token in a campaign with the EIP-2612 signature off chain
     * @param _campaignID campaign id
     * @param _amount amount to deposit
     * @param _approveMax Whether or not the approval amount in the signature is for liquidity or uint(-1).
     * @param _deadline Unix timestamp after which the transaction will revert.
     * @param _v The v component of the permit signature.
     * @param _r The r component of the permit signature.
     * @param _s The s component of the permit signature.
     */
    function depositWithPermit(
        uint256 _campaignID,
        uint256 _amount,
        bool _approveMax,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external;

    /**
     * @notice Withdraw staking token in a campaign. Also withdraw the current pending reward
     * @param _campaignID campaign id
     * @param _amount amount to withdraw
     */
    function withdraw(uint256 _campaignID, uint256 _amount) external;

    /**
     * @notice Harvest campaigns, will claim rewards token of every campaign ids in the array
     * @param _campaignIDs array of campaign id
     */
    function harvest(uint256[] calldata _campaignIDs) external;

    /**
     * @notice Withdraw without caring about rewards. EMERGENCY ONLY.
     * @param _campaignID campaign id
     */
    function emergencyWithdraw(uint256 _campaignID) external;

    /**
     * @notice get Reward info for a campaign ID and index, that is a set of {endBlock, rewardPerBlock}
     *  indexed by campaign ID
     * @param _campaignID campaign id
     * @param _rewardIndex index of the reward info
     * @return endBlock_ end block of this reward info
     * @return rewardPerBlock_ reward per block to distribute
     */
    function campaignRewardInfo(
        uint256 _campaignID,
        uint256 _rewardIndex
    ) external view returns (uint256 endBlock_, uint256 rewardPerBlock_);

    /**
     * @notice get a Campaign Reward info for a campaign ID
     * @param _campaignID campaign id
     * @return all params from CampaignInfo struct
     */
    function campaignInfo(
        uint256 _campaignID
    ) external view returns (IERC20, IERC20, uint256, uint256, uint256, uint256, uint256);

    /**
     * @notice get a User Reward info for a campaign ID and user address
     * @param _campaignID campaign id
     * @param _user user address
     * @return all params from UserInfo struct
     */
    function userInfo(uint256 _campaignID, address _user) external view returns (uint256, uint256);

    /**
     * @notice how many reward phases can be set for a campaign
     * @return rewards phases size limit
     */
    function rewardInfoLimit() external view returns (uint256);

    /**
     * @notice get reward Manager address holding rewards to distribute
     * @return address of reward manager
     */
    function rewardManager() external view returns (address);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_rewardManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignID","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"stakingToken","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"}],"name":"AddCampaignInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignID","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"phase","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"name":"AddRewardInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"campaign","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"campaign","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignID","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"phase","type":"uint256"}],"name":"RemoveRewardInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rewardInfoLimit","type":"uint256"}],"name":"SetRewardInfoLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignID","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"phase","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"name":"UpdateRewardInfo","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"campaign","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"_stakingToken","type":"address"},{"internalType":"contract IERC20","name":"_rewardToken","type":"address"},{"internalType":"uint256","name":"_startBlock","type":"uint256"}],"name":"addCampaignInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"uint256","name":"_rewardPerBlock","type":"uint256"}],"name":"addRewardInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256[]","name":"_endBlock","type":"uint256[]"},{"internalType":"uint256[]","name":"_rewardPerBlock","type":"uint256[]"}],"name":"addRewardInfoMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"attemptTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"campaignInfo","outputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"},{"internalType":"contract IERC20","name":"rewardToken","type":"address"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"lastRewardBlock","type":"uint256"},{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint256","name":"totalStaked","type":"uint256"},{"internalType":"uint256","name":"totalRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"campaignInfoLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"campaignRewardInfo","outputs":[{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"uint256","name":"rewardPerBlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"currentEndBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"currentRewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_approveMax","type":"bool"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"depositWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_to","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"}],"name":"getMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_campaignIDs","type":"uint256[]"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"massUpdateCampaigns","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"removeLastRewardInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"rewardInfoLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardInfoLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_updatedRewardInfoLimit","type":"uint256"}],"name":"setRewardInfoLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"}],"name":"updateCampaign","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_campaignID","type":"uint256[]"},{"internalType":"uint256[][]","name":"_rewardIndex","type":"uint256[][]"},{"internalType":"uint256[][]","name":"_endBlock","type":"uint256[][]"},{"internalType":"uint256[][]","name":"_rewardPerBlock","type":"uint256[][]"}],"name":"updateCampaignsRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256","name":"_rewardIndex","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"uint256","name":"_rewardPerBlock","type":"uint256"}],"name":"updateRewardInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256[]","name":"_rewardIndex","type":"uint256[]"},{"internalType":"uint256[]","name":"_endBlock","type":"uint256[]"},{"internalType":"uint256[]","name":"_rewardPerBlock","type":"uint256[]"}],"name":"updateRewardMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_campaignID","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b50604051620033e0380380620033e083398101604081905262000034916200012b565b6200003f33620000db565b6001805560346005556001600160a01b038116620000c95760405162461bcd60e51b815260206004820152603860248201527f4661726d696e6752616e67653a3a636f6e7374727563746f723a3a526577617260448201527f64206d616e61676572206973206e6f7420646566696e65640000000000000000606482015260840160405180910390fd5b6001600160a01b03166080526200015d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156200013e57600080fd5b81516001600160a01b03811681146200015657600080fd5b9392505050565b60805161323d620001a3600039600081816101ff0152818161151201528181611b3701528181611ba601528181611c6b0152818161230c015261254e015261323d6000f3fe608060405234801561001057600080fd5b50600436106101d95760003560e01c8063715018a6116101045780639a63bc16116100a2578063e2bbb15811610071578063e2bbb1581461046c578063eebdced51461047f578063f2fde38b14610487578063fa8f5f191461049a57600080fd5b80639a63bc16146103e0578063bb2238ec146103f3578063cdc8c93014610446578063cef7042d1461045957600080fd5b80638d48aff0116100de5780638d48aff0146103775780638da5cb5b1461038a57806393f1a40b1461039b57806398969e82146103cd57600080fd5b8063715018a6146103495780637bafb0291461035157806380637e891461036457600080fd5b80633bbda19b1161017c5780634ad7ce801161014b5780634ad7ce80146102fb5780634ae56bae146103035780635312ea8e146103235780635d14b06f1461033657600080fd5b80633bbda19b146102af578063409e00fc146102c257806342ee0aba146102d5578063441a3e70146102e857600080fd5b80631693074b116101b85780631693074b146102615780632ea807c51461027657806330d78fda1461028957806333824b871461029c57600080fd5b8062d74850146101de5780630f4ef8a6146101fa57806310f7a6af14610239575b600080fd5b6101e760055481565b6040519081526020015b60405180910390f35b6102217f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101f1565b61024c610247366004612b8f565b6104ad565b604080519283526020830191909152016101f1565b61027461026f366004612bc6565b6104e9565b005b610274610284366004612c17565b610572565b610274610297366004612c51565b6108ab565b6102746102aa366004612cbf565b610908565b6102746102bd366004612d24565b61094b565b6102746102d0366004612d9e565b610a1d565b6102746102e3366004612e85565b610c88565b6102746102f6366004612b8f565b610d85565b6003546101e7565b6101e7610311366004612cbf565b60009081526002602052604090205490565b610274610331366004612cbf565b610da4565b610274610344366004612f17565b610e6c565b610274610eb3565b6101e761035f366004612c17565b610ec7565b610274610372366004612cbf565b610f10565b6101e7610385366004612cbf565b611129565b6000546001600160a01b0316610221565b61024c6103a9366004612f59565b60046020908152600092835260408084209091529082529020805460019091015482565b6101e76103db366004612f59565b61113b565b6101e76103ee366004612cbf565b611170565b610406610401366004612cbf565b61117c565b604080516001600160a01b039889168152979096166020880152948601939093526060850191909152608084015260a083015260c082015260e0016101f1565b610274610454366004612f89565b6111d8565b610274610467366004612cbf565b611600565b61027461047a366004612b8f565b61161a565b61027461177c565b610274610495366004612fbb565b6117ad565b6102746104a8366004612fd8565b611823565b600260205281600052604060002081815481106104c957600080fd5b600091825260209091206002909102018054600190910154909250905082565b3330146105575760405162461bcd60e51b815260206004820152603160248201527f4661726d696e6752616e67653a3a617474656d70745472616e736665723a3a53604482015270656e646572206e6f74206661726d696e6760781b60648201526084015b60405180910390fd5b61056c6001600160a01b0385168484846119fa565b50505050565b61057a611a65565b610582611abf565b600083815260026020526040812060038054919291869081106105a7576105a761309c565b9060005260206000209060070201905060055482805490501061063c5760405162461bcd60e51b815260206004820152604160248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a72657760448201527f61726420696e666f206c656e677468206578636565647320746865206c696d696064820152601d60fa1b608482015260a40161054e565b8154158061067c5750815443908390610657906001906130c8565b815481106106675761066761309c565b90600052602060002090600202016000015410155b6106e15760405162461bcd60e51b815260206004820152603060248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a72657760448201526f185c99081c195c9a5bd908195b99195960821b606482015260840161054e565b8154158061072057508154849083906106fc906001906130c8565b8154811061070c5761070c61309c565b906000526020600020906002020160000154105b6107825760405162461bcd60e51b815260206004820152602d60248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a62616460448201526c206e657720656e64626c6f636b60981b606482015260840161054e565b8154600090156107c3578254839061079c906001906130c8565b815481106107ac576107ac61309c565b9060005260206000209060020201600001546107c9565b81600201545b905060006107d782876130c8565b905060006107e582876130db565b90508084600601546107f791906130f2565b6006850155604080518082019091528781526020808201888152875460018181018a5560008a81529390932093516002909102909301928355519181019190915584015461084f906001600160a01b0316828a611b18565b845461085d906001906130c8565b60408051898152602081018990528a917fad90731bd0d97445f5af66088f3adebf343c520c20e033cc42f93b124258cdc2910160405180910390a350505050506108a660018055565b505050565b6108f5600388815481106108c1576108c161309c565b60009182526020909120600790910201546001600160a01b03163330886108e857896108ec565b6000195b88888888611c91565b6108ff878761161a565b50505050505050565b610910611a65565b60058190556040518181527fb64f58843e750a8bea7135ef396cf0a7790bfc9a8f43f11ac0e0aacc1b5787ba9060200160405180910390a150565b610953611a65565b8281146109c85760405162461bcd60e51b815260206004820152603860248201527f4661726d696e6752616e67653a3a6164645265776172644d756c7469706c653a60448201527f3a77726f6e6720706172616d6574657273206c656e6774680000000000000000606482015260840161054e565b60005b808414610a1557610a0d868686848181106109e8576109e861309c565b90506020020135858585818110610a0157610a0161309c565b90506020020135610572565b6001016109cb565b505050505050565b610a25611a65565b438111610aa55760405162461bcd60e51b815260206004820152604260248201527f4661726d696e6752616e67653a3a61646443616d706169676e496e666f3a3a5360448201527f7461727420626c6f636b2073686f756c6420626520696e207468652066757475606482015261726560f01b608482015260a40161054e565b6040805160e0810182526001600160a01b038086168252848116602083019081529282018481526060830185815260006080850181815260a0860182815260c08701838152600380546001818101835595829052985160079099027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180549a8a166001600160a01b03199b8c1617905599517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c8b0180549190991699169890981790965593517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d88015591517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85e87015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85f86015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f86085015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f8619093019290925554610c3891906130c8565b604080516001600160a01b038087168252851660208201529081018390527f9b2f18f9a188a5aec4a95ee3164fe234dfbb6117628b2ad1a581939e61c69f4e9060600160405180910390a2505050565b610c90611a65565b81518351148015610ca2575080518351145b610d145760405162461bcd60e51b815260206004820152603b60248201527f4661726d696e6752616e67653a3a7570646174655265776172644d756c74697060448201527f6c653a3a77726f6e6720706172616d6574657273206c656e6774680000000000606482015260840161054e565b60005b83518114610d7e57610d7685858381518110610d3557610d3561309c565b6020026020010151858481518110610d4f57610d4f61309c565b6020026020010151858581518110610d6957610d6961309c565b60200260200101516111d8565b600101610d17565b5050505050565b610d8d611abf565b610d978282611e67565b610da060018055565b5050565b610dac611abf565b600060038281548110610dc157610dc161309c565b60009182526020808320858452600482526040808520338652909252922080546007929092029092016005810154909350610dfd9082906130c8565b6005840155600080835560018301558254610e22906001600160a01b03163383612018565b604080518281526020810186905233917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595910160405180910390a2505050610e6960018055565b50565b610e74611abf565b60005b808214610ea957610ea1838383818110610e9357610e9361309c565b905060200201356000611e67565b600101610e77565b50610da060018055565b610ebb611a65565b610ec56000612048565b565b60008184101580610ed757508284115b15610ee457506000610f09565b818311610efc57610ef584846130c8565b9050610f09565b610f0684836130c8565b90505b9392505050565b610f18611a65565b60008181526002602052604081206003805491929184908110610f3d57610f3d61309c565b6000918252602082208454600790920201925090819003610fbf5760405162461bcd60e51b815260206004820152603660248201527f4661726d696e6752616e67653a3a75706461746543616d706169676e7352657760448201527530b932399d1d3737903932bbb0b93224b73337a632b760511b606482015260840161054e565b600083610fcd6001846130c8565b81548110610fdd57610fdd61309c565b6000918252602090912060029091020180549091504381116110675760405162461bcd60e51b815260206004820152603760248201527f4661726d696e6752616e67653a3a72656d6f76654c617374526577617264496e60448201527f666f3a3a72657761726420706572696f6420656e646564000000000000000000606482015260840161054e565b61107086612098565b6001820154156110b95760008061109661108b6001876130c8565b8460008a8a8961243b565b9150915081156110b6578086600601546110b091906130c8565b60068701555b50505b848054806110c9576110c9613105565b60008281526020812060026000199093019283020181815560019081019190915591556110f690846130c8565b60405187907f997b6670781194c0d30c477be41ce4ba9b7f3f12417aa00965b9d9f978251e2390600090a3505050505050565b60006111358243612586565b92915050565b60008281526004602090815260408083206001600160a01b038516845290915281208054600190910154610f0991859161267c565b60006111358243612878565b6003818154811061118c57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919087565b6111e0611a65565b6111e8611abf565b6000848152600260205260408120600380549192918790811061120d5761120d61309c565b9060005260206000209060070201905060008286815481106112315761123161309c565b60009182526020909120600290910201805490915061124f88612098565b438110156112bb5760405162461bcd60e51b815260206004820152603360248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a6044820152721c995dd85c99081c195c9a5bd908195b991959606a1b606482015260840161054e565b86156113565785846112ce60018a6130c8565b815481106112de576112de61309c565b906000526020600020906002020160000154106113565760405162461bcd60e51b815260206004820152603060248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a60448201526f626164206e657720656e64626c6f636b60801b606482015260840161054e565b6113618760016130f2565b8454111561141657836113758860016130f2565b815481106113855761138561309c565b90600052602060002090600202016000015486106114165760405162461bcd60e51b815260206004820152604260248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a60448201527f72657761726420706572696f6420656e6420697320696e206e6578742072616e606482015261676560f01b608482015260a40161054e565b60008061142789898989898961243b565b915091508115801561143857508015155b15611456576001850154611456906001600160a01b0316828c611b18565b828814158015611473575085548990611471906001906130c8565b115b1561157b576000866114868b60016130f2565b815481106114965761149661309c565b6000918252602082206002909102018054909250906114b586836130c8565b905060006114c38c846130c8565b600185015490915060006114d782856130db565b9050826114e485846130db565b6114ee919061311b565b915060006114fc83856130db565b60018801849055905081811015611573576115507f000000000000000000000000000000000000000000000000000000000000000061153b83856130c8565b60018f01546001600160a01b03169190612018565b61155a81836130c8565b8c600601600082825461156d91906130c8565b90915550505b505050505050505b816115955780856006015461159091906130f2565b6115a5565b8085600601546115a591906130c8565b60068601558784556001840187905560408051898152602081018990528a918c917fcd251e3ce758f4da844a7b790619743994a9ce956a4abb78aec611623ae8af5f910160405180910390a350505050505061056c60018055565b611608611abf565b61161181612098565b610e6960018055565b611622611abf565b6000600383815481106116375761163761309c565b6000918252602080832086845260048252604080852033865290925292206007909102909101915061166884612098565b8054156116cb576000816001015468056bc75e2d631000008460040154846000015461169491906130db565b61169e919061311b565b6116a891906130c8565b905080156116c95760018301546116c9906001600160a01b03163383612018565b505b821561170c5780546116de9084906130f2565b815560058201546116f09084906130f2565b6005830155815461170c906001600160a01b03163330866119fa565b6004820154815468056bc75e2d6310000091611727916130db565b611731919061311b565b6001820155604080518481526020810186905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a25050610da060018055565b611784611abf565b60035460005b8181146117a25761179a81612098565b60010161178a565b5050610ec560018055565b6117b5611a65565b6001600160a01b03811661181a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054e565b610e6981612048565b61182b611a65565b868514801561183957508483145b801561184457508481145b6118b65760405162461bcd60e51b815260206004820152603d60248201527f4661726d696e6752616e67653a3a75706461746543616d706169676e7352657760448201527f617264733a3a77726f6e6720726577617264496e666f206c656e677468000000606482015260840161054e565b60005b8088146119ef576119e78989838181106118d5576118d561309c565b905060200201358888848181106118ee576118ee61309c565b9050602002810190611900919061313d565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a92508991508690508181106119465761194661309c565b9050602002810190611958919061313d565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525089925088915087905081811061199e5761199e61309c565b90506020028101906119b0919061313d565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250610c8892505050565b6001016118b9565b505050505050505050565b6040516001600160a01b038085166024830152831660448201526064810182905261056c9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612995565b6000546001600160a01b03163314610ec55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054e565b600260015403611b115760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161054e565b6002600155565b604051631693074b60e01b81526001600160a01b0380851660048301527f000000000000000000000000000000000000000000000000000000000000000016602482015230604482018190526064820184905290631693074b90608401600060405180830381600087803b158015611b8f57600080fd5b505af1925050508015611ba0575060015b6108a6577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681604051602401611be191815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663eee4f11b60e01b17905251611c1691906131ab565b6000604051808303816000865af19150503d8060008114611c53576040519150601f19603f3d011682016040523d82523d6000602084013e611c58565b606091505b506108a69150506001600160a01b0384167f000000000000000000000000000000000000000000000000000000000000000030856119fa565b604051623f675f60e91b81526001600160a01b038881166004830152600091908a1690637ecebe0090602401602060405180830381865afa158015611cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfe91906131c7565b60405163d505accf60e01b81526001600160a01b038a811660048301528981166024830152604482018990526064820188905260ff8716608483015260a4820186905260c48201859052919250908a169063d505accf9060e401600060405180830381600087803b158015611d7257600080fd5b505af1158015611d86573d6000803e3d6000fd5b5050604051623f675f60e91b81526001600160a01b038b81166004830152600093508c169150637ecebe0090602401602060405180830381865afa158015611dd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df691906131c7565b9050611e038260016130f2565b8114611e5b5760405162461bcd60e51b815260206004820152602160248201527f5361666545524332303a207065726d697420646964206e6f74207375636365656044820152601960fa1b606482015260840161054e565b50505050505050505050565b600060038381548110611e7c57611e7c61309c565b600091825260208083208684526004825260408085203386529092529220805460079092029092019250831115611f095760405162461bcd60e51b815260206004820152602b60248201527f4661726d696e6752616e67653a3a77697468647261773a3a626164207769746860448201526a191c985dc8185b5bdd5b9d60aa1b606482015260840161054e565b611f1284612098565b6000816001015468056bc75e2d6310000084600401548460000154611f3791906130db565b611f41919061311b565b611f4b91906130c8565b90508015611f6c576001830154611f6c906001600160a01b03163383612018565b8315611fac578154611f7f9085906130c8565b82556005830154611f919085906130c8565b60058401558254611fac906001600160a01b03163386612018565b6004830154825468056bc75e2d6310000091611fc7916130db565b611fd1919061311b565b6001830155604080518581526020810187905233917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a25050505050565b6040516001600160a01b0383166024820152604481018290526108a690849063a9059cbb60e01b90606401611a2e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60035481106121065760405162461bcd60e51b815260206004820152603460248201527f4661726d696e6752616e67653a3a5f75706461746543616d706169676e3a3a43604482015273185b5c185a59db881a59081b9bdd081d985b1a5960621b606482015260840161054e565b60006003828154811061211b5761211b61309c565b60009182526020808320858452600282526040808520805482518186028101860190935280835260079095029092019550929091849084015b8282101561219a57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190612154565b505050509050816003015443116121b057505050565b816005015460000361233d576000805b825181146122f15783600301548382815181106121df576121df61309c565b602002602001015160000151106122e95760008160000361220457846003015461222d565b836122106001846130c8565b815181106122205761222061309c565b6020026020010151600001515b90506000438584815181106122445761224461309c565b60200260200101516000015111905060008660030154831161226a57866003015461226c565b825b82612294578685815181106122835761228361309c565b602002602001015160000151612296565b435b6122a091906130c8565b9050808685815181106122b5576122b561309c565b6020026020010151602001516122cb91906130db565b6122d590866130f2565b945081156122e5575050506122f1565b5050505b6001016121c0565b508015612331576001830154612331906001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000083612018565b50504360039091015550565b60005b8151811461056c5760006123768460030154438585815181106123655761236561309c565b602002602001015160000151610ec7565b90508015612432578282815181106123905761239061309c565b6020026020010151600001514311156123cb578282815181106123b5576123b561309c565b60209081029190910101515160038501556123d2565b4360038501555b83600501548383815181106123e9576123e961309c565b6020026020010151602001518261240091906130db565b6124139068056bc75e2d631000006130db565b61241d919061311b565b846004015461242c91906130f2565b60048501555b50600101612340565b600080808815612478578561245160018b6130c8565b815481106124615761246161309c565b90600052602060002090600202016000015461247e565b84600201545b9050600081431161248f5781612491565b435b905060008286600001546124a591906130c8565b905060006124b3838c6130c8565b60018801549091506000816124c887876130c8565b6124d291906130db565b905060006124e085846130db565b905060006124ee858f6130db565b90506124fa83826130f2565b821199508961251d578161250e84836130f2565b61251891906130c8565b612532565b8261252882846130c8565b61253291906130c8565b985089156125735760018c0154612573906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008b612018565b5050505050505050965096945050505050565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b828210156125f5578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906125af565b505082519293505050600081900361261257600092505050611135565b60005b8181146126705782818151811061262e5761262e61309c565b6020026020010151600001518511612668578281815181106126525761265261309c565b6020026020010151602001519350505050611135565b600101612615565b50600095945050505050565b600080600385815481106126925761269261309c565b600091825260208083206040805160e081018252600790940290910180546001600160a01b03908116855260018201541684840152600280820154858401526003820154606086015260048201546080860152600582015460a086015260069091015460c08501528985528252808420805482518185028101850190935280835293955090929091849084015b828210156127655783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061271f565b50505050905060008260800151905082606001514311801561278a575060a083015115155b1561284457606083015160005b835181146128415760006127b883438785815181106123655761236561309c565b90508015612838578482815181106127d2576127d261309c565b60200260200101516000015192508560a001518583815181106127f7576127f761309c565b6020026020010151602001518261280e91906130db565b6128219068056bc75e2d631000006130db565b61282b919061311b565b61283590856130f2565b93505b50600101612797565b50505b8468056bc75e2d6310000061285983896130db565b612863919061311b565b61286d91906130c8565b979650505050505050565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b828210156128e7578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906128a1565b505082519293505050600081900361290457600092505050611135565b60005b818114612962578281815181106129205761292061309c565b602002602001015160000151851161295a578281815181106129445761294461309c565b6020026020010151600001519350505050611135565b600101612907565b508161296f6001836130c8565b8151811061297f5761297f61309c565b6020026020010151600001519250505092915050565b60006129ea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a6a9092919063ffffffff16565b9050805160001480612a0b575080806020019051810190612a0b91906131e0565b6108a65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054e565b6060610f06848460008585600080866001600160a01b03168587604051612a9191906131ab565b60006040518083038185875af1925050503d8060008114612ace576040519150601f19603f3d011682016040523d82523d6000602084013e612ad3565b606091505b5091509150612ae487838387612af1565b925050505b949350505050565b60608315612b60578251600003612b59576001600160a01b0385163b612b595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054e565b5081612ae9565b612ae98383815115612b755781518083602001fd5b8060405162461bcd60e51b815260040161054e91906131fd565b60008060408385031215612ba257600080fd5b50508035926020909101359150565b6001600160a01b0381168114610e6957600080fd5b60008060008060808587031215612bdc57600080fd5b8435612be781612bb1565b93506020850135612bf781612bb1565b92506040850135612c0781612bb1565b9396929550929360600135925050565b600080600060608486031215612c2c57600080fd5b505081359360208301359350604090920135919050565b8015158114610e6957600080fd5b600080600080600080600060e0888a031215612c6c57600080fd5b87359650602088013595506040880135612c8581612c43565b945060608801359350608088013560ff81168114612ca257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600060208284031215612cd157600080fd5b5035919050565b60008083601f840112612cea57600080fd5b50813567ffffffffffffffff811115612d0257600080fd5b6020830191508360208260051b8501011115612d1d57600080fd5b9250929050565b600080600080600060608688031215612d3c57600080fd5b85359450602086013567ffffffffffffffff80821115612d5b57600080fd5b612d6789838a01612cd8565b90965094506040880135915080821115612d8057600080fd5b50612d8d88828901612cd8565b969995985093965092949392505050565b600080600060608486031215612db357600080fd5b8335612dbe81612bb1565b92506020840135612dce81612bb1565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612e0657600080fd5b8135602067ffffffffffffffff80831115612e2357612e23612ddf565b8260051b604051601f19603f83011681018181108482111715612e4857612e48612ddf565b604052938452858101830193838101925087851115612e6657600080fd5b83870191505b8482101561286d57813583529183019190830190612e6c565b60008060008060808587031215612e9b57600080fd5b84359350602085013567ffffffffffffffff80821115612eba57600080fd5b612ec688838901612df5565b94506040870135915080821115612edc57600080fd5b612ee888838901612df5565b93506060870135915080821115612efe57600080fd5b50612f0b87828801612df5565b91505092959194509250565b60008060208385031215612f2a57600080fd5b823567ffffffffffffffff811115612f4157600080fd5b612f4d85828601612cd8565b90969095509350505050565b60008060408385031215612f6c57600080fd5b823591506020830135612f7e81612bb1565b809150509250929050565b60008060008060808587031215612f9f57600080fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215612fcd57600080fd5b8135610f0981612bb1565b6000806000806000806000806080898b031215612ff457600080fd5b883567ffffffffffffffff8082111561300c57600080fd5b6130188c838d01612cd8565b909a50985060208b013591508082111561303157600080fd5b61303d8c838d01612cd8565b909850965060408b013591508082111561305657600080fd5b6130628c838d01612cd8565b909650945060608b013591508082111561307b57600080fd5b506130888b828c01612cd8565b999c989b5096995094979396929594505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115611135576111356130b2565b8082028115828204841417611135576111356130b2565b80820180821115611135576111356130b2565b634e487b7160e01b600052603160045260246000fd5b60008261313857634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261315457600080fd5b83018035915067ffffffffffffffff82111561316f57600080fd5b6020019150600581901b3603821315612d1d57600080fd5b60005b838110156131a257818101518382015260200161318a565b50506000910152565b600082516131bd818460208701613187565b9190910192915050565b6000602082840312156131d957600080fd5b5051919050565b6000602082840312156131f257600080fd5b8151610f0981612c43565b602081526000825180602084015261321c816040850160208701613187565b601f01601f1916919091016040019291505056fea164736f6c6343000811000a000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101d95760003560e01c8063715018a6116101045780639a63bc16116100a2578063e2bbb15811610071578063e2bbb1581461046c578063eebdced51461047f578063f2fde38b14610487578063fa8f5f191461049a57600080fd5b80639a63bc16146103e0578063bb2238ec146103f3578063cdc8c93014610446578063cef7042d1461045957600080fd5b80638d48aff0116100de5780638d48aff0146103775780638da5cb5b1461038a57806393f1a40b1461039b57806398969e82146103cd57600080fd5b8063715018a6146103495780637bafb0291461035157806380637e891461036457600080fd5b80633bbda19b1161017c5780634ad7ce801161014b5780634ad7ce80146102fb5780634ae56bae146103035780635312ea8e146103235780635d14b06f1461033657600080fd5b80633bbda19b146102af578063409e00fc146102c257806342ee0aba146102d5578063441a3e70146102e857600080fd5b80631693074b116101b85780631693074b146102615780632ea807c51461027657806330d78fda1461028957806333824b871461029c57600080fd5b8062d74850146101de5780630f4ef8a6146101fa57806310f7a6af14610239575b600080fd5b6101e760055481565b6040519081526020015b60405180910390f35b6102217f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f81565b6040516001600160a01b0390911681526020016101f1565b61024c610247366004612b8f565b6104ad565b604080519283526020830191909152016101f1565b61027461026f366004612bc6565b6104e9565b005b610274610284366004612c17565b610572565b610274610297366004612c51565b6108ab565b6102746102aa366004612cbf565b610908565b6102746102bd366004612d24565b61094b565b6102746102d0366004612d9e565b610a1d565b6102746102e3366004612e85565b610c88565b6102746102f6366004612b8f565b610d85565b6003546101e7565b6101e7610311366004612cbf565b60009081526002602052604090205490565b610274610331366004612cbf565b610da4565b610274610344366004612f17565b610e6c565b610274610eb3565b6101e761035f366004612c17565b610ec7565b610274610372366004612cbf565b610f10565b6101e7610385366004612cbf565b611129565b6000546001600160a01b0316610221565b61024c6103a9366004612f59565b60046020908152600092835260408084209091529082529020805460019091015482565b6101e76103db366004612f59565b61113b565b6101e76103ee366004612cbf565b611170565b610406610401366004612cbf565b61117c565b604080516001600160a01b039889168152979096166020880152948601939093526060850191909152608084015260a083015260c082015260e0016101f1565b610274610454366004612f89565b6111d8565b610274610467366004612cbf565b611600565b61027461047a366004612b8f565b61161a565b61027461177c565b610274610495366004612fbb565b6117ad565b6102746104a8366004612fd8565b611823565b600260205281600052604060002081815481106104c957600080fd5b600091825260209091206002909102018054600190910154909250905082565b3330146105575760405162461bcd60e51b815260206004820152603160248201527f4661726d696e6752616e67653a3a617474656d70745472616e736665723a3a53604482015270656e646572206e6f74206661726d696e6760781b60648201526084015b60405180910390fd5b61056c6001600160a01b0385168484846119fa565b50505050565b61057a611a65565b610582611abf565b600083815260026020526040812060038054919291869081106105a7576105a761309c565b9060005260206000209060070201905060055482805490501061063c5760405162461bcd60e51b815260206004820152604160248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a72657760448201527f61726420696e666f206c656e677468206578636565647320746865206c696d696064820152601d60fa1b608482015260a40161054e565b8154158061067c5750815443908390610657906001906130c8565b815481106106675761066761309c565b90600052602060002090600202016000015410155b6106e15760405162461bcd60e51b815260206004820152603060248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a72657760448201526f185c99081c195c9a5bd908195b99195960821b606482015260840161054e565b8154158061072057508154849083906106fc906001906130c8565b8154811061070c5761070c61309c565b906000526020600020906002020160000154105b6107825760405162461bcd60e51b815260206004820152602d60248201527f4661726d696e6752616e67653a3a616464526577617264496e666f3a3a62616460448201526c206e657720656e64626c6f636b60981b606482015260840161054e565b8154600090156107c3578254839061079c906001906130c8565b815481106107ac576107ac61309c565b9060005260206000209060020201600001546107c9565b81600201545b905060006107d782876130c8565b905060006107e582876130db565b90508084600601546107f791906130f2565b6006850155604080518082019091528781526020808201888152875460018181018a5560008a81529390932093516002909102909301928355519181019190915584015461084f906001600160a01b0316828a611b18565b845461085d906001906130c8565b60408051898152602081018990528a917fad90731bd0d97445f5af66088f3adebf343c520c20e033cc42f93b124258cdc2910160405180910390a350505050506108a660018055565b505050565b6108f5600388815481106108c1576108c161309c565b60009182526020909120600790910201546001600160a01b03163330886108e857896108ec565b6000195b88888888611c91565b6108ff878761161a565b50505050505050565b610910611a65565b60058190556040518181527fb64f58843e750a8bea7135ef396cf0a7790bfc9a8f43f11ac0e0aacc1b5787ba9060200160405180910390a150565b610953611a65565b8281146109c85760405162461bcd60e51b815260206004820152603860248201527f4661726d696e6752616e67653a3a6164645265776172644d756c7469706c653a60448201527f3a77726f6e6720706172616d6574657273206c656e6774680000000000000000606482015260840161054e565b60005b808414610a1557610a0d868686848181106109e8576109e861309c565b90506020020135858585818110610a0157610a0161309c565b90506020020135610572565b6001016109cb565b505050505050565b610a25611a65565b438111610aa55760405162461bcd60e51b815260206004820152604260248201527f4661726d696e6752616e67653a3a61646443616d706169676e496e666f3a3a5360448201527f7461727420626c6f636b2073686f756c6420626520696e207468652066757475606482015261726560f01b608482015260a40161054e565b6040805160e0810182526001600160a01b038086168252848116602083019081529282018481526060830185815260006080850181815260a0860182815260c08701838152600380546001818101835595829052985160079099027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180549a8a166001600160a01b03199b8c1617905599517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c8b0180549190991699169890981790965593517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d88015591517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85e87015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85f86015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f86085015590517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f8619093019290925554610c3891906130c8565b604080516001600160a01b038087168252851660208201529081018390527f9b2f18f9a188a5aec4a95ee3164fe234dfbb6117628b2ad1a581939e61c69f4e9060600160405180910390a2505050565b610c90611a65565b81518351148015610ca2575080518351145b610d145760405162461bcd60e51b815260206004820152603b60248201527f4661726d696e6752616e67653a3a7570646174655265776172644d756c74697060448201527f6c653a3a77726f6e6720706172616d6574657273206c656e6774680000000000606482015260840161054e565b60005b83518114610d7e57610d7685858381518110610d3557610d3561309c565b6020026020010151858481518110610d4f57610d4f61309c565b6020026020010151858581518110610d6957610d6961309c565b60200260200101516111d8565b600101610d17565b5050505050565b610d8d611abf565b610d978282611e67565b610da060018055565b5050565b610dac611abf565b600060038281548110610dc157610dc161309c565b60009182526020808320858452600482526040808520338652909252922080546007929092029092016005810154909350610dfd9082906130c8565b6005840155600080835560018301558254610e22906001600160a01b03163383612018565b604080518281526020810186905233917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595910160405180910390a2505050610e6960018055565b50565b610e74611abf565b60005b808214610ea957610ea1838383818110610e9357610e9361309c565b905060200201356000611e67565b600101610e77565b50610da060018055565b610ebb611a65565b610ec56000612048565b565b60008184101580610ed757508284115b15610ee457506000610f09565b818311610efc57610ef584846130c8565b9050610f09565b610f0684836130c8565b90505b9392505050565b610f18611a65565b60008181526002602052604081206003805491929184908110610f3d57610f3d61309c565b6000918252602082208454600790920201925090819003610fbf5760405162461bcd60e51b815260206004820152603660248201527f4661726d696e6752616e67653a3a75706461746543616d706169676e7352657760448201527530b932399d1d3737903932bbb0b93224b73337a632b760511b606482015260840161054e565b600083610fcd6001846130c8565b81548110610fdd57610fdd61309c565b6000918252602090912060029091020180549091504381116110675760405162461bcd60e51b815260206004820152603760248201527f4661726d696e6752616e67653a3a72656d6f76654c617374526577617264496e60448201527f666f3a3a72657761726420706572696f6420656e646564000000000000000000606482015260840161054e565b61107086612098565b6001820154156110b95760008061109661108b6001876130c8565b8460008a8a8961243b565b9150915081156110b6578086600601546110b091906130c8565b60068701555b50505b848054806110c9576110c9613105565b60008281526020812060026000199093019283020181815560019081019190915591556110f690846130c8565b60405187907f997b6670781194c0d30c477be41ce4ba9b7f3f12417aa00965b9d9f978251e2390600090a3505050505050565b60006111358243612586565b92915050565b60008281526004602090815260408083206001600160a01b038516845290915281208054600190910154610f0991859161267c565b60006111358243612878565b6003818154811061118c57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919087565b6111e0611a65565b6111e8611abf565b6000848152600260205260408120600380549192918790811061120d5761120d61309c565b9060005260206000209060070201905060008286815481106112315761123161309c565b60009182526020909120600290910201805490915061124f88612098565b438110156112bb5760405162461bcd60e51b815260206004820152603360248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a6044820152721c995dd85c99081c195c9a5bd908195b991959606a1b606482015260840161054e565b86156113565785846112ce60018a6130c8565b815481106112de576112de61309c565b906000526020600020906002020160000154106113565760405162461bcd60e51b815260206004820152603060248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a60448201526f626164206e657720656e64626c6f636b60801b606482015260840161054e565b6113618760016130f2565b8454111561141657836113758860016130f2565b815481106113855761138561309c565b90600052602060002090600202016000015486106114165760405162461bcd60e51b815260206004820152604260248201527f4661726d696e6752616e67653a3a757064617465526577617264496e666f3a3a60448201527f72657761726420706572696f6420656e6420697320696e206e6578742072616e606482015261676560f01b608482015260a40161054e565b60008061142789898989898961243b565b915091508115801561143857508015155b15611456576001850154611456906001600160a01b0316828c611b18565b828814158015611473575085548990611471906001906130c8565b115b1561157b576000866114868b60016130f2565b815481106114965761149661309c565b6000918252602082206002909102018054909250906114b586836130c8565b905060006114c38c846130c8565b600185015490915060006114d782856130db565b9050826114e485846130db565b6114ee919061311b565b915060006114fc83856130db565b60018801849055905081811015611573576115507f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f61153b83856130c8565b60018f01546001600160a01b03169190612018565b61155a81836130c8565b8c600601600082825461156d91906130c8565b90915550505b505050505050505b816115955780856006015461159091906130f2565b6115a5565b8085600601546115a591906130c8565b60068601558784556001840187905560408051898152602081018990528a918c917fcd251e3ce758f4da844a7b790619743994a9ce956a4abb78aec611623ae8af5f910160405180910390a350505050505061056c60018055565b611608611abf565b61161181612098565b610e6960018055565b611622611abf565b6000600383815481106116375761163761309c565b6000918252602080832086845260048252604080852033865290925292206007909102909101915061166884612098565b8054156116cb576000816001015468056bc75e2d631000008460040154846000015461169491906130db565b61169e919061311b565b6116a891906130c8565b905080156116c95760018301546116c9906001600160a01b03163383612018565b505b821561170c5780546116de9084906130f2565b815560058201546116f09084906130f2565b6005830155815461170c906001600160a01b03163330866119fa565b6004820154815468056bc75e2d6310000091611727916130db565b611731919061311b565b6001820155604080518481526020810186905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a25050610da060018055565b611784611abf565b60035460005b8181146117a25761179a81612098565b60010161178a565b5050610ec560018055565b6117b5611a65565b6001600160a01b03811661181a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054e565b610e6981612048565b61182b611a65565b868514801561183957508483145b801561184457508481145b6118b65760405162461bcd60e51b815260206004820152603d60248201527f4661726d696e6752616e67653a3a75706461746543616d706169676e7352657760448201527f617264733a3a77726f6e6720726577617264496e666f206c656e677468000000606482015260840161054e565b60005b8088146119ef576119e78989838181106118d5576118d561309c565b905060200201358888848181106118ee576118ee61309c565b9050602002810190611900919061313d565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a92508991508690508181106119465761194661309c565b9050602002810190611958919061313d565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525089925088915087905081811061199e5761199e61309c565b90506020028101906119b0919061313d565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250610c8892505050565b6001016118b9565b505050505050505050565b6040516001600160a01b038085166024830152831660448201526064810182905261056c9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612995565b6000546001600160a01b03163314610ec55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054e565b600260015403611b115760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161054e565b6002600155565b604051631693074b60e01b81526001600160a01b0380851660048301527f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f16602482015230604482018190526064820184905290631693074b90608401600060405180830381600087803b158015611b8f57600080fd5b505af1925050508015611ba0575060015b6108a6577f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f6001600160a01b031681604051602401611be191815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663eee4f11b60e01b17905251611c1691906131ab565b6000604051808303816000865af19150503d8060008114611c53576040519150601f19603f3d011682016040523d82523d6000602084013e611c58565b606091505b506108a69150506001600160a01b0384167f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f30856119fa565b604051623f675f60e91b81526001600160a01b038881166004830152600091908a1690637ecebe0090602401602060405180830381865afa158015611cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfe91906131c7565b60405163d505accf60e01b81526001600160a01b038a811660048301528981166024830152604482018990526064820188905260ff8716608483015260a4820186905260c48201859052919250908a169063d505accf9060e401600060405180830381600087803b158015611d7257600080fd5b505af1158015611d86573d6000803e3d6000fd5b5050604051623f675f60e91b81526001600160a01b038b81166004830152600093508c169150637ecebe0090602401602060405180830381865afa158015611dd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df691906131c7565b9050611e038260016130f2565b8114611e5b5760405162461bcd60e51b815260206004820152602160248201527f5361666545524332303a207065726d697420646964206e6f74207375636365656044820152601960fa1b606482015260840161054e565b50505050505050505050565b600060038381548110611e7c57611e7c61309c565b600091825260208083208684526004825260408085203386529092529220805460079092029092019250831115611f095760405162461bcd60e51b815260206004820152602b60248201527f4661726d696e6752616e67653a3a77697468647261773a3a626164207769746860448201526a191c985dc8185b5bdd5b9d60aa1b606482015260840161054e565b611f1284612098565b6000816001015468056bc75e2d6310000084600401548460000154611f3791906130db565b611f41919061311b565b611f4b91906130c8565b90508015611f6c576001830154611f6c906001600160a01b03163383612018565b8315611fac578154611f7f9085906130c8565b82556005830154611f919085906130c8565b60058401558254611fac906001600160a01b03163386612018565b6004830154825468056bc75e2d6310000091611fc7916130db565b611fd1919061311b565b6001830155604080518581526020810187905233917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a25050505050565b6040516001600160a01b0383166024820152604481018290526108a690849063a9059cbb60e01b90606401611a2e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60035481106121065760405162461bcd60e51b815260206004820152603460248201527f4661726d696e6752616e67653a3a5f75706461746543616d706169676e3a3a43604482015273185b5c185a59db881a59081b9bdd081d985b1a5960621b606482015260840161054e565b60006003828154811061211b5761211b61309c565b60009182526020808320858452600282526040808520805482518186028101860190935280835260079095029092019550929091849084015b8282101561219a57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190612154565b505050509050816003015443116121b057505050565b816005015460000361233d576000805b825181146122f15783600301548382815181106121df576121df61309c565b602002602001015160000151106122e95760008160000361220457846003015461222d565b836122106001846130c8565b815181106122205761222061309c565b6020026020010151600001515b90506000438584815181106122445761224461309c565b60200260200101516000015111905060008660030154831161226a57866003015461226c565b825b82612294578685815181106122835761228361309c565b602002602001015160000151612296565b435b6122a091906130c8565b9050808685815181106122b5576122b561309c565b6020026020010151602001516122cb91906130db565b6122d590866130f2565b945081156122e5575050506122f1565b5050505b6001016121c0565b508015612331576001830154612331906001600160a01b03167f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f83612018565b50504360039091015550565b60005b8151811461056c5760006123768460030154438585815181106123655761236561309c565b602002602001015160000151610ec7565b90508015612432578282815181106123905761239061309c565b6020026020010151600001514311156123cb578282815181106123b5576123b561309c565b60209081029190910101515160038501556123d2565b4360038501555b83600501548383815181106123e9576123e961309c565b6020026020010151602001518261240091906130db565b6124139068056bc75e2d631000006130db565b61241d919061311b565b846004015461242c91906130f2565b60048501555b50600101612340565b600080808815612478578561245160018b6130c8565b815481106124615761246161309c565b90600052602060002090600202016000015461247e565b84600201545b9050600081431161248f5781612491565b435b905060008286600001546124a591906130c8565b905060006124b3838c6130c8565b60018801549091506000816124c887876130c8565b6124d291906130db565b905060006124e085846130db565b905060006124ee858f6130db565b90506124fa83826130f2565b821199508961251d578161250e84836130f2565b61251891906130c8565b612532565b8261252882846130c8565b61253291906130c8565b985089156125735760018c0154612573906001600160a01b03167f000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f8b612018565b5050505050505050965096945050505050565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b828210156125f5578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906125af565b505082519293505050600081900361261257600092505050611135565b60005b8181146126705782818151811061262e5761262e61309c565b6020026020010151600001518511612668578281815181106126525761265261309c565b6020026020010151602001519350505050611135565b600101612615565b50600095945050505050565b600080600385815481106126925761269261309c565b600091825260208083206040805160e081018252600790940290910180546001600160a01b03908116855260018201541684840152600280820154858401526003820154606086015260048201546080860152600582015460a086015260069091015460c08501528985528252808420805482518185028101850190935280835293955090929091849084015b828210156127655783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061271f565b50505050905060008260800151905082606001514311801561278a575060a083015115155b1561284457606083015160005b835181146128415760006127b883438785815181106123655761236561309c565b90508015612838578482815181106127d2576127d261309c565b60200260200101516000015192508560a001518583815181106127f7576127f761309c565b6020026020010151602001518261280e91906130db565b6128219068056bc75e2d631000006130db565b61282b919061311b565b61283590856130f2565b93505b50600101612797565b50505b8468056bc75e2d6310000061285983896130db565b612863919061311b565b61286d91906130c8565b979650505050505050565b600082815260026020908152604080832080548251818502810185019093528083528493849084015b828210156128e7578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906128a1565b505082519293505050600081900361290457600092505050611135565b60005b818114612962578281815181106129205761292061309c565b602002602001015160000151851161295a578281815181106129445761294461309c565b6020026020010151600001519350505050611135565b600101612907565b508161296f6001836130c8565b8151811061297f5761297f61309c565b6020026020010151600001519250505092915050565b60006129ea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a6a9092919063ffffffff16565b9050805160001480612a0b575080806020019051810190612a0b91906131e0565b6108a65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054e565b6060610f06848460008585600080866001600160a01b03168587604051612a9191906131ab565b60006040518083038185875af1925050503d8060008114612ace576040519150601f19603f3d011682016040523d82523d6000602084013e612ad3565b606091505b5091509150612ae487838387612af1565b925050505b949350505050565b60608315612b60578251600003612b59576001600160a01b0385163b612b595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054e565b5081612ae9565b612ae98383815115612b755781518083602001fd5b8060405162461bcd60e51b815260040161054e91906131fd565b60008060408385031215612ba257600080fd5b50508035926020909101359150565b6001600160a01b0381168114610e6957600080fd5b60008060008060808587031215612bdc57600080fd5b8435612be781612bb1565b93506020850135612bf781612bb1565b92506040850135612c0781612bb1565b9396929550929360600135925050565b600080600060608486031215612c2c57600080fd5b505081359360208301359350604090920135919050565b8015158114610e6957600080fd5b600080600080600080600060e0888a031215612c6c57600080fd5b87359650602088013595506040880135612c8581612c43565b945060608801359350608088013560ff81168114612ca257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600060208284031215612cd157600080fd5b5035919050565b60008083601f840112612cea57600080fd5b50813567ffffffffffffffff811115612d0257600080fd5b6020830191508360208260051b8501011115612d1d57600080fd5b9250929050565b600080600080600060608688031215612d3c57600080fd5b85359450602086013567ffffffffffffffff80821115612d5b57600080fd5b612d6789838a01612cd8565b90965094506040880135915080821115612d8057600080fd5b50612d8d88828901612cd8565b969995985093965092949392505050565b600080600060608486031215612db357600080fd5b8335612dbe81612bb1565b92506020840135612dce81612bb1565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612e0657600080fd5b8135602067ffffffffffffffff80831115612e2357612e23612ddf565b8260051b604051601f19603f83011681018181108482111715612e4857612e48612ddf565b604052938452858101830193838101925087851115612e6657600080fd5b83870191505b8482101561286d57813583529183019190830190612e6c565b60008060008060808587031215612e9b57600080fd5b84359350602085013567ffffffffffffffff80821115612eba57600080fd5b612ec688838901612df5565b94506040870135915080821115612edc57600080fd5b612ee888838901612df5565b93506060870135915080821115612efe57600080fd5b50612f0b87828801612df5565b91505092959194509250565b60008060208385031215612f2a57600080fd5b823567ffffffffffffffff811115612f4157600080fd5b612f4d85828601612cd8565b90969095509350505050565b60008060408385031215612f6c57600080fd5b823591506020830135612f7e81612bb1565b809150509250929050565b60008060008060808587031215612f9f57600080fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215612fcd57600080fd5b8135610f0981612bb1565b6000806000806000806000806080898b031215612ff457600080fd5b883567ffffffffffffffff8082111561300c57600080fd5b6130188c838d01612cd8565b909a50985060208b013591508082111561303157600080fd5b61303d8c838d01612cd8565b909850965060408b013591508082111561305657600080fd5b6130628c838d01612cd8565b909650945060608b013591508082111561307b57600080fd5b506130888b828c01612cd8565b999c989b5096995094979396929594505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115611135576111356130b2565b8082028115828204841417611135576111356130b2565b80820180821115611135576111356130b2565b634e487b7160e01b600052603160045260246000fd5b60008261313857634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261315457600080fd5b83018035915067ffffffffffffffff82111561316f57600080fd5b6020019150600581901b3603821315612d1d57600080fd5b60005b838110156131a257818101518382015260200161318a565b50506000910152565b600082516131bd818460208701613187565b9190910192915050565b6000602082840312156131d957600080fd5b5051919050565b6000602082840312156131f257600080fd5b8151610f0981612c43565b602081526000825180602084015261321c816040850160208701613187565b601f01601f1916919091016040019291505056fea164736f6c6343000811000a

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

000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f

-----Decoded View---------------
Arg [0] : _rewardManager (address): 0xC049c7fE5EAa024095861212BD8a8E8Df88a2b1f

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c049c7fe5eaa024095861212bd8a8e8df88a2b1f


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
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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.