POL Price: $0.586753 (-2.54%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Process Rewards655774482024-12-17 3:36:5843 mins ago1734406618IN
0x84be4f09...Df693a476
0 POL0.0049638330.00000011
Process Rewards655774382024-12-17 3:36:3643 mins ago1734406596IN
0x84be4f09...Df693a476
0 POL0.005296432.01000009
Stake655711312024-12-16 23:48:434 hrs ago1734392923IN
0x84be4f09...Df693a476
0 POL0.0076028430.00000003
Unstake655708492024-12-16 23:38:454 hrs ago1734392325IN
0x84be4f09...Df693a476
0 POL0.0061477432.09071221
Unstake655708392024-12-16 23:38:234 hrs ago1734392303IN
0x84be4f09...Df693a476
0 POL0.0057472230.00000004
Process Rewards655707992024-12-16 23:36:574 hrs ago1734392217IN
0x84be4f09...Df693a476
0 POL0.0049638330.00000004
Process Rewards655619622024-12-16 18:17:0810 hrs ago1734373028IN
0x84be4f09...Df693a476
0 POL0.0051910531.3732935
Process Rewards655614392024-12-16 17:58:3410 hrs ago1734371914IN
0x84be4f09...Df693a476
0 POL0.0066354340.10271611
Unstake655595522024-12-16 16:51:4611 hrs ago1734367906IN
0x84be4f09...Df693a476
0 POL0.02271183118.55383295
Unstake655595462024-12-16 16:51:3211 hrs ago1734367892IN
0x84be4f09...Df693a476
0 POL0.02277654118.89164435
Unstake655595422024-12-16 16:51:2411 hrs ago1734367884IN
0x84be4f09...Df693a476
0 POL0.02262821118.12475587
Process Rewards655595152024-12-16 16:50:2611 hrs ago1734367826IN
0x84be4f09...Df693a476
0 POL0.02068352125.00540945
Unstake655535802024-12-16 13:18:2215 hrs ago1734355102IN
0x84be4f09...Df693a476
0 POL0.0172794790.19736742
Process Rewards655529052024-12-16 12:54:2415 hrs ago1734353664IN
0x84be4f09...Df693a476
0 POL0.0127728777.19568646
Stake655401112024-12-16 5:16:5323 hrs ago1734326213IN
0x84be4f09...Df693a476
0 POL0.0077251130.48250389
Unstake655400672024-12-16 5:15:2123 hrs ago1734326121IN
0x84be4f09...Df693a476
0 POL0.0057475830.00001046
Unstake655400502024-12-16 5:14:4523 hrs ago1734326085IN
0x84be4f09...Df693a476
0 POL0.0058535430.55499689
Unstake655400352024-12-16 5:14:1323 hrs ago1734326053IN
0x84be4f09...Df693a476
0 POL0.0057475830.00001035
Unstake655400172024-12-16 5:13:3523 hrs ago1734326015IN
0x84be4f09...Df693a476
0 POL0.0057475830.00001005
Process Rewards655399882024-12-16 5:12:3123 hrs ago1734325951IN
0x84be4f09...Df693a476
0 POL0.0049638330.00001129
Unstake655266832024-12-15 21:12:1231 hrs ago1734297132IN
0x84be4f09...Df693a476
0 POL0.0060096331.36980002
Unstake655266712024-12-15 21:11:4631 hrs ago1734297106IN
0x84be4f09...Df693a476
0 POL0.0057472230.00000002
Unstake655266592024-12-15 21:11:2231 hrs ago1734297082IN
0x84be4f09...Df693a476
0 POL0.0059761531.19501658
Unstake655266442024-12-15 21:10:5031 hrs ago1734297050IN
0x84be4f09...Df693a476
0 POL0.0059872531.25298584
Process Rewards655266222024-12-15 21:10:0231 hrs ago1734297002IN
0x84be4f09...Df693a476
0 POL0.0049638330.00000002
View all transactions

Latest 1 internal transaction

Parent Transaction Hash Block From To
260347572022-03-17 9:29:481005 days ago1647509388  Contract Creation0 POL
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MechaniumStakingPool

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

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

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "./IMechaniumStakingPool.sol";
import "../MechaniumUtils/MechaniumCanReleaseUnintendedOwnable.sol";

/**
 * @title MechaniumStakingPool - Staking pool smart contract
 * @author EthernalHorizons - <https://ethernalhorizons.com/>
 * @custom:project-website  https://mechachain.io/
 * @custom:security-contact [email protected]
 */
contract MechaniumStakingPool is
    IMechaniumStakingPool,
    Ownable,
    MechaniumCanReleaseUnintendedOwnable
{
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    /**
     * ========================
     *          Events
     * ========================
     */

    /**
     * @notice Event emitted when an `account` stakes `amount` for `lockPeriod`
     */
    event Stake(address indexed account, uint256 amount, uint64 lockPeriod);

    /**
     * @notice Event emitted when an `account` unstaked a deposit (`depositId`)
     */
    event Unstake(address indexed account, uint256 amount, uint256 depositId);

    /**
     * @notice Event emitted when an `account` unstaked several deposits (`depositIds`)
     */
    event Unstake(
        address indexed account,
        uint256 amount,
        uint256[] depositIds
    );

    /**
     * @notice Event emitted when an `account` updated stake `lockPeriod` for a `depositId`
     */
    event StakeLockUpdated(
        address indexed account,
        uint256 depositId,
        uint64 lockPeriod
    );

    /**
     * @notice Event emitted when an `rewardsPerBlock` is updated
     */
    event RewardsPerBlockChanged(uint256 rewardsPerBlock);

    /**
     * @notice Event emitted when `rewards` are processed for an `account`
     */
    event ProcessRewards(address indexed account, uint256 rewards);

    /**
     * @notice Event emitted when `_rewardsPerWeight` is updated
     */
    event RewardsPerWeightUpdated(uint256 _rewardsPerWeight);

    /**
     * ========================
     *  Constants & Immutables
     * ========================
     */

    /// ERC20 token to be staked
    IERC20 public immutable stakedToken;

    /// ERC20 token to be rewarded
    IERC20 public immutable rewardToken;

    /// Block number for staking pool start
    uint32 public immutable initBlock;

    /// Staking rewards locking period
    uint64 public immutable rewardsLockingPeriod;

    /// Minimum staking time
    uint64 public immutable minStakingTime;

    /// Maximum staking time
    uint64 public immutable maxStakingTime;

    /// Minimum weight multiplier
    uint16 public immutable minWeightMultiplier;

    /// Maximum weight multiplier
    uint16 public immutable maxWeightMultiplier;

    /// Weight multiplier ( used for floating weight )
    uint256 public immutable WEIGHT_MULTIPLIER = 1e12;

    /**
     * ========================
     *         Storage
     * ========================
     */

    /// Amount of tokens to be rewarded per block
    uint256 public rewardsPerBlock;

    /// Mapping of users addresses and User structure
    mapping(address => User) public users;

    /// Total staking weight for users
    uint256 public totalUsersWeight;

    /// Total tokens staked by users
    uint256 public totalTokensStaked;

    /// Total of processed rewards
    uint256 public totalProcessedRewards;

    /// Track the last block number of rewards update
    uint256 public lastRewardsUpdate;

    /// Total rewards at the last update, use `updatedTotalRewards` for get the last value
    uint256 internal _totalRewards;

    /// Rewards in tokens per weight at the last update, use `updatedRewardsPerWeight` for get the last value
    uint256 internal _rewardsPerWeight;

    /**
     * ========================
     *     Public Functions
     * ========================
     */

    /**
     * @notice Contract constructor sets the configuration of the staking pool
     * @param stakedToken_ The token to be staked ( can be same as rewardToken if not flash pool )
     * @param rewardToken_  The token to be rewarded
     * @param initBlock_ The init block ( if set to 0 will take the current block )
     * @param minStakingTime_ The minimum allowed locking time
     * @param maxStakingTime_ The maximum allowed locking time
     * @param minWeightMultiplier_ The minimum weight multiplier ( Used to calculate weight range )
     * @param maxWeightMultiplier_ The maximum weight multiplier ( Used to calculate weight range )
     * @param rewardsLockingPeriod_  The rewards locking period ( Can be 0 if flash pool )
     * @param rewardsPerBlock_ The amount of tokens to be rewarded per block passed
     */
    constructor(
        IERC20 stakedToken_,
        IERC20 rewardToken_,
        uint32 initBlock_,
        uint64 minStakingTime_,
        uint64 maxStakingTime_,
        uint16 minWeightMultiplier_,
        uint16 maxWeightMultiplier_,
        uint64 rewardsLockingPeriod_,
        uint256 rewardsPerBlock_
    ) {
        require(rewardsPerBlock_ > 0, "Rewards can't be null");
        require(minWeightMultiplier_ > 0, "minWeightMultiplier can't be null");
        require(
            minStakingTime_ <= maxStakingTime_,
            "minStakingTime can't be greater than maxStakingTime"
        );
        require(
            minWeightMultiplier_ <= maxWeightMultiplier_,
            "minWeightMultiplier can't be greater than maxWeightMultiplier"
        );

        /// Requirement to handle flash pools
        require(
            (address(stakedToken_) == address(rewardToken_)) ||
                rewardsLockingPeriod_ == 0,
            "Rewards locking period must be 0 for flash pools"
        );
        require(
            rewardsLockingPeriod_ == 0 ||
                rewardsLockingPeriod_ >= minStakingTime_,
            "Rewards locking period must be 0 or lower than minStakingTime"
        );
        require(
            rewardsLockingPeriod_ == 0 ||
                rewardsLockingPeriod_ <= maxStakingTime_,
            "Rewards locking period must be 0 or greater than maxStakingTime"
        );

        stakedToken = stakedToken_;
        rewardToken = rewardToken_;
        initBlock = initBlock_ == 0 ? uint32(block.number) : initBlock_;
        rewardsLockingPeriod = rewardsLockingPeriod_;
        minStakingTime = minStakingTime_;
        maxStakingTime = maxStakingTime_;
        minWeightMultiplier = minWeightMultiplier_;
        maxWeightMultiplier = maxWeightMultiplier_;
        rewardsPerBlock = rewardsPerBlock_;

        _addLockedToken(address(stakedToken_));
        _addLockedToken(address(rewardToken_));
    }

    /**
     * @notice Used to stake an `amount` of tokens for a `lockPeriod` for the `msg.sender`
     * @dev Uses the `depositFor` function
     * @param amount The amount of tokens to stake
     * @param lockPeriod The locking period ( in seconds )
     */
    function stake(uint256 amount, uint64 lockPeriod)
        public
        override
        returns (bool)
    {
        address account = msg.sender;

        depositFor(account, amount, uint256(lockPeriod));

        return true;
    }

    /**
     * @notice Used to stake an `amount` of tokens for a `lockPeriod` for an `account`
     * @dev Will make a safe transfer from the `account` and calculate the weight and create a deposit
     * @param account The account that we will stake the tokens for
     * @param amount The amount of tokens to stake
     * @param lockPeriod The locking period ( in seconds )
     */
    function depositFor(
        address account,
        uint256 amount,
        uint256 lockPeriod
    ) public override returns (bool) {
        require(account != address(0), "Address must not be 0");
        require(amount > 0, "Amount must be superior to zero");
        require(
            lockPeriod >= minStakingTime,
            "Staking time less than minimum required"
        );
        require(
            lockPeriod <= maxStakingTime,
            "Staking time greater than maximum required"
        );

        // Update rewards
        if (canUpdateRewards()) {
            updateRewards();
        }

        // Process rewards with no update to not do it twice
        _processRewards(account, false);

        stakedToken.safeTransferFrom(msg.sender, address(this), amount);

        User storage user = users[account];

        uint64 _lockPeriod = uint64(lockPeriod);

        uint256 weight = calculateUserWeight(amount, _lockPeriod);

        uint64 lockStart = uint64(block.timestamp);
        uint64 lockEnd = lockStart + _lockPeriod;

        Deposit memory deposit = Deposit({
            amount: amount,
            weight: weight,
            lockedFrom: lockStart,
            lockedUntil: lockEnd,
            isRewards: false,
            isClaimed: false
        });

        // Update user and total records
        user.deposits.push(deposit);
        _increaseUserRecords(user, amount, weight, true);

        emit Stake(account, amount, _lockPeriod);

        return true;
    }

    /**
     * @notice Used to calculate and pay pending rewards to the `msg.sender`
     *
     * @dev Automatically updates rewards before processing them
     * @dev When there are no rewards to calculate, throw error
     * @dev If `rewardsLockingPeriod` is set, rewards are staked in a new deposit,
     *      otherwise they are transmitted directly to the user (as for flash pools)
     *
     * @return userPendingRewards rewards calculated and optionally re-staked
     */
    function processRewards()
        public
        override
        returns (uint256 userPendingRewards)
    {
        userPendingRewards = _processRewards(msg.sender, true);
        require(userPendingRewards != 0, "No rewards to process");
    }

    /**
     * @notice Used to unstake several deposits for the `msg.sender`
     *
     * @dev ProcessRewards and transfer all deposits to the user
     * @dev Revert if the `lockedUntil` of a deposit has not passed
     *
     * @param depositIds Array of deposit id that will be unstaked
     */
    function unstake(uint256[] memory depositIds)
        public
        override
        returns (bool)
    {
        // Update rewards
        if (canUpdateRewards()) {
            updateRewards();
        }

        // Process rewards with no update to not do it twice
        _processRewards(msg.sender, false);

        User storage user = users[msg.sender];

        uint256 totalAmount = 0;
        uint256 totalWeight = 0;
        for (uint256 i = 0; i < depositIds.length; i++) {
            (uint256 amount, uint256 weight) = _drainDeposit(
                user,
                depositIds[i]
            );
            totalAmount = totalAmount.add(amount);
            totalWeight = totalWeight.add(weight);
        }

        // Update user and total records
        _decreaseUserRecords(user, totalAmount, totalWeight, true);

        // Transfer tokens
        rewardToken.safeTransfer(msg.sender, totalAmount);

        emit Unstake(msg.sender, totalAmount, depositIds);
        return true;
    }

    /**
     * @notice Used to unstake a `depositId` for the `msg.sender`
     *
     * @dev ProcessRewards and transfer all the deposit to the user
     * @dev Revert if the `lockedUntil` of the deposit has not passed
     *
     * @param depositId The deposit id that will be unstaked
     */
    function unstake(uint256 depositId) public override returns (bool) {
        // Update rewards
        if (canUpdateRewards()) {
            updateRewards();
        }

        // Process rewards with no update to not do it twice
        _processRewards(msg.sender, false);

        User storage user = users[msg.sender];
        (uint256 amount, uint256 weight) = _drainDeposit(user, depositId);

        // Update user and total records
        _decreaseUserRecords(user, amount, weight, true);

        // Transfer tokens
        stakedToken.safeTransfer(msg.sender, amount);

        emit Unstake(msg.sender, amount, depositId);
        return true;
    }

    /**
     * @notice Used to update the rewards per weight and the total rewards
     * @dev Must be called before each total weight change
     */
    function updateRewards() public override returns (bool) {
        require(canUpdateRewards(), "initBlock is not reached");

        if (totalUsersWeight > 0) {
            _rewardsPerWeight = updatedRewardsPerWeight();
            _totalRewards = updatedTotalRewards();
        }

        lastRewardsUpdate = block.number;

        emit RewardsPerWeightUpdated(_rewardsPerWeight);

        return true;
    }

    /**
     * @notice Used to change the rewardsPerBlock
     *
     * @dev Will update rewards before changing the rewardsPerBlock
     * @dev Can only by call by owner (the factory if deployed by it)
     * @dev Revert if the new rewards per block is less than the previous one
     *
     * @param rewardsPerBlock_ the new value for rewardsPerBlock ( must be superior to old value )
     */
    function setRewardsPerBlock(uint256 rewardsPerBlock_)
        public
        override
        onlyOwner
        returns (bool)
    {
        require(
            rewardsPerBlock_ > rewardsPerBlock,
            "Rewards per block must be greater than the previous one"
        );

        if (canUpdateRewards()) {
            updateRewards();
        }

        rewardsPerBlock = rewardsPerBlock_;

        emit RewardsPerBlockChanged(rewardsPerBlock);

        return true;
    }

    /**
     * ========================
     *           Views
     * ========================
     */

    /**
     * @notice Used to get the remaining allocated tokens
     */
    function remainingAllocatedTokens() public view override returns (uint256) {
        uint256 balance = rewardToken.balanceOf(address(this));

        uint256 remainingTokens = balance.sub(
            totalTokensStaked.add(updatedTotalRewards()).sub(
                totalProcessedRewards
            )
        );

        return remainingTokens;
    }

    /**
     * @notice Used to get the pending rewards for an `account`
     * @param account The account to calculate the pending rewards for
     * @return the rewards that the user has but which have not been processed
     */
    function pendingRewards(address account)
        public
        view
        override
        returns (uint256)
    {
        if (block.number < initBlock || users[account].totalStaked == 0) {
            return 0;
        }

        // All rewards according to account weight
        uint256 _pendingRewards = weightToReward(
            users[account].totalWeight,
            updatedRewardsPerWeight()
        );

        // Remove rewards released before accounts allocations or that they have already been processed
        _pendingRewards = _pendingRewards.sub(users[account].missingRewards);

        return _pendingRewards;
    }

    /**
     * @notice Can we call the rewards update function or is it useless and will cause an error
     */
    function canUpdateRewards() public view override returns (bool) {
        return block.number >= initBlock;
    }

    /**
     * @notice Used to get the balance for an `account`
     * @param account The account to get the balance for
     */
    function balanceOf(address account) public view override returns (uint256) {
        User memory user = users[account];
        return user.totalStaked.add(pendingRewards(account));
    }

    /**
     * @notice Used to get the deposit (`depositId`) for an `account`
     * @param account The account to get the balance for
     * @param depositId The deposit id the get
     */
    function getDeposit(address account, uint256 depositId)
        public
        view
        override
        returns (Deposit memory)
    {
        User memory user = users[account];

        require(depositId < user.deposits.length, "Deposit does not exist");

        Deposit memory deposit = user.deposits[depositId];

        return deposit;
    }

    /**
     * @notice Used to get the length of deposits for an `account`
     * @param account The account to get the balance for
     */
    function getDepositsLength(address account)
        public
        view
        override
        returns (uint256)
    {
        User memory user = users[account];

        return user.deposits.length;
    }

    /**
     * @notice Used to get the User data for an `account`
     * @param account The account address
     */
    function getUser(address account)
        public
        view
        override
        returns (User memory)
    {
        User memory user = users[account];

        return user;
    }

    /**
     * @notice Get the updated rewards
     * @dev Used to calculate the rewards for last period ( in blocks ) without updating them
     */
    function updatedRewards() public view override returns (uint256) {
        if (block.number < initBlock) {
            return 0;
        }

        uint256 _lastRewardsUpdate = lastRewardsUpdate > 0
            ? lastRewardsUpdate
            : initBlock;

        uint256 passedBlocks = block.number.sub(_lastRewardsUpdate);

        uint256 cumulatedRewards = passedBlocks.mul(rewardsPerBlock);

        /**
         * Calculate old remaining tokens
         * Used to check if we have enough tokens to reward
         */
        uint256 balance = rewardToken.balanceOf(address(this));

        uint256 oldRemainingTokens = balance.sub(
            totalTokensStaked.add(_totalRewards).sub(totalProcessedRewards)
        );

        return
            cumulatedRewards > oldRemainingTokens
                ? oldRemainingTokens
                : cumulatedRewards;
    }

    /**
     * @notice Get the total updated rewards
     * @dev Used to calculate the rewards from the init block without updating them
     */
    function updatedTotalRewards() public view override returns (uint256) {
        uint256 _updatedTotalRewards = _totalRewards.add(updatedRewards());

        return _updatedTotalRewards;
    }

    /**
     * @notice Get the updated rewards per weight
     * @dev Used to calculate `_rewardsPerWeight` without updating them
     */
    function updatedRewardsPerWeight() public view override returns (uint256) {
        uint256 cumulatedRewards = updatedRewards();

        cumulatedRewards = cumulatedRewards.mul(WEIGHT_MULTIPLIER);

        uint256 newRewardsPerWeight = cumulatedRewards.div(
            totalUsersWeight > 0 ? totalUsersWeight : 1
        );

        newRewardsPerWeight = newRewardsPerWeight.add(_rewardsPerWeight);

        return newRewardsPerWeight;
    }

    /**
     * @notice Calculate the weight based on `amount` and `stakingTime`
     * @param amount The staking amount
     * @param stakingTime The staking time
     */
    function calculateUserWeight(uint256 amount, uint64 stakingTime)
        public
        view
        override
        returns (uint256)
    {
        return
            amount
                .mul(
                    _getRange(
                        minStakingTime,
                        uint256(minWeightMultiplier).mul(WEIGHT_MULTIPLIER),
                        maxStakingTime,
                        uint256(maxWeightMultiplier).mul(WEIGHT_MULTIPLIER),
                        uint256(stakingTime)
                    )
                )
                .div(WEIGHT_MULTIPLIER);
    }

    /**
     * @dev Converts stake weight to reward value, applying the division on weight
     *
     * @param weight_ stake weight
     * @param rewardsPerWeight_ reward per weight
     * @return reward value normalized with WEIGHT_MULTIPLIER
     */
    function weightToReward(uint256 weight_, uint256 rewardsPerWeight_)
        public
        pure
        override
        returns (uint256)
    {
        return weight_.mul(rewardsPerWeight_).div(WEIGHT_MULTIPLIER);
    }

    /**
     * ========================
     *     Private functions
     * ========================
     */

    /**
     * @notice Update the user and total records by increasing the weight and the total staked
     *
     * @dev Increase user's `totalStaked`, `totalWeight` and reset `missingRewards`
     * @dev Increase `totalUsersWeight` and `totalTokensStaked`
     * @dev Rewards MUST be updated before and processed for this users
     *
     * @param user The user to update
     * @param amount The amount to increase
     * @param weight The weight to increase
     */
    function _increaseUserRecords(
        User storage user,
        uint256 amount,
        uint256 weight,
        bool updateMissingRewards
    ) internal returns (bool) {
        // Update user records
        user.totalStaked = user.totalStaked.add(amount);
        user.totalWeight = user.totalWeight.add(weight);

        if (updateMissingRewards) {
            // Reset the missingRewards of the user
            user.missingRewards = weightToReward(
                user.totalWeight,
                _rewardsPerWeight
            );
        }

        // Update total records
        totalUsersWeight = totalUsersWeight.add(weight);
        totalTokensStaked = totalTokensStaked.add(amount);
        return true;
    }

    /**
     * @notice Update the user and total records by decreasing the weight and the total staked
     *
     * @dev Decrease user's `totalStaked`, `totalWeight` and reset `missingRewards`
     * @dev Decrease `totalUsersWeight` and `totalTokensStaked`
     * @dev Rewards MUST be updated before and processed for this users
     * @dev If `updateMissingRewards` is false, `missingRewards` rewards MUST be updated after
     *
     * @param user The user to update
     * @param amount The amount to decrease
     * @param weight The weight to decrease
     * @param updateMissingRewards If we have to update the missing rewards of the user
     */
    function _decreaseUserRecords(
        User storage user,
        uint256 amount,
        uint256 weight,
        bool updateMissingRewards
    ) internal returns (bool) {
        // Update user records
        user.totalStaked = user.totalStaked.sub(amount);
        user.totalWeight = user.totalWeight.sub(weight);

        if (updateMissingRewards) {
            // Reset the missingRewards of the user
            user.missingRewards = weightToReward(
                user.totalWeight,
                _rewardsPerWeight
            );
        }

        // Update total records
        totalUsersWeight = totalUsersWeight.sub(weight);
        totalTokensStaked = totalTokensStaked.sub(amount);
        return true;
    }

    /**
     * @notice Remove a deposit if the locking is over and return its amount and weight
     *
     * @dev Set the deposit's `isClaimed` to true
     * @dev Revert if `depositId` does not exist or if the `lockedUntil`
     *      of the deposit has not passed
     * @dev Does not update records : rewards MUST be updated before and
     *      user's profile and total record MUST be updated after
     *
     * @param user The user who owns the deposit
     * @param depositId The deposit id that will be drain
     */
    function _drainDeposit(User storage user, uint256 depositId)
        internal
        returns (uint256 amount, uint256 weight)
    {
        require(depositId < user.deposits.length, "Deposit does not exist");
        Deposit storage deposit = user.deposits[depositId];
        require(!deposit.isClaimed, "Deposit already claimed");
        require(
            deposit.lockedUntil <= uint64(block.timestamp),
            "Staking of this deposit is not yet complete"
        );

        amount = deposit.amount;
        weight = deposit.weight;

        // Claim deposit
        deposit.isClaimed = true;
    }

    /**
     * @notice Used to calculate and pay pending rewards to the `_staker`
     *
     * @dev When there are no rewards to calculate, function doesn't throw and exits silently
     * @dev If `rewardsLockingPeriod` is set, rewards are staked in a new deposit,
     *      otherwise they are transmitted directly to the user (as for flash pools)
     * @dev If `_withUpdate` is false, rewards MUST be updated before and user's missing rewards
     *      MUST be reset after
     * @dev Executed internally in `unstake`, `depositFor`, `updateStakeLock` and `processRewards` functions
     *
     * @param _staker Staker address
     * @param _withUpdate If we need to update rewards and user's missing rewards in this function
     *
     * @return userPendingRewards rewards calculated and optionally re-staked
     */

    function _processRewards(address _staker, bool _withUpdate)
        internal
        returns (uint256 userPendingRewards)
    {
        if (_withUpdate && canUpdateRewards()) {
            // Update rewards before use them if it hasn't been done before
            updateRewards();
        }

        userPendingRewards = pendingRewards(_staker);
        if (userPendingRewards == 0) {
            return 0;
        }

        User storage user = users[_staker];

        // If no locking/staking for rewards
        if (rewardsLockingPeriod == 0) {
            // transfer tokens for user
            rewardToken.safeTransfer(_staker, userPendingRewards);
        } else {
            // Stake rewards
            uint256 weight = calculateUserWeight(
                userPendingRewards,
                rewardsLockingPeriod
            );

            uint64 lockStart = uint64(block.timestamp);
            uint64 lockEnd = lockStart + rewardsLockingPeriod;

            Deposit memory deposit = Deposit({
                amount: userPendingRewards,
                weight: weight,
                lockedFrom: lockStart,
                lockedUntil: lockEnd,
                isRewards: true,
                isClaimed: false
            });

            // Update user and total records
            user.deposits.push(deposit);
            _increaseUserRecords(user, userPendingRewards, weight, false);
        }

        user.releasedRewards = user.releasedRewards.add(userPendingRewards);
        totalProcessedRewards = totalProcessedRewards.add(userPendingRewards);

        if (_withUpdate) {
            // Reset the missingRewards of the user if it will not be done next
            user.missingRewards = weightToReward(
                user.totalWeight,
                _rewardsPerWeight
            );
        }

        emit ProcessRewards(_staker, userPendingRewards);
    }

    /**
     * @notice Used to get the range for the staking time
     * @param x1 The minimum staking time
     * @param y1 The minimum weight time
     * @param x2 The maximum staking time
     * @param y2 The maximum weight time
     * @param a The actual staking time
     */
    function _getRange(
        uint256 x1,
        uint256 y1,
        uint256 x2,
        uint256 y2,
        uint256 a
    ) internal pure returns (uint256) {
        return y1.add(a.sub(x1).mul(y2.sub(y1)).div(x2.sub(x1)));
    }
}

File 2 of 10 : MechaniumCanReleaseUnintendedOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./IMechaniumCanReleaseUnintendedOwnable.sol";

/**
 * @title MechaniumCanReleaseUnintendedOwnable - Abstract class for util can release unintended tokens smart contract
 * @author EthernalHorizons - <https://ethernalhorizons.com/>
 * @custom:project-website  https://mechachain.io/
 * @custom:security-contact [email protected]
 */
abstract contract MechaniumCanReleaseUnintendedOwnable is
    Ownable,
    IMechaniumCanReleaseUnintendedOwnable
{
    using SafeERC20 for IERC20;

    /**
     * @notice Event emitted when release unintended `amount` of `token` for `account` address
     */
    event ReleaseUintentedTokens(
        address indexed token,
        address indexed account,
        uint256 amount
    );

    /// Locked tokens that can't be released for contract
    mapping(address => bool) private _lockedTokens;

    /// fallback payable function ( used to receive ETH in tests )
    fallback() external payable {}

    /// receive payable function ( used to receive ETH in tests )
    receive() external payable {}

    /**
     * @notice Add a locked `token_` ( can't be released )
     */
    function _addLockedToken(address token_) internal {
        _lockedTokens[token_] = true;
    }

    /**
     * @notice Release an `amount` of `token` to an `account`
     * This function is used to prevent unintended tokens that got sent to be stuck on the contract
     * @param token The address of the token contract (zero address for claiming native coins).
     * @param account The address of the tokens/coins receiver.
     * @param amount Amount to claim.
     */
    function releaseUnintended(
        address token,
        address account,
        uint256 amount
    ) public override onlyOwner returns (bool) {
        require(amount > 0, "Amount must be superior to zero");
        require(
            account != address(0) && account != address(this),
            "Amount must be superior to zero"
        );
        require(!_lockedTokens[token], "Token can't be released");

        if (token == address(0)) {
            require(
                address(this).balance >= amount,
                "Address: insufficient balance"
            );
            (bool success, ) = account.call{value: amount}("");
            require(
                success,
                "Address: unable to send value, recipient may have reverted"
            );
        } else {
            IERC20 customToken = IERC20(token);
            require(
                customToken.balanceOf(address(this)) >= amount,
                "Address: insufficient balance"
            );
            customToken.safeTransfer(account, amount);
        }

        emit ReleaseUintentedTokens(token, account, amount);

        return true;
    }
}

File 3 of 10 : IMechaniumCanReleaseUnintendedOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

/**
 * @dev Mechanium can release unintended ( ownable ) smart contract interface
 * @author EthernalHorizons - <https://ethernalhorizons.com/>
 * @custom:project-website  https://mechachain.io/
 * @custom:security-contact [email protected]
 */
interface IMechaniumCanReleaseUnintendedOwnable {
    /**
     * @dev Release unintended tokens sent to smart contract ( only owner )
     * This function is used to prevent unintended tokens that got sent to be stuck on the contract
     * @param token The address of the token contract (zero address for claiming native coins).
     * @param account The address of the tokens/coins receiver.
     * @param amount Amount to claim.
     */
    function releaseUnintended(
        address token,
        address account,
        uint256 amount
    ) external returns (bool);
}

File 4 of 10 : IMechaniumStakingPool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

/**
 * @title Staking pool smart contract interface
 * @author EthernalHorizons - <https://ethernalhorizons.com/>
 * @custom:project-website  https://mechachain.io/
 * @custom:security-contact [email protected]
 */
interface IMechaniumStakingPool {
    struct User {
        uint256 totalStaked;
        uint256 totalWeight;
        uint256 missingRewards;
        uint256 releasedRewards;
        Deposit[] deposits;
    }

    struct Deposit {
        uint256 amount;
        uint256 weight;
        uint64 lockedFrom;
        uint64 lockedUntil;
        bool isRewards;
        bool isClaimed;
    }

    /**
     * @notice Used to stake an `amount` of tokens for a `lockPeriod` for the `msg.sender`
     */
    function stake(uint256 amount, uint64 lockPeriod) external returns (bool);

    /**
     * @notice Used to stake an `amount` of tokens for a `lockPeriod` for an `account`
     */
    function depositFor(
        address account,
        uint256 amount,
        uint256 lockPeriod
    ) external returns (bool);

    /**
     * @notice Used to calculate and pay pending rewards to the `msg.sender`
     */
    function processRewards() external returns (uint256);

    /**
     * @notice Used to unstake several deposits for the `msg.sender`
     */
    function unstake(uint256[] memory depositIds) external returns (bool);

    /**
     * @notice Used to unstake a `depositId` for the `msg.sender`
     */
    function unstake(uint256 depositId) external returns (bool);

    /**
     * @notice Used to update the rewards per weight and the total rewards
     */
    function updateRewards() external returns (bool);

    /**
     * @notice Used to change the rewardsPerBlock
     */
    function setRewardsPerBlock(uint256 rewardsPerBlock)
        external
        returns (bool);

    /**
     * @notice Used to get the remaining allocated tokens
     */
    function remainingAllocatedTokens() external returns (uint256);

    /**
     * @notice Used to get the pending rewards for an `account`
     */
    function pendingRewards(address account) external returns (uint256);

    /**
     * @notice Can we call the rewards function or is it useless and will cause an error
     */
    function canUpdateRewards() external returns (bool);

    /**
     * @notice Used to get the balance for an `account`
     */
    function balanceOf(address account) external returns (uint256);

    /**
     * @notice Used to get the deposit (`depositId`) for an `account`
     */
    function getDeposit(address account, uint256 depositId)
        external
        returns (Deposit memory);

    /**
     * @notice Used to get the length of deposits for an `account`
     */
    function getDepositsLength(address account) external returns (uint256);

    /**
     * @notice Used to get the User data for an `account`
     */
    function getUser(address account) external returns (User memory);

    /**
     * @notice Get the updated rewards
     */
    function updatedRewards() external returns (uint256);

    /**
     * @notice Get the total updated rewards
     */
    function updatedTotalRewards() external returns (uint256);

    /**
     * @notice Get the updated rewards per weight
     */
    function updatedRewardsPerWeight() external returns (uint256);

    /**
     * @notice Calculate the weight based on `amount` and `stakingTime`
     */
    function calculateUserWeight(uint256 amount, uint64 stakingTime)
        external
        returns (uint256);

    /**
     * @notice Converts stake weight to reward value, applying the division on weight
     */
    function weightToReward(uint256 _weight, uint256 _rewardsPerWeight)
        external
        returns (uint256);
}

File 5 of 10 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 10 : 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 7 of 10 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev 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) {
        require(isContract(target), "Address: delegate call to non-contract");

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

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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 9 of 10 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

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

File 10 of 10 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20","name":"stakedToken_","type":"address"},{"internalType":"contract IERC20","name":"rewardToken_","type":"address"},{"internalType":"uint32","name":"initBlock_","type":"uint32"},{"internalType":"uint64","name":"minStakingTime_","type":"uint64"},{"internalType":"uint64","name":"maxStakingTime_","type":"uint64"},{"internalType":"uint16","name":"minWeightMultiplier_","type":"uint16"},{"internalType":"uint16","name":"maxWeightMultiplier_","type":"uint16"},{"internalType":"uint64","name":"rewardsLockingPeriod_","type":"uint64"},{"internalType":"uint256","name":"rewardsPerBlock_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"}],"name":"ProcessRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReleaseUintentedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rewardsPerBlock","type":"uint256"}],"name":"RewardsPerBlockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_rewardsPerWeight","type":"uint256"}],"name":"RewardsPerWeightUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"lockPeriod","type":"uint64"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"lockPeriod","type":"uint64"}],"name":"StakeLockUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"Unstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"depositIds","type":"uint256[]"}],"name":"Unstake","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"WEIGHT_MULTIPLIER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"stakingTime","type":"uint64"}],"name":"calculateUserWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canUpdateRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"lockPeriod","type":"uint256"}],"name":"depositFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"getDeposit","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"weight","type":"uint256"},{"internalType":"uint64","name":"lockedFrom","type":"uint64"},{"internalType":"uint64","name":"lockedUntil","type":"uint64"},{"internalType":"bool","name":"isRewards","type":"bool"},{"internalType":"bool","name":"isClaimed","type":"bool"}],"internalType":"struct IMechaniumStakingPool.Deposit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getDepositsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getUser","outputs":[{"components":[{"internalType":"uint256","name":"totalStaked","type":"uint256"},{"internalType":"uint256","name":"totalWeight","type":"uint256"},{"internalType":"uint256","name":"missingRewards","type":"uint256"},{"internalType":"uint256","name":"releasedRewards","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"weight","type":"uint256"},{"internalType":"uint64","name":"lockedFrom","type":"uint64"},{"internalType":"uint64","name":"lockedUntil","type":"uint64"},{"internalType":"bool","name":"isRewards","type":"bool"},{"internalType":"bool","name":"isClaimed","type":"bool"}],"internalType":"struct IMechaniumStakingPool.Deposit[]","name":"deposits","type":"tuple[]"}],"internalType":"struct IMechaniumStakingPool.User","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initBlock","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRewardsUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxStakingTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWeightMultiplier","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minStakingTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minWeightMultiplier","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"processRewards","outputs":[{"internalType":"uint256","name":"userPendingRewards","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"releaseUnintended","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"remainingAllocatedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsLockingPeriod","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardsPerBlock_","type":"uint256"}],"name":"setRewardsPerBlock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"lockPeriod","type":"uint64"}],"name":"stake","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakedToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalProcessedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTokensStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalUsersWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"unstake","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"depositIds","type":"uint256[]"}],"name":"unstake","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updatedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updatedRewardsPerWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updatedTotalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"users","outputs":[{"internalType":"uint256","name":"totalStaked","type":"uint256"},{"internalType":"uint256","name":"totalWeight","type":"uint256"},{"internalType":"uint256","name":"missingRewards","type":"uint256"},{"internalType":"uint256","name":"releasedRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"weight_","type":"uint256"},{"internalType":"uint256","name":"rewardsPerWeight_","type":"uint256"}],"name":"weightToReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101a060405264e8d4a51000610180523480156200001c57600080fd5b5060405162003242380380620032428339810160408190526200003f9162000526565b6200004a336200048e565b60008111620000a05760405162461bcd60e51b815260206004820152601560248201527f526577617264732063616e2774206265206e756c6c000000000000000000000060448201526064015b60405180910390fd5b60008461ffff1611620001005760405162461bcd60e51b815260206004820152602160248201527f6d696e5765696768744d756c7469706c6965722063616e2774206265206e756c6044820152601b60fa1b606482015260840162000097565b846001600160401b0316866001600160401b031611156200018a5760405162461bcd60e51b815260206004820152603360248201527f6d696e5374616b696e6754696d652063616e277420626520677265617465722060448201527f7468616e206d61785374616b696e6754696d6500000000000000000000000000606482015260840162000097565b8261ffff168461ffff1611156200020a5760405162461bcd60e51b815260206004820152603d60248201527f6d696e5765696768744d756c7469706c6965722063616e27742062652067726560448201527f61746572207468616e206d61785765696768744d756c7469706c696572000000606482015260840162000097565b876001600160a01b0316896001600160a01b031614806200023257506001600160401b038216155b620002885760405162461bcd60e51b815260206004820152603060248201526000805160206200322283398151915260448201526f20666f7220666c61736820706f6f6c7360801b606482015260840162000097565b6001600160401b0382161580620002b15750856001600160401b0316826001600160401b031610155b620003145760405162461bcd60e51b815260206004820152603d60248201526000805160206200322283398151915260448201527f206f72206c6f776572207468616e206d696e5374616b696e6754696d65000000606482015260840162000097565b6001600160401b03821615806200033d5750846001600160401b0316826001600160401b031611155b620003a05760405162461bcd60e51b815260206004820152603f60248201526000805160206200322283398151915260448201527f206f722067726561746572207468616e206d61785374616b696e6754696d6500606482015260840162000097565b6001600160601b031960608a811b821660805289901b1660a05263ffffffff871615620003ce5786620003d0565b435b6001600160e01b031960e091821b1660c09081526001600160c01b031984821b811690925287811b82166101005286901b16610120526001600160f01b031960f085811b82166101405284901b1661016052600281905562000453896001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b6200047f886001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b505050505050505050620005e2565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620004f657600080fd5b919050565b805161ffff81168114620004f657600080fd5b80516001600160401b0381168114620004f657600080fd5b60008060008060008060008060006101208a8c0312156200054657600080fd5b620005518a620004de565b98506200056160208b01620004de565b975060408a015163ffffffff811681146200057b57600080fd5b96506200058b60608b016200050e565b95506200059b60808b016200050e565b9450620005ab60a08b01620004fb565b9350620005bb60c08b01620004fb565b9250620005cb60e08b016200050e565b91506101008a015190509295985092959850929598565b60805160601c60a05160601c60c05160e01c60e05160c01c6101005160c01c6101205160c01c6101405160f01c6101605160f01c61018051612b166200070c6000396000818161064501528181611283015281816115600152818161189301526119640152600081816102f2015261194201526000818161052d01526118ea0152600081816107b50152818161102c015261191a01526000818161061101528181610fa301526118c201526000818161036301528181611de501528181611e4a0152611e780152600081816103e401528181610da801528181610e5601528181611b5b0152611b9a01526000818161076c015281816116cd0152818161182a01528181611c120152611e1601526000818161067901528181610d3601526110e60152612b166000f3fe6080604052600436106102115760003560e01c8063952e68cf11610117578063d4bc8e01116100a5578063f2fde38b1161006c578063f2fde38b14610725578063f77ecb6d14610745578063f7c618c11461075a578063f9fc0d071461078e578063ff270039146107a357005b8063d4bc8e011461069b578063e449f341146106b0578063e45c9194146106d0578063e874db13146106f0578063e8d3cad51461070557005b8063b0e31b2d116100e9578063b0e31b2d146105d3578063b501f70c146105e9578063c057eca7146105ff578063c290d8bd14610633578063cc7a262e1461066757005b8063952e68cf146104fb57806397875eec1461051b578063a1003b291461054f578063a87430ba1461056f57005b80634cf5fbf51161019f5780636f77926b116101665780636f77926b1461044757806370a0823114610474578063715018a6146104945780638da5cb5b146104a95780638e169d47146104db57005b80634cf5fbf51461039d5780634ff5ba72146103bd5780635d05125b146103d25780635eeb67101461041b5780636dbd26fd1461043157005b806331d7a262116101e357806331d7a262146102c05780633cf783c4146102e05780633cf8b6b3146103275780633e158b0c1461033c578063469e243b1461035157005b80630bb1a59e1461021a5780632726b5061461024357806327ecfdf6146102705780632e17de78146102a057005b3661021857005b005b34801561022657600080fd5b5061023060075481565b6040519081526020015b60405180910390f35b34801561024f57600080fd5b5061026361025e366004612602565b6107d7565b60405161023a91906128dd565b34801561027c57600080fd5b5061029061028b3660046125c6565b610982565b604051901515815260200161023a565b3480156102ac57600080fd5b506102906102bb366004612745565b610cd7565b3480156102cc57600080fd5b506102306102db3660046125ab565b610da4565b3480156102ec57600080fd5b506103147f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff909116815260200161023a565b34801561033357600080fd5b50610290610e4f565b34801561034857600080fd5b50610290610e7c565b34801561035d57600080fd5b506103857f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160401b03909116815260200161023a565b3480156103a957600080fd5b506102906103b836600461262c565b610f31565b3480156103c957600080fd5b50610230611270565b3480156103de57600080fd5b506104067f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff909116815260200161023a565b34801561042757600080fd5b5061023060025481565b34801561043d57600080fd5b5061023060045481565b34801561045357600080fd5b506104676104623660046125ab565b6112e1565b60405161023a91906128eb565b34801561048057600080fd5b5061023061048f3660046125ab565b611411565b3480156104a057600080fd5b50610218611523565b3480156104b557600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161023a565b3480156104e757600080fd5b506102306104f6366004612777565b611559565b34801561050757600080fd5b50610290610516366004612799565b61158f565b34801561052757600080fd5b506103147f000000000000000000000000000000000000000000000000000000000000000081565b34801561055b57600080fd5b5061029061056a366004612745565b6115b1565b34801561057b57600080fd5b506105b361058a3660046125ab565b600360208190526000918252604090912080546001820154600283015492909301549092919084565b60408051948552602085019390935291830152606082015260800161023a565b3480156105df57600080fd5b5061023060055481565b3480156105f557600080fd5b5061023060065481565b34801561060b57600080fd5b506103857f000000000000000000000000000000000000000000000000000000000000000081565b34801561063f57600080fd5b506102307f000000000000000000000000000000000000000000000000000000000000000081565b34801561067357600080fd5b506104c37f000000000000000000000000000000000000000000000000000000000000000081565b3480156106a757600080fd5b506102306116ab565b3480156106bc57600080fd5b506102906106cb36600461265f565b611775565b3480156106dc57600080fd5b506102306106eb366004612799565b61188c565b3480156106fc57600080fd5b5061023061199e565b34801561071157600080fd5b506102306107203660046125ab565b6119b5565b34801561073157600080fd5b506102186107403660046125ab565b611abc565b34801561075157600080fd5b50610230611b57565b34801561076657600080fd5b506104c37f000000000000000000000000000000000000000000000000000000000000000081565b34801561079a57600080fd5b50610230611ccb565b3480156107af57600080fd5b506103857f000000000000000000000000000000000000000000000000000000000000000081565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091526001600160a01b0383166000908152600360208181526040808420815160a08101835281548152600182015481850152600282015481840152938101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156108f85760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a0830152908352909201910161086e565b5050505081525050905080608001515183106109545760405162461bcd60e51b815260206004820152601660248201527511195c1bdcda5d08191bd95cc81b9bdd08195e1a5cdd60521b60448201526064015b60405180910390fd5b60008160800151848151811061096c5761096c612ab4565b6020026020010151905080925050505b92915050565b600080546001600160a01b031633146109ad5760405162461bcd60e51b815260040161094b90612871565b600082116109cd5760405162461bcd60e51b815260040161094b906128a6565b6001600160a01b038316158015906109ee57506001600160a01b0383163014155b610a0a5760405162461bcd60e51b815260040161094b906128a6565b6001600160a01b03841660009081526001602052604090205460ff1615610a735760405162461bcd60e51b815260206004820152601760248201527f546f6b656e2063616e27742062652072656c6561736564000000000000000000604482015260640161094b565b6001600160a01b038416610ba05781471015610ad15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161094b565b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114610b1e576040519150601f19603f3d011682016040523d82523d6000602084013e610b23565b606091505b5050905080610b9a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161094b565b50610c7f565b6040516370a0823160e01b8152306004820152849083906001600160a01b038316906370a082319060240160206040518083038186803b158015610be357600080fd5b505afa158015610bf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1b919061275e565b1015610c695760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161094b565b610c7d6001600160a01b0382168585611d22565b505b826001600160a01b0316846001600160a01b03167f0f3627ee427649d0bea7197dde90c68a6b9f91b96b1c52256bfe45620c53841784604051610cc491815260200190565b60405180910390a35060015b9392505050565b6000610ce1610e4f565b15610cf057610cee610e7c565b505b610cfb336000611d8a565b503360009081526003602052604081209080610d178386612000565b91509150610d288383836001612179565b50610d5d6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163384611d22565b604080518381526020810187905233917ff960dbf9e5d0682f7a298ed974e33a28b4464914b7a2bfac12ae419a9afeb28091015b60405180910390a2506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff16431080610df057506001600160a01b038216600090815260036020526040902054155b15610dfd57506000919050565b6001600160a01b038216600090815260036020526040812060010154610e25906104f6611270565b6001600160a01b038416600090815260036020526040902060020154909150610cd09082906121e5565b63ffffffff7f00000000000000000000000000000000000000000000000000000000000000001643101590565b6000610e86610e4f565b610ed25760405162461bcd60e51b815260206004820152601860248201527f696e6974426c6f636b206973206e6f7420726561636865640000000000000000604482015260640161094b565b60045415610ef157610ee2611270565b600955610eed61199e565b6008555b436007556009546040519081527faac1802288db8019f8ec43430efc11a152c72473c57d6ddcde3b6dd0c89260679060200160405180910390a150600190565b60006001600160a01b038416610f815760405162461bcd60e51b8152602060048201526015602482015274041646472657373206d757374206e6f74206265203605c1b604482015260640161094b565b60008311610fa15760405162461bcd60e51b815260040161094b906128a6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b031682101561102a5760405162461bcd60e51b815260206004820152602760248201527f5374616b696e672074696d65206c657373207468616e206d696e696d756d2072604482015266195c5d5a5c995960ca1b606482015260840161094b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03168211156110b65760405162461bcd60e51b815260206004820152602a60248201527f5374616b696e672074696d652067726561746572207468616e206d6178696d756044820152691b481c995c5d5a5c995960b21b606482015260840161094b565b6110be610e4f565b156110cd576110cb610e7c565b505b6110d8846000611d8a565b5061110e6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330866121f1565b6001600160a01b0384166000908152600360205260408120908390611133868361188c565b905042600061114284836129d4565b6040805160c0810182528a815260208082018781526001600160401b038088169484019485528086166060850190815260006080860181815260a0870182815260048f018054600181810183559185529790932088516003909802019687559451868301559651600290950180549251975194511515600160881b0260ff60881b19951515600160801b029590951661ffff60801b19988516600160401b026001600160801b031990941696909416959095179190911795909516171790559192506112139087908b90879061222f565b50604080518a81526001600160401b03871660208201526001600160a01b038c16917f3cde85058f06453cc8659ddf48d7e85206077357e9438a4abd2bdd431534e62b910160405180910390a25060019998505050505050505050565b60008061127b611b57565b90506112a7817f000000000000000000000000000000000000000000000000000000000000000061228d565b905060006112ca6000600454116112bf5760016112c3565b6004545b8390612299565b9050610cd0600954826122a590919063ffffffff16565b6113136040518060a0016040528060008152602001600081526020016000815260200160008152602001606081525090565b6001600160a01b0382166000908152600360208181526040808420815160a08101835281548152600182015481850152600282015481840152938101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156114025760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a08301529083529092019101611378565b50505091525090949350505050565b6001600160a01b0381166000908152600360208181526040808420815160a081018352815481526001820154818501526002820154818401529381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156115055760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a0830152908352909201910161147b565b50505050815250509050610cd061151b84610da4565b8251906122a5565b6000546001600160a01b0316331461154d5760405162461bcd60e51b815260040161094b90612871565b61155760006122b1565b565b6000610cd07f0000000000000000000000000000000000000000000000000000000000000000611589858561228d565b90612299565b6000336115a681856001600160401b038616610f31565b506001949350505050565b600080546001600160a01b031633146115dc5760405162461bcd60e51b815260040161094b90612871565b60025482116116535760405162461bcd60e51b815260206004820152603760248201527f526577617264732070657220626c6f636b206d7573742062652067726561746560448201527f72207468616e207468652070726576696f7573206f6e65000000000000000000606482015260840161094b565b61165b610e4f565b1561166a57611668610e7c565b505b60028290556040518281527f64ce1148dc754b3cc682da18ae39ef60846a2f5b66c1a99999d8f4991afc0bb89060200160405180910390a15060015b919050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611747919061275e565b90506000610cd061176e60065461176861175f61199e565b600554906122a5565b906121e5565b83906121e5565b600061177f610e4f565b1561178e5761178c610e7c565b505b611799336000611d8a565b503360009081526003602052604081209080805b855181101561180e576000806117dc868985815181106117cf576117cf612ab4565b6020026020010151612000565b90925090506117eb85836122a5565b94506117f784826122a5565b93505050808061180690612a83565b9150506117ad565b5061181c8383836001612179565b506118516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163384611d22565b336001600160a01b03167fe69f2c813fbacdba640c6e65761e2d4b772375f2fbe475137078d3ed850aff578387604051610d9192919061296e565b6000610cd07f00000000000000000000000000000000000000000000000000000000000000006115896119976001600160401b037f00000000000000000000000000000000000000000000000000000000000000001661191061ffff7f0000000000000000000000000000000000000000000000000000000000000000168561228d565b6001600160401b037f00000000000000000000000000000000000000000000000000000000000000001661198861ffff7f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000061228d565b896001600160401b0316612301565b869061228d565b60008061097c6119ac611b57565b600854906122a5565b6001600160a01b0381166000908152600360208181526040808420815160a081018352815481526001820154818501526002820154818401529381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b82821015611aa95760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a08301529083529092019101611a1f565b5050509152505060800151519392505050565b6000546001600160a01b03163314611ae65760405162461bcd60e51b815260040161094b90612871565b6001600160a01b038116611b4b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161094b565b611b54816122b1565b50565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff16431015611b8d5750600090565b60008060075411611bc4577f000000000000000000000000000000000000000000000000000000000000000063ffffffff16611bc8565b6007545b90506000611bd643836121e5565b90506000611bef6002548361228d90919063ffffffff16565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b158015611c5457600080fd5b505afa158015611c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8c919061275e565b90506000611cb061176e6006546117686008546005546122a590919063ffffffff16565b9050808311611cbf5782611cc1565b805b9550505050505090565b6000611cd8336001611d8a565b905080611d1f5760405162461bcd60e51b81526020600482015260156024820152744e6f207265776172647320746f2070726f6365737360581b604482015260640161094b565b90565b6040516001600160a01b038316602482015260448101829052611d8590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612341565b505050565b6000818015611d9c5750611d9c610e4f565b15611dab57611da9610e7c565b505b611db483610da4565b905080611dc35750600061097c565b6001600160a01b03831660009081526003602052604090206001600160401b037f000000000000000000000000000000000000000000000000000000000000000016611e4257611e3d6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168584611d22565b611f76565b6000611e6e837f000000000000000000000000000000000000000000000000000000000000000061188c565b9050426000611e9d7f0000000000000000000000000000000000000000000000000000000000000000836129d4565b6040805160c08101825287815260208082018781526001600160401b0380881694840194855280861660608501908152600160808601818152600060a0880181815260048f018054808601825590835297822089516003909902019788559551928701929092559651600290950180549251975194511515600160881b0260ff60881b19951515600160801b029590951661ffff60801b19988516600160401b026001600160801b03199094169690941695909517919091179590951617179055919250611f709086908890879061222f565b50505050505b6003810154611f8590836122a5565b6003820155600654611f9790836122a5565b6006558215611fb657611fb08160010154600954611559565b60028201555b836001600160a01b03167ffbeb7414ce0271b4dc3473d7183104ee328d3e6a1083c1132ae875828544123783604051611ff191815260200190565b60405180910390a25092915050565b6004820154600090819083106120515760405162461bcd60e51b815260206004820152601660248201527511195c1bdcda5d08191bd95cc81b9bdd08195e1a5cdd60521b604482015260640161094b565b600084600401848154811061206857612068612ab4565b906000526020600020906003020190508060020160119054906101000a900460ff16156120d75760405162461bcd60e51b815260206004820152601760248201527f4465706f73697420616c726561647920636c61696d6564000000000000000000604482015260640161094b565b60028101546001600160401b03428116600160401b9092041611156121525760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e67206f662074686973206465706f736974206973206e6f74207960448201526a657420636f6d706c65746560a81b606482015260840161094b565b805460018201546002909201805460ff60881b1916600160881b1790559590945092505050565b835460009061218890856121e5565b8555600185015461219990846121e5565b600186015581156121ba576121b48560010154600954611559565b60028601555b6004546121c790846121e5565b6004556005546121d790856121e5565b600555506001949350505050565b6000610cd08284612a40565b6040516001600160a01b03808516602483015283166044820152606481018290526122299085906323b872dd60e01b90608401611d4e565b50505050565b835460009061223e90856122a5565b8555600185015461224f90846122a5565b600186015581156122705761226a8560010154600954611559565b60028601555b60045461227d90846122a5565b6004556005546121d790856122a5565b6000610cd08284612a21565b6000610cd082846129ff565b6000610cd082846129bc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061233761233061231386896121e5565b611589612320878a6121e5565b61232a878c6121e5565b9061228d565b86906122a5565b9695505050505050565b6000612396826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124139092919063ffffffff16565b805190915015611d8557808060200190518101906123b49190612723565b611d855760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161094b565b6060612422848460008561242a565b949350505050565b60608247101561248b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161094b565b6001600160a01b0385163b6124e25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161094b565b600080866001600160a01b031685876040516124fe9190612822565b60006040518083038185875af1925050503d806000811461253b576040519150601f19603f3d011682016040523d82523d6000602084013e612540565b606091505b509150915061255082828661255b565b979650505050505050565b6060831561256a575081610cd0565b82511561257a5782518084602001fd5b8160405162461bcd60e51b815260040161094b919061283e565b80356001600160a01b03811681146116a657600080fd5b6000602082840312156125bd57600080fd5b610cd082612594565b6000806000606084860312156125db57600080fd5b6125e484612594565b92506125f260208501612594565b9150604084013590509250925092565b6000806040838503121561261557600080fd5b61261e83612594565b946020939093013593505050565b60008060006060848603121561264157600080fd5b61264a84612594565b95602085013595506040909401359392505050565b6000602080838503121561267257600080fd5b82356001600160401b038082111561268957600080fd5b818501915085601f83011261269d57600080fd5b8135818111156126af576126af612aca565b8060051b604051601f19603f830116810181811085821117156126d4576126d4612aca565b604052828152858101935084860182860187018a10156126f357600080fd5b600095505b838610156127165780358552600195909501949386019386016126f8565b5098975050505050505050565b60006020828403121561273557600080fd5b81518015158114610cd057600080fd5b60006020828403121561275757600080fd5b5035919050565b60006020828403121561277057600080fd5b5051919050565b6000806040838503121561278a57600080fd5b50508035926020909101359150565b600080604083850312156127ac57600080fd5b8235915060208301356001600160401b03811681146127ca57600080fd5b809150509250929050565b805182526020810151602083015260408101516001600160401b038082166040850152806060840151166060850152505060808101511515608083015260a0810151151560a08301525050565b60008251612834818460208701612a57565b9190910192915050565b602081526000825180602084015261285d816040850160208701612a57565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f416d6f756e74206d757374206265207375706572696f7220746f207a65726f00604082015260600190565b60c0810161097c82846127d5565b6000602080835260c08084018551838601528286015160408601526040860151606086015260608601516080860152608086015160a08087015281815180845260e0880191508583019350600092505b808310156129625761294e8285516127d5565b92850192600192909201919084019061293b565b50979650505050505050565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156129af57845183529383019391830191600101612993565b5090979650505050505050565b600082198211156129cf576129cf612a9e565b500190565b60006001600160401b038083168185168083038211156129f6576129f6612a9e565b01949350505050565b600082612a1c57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612a3b57612a3b612a9e565b500290565b600082821015612a5257612a52612a9e565b500390565b60005b83811015612a72578181015183820152602001612a5a565b838111156122295750506000910152565b6000600019821415612a9757612a97612a9e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea264697066735822122018aadb8d1c0a8d5d90895db9afdf3334e1b5a3632f0d69885d5115d539fa751964736f6c6343000807003352657761726473206c6f636b696e6720706572696f64206d7573742062652030000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa00000000000000000000000000000000000000000000000000000000018dcfbc000000000000000000000000000000000000000000000000000000000076a7000000000000000000000000000000000000000000000000000000000002514300000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000ed4e00000000000000000000000000000000000000000000000000031f8b17b50357d0

