ETH Price: $2,273.75 (-7.22%)

Contract

0xb1b12d9B379652690e7cAb154163758d88C76366

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Withdraw258347982025-11-20 5:37:0273 days ago1763617022IN
0xb1b12d9B...d88C76366
0 ETH0.000004190.03740231
Set Moth Oracle255417942025-11-11 16:50:3382 days ago1762879833IN
0xb1b12d9B...d88C76366
0 ETH0.000001560.05399035
Withdraw240997422025-10-03 12:57:53121 days ago1759496273IN
0xb1b12d9B...d88C76366
0 ETH0.000004780.04244852
Collect Eth240570602025-10-02 10:22:40122 days ago1759400560IN
0xb1b12d9B...d88C76366
0 ETH0.000001870.05316
Harvest240517952025-10-02 7:15:01122 days ago1759389301IN
0xb1b12d9B...d88C76366
0.01567985 ETH0.000006230.04179072
Withdraw239765222025-09-30 8:38:31124 days ago1759221511IN
0xb1b12d9B...d88C76366
0 ETH0.000003980.04669232
Collect Eth237387382025-09-24 10:15:10130 days ago1758708910IN
0xb1b12d9B...d88C76366
0 ETH0.000001870.0532185
Withdraw236998612025-09-23 12:24:44131 days ago1758630284IN
0xb1b12d9B...d88C76366
0 ETH0.000004540.04235069
Withdraw236720372025-09-22 20:47:25132 days ago1758574045IN
0xb1b12d9B...d88C76366
0 ETH0.000004390.04655948
Harvest All236720262025-09-22 20:47:03132 days ago1758574023IN
0xb1b12d9B...d88C76366
0.00950168 ETH0.000017190.04412901
Withdraw236285862025-09-21 20:27:05133 days ago1758486425IN
0xb1b12d9B...d88C76366
0 ETH0.000003950.04288958
Withdraw236285702025-09-21 20:26:33133 days ago1758486393IN
0xb1b12d9B...d88C76366
0 ETH0.00000510.0420845
Withdraw236285582025-09-21 20:26:09133 days ago1758486369IN
0xb1b12d9B...d88C76366
0 ETH0.000003930.04290707
Withdraw235708762025-09-20 11:48:10134 days ago1758368890IN
0xb1b12d9B...d88C76366
0 ETH0.000005370.04600462
Withdraw235403202025-09-19 18:23:15135 days ago1758306195IN
0xb1b12d9B...d88C76366
0 ETH0.000003860.0428013
Collect Eth235388932025-09-19 17:34:43135 days ago1758303283IN
0xb1b12d9B...d88C76366
0 ETH0.000001710.04881936
Harvest All235385162025-09-19 17:22:07135 days ago1758302527IN
0xb1b12d9B...d88C76366
0.00008172 ETH0.000013530.03680933
Collect Eth235343952025-09-19 15:04:42135 days ago1758294282IN
0xb1b12d9B...d88C76366
0 ETH0.000001620.04619031
Harvest All235343632025-09-19 15:03:38135 days ago1758294218IN
0xb1b12d9B...d88C76366
0.826141 ETH0.000016980.04412901
Withdraw235310422025-09-19 13:12:54135 days ago1758287574IN
0xb1b12d9B...d88C76366
0 ETH0.00000350.0389106
Collect Eth235303192025-09-19 12:48:48135 days ago1758286128IN
0xb1b12d9B...d88C76366
0 ETH0.00000170.0483288
Harvest All235299422025-09-19 12:36:14135 days ago1758285374IN
0xb1b12d9B...d88C76366
0.10022707 ETH0.000014420.0367504
Collect Eth235258182025-09-19 10:18:41135 days ago1758277121IN
0xb1b12d9B...d88C76366
0 ETH0.000001670.04742791
Withdraw235238962025-09-19 9:14:35135 days ago1758273275IN
0xb1b12d9B...d88C76366
0 ETH0.000004390.04655911
Harvest235238852025-09-19 9:14:13135 days ago1758273253IN
0xb1b12d9B...d88C76366
0.01155069 ETH0.000006690.04554685
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
258347982025-11-20 5:37:0273 days ago1763617022
0xb1b12d9B...d88C76366
0 ETH
258347982025-11-20 5:37:0273 days ago1763617022
0xb1b12d9B...d88C76366
0 ETH
240997422025-10-03 12:57:53121 days ago1759496273
0xb1b12d9B...d88C76366
0 ETH
240997422025-10-03 12:57:53121 days ago1759496273
0xb1b12d9B...d88C76366
0 ETH
240570602025-10-02 10:22:40122 days ago1759400560
0xb1b12d9B...d88C76366
0.01507099 ETH
240517952025-10-02 7:15:01122 days ago1759389301
0xb1b12d9B...d88C76366
0.00060886 ETH
240517952025-10-02 7:15:01122 days ago1759389301
0xb1b12d9B...d88C76366
0 ETH
240517952025-10-02 7:15:01122 days ago1759389301
0xb1b12d9B...d88C76366
0 ETH
240517952025-10-02 7:15:01122 days ago1759389301
0xb1b12d9B...d88C76366
0 ETH
240517952025-10-02 7:15:01122 days ago1759389301
0xb1b12d9B...d88C76366
0 ETH
239765222025-09-30 8:38:31124 days ago1759221511
0xb1b12d9B...d88C76366
0 ETH
239765222025-09-30 8:38:31124 days ago1759221511
0xb1b12d9B...d88C76366
0 ETH
237387382025-09-24 10:15:10130 days ago1758708910
0xb1b12d9B...d88C76366
0.00913272 ETH
236998612025-09-23 12:24:44131 days ago1758630284
0xb1b12d9B...d88C76366
0 ETH
236998612025-09-23 12:24:44131 days ago1758630284
0xb1b12d9B...d88C76366
0 ETH
236720372025-09-22 20:47:25132 days ago1758574045
0xb1b12d9B...d88C76366
0 ETH
236720372025-09-22 20:47:25132 days ago1758574045
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0.00036896 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
236720262025-09-22 20:47:03132 days ago1758574023
0xb1b12d9B...d88C76366
0 ETH
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MothGenesisRewardPool

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: BUSL-1.1

/**************************************************************************************************************************************************

 /$$      /$$             /$$     /$$             /$$$$$$$$ /$$                                                  
| $$$    /$$$            | $$    | $$            | $$_____/|__/                                                  
| $$$$  /$$$$  /$$$$$$  /$$$$$$  | $$$$$$$       | $$       /$$ /$$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$$  /$$$$$$ 
| $$ $$/$$ $$ /$$__  $$|_  $$_/  | $$__  $$      | $$$$$   | $$| $$__  $$ |____  $$| $$__  $$ /$$_____/ /$$__  $$
| $$  $$$| $$| $$  \ $$  | $$    | $$  \ $$      | $$__/   | $$| $$  \ $$  /$$$$$$$| $$  \ $$| $$      | $$$$$$$$
| $$\  $ | $$| $$  | $$  | $$ /$$| $$  | $$      | $$      | $$| $$  | $$ /$$__  $$| $$  | $$| $$      | $$_____/
| $$ \/  | $$|  $$$$$$/  |  $$$$/| $$  | $$      | $$      | $$| $$  | $$|  $$$$$$$| $$  | $$|  $$$$$$$|  $$$$$$$
|__/     |__/ \______/    \___/  |__/  |__/      |__/      |__/|__/  |__/ \_______/|__/  |__/ \_______/ \_______/
                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                           
#### Website: https://moth.finance/
#### Author: kell

**************************************************************************************************************************************************/

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../interfaces/IBasisAsset.sol";

import "../interfaces/IOracle.sol";