Deployed Bytecode

0x6080604052600436106102115760003560e01c8063952e68cf11610117578063d4bc8e01116100a5578063f2fde38b1161006c578063f2fde38b14610725578063f77ecb6d14610745578063f7c618c11461075a578063f9fc0d071461078e578063ff270039146107a357005b8063d4bc8e011461069b578063e449f341146106b0578063e45c9194146106d0578063e874db13146106f0578063e8d3cad51461070557005b8063b0e31b2d116100e9578063b0e31b2d146105d3578063b501f70c146105e9578063c057eca7146105ff578063c290d8bd14610633578063cc7a262e1461066757005b8063952e68cf146104fb57806397875eec1461051b578063a1003b291461054f578063a87430ba1461056f57005b80634cf5fbf51161019f5780636f77926b116101665780636f77926b1461044757806370a0823114610474578063715018a6146104945780638da5cb5b146104a95780638e169d47146104db57005b80634cf5fbf51461039d5780634ff5ba72146103bd5780635d05125b146103d25780635eeb67101461041b5780636dbd26fd1461043157005b806331d7a262116101e357806331d7a262146102c05780633cf783c4146102e05780633cf8b6b3146103275780633e158b0c1461033c578063469e243b1461035157005b80630bb1a59e1461021a5780632726b5061461024357806327ecfdf6146102705780632e17de78146102a057005b3661021857005b005b34801561022657600080fd5b5061023060075481565b6040519081526020015b60405180910390f35b34801561024f57600080fd5b5061026361025e366004612602565b6107d7565b60405161023a91906128dd565b34801561027c57600080fd5b5061029061028b3660046125c6565b610982565b604051901515815260200161023a565b3480156102ac57600080fd5b506102906102bb366004612745565b610cd7565b3480156102cc57600080fd5b506102306102db3660046125ab565b610da4565b3480156102ec57600080fd5b506103147f000000000000000000000000000000000000000000000000000000000000000381565b60405161ffff909116815260200161023a565b34801561033357600080fd5b50610290610e4f565b34801561034857600080fd5b50610290610e7c565b34801561035d57600080fd5b506103857f0000000000000000000000000000000000000000000000000000000000ed4e0081565b6040516001600160401b03909116815260200161023a565b3480156103a957600080fd5b506102906103b836600461262c565b610f31565b3480156103c957600080fd5b50610230611270565b3480156103de57600080fd5b506104067f00000000000000000000000000000000000000000000000000000000018dcfbc81565b60405163ffffffff909116815260200161023a565b34801561042757600080fd5b5061023060025481565b34801561043d57600080fd5b5061023060045481565b34801561045357600080fd5b506104676104623660046125ab565b6112e1565b60405161023a91906128eb565b34801561048057600080fd5b5061023061048f3660046125ab565b611411565b3480156104a057600080fd5b50610218611523565b3480156104b557600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161023a565b3480156104e757600080fd5b506102306104f6366004612777565b611559565b34801561050757600080fd5b50610290610516366004612799565b61158f565b34801561052757600080fd5b506103147f000000000000000000000000000000000000000000000000000000000000000181565b34801561055b57600080fd5b5061029061056a366004612745565b6115b1565b34801561057b57600080fd5b506105b361058a3660046125ab565b600360208190526000918252604090912080546001820154600283015492909301549092919084565b60408051948552602085019390935291830152606082015260800161023a565b3480156105df57600080fd5b5061023060055481565b3480156105f557600080fd5b5061023060065481565b34801561060b57600080fd5b506103857f000000000000000000000000000000000000000000000000000000000076a70081565b34801561063f57600080fd5b506102307f000000000000000000000000000000000000000000000000000000e8d4a5100081565b34801561067357600080fd5b506104c37f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa81565b3480156106a757600080fd5b506102306116ab565b3480156106bc57600080fd5b506102906106cb36600461265f565b611775565b3480156106dc57600080fd5b506102306106eb366004612799565b61188c565b3480156106fc57600080fd5b5061023061199e565b34801561071157600080fd5b506102306107203660046125ab565b6119b5565b34801561073157600080fd5b506102186107403660046125ab565b611abc565b34801561075157600080fd5b50610230611b57565b34801561076657600080fd5b506104c37f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa81565b34801561079a57600080fd5b50610230611ccb565b3480156107af57600080fd5b506103857f000000000000000000000000000000000000000000000000000000000251430081565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091526001600160a01b0383166000908152600360208181526040808420815160a08101835281548152600182015481850152600282015481840152938101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156108f85760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a0830152908352909201910161086e565b5050505081525050905080608001515183106109545760405162461bcd60e51b815260206004820152601660248201527511195c1bdcda5d08191bd95cc81b9bdd08195e1a5cdd60521b60448201526064015b60405180910390fd5b60008160800151848151811061096c5761096c612ab4565b6020026020010151905080925050505b92915050565b600080546001600160a01b031633146109ad5760405162461bcd60e51b815260040161094b90612871565b600082116109cd5760405162461bcd60e51b815260040161094b906128a6565b6001600160a01b038316158015906109ee57506001600160a01b0383163014155b610a0a5760405162461bcd60e51b815260040161094b906128a6565b6001600160a01b03841660009081526001602052604090205460ff1615610a735760405162461bcd60e51b815260206004820152601760248201527f546f6b656e2063616e27742062652072656c6561736564000000000000000000604482015260640161094b565b6001600160a01b038416610ba05781471015610ad15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161094b565b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114610b1e576040519150601f19603f3d011682016040523d82523d6000602084013e610b23565b606091505b5050905080610b9a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161094b565b50610c7f565b6040516370a0823160e01b8152306004820152849083906001600160a01b038316906370a082319060240160206040518083038186803b158015610be357600080fd5b505afa158015610bf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1b919061275e565b1015610c695760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161094b565b610c7d6001600160a01b0382168585611d22565b505b826001600160a01b0316846001600160a01b03167f0f3627ee427649d0bea7197dde90c68a6b9f91b96b1c52256bfe45620c53841784604051610cc491815260200190565b60405180910390a35060015b9392505050565b6000610ce1610e4f565b15610cf057610cee610e7c565b505b610cfb336000611d8a565b503360009081526003602052604081209080610d178386612000565b91509150610d288383836001612179565b50610d5d6001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa163384611d22565b604080518381526020810187905233917ff960dbf9e5d0682f7a298ed974e33a28b4464914b7a2bfac12ae419a9afeb28091015b60405180910390a2506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000018dcfbc63ffffffff16431080610df057506001600160a01b038216600090815260036020526040902054155b15610dfd57506000919050565b6001600160a01b038216600090815260036020526040812060010154610e25906104f6611270565b6001600160a01b038416600090815260036020526040902060020154909150610cd09082906121e5565b63ffffffff7f00000000000000000000000000000000000000000000000000000000018dcfbc1643101590565b6000610e86610e4f565b610ed25760405162461bcd60e51b815260206004820152601860248201527f696e6974426c6f636b206973206e6f7420726561636865640000000000000000604482015260640161094b565b60045415610ef157610ee2611270565b600955610eed61199e565b6008555b436007556009546040519081527faac1802288db8019f8ec43430efc11a152c72473c57d6ddcde3b6dd0c89260679060200160405180910390a150600190565b60006001600160a01b038416610f815760405162461bcd60e51b8152602060048201526015602482015274041646472657373206d757374206e6f74206265203605c1b604482015260640161094b565b60008311610fa15760405162461bcd60e51b815260040161094b906128a6565b7f000000000000000000000000000000000000000000000000000000000076a7006001600160401b031682101561102a5760405162461bcd60e51b815260206004820152602760248201527f5374616b696e672074696d65206c657373207468616e206d696e696d756d2072604482015266195c5d5a5c995960ca1b606482015260840161094b565b7f00000000000000000000000000000000000000000000000000000000025143006001600160401b03168211156110b65760405162461bcd60e51b815260206004820152602a60248201527f5374616b696e672074696d652067726561746572207468616e206d6178696d756044820152691b481c995c5d5a5c995960b21b606482015260840161094b565b6110be610e4f565b156110cd576110cb610e7c565b505b6110d8846000611d8a565b5061110e6001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa163330866121f1565b6001600160a01b0384166000908152600360205260408120908390611133868361188c565b905042600061114284836129d4565b6040805160c0810182528a815260208082018781526001600160401b038088169484019485528086166060850190815260006080860181815260a0870182815260048f018054600181810183559185529790932088516003909802019687559451868301559651600290950180549251975194511515600160881b0260ff60881b19951515600160801b029590951661ffff60801b19988516600160401b026001600160801b031990941696909416959095179190911795909516171790559192506112139087908b90879061222f565b50604080518a81526001600160401b03871660208201526001600160a01b038c16917f3cde85058f06453cc8659ddf48d7e85206077357e9438a4abd2bdd431534e62b910160405180910390a25060019998505050505050505050565b60008061127b611b57565b90506112a7817f000000000000000000000000000000000000000000000000000000e8d4a5100061228d565b905060006112ca6000600454116112bf5760016112c3565b6004545b8390612299565b9050610cd0600954826122a590919063ffffffff16565b6113136040518060a0016040528060008152602001600081526020016000815260200160008152602001606081525090565b6001600160a01b0382166000908152600360208181526040808420815160a08101835281548152600182015481850152600282015481840152938101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156114025760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a08301529083529092019101611378565b50505091525090949350505050565b6001600160a01b0381166000908152600360208181526040808420815160a081018352815481526001820154818501526002820154818401529381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156115055760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a0830152908352909201910161147b565b50505050815250509050610cd061151b84610da4565b8251906122a5565b6000546001600160a01b0316331461154d5760405162461bcd60e51b815260040161094b90612871565b61155760006122b1565b565b6000610cd07f000000000000000000000000000000000000000000000000000000e8d4a51000611589858561228d565b90612299565b6000336115a681856001600160401b038616610f31565b506001949350505050565b600080546001600160a01b031633146115dc5760405162461bcd60e51b815260040161094b90612871565b60025482116116535760405162461bcd60e51b815260206004820152603760248201527f526577617264732070657220626c6f636b206d7573742062652067726561746560448201527f72207468616e207468652070726576696f7573206f6e65000000000000000000606482015260840161094b565b61165b610e4f565b1561166a57611668610e7c565b505b60028290556040518281527f64ce1148dc754b3cc682da18ae39ef60846a2f5b66c1a99999d8f4991afc0bb89060200160405180910390a15060015b919050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa16906370a082319060240160206040518083038186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611747919061275e565b90506000610cd061176e60065461176861175f61199e565b600554906122a5565b906121e5565b83906121e5565b600061177f610e4f565b1561178e5761178c610e7c565b505b611799336000611d8a565b503360009081526003602052604081209080805b855181101561180e576000806117dc868985815181106117cf576117cf612ab4565b6020026020010151612000565b90925090506117eb85836122a5565b94506117f784826122a5565b93505050808061180690612a83565b9150506117ad565b5061181c8383836001612179565b506118516001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa163384611d22565b336001600160a01b03167fe69f2c813fbacdba640c6e65761e2d4b772375f2fbe475137078d3ed850aff578387604051610d9192919061296e565b6000610cd07f000000000000000000000000000000000000000000000000000000e8d4a510006115896119976001600160401b037f000000000000000000000000000000000000000000000000000000000076a7001661191061ffff7f0000000000000000000000000000000000000000000000000000000000000001168561228d565b6001600160401b037f00000000000000000000000000000000000000000000000000000000025143001661198861ffff7f0000000000000000000000000000000000000000000000000000000000000003167f000000000000000000000000000000000000000000000000000000e8d4a5100061228d565b896001600160401b0316612301565b869061228d565b60008061097c6119ac611b57565b600854906122a5565b6001600160a01b0381166000908152600360208181526040808420815160a081018352815481526001820154818501526002820154818401529381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b82821015611aa95760008481526020908190206040805160c0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b8104909216606084015260ff600160801b8304811615156080850152600160881b909204909116151560a08301529083529092019101611a1f565b5050509152505060800151519392505050565b6000546001600160a01b03163314611ae65760405162461bcd60e51b815260040161094b90612871565b6001600160a01b038116611b4b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161094b565b611b54816122b1565b50565b60007f00000000000000000000000000000000000000000000000000000000018dcfbc63ffffffff16431015611b8d5750600090565b60008060075411611bc4577f00000000000000000000000000000000000000000000000000000000018dcfbc63ffffffff16611bc8565b6007545b90506000611bd643836121e5565b90506000611bef6002548361228d90919063ffffffff16565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa16906370a082319060240160206040518083038186803b158015611c5457600080fd5b505afa158015611c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8c919061275e565b90506000611cb061176e6006546117686008546005546122a590919063ffffffff16565b9050808311611cbf5782611cc1565b805b9550505050505090565b6000611cd8336001611d8a565b905080611d1f5760405162461bcd60e51b81526020600482015260156024820152744e6f207265776172647320746f2070726f6365737360581b604482015260640161094b565b90565b6040516001600160a01b038316602482015260448101829052611d8590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612341565b505050565b6000818015611d9c5750611d9c610e4f565b15611dab57611da9610e7c565b505b611db483610da4565b905080611dc35750600061097c565b6001600160a01b03831660009081526003602052604090206001600160401b037f0000000000000000000000000000000000000000000000000000000000ed4e0016611e4257611e3d6001600160a01b037f000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa168584611d22565b611f76565b6000611e6e837f0000000000000000000000000000000000000000000000000000000000ed4e0061188c565b9050426000611e9d7f0000000000000000000000000000000000000000000000000000000000ed4e00836129d4565b6040805160c08101825287815260208082018781526001600160401b0380881694840194855280861660608501908152600160808601818152600060a0880181815260048f018054808601825590835297822089516003909902019788559551928701929092559651600290950180549251975194511515600160881b0260ff60881b19951515600160801b029590951661ffff60801b19988516600160401b026001600160801b03199094169690941695909517919091179590951617179055919250611f709086908890879061222f565b50505050505b6003810154611f8590836122a5565b6003820155600654611f9790836122a5565b6006558215611fb657611fb08160010154600954611559565b60028201555b836001600160a01b03167ffbeb7414ce0271b4dc3473d7183104ee328d3e6a1083c1132ae875828544123783604051611ff191815260200190565b60405180910390a25092915050565b6004820154600090819083106120515760405162461bcd60e51b815260206004820152601660248201527511195c1bdcda5d08191bd95cc81b9bdd08195e1a5cdd60521b604482015260640161094b565b600084600401848154811061206857612068612ab4565b906000526020600020906003020190508060020160119054906101000a900460ff16156120d75760405162461bcd60e51b815260206004820152601760248201527f4465706f73697420616c726561647920636c61696d6564000000000000000000604482015260640161094b565b60028101546001600160401b03428116600160401b9092041611156121525760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e67206f662074686973206465706f736974206973206e6f74207960448201526a657420636f6d706c65746560a81b606482015260840161094b565b805460018201546002909201805460ff60881b1916600160881b1790559590945092505050565b835460009061218890856121e5565b8555600185015461219990846121e5565b600186015581156121ba576121b48560010154600954611559565b60028601555b6004546121c790846121e5565b6004556005546121d790856121e5565b600555506001949350505050565b6000610cd08284612a40565b6040516001600160a01b03808516602483015283166044820152606481018290526122299085906323b872dd60e01b90608401611d4e565b50505050565b835460009061223e90856122a5565b8555600185015461224f90846122a5565b600186015581156122705761226a8560010154600954611559565b60028601555b60045461227d90846122a5565b6004556005546121d790856122a5565b6000610cd08284612a21565b6000610cd082846129ff565b6000610cd082846129bc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061233761233061231386896121e5565b611589612320878a6121e5565b61232a878c6121e5565b9061228d565b86906122a5565b9695505050505050565b6000612396826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124139092919063ffffffff16565b805190915015611d8557808060200190518101906123b49190612723565b611d855760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161094b565b6060612422848460008561242a565b949350505050565b60608247101561248b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161094b565b6001600160a01b0385163b6124e25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161094b565b600080866001600160a01b031685876040516124fe9190612822565b60006040518083038185875af1925050503d806000811461253b576040519150601f19603f3d011682016040523d82523d6000602084013e612540565b606091505b509150915061255082828661255b565b979650505050505050565b6060831561256a575081610cd0565b82511561257a5782518084602001fd5b8160405162461bcd60e51b815260040161094b919061283e565b80356001600160a01b03811681146116a657600080fd5b6000602082840312156125bd57600080fd5b610cd082612594565b6000806000606084860312156125db57600080fd5b6125e484612594565b92506125f260208501612594565b9150604084013590509250925092565b6000806040838503121561261557600080fd5b61261e83612594565b946020939093013593505050565b60008060006060848603121561264157600080fd5b61264a84612594565b95602085013595506040909401359392505050565b6000602080838503121561267257600080fd5b82356001600160401b038082111561268957600080fd5b818501915085601f83011261269d57600080fd5b8135818111156126af576126af612aca565b8060051b604051601f19603f830116810181811085821117156126d4576126d4612aca565b604052828152858101935084860182860187018a10156126f357600080fd5b600095505b838610156127165780358552600195909501949386019386016126f8565b5098975050505050505050565b60006020828403121561273557600080fd5b81518015158114610cd057600080fd5b60006020828403121561275757600080fd5b5035919050565b60006020828403121561277057600080fd5b5051919050565b6000806040838503121561278a57600080fd5b50508035926020909101359150565b600080604083850312156127ac57600080fd5b8235915060208301356001600160401b03811681146127ca57600080fd5b809150509250929050565b805182526020810151602083015260408101516001600160401b038082166040850152806060840151166060850152505060808101511515608083015260a0810151151560a08301525050565b60008251612834818460208701612a57565b9190910192915050565b602081526000825180602084015261285d816040850160208701612a57565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f416d6f756e74206d757374206265207375706572696f7220746f207a65726f00604082015260600190565b60c0810161097c82846127d5565b6000602080835260c08084018551838601528286015160408601526040860151606086015260608601516080860152608086015160a08087015281815180845260e0880191508583019350600092505b808310156129625761294e8285516127d5565b92850192600192909201919084019061293b565b50979650505050505050565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156129af57845183529383019391830191600101612993565b5090979650505050505050565b600082198211156129cf576129cf612a9e565b500190565b60006001600160401b038083168185168083038211156129f6576129f6612a9e565b01949350505050565b600082612a1c57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612a3b57612a3b612a9e565b500290565b600082821015612a5257612a52612a9e565b500390565b60005b83811015612a72578181015183820152602001612a5a565b838111156122295750506000910152565b6000600019821415612a9757612a97612a9e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea264697066735822122018aadb8d1c0a8d5d90895db9afdf3334e1b5a3632f0d69885d5115d539fa751964736f6c63430008070033

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