contract MothGenesisRewardPool is ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // governance
    address public operator;

    // Info of each user.
    struct UserInfo {
        uint256 amount; // How many LP tokens the user has provided.
        uint256 rewardDebt; // Reward debt. See explanation below.
    }

    // Info of each pool.
    struct PoolInfo {
        IERC20 token; // Address of LP token contract.
        uint256 depFee; // deposit fee that is applied to created pool.
        uint256 allocPoint; // How many allocation points assigned to this pool. MOTHs to distribute per block.
        uint256 lastRewardTime; // Last time that MOTHs distribution occurs.
        uint256 accMothPerShare; // Accumulated MOTHs per share, times 1e18. See below.
        bool isStarted; // if lastRewardTime has passed
        uint256 poolMothPerSec; // rewards per second for pool (acts as allocPoint)
    }
    
    IERC20 public moth;
    IOracle public mothOracle;
    mapping(uint256 => bool) public pegStabilityModuleFeeEnabled; // pid => is enabled
    mapping(uint256 => uint256) public pegStabilityModuleFee; // pid => fee in basis points (1000 = 100%)
    uint256 public minClaimThreshold = 1e12; // 0.000001 MOTH
    address public bribesSafe;

    // Info of each pool.
    PoolInfo[] public poolInfo;

    // Info of each user that stakes LP tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;
    // Pending rewards for each user in each pool (pending rewards accrued since last deposit/withdrawal)
    mapping(uint256 => mapping(address => uint256)) public pendingRewards;

    // Total allocation points. Must be the sum of all allocation points in all pools.
    uint256 public totalAllocPoint = 0;

    // The time when MOTH mining starts.
    uint256 public poolStartTime;

    // The time when MOTH mining ends.
    uint256 public poolEndTime;
    uint256 public mothPerSecond = 0 ether;
    uint256 public runningTime = 4 days;

    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event RewardPaid(address indexed user, uint256 amount);

    constructor(
        address _moth,
        address _bribesSafe,
        uint256 _poolStartTime
    ) {
        require(block.timestamp < _poolStartTime, "pool cant be started in the past");
        if (_moth != address(0)) moth = IERC20(_moth);
        if(_bribesSafe != address(0)) bribesSafe = _bribesSafe;

        poolStartTime = _poolStartTime;
        poolEndTime = _poolStartTime + runningTime;
        operator = msg.sender;
        bribesSafe = _bribesSafe;
    }

    modifier onlyOperator() {
        require(operator == msg.sender, "MothGenesisRewardPool: caller is not the operator");
        _;
    }

    function poolLength() external view returns (uint256) {
        return poolInfo.length;
    }

    function checkPoolDuplicate(IERC20 _token) internal view {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            require(poolInfo[pid].token != _token, "MothGenesisRewardPool: existing pool?");
        }
    }

    // bulk add pools
    function addBulk(uint256[] calldata _allocPoints, uint256[] calldata _depFees, IERC20[] calldata _tokens, bool _withUpdate, uint256 _lastRewardTime) external onlyOperator {
        require(_allocPoints.length == _depFees.length && _allocPoints.length == _tokens.length, "MothGenesisRewardPool: invalid length");
        for (uint256 i = 0; i < _allocPoints.length; i++) {
            add(_allocPoints[i], _depFees[i], _tokens[i], _withUpdate, _lastRewardTime);
        }
    }

    // Add new lp to the pool. Can only be called by operator.
    function add(
        uint256 _allocPoint,
        uint256 _depFee,
        IERC20 _token,
        bool _withUpdate,
        uint256 _lastRewardTime
    ) public onlyOperator {
        checkPoolDuplicate(_token);
        if (_withUpdate) {
            massUpdatePools();
        }
        if (block.timestamp < poolStartTime) {
            // chef is sleeping
            if (_lastRewardTime == 0) {
                _lastRewardTime = poolStartTime;
            } else {
                if (_lastRewardTime < poolStartTime) {
                    _lastRewardTime = poolStartTime;
                }
            }
        } else {
            // chef is cooking
            if (_lastRewardTime == 0 || _lastRewardTime < block.timestamp) {
                _lastRewardTime = block.timestamp;
            }
        }
        bool _isStarted = (_lastRewardTime <= poolStartTime) || (_lastRewardTime <= block.timestamp);
        poolInfo.push(PoolInfo({
            token: _token,
            depFee: _depFee,
            allocPoint: _allocPoint,
            poolMothPerSec: _allocPoint,
            lastRewardTime: _lastRewardTime,
            accMothPerShare: 0,
            isStarted: _isStarted
        }));        

        pegStabilityModuleFeeEnabled[poolInfo.length - 1] = true; // default to true
        pegStabilityModuleFee[poolInfo.length - 1] = 950; // default to 95%

        if (_isStarted) {
            totalAllocPoint = totalAllocPoint.add(_allocPoint);
            mothPerSecond = mothPerSecond.add(_allocPoint);
        }
    }

    // Update the given pool's MOTH allocation point. Can only be called by the operator.
    function set(uint256 _pid, uint256 _allocPoint, uint256 _depFee) public onlyOperator {
        massUpdatePools();

        PoolInfo storage pool = poolInfo[_pid];
        require(_depFee < 100);  // deposit fee cant be more than 1%;
        pool.depFee = _depFee;

        if (pool.isStarted) {
            totalAllocPoint = totalAllocPoint.sub(pool.allocPoint).add(_allocPoint);
            mothPerSecond = mothPerSecond.sub(pool.poolMothPerSec).add(_allocPoint);
        }
        pool.allocPoint = _allocPoint;
        pool.poolMothPerSec = _allocPoint;
    }

    function bulkSet(uint256[] calldata _pids, uint256[] calldata _allocPoints, uint256[] calldata _depFees) external onlyOperator {
        require(_pids.length == _allocPoints.length && _pids.length == _depFees.length, "MothGenesisRewardPool: invalid length");
        for (uint256 i = 0; i < _pids.length; i++) {
            set(_pids[i], _allocPoints[i], _depFees[i]);
        }
    }

    // Return accumulate rewards over the given _from to _to block.
    function getGeneratedReward(uint256 _fromTime, uint256 _toTime) public view returns (uint256) {
        if (_fromTime >= _toTime) return 0;
        if (_toTime >= poolEndTime) {
            if (_fromTime >= poolEndTime) return 0;
            if (_fromTime <= poolStartTime) return poolEndTime.sub(poolStartTime).mul(mothPerSecond);
            return poolEndTime.sub(_fromTime).mul(mothPerSecond);
        } else {
            if (_toTime <= poolStartTime) return 0;
            if (_fromTime <= poolStartTime) return _toTime.sub(poolStartTime).mul(mothPerSecond);
            return _toTime.sub(_fromTime).mul(mothPerSecond);
        }
    }

    // View function to see pending MOTHs on frontend.
    function pendingMOTH(uint256 _pid, address _user) public view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accMothPerShare = pool.accMothPerShare;
        uint256 tokenSupply = pool.token.balanceOf(address(this));
        if (block.timestamp > pool.lastRewardTime && tokenSupply != 0) {
            uint256 _generatedReward = getGeneratedReward(pool.lastRewardTime, block.timestamp);
            uint256 _mothReward = _generatedReward.mul(pool.allocPoint).div(totalAllocPoint);
            accMothPerShare = accMothPerShare.add(_mothReward.mul(1e18).div(tokenSupply));
        }
        return user.amount.mul(accMothPerShare).div(1e18).sub(user.rewardDebt);
    }

    // View function to see pending MOTHs on frontend and any other pending rewards accumulated.
    function pendingMothAndPendingRewards(uint256 _pid, address _user) external view returns (uint256) {
        uint256 _pendingShare = pendingMOTH(_pid, _user);
        return _pendingShare.add(pendingRewards[_pid][_user]);
    }

    function massUpdatePools() public {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    // massUpdatePoolsInRange
    function massUpdatePoolsInRange(uint256 _fromPid, uint256 _toPid) public {
        require(_fromPid <= _toPid, "MothGenesisRewardPool: invalid range");
        for (uint256 pid = _fromPid; pid <= _toPid; ++pid) {
            updatePool(pid);
        }
    }

    // Update reward variables of the given pool to be up-to-date.
    function updatePool(uint256 _pid) private {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.timestamp <= pool.lastRewardTime) {
            return;
        }
        uint256 tokenSupply = pool.token.balanceOf(address(this));
        if (tokenSupply == 0) {
            pool.lastRewardTime = block.timestamp;
            return;
        }
        if (!pool.isStarted) {
            pool.isStarted = true;
            totalAllocPoint = totalAllocPoint.add(pool.allocPoint);
            mothPerSecond = mothPerSecond.add(pool.poolMothPerSec);
        }
        if (totalAllocPoint > 0) {
            uint256 _generatedReward = getGeneratedReward(pool.lastRewardTime, block.timestamp);
            uint256 _mothReward = _generatedReward.mul(pool.allocPoint).div(totalAllocPoint);
            pool.accMothPerShare = pool.accMothPerShare.add(_mothReward.mul(1e18).div(tokenSupply));
        }
        pool.lastRewardTime = block.timestamp;
    }

    // Deposit LP tokens.
    function deposit(uint256 _pid, uint256 _amount) public nonReentrant {
        address _sender = msg.sender;
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_sender];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 _pending = user.amount.mul(pool.accMothPerShare).div(1e18).sub(user.rewardDebt);
            if (_pending > 0) {
                // safeMothTransfer(_sender, _pending);
                // emit RewardPaid(_sender, _pending);

                // accrue pending rewards to be claimed later
                pendingRewards[_pid][_sender] = pendingRewards[_pid][_sender].add(_pending);
            }
        }
        if (_amount > 0 ) {
            pool.token.safeTransferFrom(_sender, address(this), _amount);
            uint256 depositDebt = _amount.mul(pool.depFee).div(10000);
            user.amount = user.amount.add(_amount.sub(depositDebt));
            pool.token.safeTransfer(bribesSafe, depositDebt);
        }
        user.rewardDebt = user.amount.mul(pool.accMothPerShare).div(1e18);
        emit Deposit(_sender, _pid, _amount);
    }

    // Withdraw LP tokens.
    function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {
        address _sender = msg.sender;
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_sender];
        require(user.amount >= _amount, "withdraw: not good");
        updatePool(_pid);
        uint256 _pending = user.amount.mul(pool.accMothPerShare).div(1e18).sub(user.rewardDebt);
        if (_pending > 0) {
            // safeMothTransfer(_sender, _pending);
            // emit RewardPaid(_sender, _pending);

            // accrue pending rewards to be claimed later
            pendingRewards[_pid][_sender] = pendingRewards[_pid][_sender].add(_pending);
        }
        if (_amount > 0) {
            user.amount = user.amount.sub(_amount);
            pool.token.safeTransfer(_sender, _amount);
        }
        user.rewardDebt = user.amount.mul(pool.accMothPerShare).div(1e18);
        emit Withdraw(_sender, _pid, _amount);
    }

    function harvest(uint256 _pid) public payable nonReentrant { 
        address _sender = msg.sender;
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_sender];

        // Ensure rewards are updated
        updatePool(_pid);

        // Calculate the latest pending rewards
        uint256 _pending = user.amount.mul(pool.accMothPerShare).div(1e18).sub(user.rewardDebt);
        uint256 _accumulatedPending = pendingRewards[_pid][_sender];
        uint256 _rewardsToClaim = _pending.add(_accumulatedPending);

        // Ensure that the user is claiming an amount above the minimum threshold
        require(_rewardsToClaim >= minClaimThreshold, "Claim amount below minimum threshold");

        if (_rewardsToClaim > 0) {
            pendingRewards[_pid][_sender] = 0;

            uint256 amountEthToPay = 0;
            if (pegStabilityModuleFeeEnabled[_pid]) {
                uint256 currentMOTHPriceInEth = mothOracle.twap(address(moth), 1e18);
                amountEthToPay = (currentMOTHPriceInEth.mul(_rewardsToClaim).div(1e18)).mul(pegStabilityModuleFee[_pid]).div(1000);
                require(msg.value >= amountEthToPay, "insufficient Eth for PSM cost");
            } else {
                require(msg.value == 0, "MothRewardPool: invalid msg.value");
            }

            safeMothTransfer(_sender, _rewardsToClaim);
            emit RewardPaid(_sender, _rewardsToClaim);

            if (pegStabilityModuleFeeEnabled[_pid] && msg.value > amountEthToPay) {
                uint256 refundAmount = msg.value - amountEthToPay;
                (bool success, ) = _sender.call{value: refundAmount}("");
                require(success, "Refund failed");
            }
        }
        // Update the user’s reward debt
        user.rewardDebt = user.amount.mul(pool.accMothPerShare).div(1e18);
    }

    function harvestAll() public payable nonReentrant {
        address _sender = msg.sender;
        uint256 length = poolInfo.length;
        uint256 totalUserRewardsToClaim = 0;
        uint256 amountEthToPay = 0;

        for (uint256 pid = 0; pid < length; ++pid) {
            PoolInfo storage pool = poolInfo[pid];
            UserInfo storage user = userInfo[pid][_sender];

            // Ensure rewards are updated
            updatePool(pid);

            // Calculate the latest pending rewards
            uint256 _pending = user.amount.mul(pool.accMothPerShare).div(1e18).sub(user.rewardDebt);
            uint256 _accumulatedPending = pendingRewards[pid][_sender];
            uint256 _rewardsToClaim = _pending.add(_accumulatedPending);

            if (_rewardsToClaim > 0) {
                pendingRewards[pid][_sender] = 0;
                totalUserRewardsToClaim = totalUserRewardsToClaim.add(_rewardsToClaim);

                if (pegStabilityModuleFeeEnabled[pid]) {
                    uint256 currentMOTHPriceInEth = mothOracle.twap(address(moth), 1e18);
                    amountEthToPay = amountEthToPay.add((currentMOTHPriceInEth.mul(_rewardsToClaim).div(1e18)).mul(pegStabilityModuleFee[pid]).div(1000));
                }
            }
            // Update the user’s reward debt
            user.rewardDebt = user.amount.mul(pool.accMothPerShare).div(1e18);
        }

        // Ensure that the user is claiming an amount above the minimum threshold
        require(totalUserRewardsToClaim >= minClaimThreshold, "Claim amount below minimum threshold");
        if (amountEthToPay == 0) {
            require(msg.value == 0, "MothRewardPool: invalid msg.value");
        } else {
            require(msg.value >= amountEthToPay, "insufficient Eth for PSM cost");
        }

        if (totalUserRewardsToClaim > 0) {
            safeMothTransfer(_sender, totalUserRewardsToClaim);
            emit RewardPaid(_sender, totalUserRewardsToClaim);

            if (msg.value > amountEthToPay) {
                uint256 refundAmount = msg.value - amountEthToPay;
                (bool success, ) = _sender.call{value: refundAmount}("");
                require(success, "Refund failed");
            }
        }
    }

    // Withdraw without caring about rewards. EMERGENCY ONLY.
    function emergencyWithdraw(uint256 _pid) public nonReentrant {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        uint256 _amount = user.amount;
        pendingRewards[_pid][msg.sender] = 0;
        user.amount = 0;
        user.rewardDebt = 0;
        pool.token.safeTransfer(msg.sender, _amount);
        emit EmergencyWithdraw(msg.sender, _pid, _amount);
    }

    // Safe moth transfer function, just in case if rounding error causes pool to not have enough MOTHs.
    function safeMothTransfer(address _to, uint256 _amount) internal {
        uint256 _mothBal = moth.balanceOf(address(this));
        if (_mothBal > 0) {
            if (_amount > _mothBal) {
                moth.safeTransfer(_to, _mothBal);
            } else {
                moth.safeTransfer(_to, _amount);
            }
        }
    }

    function setOperator(address _operator) external onlyOperator {
        operator = _operator;
    }

    function setBribesSafe(address _bribesSafe) public onlyOperator {
        bribesSafe = _bribesSafe;
    }

    function setPegStabilityModuleFee(uint256 _pegStabilityModuleFee, uint256 _pid) external onlyOperator {
        require(_pegStabilityModuleFee <= 300, "MothRewardPool: invalid peg stability module fee"); // max 30%
        pegStabilityModuleFee[_pid] = _pegStabilityModuleFee;
    }

    function setMothOracle(IOracle _mothOracle) external onlyOperator {
        mothOracle = _mothOracle;
    }

    function setPegStabilityModuleFeeEnabled(bool _enabled, uint256 _pid) external onlyOperator {
        pegStabilityModuleFeeEnabled[_pid] = _enabled;
    }

    function setMinClaimThreshold(uint256 _minClaimThreshold) external onlyOperator {
        require(_minClaimThreshold >= 0, "MothRewardPool: invalid min claim threshold");
        require(_minClaimThreshold <= 1e18, "MothRewardPool: invalid max claim threshold");
        minClaimThreshold = _minClaimThreshold;
    }

    // Can't withdraw MOTH or pool tokens from this contract.
    function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to) external onlyOperator {
        uint256 length = poolInfo.length;
        require(_token != moth, "MothGenesisRewardPool: Cannot withdraw MOTH");
        for (uint256 pid = 0; pid < length; ++pid) {
            PoolInfo storage pool = poolInfo[pid];
            require(_token != pool.token, "MothGenesisRewardPool: Token cannot be pool token");
        }
        _token.safeTransfer(to, amount);
    }

    /**
     * @notice Collects the Eth.
     * @param amount The amount of Eth to collect
     */

    function collectEth(uint256 amount) public onlyOperator {
        (bool sent,) = bribesSafe.call{value: amount}("");
        require(sent, "failed to send Eth");
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IBasisAsset {
    function mint(address recipient, uint256 amount) external returns (bool);

    function burn(uint256 amount) external;

    function burnFrom(address from, uint256 amount) external;

    function isOperator() external returns (bool);

    function operator() external view returns (address);

    function transferOperator(address newOperator_) external;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IOracle {
    function update() external;

    function consult(address _token, uint256 _amountIn) external view returns (uint256 amountOut);

    function twap(address _token, uint256 _amountIn) external view returns (uint256 _amountOut);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_moth","type":"address"},{"internalType":"address","name":"_bribesSafe","type":"address"},{"internalType":"uint256","name":"_poolStartTime","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"uint256","name":"_depFee","type":"uint256"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"bool","name":"_withUpdate","type":"bool"},{"internalType":"uint256","name":"_lastRewardTime","type":"uint256"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_allocPoints","type":"uint256[]"},{"internalType":"uint256[]","name":"_depFees","type":"uint256[]"},{"internalType":"contract IERC20[]","name":"_tokens","type":"address[]"},{"internalType":"bool","name":"_withUpdate","type":"bool"},{"internalType":"uint256","name":"_lastRewardTime","type":"uint256"}],"name":"addBulk","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bribesSafe","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_pids","type":"uint256[]"},{"internalType":"uint256[]","name":"_allocPoints","type":"uint256[]"},{"internalType":"uint256[]","name":"_depFees","type":"uint256[]"}],"name":"bulkSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"collectEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromTime","type":"uint256"},{"internalType":"uint256","name":"_toTime","type":"uint256"}],"name":"getGeneratedReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"governanceRecoverUnsupported","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"harvest","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"harvestAll","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromPid","type":"uint256"},{"internalType":"uint256","name":"_toPid","type":"uint256"}],"name":"massUpdatePoolsInRange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minClaimThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"moth","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mothOracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mothPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pegStabilityModuleFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pegStabilityModuleFeeEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingMOTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingMothAndPendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolEndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"depFee","type":"uint256"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"internalType":"uint256","name":"accMothPerShare","type":"uint256"},{"internalType":"bool","name":"isStarted","type":"bool"},{"internalType":"uint256","name":"poolMothPerSec","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"runningTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"uint256","name":"_depFee","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bribesSafe","type":"address"}],"name":"setBribesSafe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minClaimThreshold","type":"uint256"}],"name":"setMinClaimThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"_mothOracle","type":"address"}],"name":"setMothOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pegStabilityModuleFee","type":"uint256"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"setPegStabilityModuleFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"setPegStabilityModuleFeeEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405264e8d4a510006006556000600b556000600e5562054600600f5534801561002a57600080fd5b50604051612dbf380380612dbf8339810160408190526100499161015d565b60016000554281116100a15760405162461bcd60e51b815260206004820181905260248201527f706f6f6c2063616e74206265207374617274656420696e207468652070617374604482015260640160405180910390fd5b6001600160a01b038316156100cc57600280546001600160a01b0319166001600160a01b0385161790555b6001600160a01b038216156100f757600780546001600160a01b0319166001600160a01b0384161790555b600c819055600f546101099082610199565b600d555060018054336001600160a01b031991821617909155600780549091166001600160a01b0392909216919091179055506101c0565b80516001600160a01b038116811461015857600080fd5b919050565b60008060006060848603121561017257600080fd5b61017b84610141565b925061018960208501610141565b9150604084015190509250925092565b808201808211156101ba57634e487b7160e01b600052601160045260246000fd5b92915050565b612bf0806101cf6000396000f3fe6080604052600436106102255760003560e01c806362d3036811610123578063b279e31e116100ab578063d18df53c1161006f578063d18df53c146106ab578063ddc63262146106e3578063de89c76c146106f6578063e2bbb15814610716578063fddc298c1461073657600080fd5b8063b279e31e14610615578063b3ab15fb14610635578063b947a88d14610655578063bc268f1214610675578063ced8a5d71461068b57600080fd5b80638ed955b9116100f25780638ed955b91461056357806390c5ed6a1461056b57806393f1a40b1461058b578063943f013d146105df578063a2bc6739146105f557600080fd5b806362d30368146104f8578063630b5ba1146105185780636e271dd51461052d5780637e599ee81461054357600080fd5b806346ad6e74116101b157806354575af41161017557806354575af41461044a578063570ca7351461046a5780635b488f34146104a25780635f96dc11146104c25780636128a8fd146104d857600080fd5b806346ad6e741461039d5780634b954bfd146103bd5780634e4530e8146103dd57806351637ba91461040a5780635312ea8e1461042a57600080fd5b80632a0d8bd1116101f85780632a0d8bd1146102e557806330a3b4da146103075780633695dad11461034757806343b0e8df1461035d578063441a3e701461037d57600080fd5b8063081e3eda1461022a5780631526fe271461024e57806317caf6f1146102af578063231f0c6a146102c5575b600080fd5b34801561023657600080fd5b506008545b6040519081526020015b60405180910390f35b34801561025a57600080fd5b5061026e610269366004612606565b610756565b604080516001600160a01b03909816885260208801969096529486019390935260608501919091526080840152151560a083015260c082015260e001610245565b3480156102bb57600080fd5b5061023b600b5481565b3480156102d157600080fd5b5061023b6102e036600461261f565b6107b2565b3480156102f157600080fd5b50610305610300366004612606565b610877565b005b34801561031357600080fd5b50610337610322366004612606565b60046020526000908152604090205460ff1681565b6040519015158152602001610245565b34801561035357600080fd5b5061023b60065481565b34801561036957600080fd5b50610305610378366004612641565b610946565b34801561038957600080fd5b5061030561039836600461261f565b610a11565b3480156103a957600080fd5b506103056103b836600461267b565b610be4565b3480156103c957600080fd5b506103056103d83660046126bc565b610c2d565b3480156103e957600080fd5b5061023b6103f8366004612606565b60056020526000908152604090205481565b34801561041657600080fd5b50610305610425366004612606565b610c79565b34801561043657600080fd5b50610305610445366004612606565b610d14565b34801561045657600080fd5b506103056104653660046126d9565b610de1565b34801561047657600080fd5b5060015461048a906001600160a01b031681565b6040516001600160a01b039091168152602001610245565b3480156104ae57600080fd5b5060035461048a906001600160a01b031681565b3480156104ce57600080fd5b5061023b600c5481565b3480156104e457600080fd5b5061023b6104f336600461271b565b610f4e565b34801561050457600080fd5b50610305610513366004612797565b6110ad565b34801561052457600080fd5b50610305611182565b34801561053957600080fd5b5061023b600d5481565b34801561054f57600080fd5b5060025461048a906001600160a01b031681565b6103056111a1565b34801561057757600080fd5b5061030561058636600461285a565b61155d565b34801561059757600080fd5b506105ca6105a636600461271b565b60096020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610245565b3480156105eb57600080fd5b5061023b600f5481565b34801561060157600080fd5b5061023b61061036600461271b565b611808565b34801561062157600080fd5b5061030561063036600461261f565b61184e565b34801561064157600080fd5b506103056106503660046126bc565b6118f4565b34801561066157600080fd5b5061030561067036600461261f565b611940565b34801561068157600080fd5b5061023b600e5481565b34801561069757600080fd5b506103056106a63660046126bc565b6119c3565b3480156106b757600080fd5b5061023b6106c636600461271b565b600a60209081526000928352604080842090915290825290205481565b6103056106f1366004612606565b611a0f565b34801561070257600080fd5b5060075461048a906001600160a01b031681565b34801561072257600080fd5b5061030561073136600461261f565b611da0565b34801561074257600080fd5b506103056107513660046128ac565b611f72565b6008818154811061076657600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b0390951696509294919390929160ff169087565b60008183106107c357506000610871565b600d54821061082b57600d5483106107dd57506000610871565b600c54831161081057610809600e54610803600c54600d5461203590919063ffffffff16565b90612048565b9050610871565b610809600e5461080385600d5461203590919063ffffffff16565b600c54821161083c57506000610871565b600c54831161086057610809600e54610803600c548561203590919063ffffffff16565b600e54610809906108038486612035565b92915050565b6001546001600160a01b031633146108aa5760405162461bcd60e51b81526004016108a190612952565b60405180910390fd5b6007546040516000916001600160a01b03169083908381818185875af1925050503d80600081146108f7576040519150601f19603f3d011682016040523d82523d6000602084013e6108fc565b606091505b50509050806109425760405162461bcd60e51b81526020600482015260126024820152710ccc2d2d8cac840e8de40e6cadcc8408ae8d60731b60448201526064016108a1565b5050565b6001546001600160a01b031633146109705760405162461bcd60e51b81526004016108a190612952565b610978611182565b60006008848154811061098d5761098d6129a3565b90600052602060002090600702019050606482106109aa57600080fd5b60018101829055600581015460ff16156109ff576109e1836109db8360020154600b5461203590919063ffffffff16565b90612054565b600b556006810154600e546109fb9185916109db91612035565b600e555b60028101839055600601919091555050565b610a19612060565b6000339050600060088481548110610a3357610a336129a3565b600091825260208083208784526009825260408085206001600160a01b03881686529092529220805460079092029092019250841115610aaa5760405162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b60448201526064016108a1565b610ab3856120b9565b6000610af08260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b90612224565b90612035565b90508015610b49576000868152600a602090815260408083206001600160a01b0388168452909152902054610b259082612054565b6000878152600a602090815260408083206001600160a01b03891684529091529020555b8415610b73578154610b5b9086612035565b82558254610b73906001600160a01b03168587612230565b60048301548254610b9191670de0b6b3a764000091610ae491612048565b600183015560405185815286906001600160a01b038616907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689060200160405180910390a3505050506109426001600055565b6001546001600160a01b03163314610c0e5760405162461bcd60e51b81526004016108a190612952565b6000908152600460205260409020805460ff1916911515919091179055565b6001546001600160a01b03163314610c575760405162461bcd60e51b81526004016108a190612952565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610ca35760405162461bcd60e51b81526004016108a190612952565b670de0b6b3a7640000811115610d0f5760405162461bcd60e51b815260206004820152602b60248201527f4d6f7468526577617264506f6f6c3a20696e76616c6964206d617820636c616960448201526a1b481d1a1c995cda1bdb1960aa1b60648201526084016108a1565b600655565b610d1c612060565b600060088281548110610d3157610d316129a3565b60009182526020808320858452600982526040808520338087529084528186208054898852600a86528388208389529095529186208690558582556001820195909555600790930201805490945091929091610d9a916001600160a01b03919091169083612230565b604051818152849033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a3505050610dde6001600055565b50565b6001546001600160a01b03163314610e0b5760405162461bcd60e51b81526004016108a190612952565b6008546002546001600160a01b0390811690851603610e805760405162461bcd60e51b815260206004820152602b60248201527f4d6f746847656e65736973526577617264506f6f6c3a2043616e6e6f7420776960448201526a0e8d0c8e4c2ee409a9ea8960ab1b60648201526084016108a1565b60005b81811015610f3357600060088281548110610ea057610ea06129a3565b6000918252602090912060079091020180549091506001600160a01b0390811690871603610f2a5760405162461bcd60e51b815260206004820152603160248201527f4d6f746847656e65736973526577617264506f6f6c3a20546f6b656e2063616e6044820152703737ba103132903837b7b6103a37b5b2b760791b60648201526084016108a1565b50600101610e83565b50610f486001600160a01b0385168385612230565b50505050565b60008060088481548110610f6457610f646129a3565b600091825260208083208784526009825260408085206001600160a01b0389811687529352808520600460079590950290920184810154815492516370a0823160e01b8152309681019690965290965091949193919216906370a0823190602401602060405180830381865afa158015610fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100691906129b9565b905083600301544211801561101a57508015155b1561107757600061102f8560030154426107b2565b90506000611050600b54610ae488600201548561204890919063ffffffff16565b905061107261106b84610ae484670de0b6b3a7640000612048565b8590612054565b935050505b6110a28360010154610aea670de0b6b3a7640000610ae486886000015461204890919063ffffffff16565b979650505050505050565b6001546001600160a01b031633146110d75760405162461bcd60e51b81526004016108a190612952565b86851480156110e557508683145b6111015760405162461bcd60e51b81526004016108a1906129d2565b60005b878110156111775761116f898983818110611121576111216129a3565b9050602002013588888481811061113a5761113a6129a3565b90506020020135878785818110611153576111536129a3565b905060200201602081019061116891906126bc565b868661155d565b600101611104565b505050505050505050565b60085460005b8181101561094257611199816120b9565b600101611188565b6111a9612060565b6008543390600080805b838110156113b0576000600882815481106111d0576111d06129a3565b600091825260208083208584526009825260408085206001600160a01b038c16865290925292206007909102909101915061120a836120b9565b600061123b8260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b6000858152600a602090815260408083206001600160a01b038d16845290915281205491925061126b8383612054565b9050801561137e576000868152600a602090815260408083206001600160a01b038e1684529091528120556112a08882612054565b60008781526004602052604090205490985060ff161561137e57600354600254604051630d01142560e31b81526001600160a01b039182166004820152670de0b6b3a764000060248201526000929190911690636808a12890604401602060405180830381865afa158015611319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133d91906129b9565b60008881526005602052604090205490915061137a90611373906103e890610ae490610803670de0b6b3a764000083888a612048565b8990612054565b9750505b6004850154845461139c91670de0b6b3a764000091610ae491612048565b6001948501555050509190910190506111b3565b506006548210156113d35760405162461bcd60e51b81526004016108a190612a17565b806000036113fe5734156113f95760405162461bcd60e51b81526004016108a190612a5b565b61144e565b8034101561144e5760405162461bcd60e51b815260206004820152601d60248201527f696e73756666696369656e742045746820666f722050534d20636f737400000060448201526064016108a1565b811561154d5761145e8483612293565b836001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868360405161149991815260200190565b60405180910390a28034111561154d5760006114b58234612ab2565b90506000856001600160a01b03168260405160006040518083038185875af1925050503d8060008114611504576040519150601f19603f3d011682016040523d82523d6000602084013e611509565b606091505b505090508061154a5760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016108a1565b50505b5050505061155b6001600055565b565b6001546001600160a01b031633146115875760405162461bcd60e51b81526004016108a190612952565b6115908361233e565b811561159e5761159e611182565b600c544210156115cd57806000036115b95750600c546115e1565b600c548110156115c85750600c545b6115e1565b8015806115d957504281105b156115e15750425b6000600c54821115806115f45750428211155b6040805160e0810182526001600160a01b038781168252602082018981529282018a81526060830187815260006080850181815287151560a0870190815260c087018f8152600880546001808201835582875299517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3600790920291820180546001600160a01b03191691909a161790985598517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee488015594517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee587015592517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee6860155517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee785015590517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee88401805460ff191691151591909117905590517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee99092019190915591549293509160049190611790908490612ab2565b815260208101919091526040016000908120805460ff1916921515929092179091556008546103b6916005916117c890600190612ab2565b8152602081019190915260400160002055801561180057600b546117ec9087612054565b600b55600e546117fc9087612054565b600e555b505050505050565b6000806118158484610f4e565b6000858152600a602090815260408083206001600160a01b0388168452909152902054909150611846908290612054565b949350505050565b6001546001600160a01b031633146118785760405162461bcd60e51b81526004016108a190612952565b61012c8211156118e35760405162461bcd60e51b815260206004820152603060248201527f4d6f7468526577617264506f6f6c3a20696e76616c696420706567207374616260448201526f696c697479206d6f64756c652066656560801b60648201526084016108a1565b600090815260056020526040902055565b6001546001600160a01b0316331461191e5760405162461bcd60e51b81526004016108a190612952565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b8082111561199c5760405162461bcd60e51b8152602060048201526024808201527f4d6f746847656e65736973526577617264506f6f6c3a20696e76616c69642072604482015263616e676560e01b60648201526084016108a1565b815b8181116119be576119ae816120b9565b6119b781612ac5565b905061199e565b505050565b6001546001600160a01b031633146119ed5760405162461bcd60e51b81526004016108a190612952565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b611a17612060565b6000339050600060088381548110611a3157611a316129a3565b600091825260208083208684526009825260408085206001600160a01b0388168652909252922060079091029091019150611a6b846120b9565b6000611a9c8260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b6000868152600a602090815260408083206001600160a01b0389168452909152812054919250611acc8383612054565b9050600654811015611af05760405162461bcd60e51b81526004016108a190612a17565b8015611d6e576000878152600a602090815260408083206001600160a01b038a1684528252808320839055898352600490915281205460ff1615611c3b57600354600254604051630d01142560e31b81526001600160a01b039182166004820152670de0b6b3a764000060248201526000929190911690636808a12890604401602060405180830381865afa158015611b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb191906129b9565b60008a815260056020526040902054909150611be3906103e890610ae490610803670de0b6b3a764000083878a612048565b915081341015611c355760405162461bcd60e51b815260206004820152601d60248201527f696e73756666696369656e742045746820666f722050534d20636f737400000060448201526064016108a1565b50611c59565b3415611c595760405162461bcd60e51b81526004016108a190612a5b565b611c638783612293565b866001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051611c9e91815260200190565b60405180910390a260008881526004602052604090205460ff168015611cc357508034115b15611d6c576000611cd48234612ab2565b90506000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d23576040519150601f19603f3d011682016040523d82523d6000602084013e611d28565b606091505b5050905080611d695760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016108a1565b50505b505b60048501548454611d8c91670de0b6b3a764000091610ae491612048565b60019485015550505060005550610dde9050565b611da8612060565b6000339050600060088481548110611dc257611dc26129a3565b600091825260208083208784526009825260408085206001600160a01b0388168652909252922060079091029091019150611dfc856120b9565b805415611e8f576000611e348260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b90508015611e8d576000868152600a602090815260408083206001600160a01b0388168452909152902054611e699082612054565b6000878152600a602090815260408083206001600160a01b03891684529091529020555b505b8315611f02578154611eac906001600160a01b03168430876123e6565b6000611ecb612710610ae485600101548861204890919063ffffffff16565b9050611ee2611eda8683612035565b835490612054565b82556007548354611f00916001600160a01b03918216911683612230565b505b60048201548154611f2091670de0b6b3a764000091610ae491612048565b600182015560405184815285906001600160a01b038516907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159060200160405180910390a35050506109426001600055565b6001546001600160a01b03163314611f9c5760405162461bcd60e51b81526004016108a190612952565b8483148015611faa57508481145b611fc65760405162461bcd60e51b81526004016108a1906129d2565b60005b8581101561202c57612024878783818110611fe657611fe66129a3565b90506020020135868684818110611fff57611fff6129a3565b90506020020135858585818110612018576120186129a3565b90506020020135610946565b600101611fc9565b50505050505050565b60006120418284612ab2565b9392505050565b60006120418284612ade565b60006120418284612af5565b6002600054036120b25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108a1565b6002600055565b6000600882815481106120ce576120ce6129a3565b90600052602060002090600702019050806003015442116120ed575050565b80546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612135573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215991906129b9565b90508060000361216e57504260039091015550565b600582015460ff166121b25760058201805460ff191660011790556002820154600b5461219a91612054565b600b556006820154600e546121ae91612054565b600e555b600b54156122195760006121ca8360030154426107b2565b905060006121eb600b54610ae486600201548561204890919063ffffffff16565b905061221161220684610ae484670de0b6b3a7640000612048565b600486015490612054565b600485015550505b504260039091015550565b60006120418284612b08565b6040516001600160a01b0383166024820152604481018290526119be90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261241e565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156122dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061230091906129b9565b905080156119be5780821115612327576002546119be906001600160a01b03168483612230565b6002546119be906001600160a01b03168484612230565b60085460005b818110156119be57826001600160a01b031660088281548110612369576123696129a3565b60009182526020909120600790910201546001600160a01b0316036123de5760405162461bcd60e51b815260206004820152602560248201527f4d6f746847656e65736973526577617264506f6f6c3a206578697374696e6720604482015264706f6f6c3f60d81b60648201526084016108a1565b600101612344565b6040516001600160a01b0380851660248301528316604482015260648101829052610f489085906323b872dd60e01b9060840161225c565b6000612473826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124f39092919063ffffffff16565b90508051600014806124945750808060200190518101906124949190612b2a565b6119be5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108a1565b6060611846848460008585600080866001600160a01b0316858760405161251a9190612b6b565b60006040518083038185875af1925050503d8060008114612557576040519150601f19603f3d011682016040523d82523d6000602084013e61255c565b606091505b50915091506110a287838387606083156125d75782516000036125d0576001600160a01b0385163b6125d05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108a1565b5081611846565b61184683838151156125ec5781518083602001fd5b8060405162461bcd60e51b81526004016108a19190612b87565b60006020828403121561261857600080fd5b5035919050565b6000806040838503121561263257600080fd5b50508035926020909101359150565b60008060006060848603121561265657600080fd5b505081359360208301359350604090920135919050565b8015158114610dde57600080fd5b6000806040838503121561268e57600080fd5b82356126998161266d565b946020939093013593505050565b6001600160a01b0381168114610dde57600080fd5b6000602082840312156126ce57600080fd5b8135612041816126a7565b6000806000606084860312156126ee57600080fd5b83356126f9816126a7565b9250602084013591506040840135612710816126a7565b809150509250925092565b6000806040838503121561272e57600080fd5b823591506020830135612740816126a7565b809150509250929050565b60008083601f84011261275d57600080fd5b50813567ffffffffffffffff81111561277557600080fd5b6020830191508360208260051b850101111561279057600080fd5b9250929050565b60008060008060008060008060a0898b0312156127b357600080fd5b883567ffffffffffffffff8111156127ca57600080fd5b6127d68b828c0161274b565b909950975050602089013567ffffffffffffffff8111156127f657600080fd5b6128028b828c0161274b565b909750955050604089013567ffffffffffffffff81111561282257600080fd5b61282e8b828c0161274b565b90955093505060608901356128428161266d565b979a9699509497939692959194509192608001359150565b600080600080600060a0868803121561287257600080fd5b8535945060208601359350604086013561288b816126a7565b9250606086013561289b8161266d565b949793965091946080013592915050565b600080600080600080606087890312156128c557600080fd5b863567ffffffffffffffff8111156128dc57600080fd5b6128e889828a0161274b565b909750955050602087013567ffffffffffffffff81111561290857600080fd5b61291489828a0161274b565b909550935050604087013567ffffffffffffffff81111561293457600080fd5b61294089828a0161274b565b979a9699509497509295939492505050565b60208082526031908201527f4d6f746847656e65736973526577617264506f6f6c3a2063616c6c6572206973604082015270103737ba103a34329037b832b930ba37b960791b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156129cb57600080fd5b5051919050565b60208082526025908201527f4d6f746847656e65736973526577617264506f6f6c3a20696e76616c6964206c6040820152640cadccee8d60db1b606082015260800190565b60208082526024908201527f436c61696d20616d6f756e742062656c6f77206d696e696d756d2074687265736040820152631a1bdb1960e21b606082015260800190565b60208082526021908201527f4d6f7468526577617264506f6f6c3a20696e76616c6964206d73672e76616c756040820152606560f81b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8181038181111561087157610871612a9c565b600060018201612ad757612ad7612a9c565b5060010190565b808202811582820484141761087157610871612a9c565b8082018082111561087157610871612a9c565b600082612b2557634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612b3c57600080fd5b81516120418161266d565b60005b83811015612b62578181015183820152602001612b4a565b50506000910152565b60008251612b7d818460208701612b47565b9190910192915050565b6020815260008251806020840152612ba6816040850160208701612b47565b601f01601f1916919091016040019291505056fea264697066735822122058d926ec00d546a567fe8a92b8505c24b1f72cd7fab42b0eaba2c810a0c1a63864736f6c634300081a0033000000000000000000000000d3003060e18a7afc318f050255291078e9cf76b3000000000000000000000000ca1416ac2dacd01f1f75bd98bcf6747708446c1f0000000000000000000000000000000000000000000000000000000068c5b120

Deployed Bytecode

0x6080604052600436106102255760003560e01c806362d3036811610123578063b279e31e116100ab578063d18df53c1161006f578063d18df53c146106ab578063ddc63262146106e3578063de89c76c146106f6578063e2bbb15814610716578063fddc298c1461073657600080fd5b8063b279e31e14610615578063b3ab15fb14610635578063b947a88d14610655578063bc268f1214610675578063ced8a5d71461068b57600080fd5b80638ed955b9116100f25780638ed955b91461056357806390c5ed6a1461056b57806393f1a40b1461058b578063943f013d146105df578063a2bc6739146105f557600080fd5b806362d30368146104f8578063630b5ba1146105185780636e271dd51461052d5780637e599ee81461054357600080fd5b806346ad6e74116101b157806354575af41161017557806354575af41461044a578063570ca7351461046a5780635b488f34146104a25780635f96dc11146104c25780636128a8fd146104d857600080fd5b806346ad6e741461039d5780634b954bfd146103bd5780634e4530e8146103dd57806351637ba91461040a5780635312ea8e1461042a57600080fd5b80632a0d8bd1116101f85780632a0d8bd1146102e557806330a3b4da146103075780633695dad11461034757806343b0e8df1461035d578063441a3e701461037d57600080fd5b8063081e3eda1461022a5780631526fe271461024e57806317caf6f1146102af578063231f0c6a146102c5575b600080fd5b34801561023657600080fd5b506008545b6040519081526020015b60405180910390f35b34801561025a57600080fd5b5061026e610269366004612606565b610756565b604080516001600160a01b03909816885260208801969096529486019390935260608501919091526080840152151560a083015260c082015260e001610245565b3480156102bb57600080fd5b5061023b600b5481565b3480156102d157600080fd5b5061023b6102e036600461261f565b6107b2565b3480156102f157600080fd5b50610305610300366004612606565b610877565b005b34801561031357600080fd5b50610337610322366004612606565b60046020526000908152604090205460ff1681565b6040519015158152602001610245565b34801561035357600080fd5b5061023b60065481565b34801561036957600080fd5b50610305610378366004612641565b610946565b34801561038957600080fd5b5061030561039836600461261f565b610a11565b3480156103a957600080fd5b506103056103b836600461267b565b610be4565b3480156103c957600080fd5b506103056103d83660046126bc565b610c2d565b3480156103e957600080fd5b5061023b6103f8366004612606565b60056020526000908152604090205481565b34801561041657600080fd5b50610305610425366004612606565b610c79565b34801561043657600080fd5b50610305610445366004612606565b610d14565b34801561045657600080fd5b506103056104653660046126d9565b610de1565b34801561047657600080fd5b5060015461048a906001600160a01b031681565b6040516001600160a01b039091168152602001610245565b3480156104ae57600080fd5b5060035461048a906001600160a01b031681565b3480156104ce57600080fd5b5061023b600c5481565b3480156104e457600080fd5b5061023b6104f336600461271b565b610f4e565b34801561050457600080fd5b50610305610513366004612797565b6110ad565b34801561052457600080fd5b50610305611182565b34801561053957600080fd5b5061023b600d5481565b34801561054f57600080fd5b5060025461048a906001600160a01b031681565b6103056111a1565b34801561057757600080fd5b5061030561058636600461285a565b61155d565b34801561059757600080fd5b506105ca6105a636600461271b565b60096020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610245565b3480156105eb57600080fd5b5061023b600f5481565b34801561060157600080fd5b5061023b61061036600461271b565b611808565b34801561062157600080fd5b5061030561063036600461261f565b61184e565b34801561064157600080fd5b506103056106503660046126bc565b6118f4565b34801561066157600080fd5b5061030561067036600461261f565b611940565b34801561068157600080fd5b5061023b600e5481565b34801561069757600080fd5b506103056106a63660046126bc565b6119c3565b3480156106b757600080fd5b5061023b6106c636600461271b565b600a60209081526000928352604080842090915290825290205481565b6103056106f1366004612606565b611a0f565b34801561070257600080fd5b5060075461048a906001600160a01b031681565b34801561072257600080fd5b5061030561073136600461261f565b611da0565b34801561074257600080fd5b506103056107513660046128ac565b611f72565b6008818154811061076657600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b0390951696509294919390929160ff169087565b60008183106107c357506000610871565b600d54821061082b57600d5483106107dd57506000610871565b600c54831161081057610809600e54610803600c54600d5461203590919063ffffffff16565b90612048565b9050610871565b610809600e5461080385600d5461203590919063ffffffff16565b600c54821161083c57506000610871565b600c54831161086057610809600e54610803600c548561203590919063ffffffff16565b600e54610809906108038486612035565b92915050565b6001546001600160a01b031633146108aa5760405162461bcd60e51b81526004016108a190612952565b60405180910390fd5b6007546040516000916001600160a01b03169083908381818185875af1925050503d80600081146108f7576040519150601f19603f3d011682016040523d82523d6000602084013e6108fc565b606091505b50509050806109425760405162461bcd60e51b81526020600482015260126024820152710ccc2d2d8cac840e8de40e6cadcc8408ae8d60731b60448201526064016108a1565b5050565b6001546001600160a01b031633146109705760405162461bcd60e51b81526004016108a190612952565b610978611182565b60006008848154811061098d5761098d6129a3565b90600052602060002090600702019050606482106109aa57600080fd5b60018101829055600581015460ff16156109ff576109e1836109db8360020154600b5461203590919063ffffffff16565b90612054565b600b556006810154600e546109fb9185916109db91612035565b600e555b60028101839055600601919091555050565b610a19612060565b6000339050600060088481548110610a3357610a336129a3565b600091825260208083208784526009825260408085206001600160a01b03881686529092529220805460079092029092019250841115610aaa5760405162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b60448201526064016108a1565b610ab3856120b9565b6000610af08260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b90612224565b90612035565b90508015610b49576000868152600a602090815260408083206001600160a01b0388168452909152902054610b259082612054565b6000878152600a602090815260408083206001600160a01b03891684529091529020555b8415610b73578154610b5b9086612035565b82558254610b73906001600160a01b03168587612230565b60048301548254610b9191670de0b6b3a764000091610ae491612048565b600183015560405185815286906001600160a01b038616907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689060200160405180910390a3505050506109426001600055565b6001546001600160a01b03163314610c0e5760405162461bcd60e51b81526004016108a190612952565b6000908152600460205260409020805460ff1916911515919091179055565b6001546001600160a01b03163314610c575760405162461bcd60e51b81526004016108a190612952565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610ca35760405162461bcd60e51b81526004016108a190612952565b670de0b6b3a7640000811115610d0f5760405162461bcd60e51b815260206004820152602b60248201527f4d6f7468526577617264506f6f6c3a20696e76616c6964206d617820636c616960448201526a1b481d1a1c995cda1bdb1960aa1b60648201526084016108a1565b600655565b610d1c612060565b600060088281548110610d3157610d316129a3565b60009182526020808320858452600982526040808520338087529084528186208054898852600a86528388208389529095529186208690558582556001820195909555600790930201805490945091929091610d9a916001600160a01b03919091169083612230565b604051818152849033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a3505050610dde6001600055565b50565b6001546001600160a01b03163314610e0b5760405162461bcd60e51b81526004016108a190612952565b6008546002546001600160a01b0390811690851603610e805760405162461bcd60e51b815260206004820152602b60248201527f4d6f746847656e65736973526577617264506f6f6c3a2043616e6e6f7420776960448201526a0e8d0c8e4c2ee409a9ea8960ab1b60648201526084016108a1565b60005b81811015610f3357600060088281548110610ea057610ea06129a3565b6000918252602090912060079091020180549091506001600160a01b0390811690871603610f2a5760405162461bcd60e51b815260206004820152603160248201527f4d6f746847656e65736973526577617264506f6f6c3a20546f6b656e2063616e6044820152703737ba103132903837b7b6103a37b5b2b760791b60648201526084016108a1565b50600101610e83565b50610f486001600160a01b0385168385612230565b50505050565b60008060088481548110610f6457610f646129a3565b600091825260208083208784526009825260408085206001600160a01b0389811687529352808520600460079590950290920184810154815492516370a0823160e01b8152309681019690965290965091949193919216906370a0823190602401602060405180830381865afa158015610fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100691906129b9565b905083600301544211801561101a57508015155b1561107757600061102f8560030154426107b2565b90506000611050600b54610ae488600201548561204890919063ffffffff16565b905061107261106b84610ae484670de0b6b3a7640000612048565b8590612054565b935050505b6110a28360010154610aea670de0b6b3a7640000610ae486886000015461204890919063ffffffff16565b979650505050505050565b6001546001600160a01b031633146110d75760405162461bcd60e51b81526004016108a190612952565b86851480156110e557508683145b6111015760405162461bcd60e51b81526004016108a1906129d2565b60005b878110156111775761116f898983818110611121576111216129a3565b9050602002013588888481811061113a5761113a6129a3565b90506020020135878785818110611153576111536129a3565b905060200201602081019061116891906126bc565b868661155d565b600101611104565b505050505050505050565b60085460005b8181101561094257611199816120b9565b600101611188565b6111a9612060565b6008543390600080805b838110156113b0576000600882815481106111d0576111d06129a3565b600091825260208083208584526009825260408085206001600160a01b038c16865290925292206007909102909101915061120a836120b9565b600061123b8260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b6000858152600a602090815260408083206001600160a01b038d16845290915281205491925061126b8383612054565b9050801561137e576000868152600a602090815260408083206001600160a01b038e1684529091528120556112a08882612054565b60008781526004602052604090205490985060ff161561137e57600354600254604051630d01142560e31b81526001600160a01b039182166004820152670de0b6b3a764000060248201526000929190911690636808a12890604401602060405180830381865afa158015611319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133d91906129b9565b60008881526005602052604090205490915061137a90611373906103e890610ae490610803670de0b6b3a764000083888a612048565b8990612054565b9750505b6004850154845461139c91670de0b6b3a764000091610ae491612048565b6001948501555050509190910190506111b3565b506006548210156113d35760405162461bcd60e51b81526004016108a190612a17565b806000036113fe5734156113f95760405162461bcd60e51b81526004016108a190612a5b565b61144e565b8034101561144e5760405162461bcd60e51b815260206004820152601d60248201527f696e73756666696369656e742045746820666f722050534d20636f737400000060448201526064016108a1565b811561154d5761145e8483612293565b836001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868360405161149991815260200190565b60405180910390a28034111561154d5760006114b58234612ab2565b90506000856001600160a01b03168260405160006040518083038185875af1925050503d8060008114611504576040519150601f19603f3d011682016040523d82523d6000602084013e611509565b606091505b505090508061154a5760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016108a1565b50505b5050505061155b6001600055565b565b6001546001600160a01b031633146115875760405162461bcd60e51b81526004016108a190612952565b6115908361233e565b811561159e5761159e611182565b600c544210156115cd57806000036115b95750600c546115e1565b600c548110156115c85750600c545b6115e1565b8015806115d957504281105b156115e15750425b6000600c54821115806115f45750428211155b6040805160e0810182526001600160a01b038781168252602082018981529282018a81526060830187815260006080850181815287151560a0870190815260c087018f8152600880546001808201835582875299517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3600790920291820180546001600160a01b03191691909a161790985598517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee488015594517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee587015592517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee6860155517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee785015590517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee88401805460ff191691151591909117905590517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee99092019190915591549293509160049190611790908490612ab2565b815260208101919091526040016000908120805460ff1916921515929092179091556008546103b6916005916117c890600190612ab2565b8152602081019190915260400160002055801561180057600b546117ec9087612054565b600b55600e546117fc9087612054565b600e555b505050505050565b6000806118158484610f4e565b6000858152600a602090815260408083206001600160a01b0388168452909152902054909150611846908290612054565b949350505050565b6001546001600160a01b031633146118785760405162461bcd60e51b81526004016108a190612952565b61012c8211156118e35760405162461bcd60e51b815260206004820152603060248201527f4d6f7468526577617264506f6f6c3a20696e76616c696420706567207374616260448201526f696c697479206d6f64756c652066656560801b60648201526084016108a1565b600090815260056020526040902055565b6001546001600160a01b0316331461191e5760405162461bcd60e51b81526004016108a190612952565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b8082111561199c5760405162461bcd60e51b8152602060048201526024808201527f4d6f746847656e65736973526577617264506f6f6c3a20696e76616c69642072604482015263616e676560e01b60648201526084016108a1565b815b8181116119be576119ae816120b9565b6119b781612ac5565b905061199e565b505050565b6001546001600160a01b031633146119ed5760405162461bcd60e51b81526004016108a190612952565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b611a17612060565b6000339050600060088381548110611a3157611a316129a3565b600091825260208083208684526009825260408085206001600160a01b0388168652909252922060079091029091019150611a6b846120b9565b6000611a9c8260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b6000868152600a602090815260408083206001600160a01b0389168452909152812054919250611acc8383612054565b9050600654811015611af05760405162461bcd60e51b81526004016108a190612a17565b8015611d6e576000878152600a602090815260408083206001600160a01b038a1684528252808320839055898352600490915281205460ff1615611c3b57600354600254604051630d01142560e31b81526001600160a01b039182166004820152670de0b6b3a764000060248201526000929190911690636808a12890604401602060405180830381865afa158015611b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb191906129b9565b60008a815260056020526040902054909150611be3906103e890610ae490610803670de0b6b3a764000083878a612048565b915081341015611c355760405162461bcd60e51b815260206004820152601d60248201527f696e73756666696369656e742045746820666f722050534d20636f737400000060448201526064016108a1565b50611c59565b3415611c595760405162461bcd60e51b81526004016108a190612a5b565b611c638783612293565b866001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051611c9e91815260200190565b60405180910390a260008881526004602052604090205460ff168015611cc357508034115b15611d6c576000611cd48234612ab2565b90506000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d23576040519150601f19603f3d011682016040523d82523d6000602084013e611d28565b606091505b5050905080611d695760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016108a1565b50505b505b60048501548454611d8c91670de0b6b3a764000091610ae491612048565b60019485015550505060005550610dde9050565b611da8612060565b6000339050600060088481548110611dc257611dc26129a3565b600091825260208083208784526009825260408085206001600160a01b0388168652909252922060079091029091019150611dfc856120b9565b805415611e8f576000611e348260010154610aea670de0b6b3a7640000610ae48760040154876000015461204890919063ffffffff16565b90508015611e8d576000868152600a602090815260408083206001600160a01b0388168452909152902054611e699082612054565b6000878152600a602090815260408083206001600160a01b03891684529091529020555b505b8315611f02578154611eac906001600160a01b03168430876123e6565b6000611ecb612710610ae485600101548861204890919063ffffffff16565b9050611ee2611eda8683612035565b835490612054565b82556007548354611f00916001600160a01b03918216911683612230565b505b60048201548154611f2091670de0b6b3a764000091610ae491612048565b600182015560405184815285906001600160a01b038516907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159060200160405180910390a35050506109426001600055565b6001546001600160a01b03163314611f9c5760405162461bcd60e51b81526004016108a190612952565b8483148015611faa57508481145b611fc65760405162461bcd60e51b81526004016108a1906129d2565b60005b8581101561202c57612024878783818110611fe657611fe66129a3565b90506020020135868684818110611fff57611fff6129a3565b90506020020135858585818110612018576120186129a3565b90506020020135610946565b600101611fc9565b50505050505050565b60006120418284612ab2565b9392505050565b60006120418284612ade565b60006120418284612af5565b6002600054036120b25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108a1565b6002600055565b6000600882815481106120ce576120ce6129a3565b90600052602060002090600702019050806003015442116120ed575050565b80546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612135573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215991906129b9565b90508060000361216e57504260039091015550565b600582015460ff166121b25760058201805460ff191660011790556002820154600b5461219a91612054565b600b556006820154600e546121ae91612054565b600e555b600b54156122195760006121ca8360030154426107b2565b905060006121eb600b54610ae486600201548561204890919063ffffffff16565b905061221161220684610ae484670de0b6b3a7640000612048565b600486015490612054565b600485015550505b504260039091015550565b60006120418284612b08565b6040516001600160a01b0383166024820152604481018290526119be90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261241e565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156122dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061230091906129b9565b905080156119be5780821115612327576002546119be906001600160a01b03168483612230565b6002546119be906001600160a01b03168484612230565b60085460005b818110156119be57826001600160a01b031660088281548110612369576123696129a3565b60009182526020909120600790910201546001600160a01b0316036123de5760405162461bcd60e51b815260206004820152602560248201527f4d6f746847656e65736973526577617264506f6f6c3a206578697374696e6720604482015264706f6f6c3f60d81b60648201526084016108a1565b600101612344565b6040516001600160a01b0380851660248301528316604482015260648101829052610f489085906323b872dd60e01b9060840161225c565b6000612473826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124f39092919063ffffffff16565b90508051600014806124945750808060200190518101906124949190612b2a565b6119be5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108a1565b6060611846848460008585600080866001600160a01b0316858760405161251a9190612b6b565b60006040518083038185875af1925050503d8060008114612557576040519150601f19603f3d011682016040523d82523d6000602084013e61255c565b606091505b50915091506110a287838387606083156125d75782516000036125d0576001600160a01b0385163b6125d05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108a1565b5081611846565b61184683838151156125ec5781518083602001fd5b8060405162461bcd60e51b81526004016108a19190612b87565b60006020828403121561261857600080fd5b5035919050565b6000806040838503121561263257600080fd5b50508035926020909101359150565b60008060006060848603121561265657600080fd5b505081359360208301359350604090920135919050565b8015158114610dde57600080fd5b6000806040838503121561268e57600080fd5b82356126998161266d565b946020939093013593505050565b6001600160a01b0381168114610dde57600080fd5b6000602082840312156126ce57600080fd5b8135612041816126a7565b6000806000606084860312156126ee57600080fd5b83356126f9816126a7565b9250602084013591506040840135612710816126a7565b809150509250925092565b6000806040838503121561272e57600080fd5b823591506020830135612740816126a7565b809150509250929050565b60008083601f84011261275d57600080fd5b50813567ffffffffffffffff81111561277557600080fd5b6020830191508360208260051b850101111561279057600080fd5b9250929050565b60008060008060008060008060a0898b0312156127b357600080fd5b883567ffffffffffffffff8111156127ca57600080fd5b6127d68b828c0161274b565b909950975050602089013567ffffffffffffffff8111156127f657600080fd5b6128028b828c0161274b565b909750955050604089013567ffffffffffffffff81111561282257600080fd5b61282e8b828c0161274b565b90955093505060608901356128428161266d565b979a9699509497939692959194509192608001359150565b600080600080600060a0868803121561287257600080fd5b8535945060208601359350604086013561288b816126a7565b9250606086013561289b8161266d565b949793965091946080013592915050565b600080600080600080606087890312156128c557600080fd5b863567ffffffffffffffff8111156128dc57600080fd5b6128e889828a0161274b565b909750955050602087013567ffffffffffffffff81111561290857600080fd5b61291489828a0161274b565b909550935050604087013567ffffffffffffffff81111561293457600080fd5b61294089828a0161274b565b979a9699509497509295939492505050565b60208082526031908201527f4d6f746847656e65736973526577617264506f6f6c3a2063616c6c6572206973604082015270103737ba103a34329037b832b930ba37b960791b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156129cb57600080fd5b5051919050565b60208082526025908201527f4d6f746847656e65736973526577617264506f6f6c3a20696e76616c6964206c6040820152640cadccee8d60db1b606082015260800190565b60208082526024908201527f436c61696d20616d6f756e742062656c6f77206d696e696d756d2074687265736040820152631a1bdb1960e21b606082015260800190565b60208082526021908201527f4d6f7468526577617264506f6f6c3a20696e76616c6964206d73672e76616c756040820152606560f81b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8181038181111561087157610871612a9c565b600060018201612ad757612ad7612a9c565b5060010190565b808202811582820484141761087157610871612a9c565b8082018082111561087157610871612a9c565b600082612b2557634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612b3c57600080fd5b81516120418161266d565b60005b83811015612b62578181015183820152602001612b4a565b50506000910152565b60008251612b7d818460208701612b47565b9190910192915050565b6020815260008251806020840152612ba6816040850160208701612b47565b601f01601f1916919091016040019291505056fea264697066735822122058d926ec00d546a567fe8a92b8505c24b1f72cd7fab42b0eaba2c810a0c1a63864736f6c634300081a0033

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

000000000000000000000000d3003060e18a7afc318f050255291078e9cf76b3000000000000000000000000ca1416ac2dacd01f1f75bd98bcf6747708446c1f0000000000000000000000000000000000000000000000000000000068c5b120

-----Decoded View---------------
Arg [0] : _moth (address): 0xD3003060E18A7afC318F050255291078e9cf76B3
Arg [1] : _bribesSafe (address): 0xCa1416Ac2daCD01f1f75Bd98Bcf6747708446C1f
Arg [2] : _poolStartTime (uint256): 1757786400

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000d3003060e18a7afc318f050255291078e9cf76b3
Arg [1] : 000000000000000000000000ca1416ac2dacd01f1f75bd98bcf6747708446c1f
Arg [2] : 0000000000000000000000000000000000000000000000000000000068c5b120


Block Transaction Gas Used Reward
view all blocks sequenced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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