000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa00000000000000000000000000000000000000000000000000000000018dcfbc000000000000000000000000000000000000000000000000000000000076a7000000000000000000000000000000000000000000000000000000000002514300000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000ed4e00000000000000000000000000000000000000000000000000031f8b17b50357d0

-----Decoded View---------------
Arg [0] : stakedToken_ (address): 0xaCd4E2d936Be9B16c01848A3742A34B3D5A5bDfa
Arg [1] : rewardToken_ (address): 0xaCd4E2d936Be9B16c01848A3742A34B3D5A5bDfa
Arg [2] : initBlock_ (uint32): 26070972
Arg [3] : minStakingTime_ (uint64): 7776000
Arg [4] : maxStakingTime_ (uint64): 38880000
Arg [5] : minWeightMultiplier_ (uint16): 1
Arg [6] : maxWeightMultiplier_ (uint16): 3
Arg [7] : rewardsLockingPeriod_ (uint64): 15552000
Arg [8] : rewardsPerBlock_ (uint256): 225051440329218000

-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa
Arg [1] : 000000000000000000000000acd4e2d936be9b16c01848a3742a34b3d5a5bdfa
Arg [2] : 00000000000000000000000000000000000000000000000000000000018dcfbc
Arg [3] : 000000000000000000000000000000000000000000000000000000000076a700
Arg [4] : 0000000000000000000000000000000000000000000000000000000002514300
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [7] : 0000000000000000000000000000000000000000000000000000000000ed4e00
Arg [8] : 000000000000000000000000000000000000000000000000031f8b17b50357d0


Block Transaction 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
[ 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.