false
true
0

Contract Address Details

0x7Cc0a0ca2f9346AceAdd5110cfa15C4FA12f9251

Contract Name
EMISSIONS
Creator
0xb8386e–f548d1 at 0x32d533–5c20e4
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
30,143 Transactions
Transfers
0 Transfers
Gas Used
0
Last Balance Update
25876644
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
EMISSIONS




Optimization enabled
true
Compiler version
v0.8.20+commit.a1b79de6




Optimization runs
200
EVM Version
paris




Verified at
2025-04-01T16:53:26.037128Z

Constructor Arguments

0x00000000000000000000000032fb5663619a657839a80133994e45c5e5cdf42700000000000000000000000047ba83b133071b2d0674ea54c0c6f7a011963d7f00000000000000000000000032463b4cc953e43c18f46e01859a0f64b20ca78e00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000d1c091338a0000000000000000000000000000000000000000000000000000000000067ec27fa000000000000000000000000133f4205141d869a72724910331c0f0b7235df7b

Arg [0] (address) : 0x32fb5663619a657839a80133994e45c5e5cdf427
Arg [1] (address) : 0x47ba83b133071b2d0674ea54c0c6f7a011963d7f
Arg [2] (address) : 0x32463b4cc953e43c18f46e01859a0f64b20ca78e
Arg [3] (uint256) : 500
Arg [4] (uint256) : 500
Arg [5] (uint256) : 3690000000000000
Arg [6] (uint256) : 1743529978
Arg [7] (address) : 0x133f4205141d869a72724910331c0f0b7235df7b

              

contracts/EMISSIONS.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";

// Import interfaces
import "./interfaces/IMasterChef.sol";
import "./interfaces/IMasterNineInch.sol";
import "./interfaces/IEMIT.sol";
import "./interfaces/IPair.sol";

contract EMISSIONS is ReentrancyGuard, Ownable, Multicall {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using SafeERC20 for IEMIT;
    using EnumerableSet for EnumerableSet.AddressSet;

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

     enum ExternalProtocol {
        NONE,
        PULSEX,
        NINEINCH
    }

    // Info of each pool.
    struct PoolInfo {
        IERC20 token; // Address of LP token contract.
        uint256 allocPoint; // How many allocation points assigned to this pool. emitToken to distribute per block.
        uint256 lastRewardTime; // Last time that emitToken distribution occurs.
        uint16 depositFeeBP; //depositfee
        uint16 withdrawFeeBP; //withdrawfee
        uint256 accTokensPerShare; // Accumulated emitToken per share, times 1e18. See below.
        bool isStarted; // if lastRewardTime has passed
        ExternalProtocol externalProtocol; //which external protocol
        address externalFarm; // Farm associated with the pool.
        uint256 lpBalance;
        uint256 externalPid;
    }

    struct PoolView {
        uint256 pid;
        address token;
        uint256 allocPoint;
        uint256 lastRewardTime;
        uint16 depositFeeBP;
        uint16 withdrawFeeBP;
        uint256 accTokensPerShare;
        bool isStarted;
        ExternalProtocol externalProtocol;
        address externalFarm;
        uint256 lpBalance;
        uint256 rewardsPerSecond;
    }

    struct UserView {
        uint256 pid;
        uint256 stakedAmount;
        uint256 unclaimedRewards;
        uint256 lpBalance;
        uint256 allowance;
    }

    IEMIT public emitToken;

    IERC20 public constant INC = IERC20(0x2fa878Ab3F87CC1C9737Fc071108F904c0B0C95d);
    IERC20 public constant BBC = IERC20(0x8b4cfb020aF9AcAd95AD80020cE8f67FBB2C700E);
    IMasterChef public constant PULSE_X_MASTERCHEF = IMasterChef(address(0xB2Ca4A66d3e57a5a9A12043B6bAD28249fE302d4));
    IMasterNineInch public constant NINE_INCH_MASTERCHEF = IMasterNineInch(address(0x444775Ae2C82560337c86f6D62909a63381De4fd)); 

    // Info of each pool.W
    PoolInfo[] public poolInfo;
    EnumerableSet.AddressSet private lpTokens;

    // Info of each user that stakes LP tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;

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

    // The time when emitToken mining starts.
    uint256 public startTime;
    address public feeAddress;
    address public devAddress;
    uint256 public feePercent;
    uint256 public devPercent;
    uint256 public rewardsPerSec;
    uint256 public constant MAX_REWARDS_PER_SEC = 25 ether;
    uint256 public referralRate = 500;
    mapping(address => address) public referral; // referral => referrer
    mapping(address => uint256) public referralEarned; // for stats
    address public emittersNft;

    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(
        IEMIT _emitToken,
        address _feeAddress,
        address _devAddress,
        uint256 _feePercent,
        uint256 _devPercent,
        uint256 _rewardsPerSec,
        uint256 _startTime,
        address _emittersNft
    ) {
        require(_rewardsPerSec <= MAX_REWARDS_PER_SEC, "too high");
        require(block.timestamp < _startTime, "EMISSIONS: late");
        require(
            _feeAddress != address(0) &&
                _devAddress != address(0) &&
                address(_emitToken) != address(0),
            "EMISSIONS: Zero address not allowed"
        );
        require(
            _devPercent <= 1000 && _feePercent <= 1000,
            "EMISSIONS: Invalid percentages"
        );
        emitToken = _emitToken;
        feeAddress = _feeAddress;
        devAddress = _devAddress;
        feePercent = _feePercent;
        devPercent = _devPercent;
        rewardsPerSec = _rewardsPerSec;
        startTime = _startTime;
        emittersNft = _emittersNft;
    }

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

    // Add a new lp to the pool
    function add(
        uint256 _allocPoint,
        IERC20 _token,
        bool _withUpdate,
        uint256 _lastRewardTime,
        uint16 _depositFeeBP,
        uint16 _withdrawFeeBP,
        ExternalProtocol _externalProtocol,
        address _externalFarm,
        uint256 _externalPid
    ) external onlyOwner {
        IPair pool_lp = IPair(address(_token));
        IERC20 token0 = IERC20(pool_lp.token0());
        IERC20 token1 = IERC20(pool_lp.token1());

        if (_externalProtocol == ExternalProtocol.NONE) {
            require(_externalFarm == address(0), "EMISSIONS: Invalid farm for NONE protocol");
        } else if (_externalProtocol == ExternalProtocol.PULSEX) {
            require(_externalFarm == address(PULSE_X_MASTERCHEF), "EMISSIONS: Invalid farm for PULSEX");
        } else if (_externalProtocol == ExternalProtocol.NINEINCH) {
            require(_externalFarm == address(NINE_INCH_MASTERCHEF), "EMISSIONS: Invalid farm for NINEINCH");
        } else {
            revert("EMISSIONS: Invalid protocol type");
        }
        
        require(
            address(token0) != address(0) && address(token1) != address(0),
            "EMISSIONS: Only LP tokens "
        );
        require(
            Address.isContract(address(_token)),
            "EMISSIONS: LP token must be a valid contract"
        );
        
        //validate lp tokens in external farms
        if (_externalProtocol == ExternalProtocol.PULSEX) {
            (IERC20 masterChefLpToken,,,) = PULSE_X_MASTERCHEF.poolInfo(_externalPid);
            require(
                _token == masterChefLpToken,
                "EMISSIONS: PulseX farm is not valid"
            );
        } else if (_externalProtocol == ExternalProtocol.NINEINCH) {
            IERC20 nineInchLpToken = NINE_INCH_MASTERCHEF.lpToken(_externalPid);
            require(
                _token == nineInchLpToken,
                "EMISSIONS: 9inch farm is not valid"
            );
        }

        require(
            _depositFeeBP <= 400 && _withdrawFeeBP <= 400,
            "EMISSIONS: Invalid deposit or withdraw fee basis points"
        );
        require(
            !lpTokens.contains(address(_token)),
            "EMISSIONS: LP already added"
        );

        if (_withUpdate) {
            massUpdatePools();
        }

        if (block.timestamp < startTime) {
            // chef is sleeping
            if (_lastRewardTime < startTime) {
                _lastRewardTime = startTime;
            }
        } else {
            // chef is cooking
            if (_lastRewardTime < block.timestamp) {
                _lastRewardTime = block.timestamp;
            }
        }
        bool _isStarted = (block.timestamp >= startTime) &&
            (block.timestamp >= _lastRewardTime);
        poolInfo.push(
            PoolInfo({
                token: _token,
                allocPoint: _allocPoint,
                lastRewardTime: _lastRewardTime,
                accTokensPerShare: 0,
                isStarted: _isStarted,
                externalProtocol: _externalProtocol,
                depositFeeBP: _depositFeeBP,
                withdrawFeeBP: _withdrawFeeBP,
                externalFarm: _externalFarm,
                lpBalance: 0,
                externalPid: _externalPid
            })
        );
        if (_isStarted) {
            totalAllocPoint = totalAllocPoint.add(_allocPoint);
        }

        lpTokens.add(address(_token));
    }

    // Update the given pool's allocation point. Can only be called by the owner.
    function set(
        uint256 _pid,
        uint256 _allocPoint,
        uint16 _depositFeeBP,
        uint16 _withdrawFeeBP
    ) external onlyOwner {
        require(
            _depositFeeBP <= 400 && _withdrawFeeBP <= 400,
            "EMISSIONS: Invalid deposit or withdraw fee basis points"
        );
        massUpdatePools();
        PoolInfo storage pool = poolInfo[_pid];
        if (pool.isStarted) {
            totalAllocPoint = totalAllocPoint.sub(pool.allocPoint).add(
                _allocPoint
            );
        }
        pool.allocPoint = _allocPoint;
        poolInfo[_pid].depositFeeBP = _depositFeeBP;
        poolInfo[_pid].withdrawFeeBP = _withdrawFeeBP;
    }

    // Return accumulate rewards over the given _from to _to block.
    function getMultiplier(
        uint256 _from,
        uint256 _to
    ) public view returns (uint256) {
        if (_from >= _to) return 0;
        if (_to <= startTime) return 0;
        if (_from >= startTime) {
            return _to.sub(_from);
        } else {
            return _to.sub(startTime);
        }
    }

    // View function to see pending $EMIT on frontend.
    function pendingShare(
        uint256 _pid,
        address _user
    ) public view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accTokensPerShare = pool.accTokensPerShare;
        uint256 tokenSupply = pool.lpBalance;
        if (block.timestamp > pool.lastRewardTime && tokenSupply != 0) {
            uint256 multiplier = getMultiplier(
                pool.lastRewardTime,
                block.timestamp
            );
            uint256 lpPercent = 10000 - devPercent - feePercent;
            uint256 _generatedReward = multiplier.mul(rewardsPerSec);
            uint256 _emitRewards = _generatedReward
                .mul(pool.allocPoint)
                .div(totalAllocPoint)
                .mul(lpPercent)
                .div(10000);
            accTokensPerShare = accTokensPerShare.add(
                _emitRewards.mul(1e18).div(tokenSupply)
            );
        }
        return
            user.amount.mul(accTokensPerShare).div(1e18).sub(user.rewardDebt);
    }

    // Update reward variables for all pools. Be careful of gas spending!
    function massUpdatePools() public {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    // Update reward variables of the given pool to be up-to-date.
    function updatePool(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.timestamp <= pool.lastRewardTime) {
            return;
        }
        if (!pool.isStarted) {
            pool.isStarted = true;
            totalAllocPoint = totalAllocPoint.add(pool.allocPoint);
        }
        uint256 tokenSupply = pool.lpBalance;
        if (tokenSupply == 0) {
            pool.lastRewardTime = block.timestamp;
            return;
        }

        if (totalAllocPoint > 0) {
            uint256 multiplier = getMultiplier(
                pool.lastRewardTime,
                block.timestamp
            );
            uint256 _generatedReward = multiplier.mul(rewardsPerSec);
            uint256 _emitRewards = _generatedReward
                .mul(pool.allocPoint)
                .div(totalAllocPoint);
            uint256 lpPercent = 10000 - devPercent - feePercent;
            emitToken.mintFor(
                devAddress,
                _emitRewards.mul(devPercent).div(10000)
            );
            emitToken.mintFor(
                feeAddress,
                _emitRewards.mul(feePercent).div(10000)
            );
            emitToken.mintFor(
                address(this),
                _emitRewards.mul(lpPercent).div(10000) + _emitRewards.mul(referralRate).div(10000)
            );

            pool.accTokensPerShare = pool.accTokensPerShare.add(
                _emitRewards.mul(1e18).div(tokenSupply).mul(lpPercent).div(
                    10000
                )
            );
        }
        pool.lastRewardTime = block.timestamp;
    }

    function deposit(
        uint256 _pid,
        uint256 _amount,
        address _referrer
    ) external nonReentrant {
        address staker = _msgSender();
        _deposit(_pid, _amount, _referrer, staker);
    }

    function depositOnBehalfOf(
        uint256 _pid,
        uint256 _amount,
        address _referrer,
        address _staker
    ) external nonReentrant {
        _deposit(_pid, _amount, _referrer, _staker);
    }

    function withdraw(uint256 _pid, uint256 _amount) external nonReentrant {
        _withdraw(_pid, _amount);
    }

    function _deposit(
        uint256 _pid,
        uint256 _amount,
        address _referrer,
        address _staker
    ) private {
        if (referral[_staker] == address(0)) {
        require(
            _referrer != address(0) &&
                _referrer != _staker &&
                _referrer != address(this),
            "EMISSIONS: Invalid referrer"
        );
            referral[_staker] = _referrer;
        } else {
            _referrer = referral[_staker];
        }

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_staker];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 _pending = user
                .amount
                .mul(pool.accTokensPerShare)
                .div(1e18)
                .sub(user.rewardDebt);
            if (_pending > 0) {
                uint256 referralAmount = ((_pending) * referralRate) / 10000;
                if (referralAmount > 0) {
                    referralEarned[_referrer] =
                        referralEarned[_referrer] +
                        referralAmount;
                    safeEmitTransfer(_referrer, referralAmount);
                }
                safeEmitTransfer(_staker, _pending);
                emit RewardPaid(_staker, _pending);
            }
        }
        if (_amount > 0) {
            pool.token.safeTransferFrom(_msgSender(), address(this), _amount);
        }

        bool hasNft = IERC721(emittersNft).balanceOf(_staker) > 0;

        if (pool.depositFeeBP > 0 && !hasNft) {
            uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000);
            pool.token.safeTransfer(feeAddress, depositFee);
            user.amount = user.amount.add(_amount).sub(depositFee);
            pool.lpBalance = pool.lpBalance.add(_amount).sub(depositFee);
        } else {
            user.amount = user.amount.add(_amount);
            pool.lpBalance = pool.lpBalance.add(_amount);
        }

        user.rewardDebt = user.amount.mul(pool.accTokensPerShare).div(1e18);
        if (pool.externalFarm != address(0)) {
            uint256 toDeposit = pool.token.balanceOf(address(this));
            address _externalFarm = pool.externalFarm;
            pool.token.approve(_externalFarm, toDeposit);
            
            if (pool.externalProtocol == ExternalProtocol.PULSEX) {
                IMasterChef(pool.externalFarm).deposit(pool.externalPid, toDeposit);
            } else if (pool.externalProtocol == ExternalProtocol.NINEINCH) {
                IMasterNineInch(pool.externalFarm).deposit(pool.externalPid, toDeposit);
            }
        }
        emit Deposit(_staker, _pid, _amount);
    }

    function _withdraw(uint256 _pid, uint256 _amount) private {
        address _sender = _msgSender();
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_sender];
        require(
            user.amount >= _amount,
            "EMISSIONS: User amount too low"
        );
        updatePool(_pid);
        address referrer = referral[_sender];
        uint256 _pending = user
            .amount
            .mul(pool.accTokensPerShare)
            .div(1e18)
            .sub(user.rewardDebt);

        if (_pending > 0) {
            uint256 referralAmount = ((_pending) * referralRate) / 10000;
            if (referralAmount > 0) {
                referralEarned[referrer] =
                    referralEarned[referrer] +
                    referralAmount;
                safeEmitTransfer(referrer, referralAmount);
            }

            safeEmitTransfer(_sender, _pending);
            emit RewardPaid(_sender, _pending);
        }
        if (_amount > 0) {
            user.amount = user.amount.sub(_amount);
            if (pool.externalFarm != address(0)) {
                if (pool.externalProtocol == ExternalProtocol.PULSEX) {
                    IMasterChef(pool.externalFarm).withdraw(pool.externalPid, _amount);
                } else if (pool.externalProtocol == ExternalProtocol.NINEINCH) {
                    IMasterNineInch(pool.externalFarm).withdraw(pool.externalPid, _amount);
                }
            }

            bool hasNft = IERC721(emittersNft).balanceOf(_sender) > 0;
            if (pool.withdrawFeeBP > 0 && !hasNft) {
                uint256 withdrawFee = _amount.mul(pool.withdrawFeeBP).div(
                    10000
                );
                pool.token.safeTransfer(feeAddress, withdrawFee);
                pool.token.safeTransfer(_sender, _amount.sub(withdrawFee));
            } else {
                pool.token.safeTransfer(_sender, _amount);
            }
        }
        user.rewardDebt = user.amount.mul(pool.accTokensPerShare).div(1e18);
        pool.lpBalance -= _amount;
        emit Withdraw(_sender, _pid, _amount);
    }

    // Withdraw without caring about rewards. EMERGENCY ONLY.
    function emergencyWithdraw(uint256 _pid) public nonReentrant {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_msgSender()];
        bool isExternalFarm = pool.externalFarm != address(0);
        uint256 _amount = user.amount;
        require(_amount > 0, "EMISSIONS: User has no amount");
        user.amount = 0;
        user.rewardDebt = 0;
        if (isExternalFarm) {
            if (pool.externalProtocol == ExternalProtocol.PULSEX) {
                IMasterChef(pool.externalFarm).emergencyWithdraw(pool.externalPid);
            } else if (pool.externalProtocol == ExternalProtocol.NINEINCH) {
                IMasterNineInch(pool.externalFarm).emergencyWithdraw(pool.externalPid);
            }
        }
        if (pool.withdrawFeeBP > 0) {
            uint256 withdrawFee = _amount.mul(pool.withdrawFeeBP).div(10000);
            pool.token.safeTransfer(feeAddress, withdrawFee);
            pool.token.safeTransfer(_msgSender(), _amount.sub(withdrawFee));
        } else {
            pool.token.safeTransfer(_msgSender(), _amount);
        }
        pool.lpBalance -= _amount;
        emit EmergencyWithdraw(_msgSender(), _pid, _amount);
    }

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

    function getExternalReward(uint256 _pid) external onlyOwner {
        PoolInfo storage pool = poolInfo[_pid];
        bool isExternalFarm = pool.externalFarm != address(0);
        require(isExternalFarm, "EMISSIONS: No externalFarm set");
        
        IERC20 rewardToken;
        if (pool.externalProtocol == ExternalProtocol.PULSEX) {
            IMasterChef(pool.externalFarm).deposit(pool.externalPid, 0);
            rewardToken = INC;
        } else if (pool.externalProtocol == ExternalProtocol.NINEINCH) {
            IMasterNineInch(pool.externalFarm).deposit(pool.externalPid, 0);
            rewardToken = BBC;
        }
        
        uint256 amountToSend = rewardToken.balanceOf(address(this));
        rewardToken.safeTransfer(feeAddress, amountToSend);
    }

    // this will emergency withdraw from external farms and unset protocol & external farm to none
    function removeExternalFarm(uint256 _pid) public onlyOwner nonReentrant {
        PoolInfo storage pool = poolInfo[_pid];
        bool isExternalFarm = pool.externalFarm != address(0);
        require(isExternalFarm, "EMISSIONS: No externalFarm set");
        
        if (pool.externalProtocol == ExternalProtocol.PULSEX) {
            IMasterChef(pool.externalFarm).emergencyWithdraw(pool.externalPid);
        } else if (pool.externalProtocol == ExternalProtocol.NINEINCH) {
            IMasterNineInch(pool.externalFarm).emergencyWithdraw(pool.externalPid);
        }
        
        pool.externalFarm = address(0);
        pool.externalProtocol = ExternalProtocol.NONE;
    }

    function setFeeAddress(address _feeAddress) external onlyOwner {
        require(
            _feeAddress != address(0),
            "EMISSIONS: Zero address not allowed"
        );
        feeAddress = _feeAddress;
    }

    function setFeePercent(uint256 _feePercent) external onlyOwner {
        require(
            _feePercent <= 1000,
            "EMISSIONS: invalid fee"
        );
        feePercent = _feePercent;
    }

    function setDevAddress(address _devAddress) external onlyOwner {
        require(
            _devAddress != address(0),
            "EMISSIONS: Invalid percentages"
        );
        devAddress = _devAddress;
    }

    function setDevPercent(uint256 _devPercent) external onlyOwner {
        require(
            _devPercent <= 1000,
            "EMISSIONS: Zero address not allowed"
        );
        devPercent = _devPercent;
    }

    function setReferralRate(uint256 _referralRate) external onlyOwner {
        require(_referralRate <= 500, "EMISSIONS: Too high");
        referralRate = _referralRate;
    }

    function updateEmissionRate(uint256 _rewardsPerSec) public onlyOwner {
        require(_rewardsPerSec <= MAX_REWARDS_PER_SEC, "too high");
        massUpdatePools();
        rewardsPerSec = _rewardsPerSec;
    }

    function getPoolView(uint256 pid) public view returns (PoolView memory) {
        require(pid < poolInfo.length, "EMISSIONS: pid out of range");
        PoolInfo memory pool = poolInfo[pid];
        uint256 lpPercent = 10000 - devPercent - feePercent;
        uint256 rewardsPerSecond;
        if(totalAllocPoint == 0){
        rewardsPerSecond = 0;
        }
        else {
        rewardsPerSecond = pool
            .allocPoint
            .mul(rewardsPerSec)
            .div(totalAllocPoint)
            .mul(lpPercent)
            .div(10000);
        }
        return
            PoolView({
                pid: pid,
                token: address(pool.token),
                allocPoint: pool.allocPoint,
                lastRewardTime: pool.lastRewardTime,
                depositFeeBP: pool.depositFeeBP,
                withdrawFeeBP: pool.withdrawFeeBP,
                accTokensPerShare: pool.accTokensPerShare,
                isStarted: pool.isStarted,
                externalProtocol: pool.externalProtocol,
                externalFarm: pool.externalFarm,
                lpBalance: pool.lpBalance,
                rewardsPerSecond: rewardsPerSecond
            });
    }

    function getAllPoolViews() external view returns (PoolView[] memory) {
        PoolView[] memory views = new PoolView[](poolInfo.length);
        for (uint256 i = 0; i < poolInfo.length; i++) {
            views[i] = getPoolView(i);
        }
        return views;
    }

    function getUserView(
        uint256 pid,
        address account
    ) public view returns (UserView memory) {
        PoolInfo memory pool = poolInfo[pid];
        UserInfo memory user = userInfo[pid][account];
        uint256 unclaimedRewards = pendingShare(pid, account);
        uint256 lpBalance = pool.token.balanceOf(account);
        return
            UserView({
                pid: pid,
                stakedAmount: user.amount,
                unclaimedRewards: unclaimedRewards,
                lpBalance: lpBalance,
                allowance: pool.token.allowance(account, address(this))
            });
    }

    function getUserViews(
        address account
    ) external view returns (UserView[] memory) {
        UserView[] memory views = new UserView[](poolInfo.length);
        for (uint256 i = 0; i < poolInfo.length; i++) {
            views[i] = getUserView(i, account);
        }
        return views;
    }
}
        

@openzeppelin/contracts/access/Ownable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/security/ReentrancyGuard.sol

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol

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

@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

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

@openzeppelin/contracts/token/ERC721/IERC721.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
          

@openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/Context.sol

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

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
          

@openzeppelin/contracts/utils/Multicall.sol

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

pragma solidity ^0.8.0;

import "./Address.sol";
import "./Context.sol";

/**
 * @dev Provides a function to batch together multiple calls in a single external call.
 *
 * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially
 * careful about sending transactions invoking {multicall}. For example, a relay address that filters function
 * selectors won't filter calls nested within a {multicall} operation.
 *
 * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {_msgSender}).
 * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data`
 * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of
 * {_msgSender} are not propagated to subcalls.
 *
 * _Available since v4.1._
 */
abstract contract Multicall is Context {
    /**
     * @dev Receives and executes a batch of function calls on this contract.
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
        bytes memory context = msg.sender == _msgSender()
            ? new bytes(0)
            : msg.data[msg.data.length - _contextSuffixLength():];

        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context));
        }
        return results;
    }
}
          

@openzeppelin/contracts/utils/introspection/IERC165.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts/utils/math/SafeMath.sol

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

@openzeppelin/contracts/utils/structs/EnumerableSet.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}
          

contracts/interfaces/IEMIT.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IEMIT is IERC20 {
    function mintFor(address _address, uint256 _amount) external returns (bool);
    function safeTokenTransfer(address _to, uint256 _amount) external;
}
          

contracts/interfaces/IMasterChef.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMasterChef is IERC20 {
    struct UserInfo {
        uint256 amount;
        uint256 rewardDebt;
    }
    struct PoolInfo {
        IERC20 lpToken;
        uint256 allocPoint;
        uint256 lastRewardTime;
        uint256 accIncPerShare;
    }
    function poolLength() external view returns (uint256);
    function getMultiplier(uint256 _from, uint256 _to) external view returns (uint256);
    function pendingInc(uint256 _pid, address _user) external view returns (uint256);
    function deposit(uint256 _pid, uint256 _amount) external;
    function withdraw(uint256 _pid, uint256 _amount) external;
    function emergencyWithdraw(uint256 _pid) external;
    function poolInfo(uint256 pid) external view returns (IERC20 lpToken, uint256 allocPoint, uint256 lastRewardTime, uint256 accIncPerShare);
}
          

contracts/interfaces/IMasterNineInch.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMasterNineInch {
    struct PoolInfo {
        uint256 accBBCPerShare;
        uint256 lastRewardBlock;
        uint256 allocPoint;
        uint256 totalBoostedShare;
        bool isRegular;
    }
    
    function deposit(uint256 _pid, uint256 _amount) external;
    function withdraw(uint256 _pid, uint256 _amount) external;
    function userInfo(uint256 _pid, address _user) external view returns (uint256, uint256);
    function emergencyWithdraw(uint256 _pid) external;
    function pendingBBC(uint256 _pid, address _user) external view returns (uint256);
    function poolInfo(uint256 _pid) external view returns (PoolInfo memory);
    function lpToken(uint256 _pid) external view returns (IERC20);
}
          

contracts/interfaces/IPair.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

interface IPair {
    function token0() external view returns (address);
    function token1() external view returns (address);
}
          

Compiler Settings

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

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_emitToken","internalType":"contract IEMIT"},{"type":"address","name":"_feeAddress","internalType":"address"},{"type":"address","name":"_devAddress","internalType":"address"},{"type":"uint256","name":"_feePercent","internalType":"uint256"},{"type":"uint256","name":"_devPercent","internalType":"uint256"},{"type":"uint256","name":"_rewardsPerSec","internalType":"uint256"},{"type":"uint256","name":"_startTime","internalType":"uint256"},{"type":"address","name":"_emittersNft","internalType":"address"}]},{"type":"event","name":"Deposit","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"EmergencyWithdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"BBC","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"INC","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_REWARDS_PER_SEC","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IMasterNineInch"}],"name":"NINE_INCH_MASTERCHEF","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IMasterChef"}],"name":"PULSE_X_MASTERCHEF","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"add","inputs":[{"type":"uint256","name":"_allocPoint","internalType":"uint256"},{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"bool","name":"_withUpdate","internalType":"bool"},{"type":"uint256","name":"_lastRewardTime","internalType":"uint256"},{"type":"uint16","name":"_depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"_withdrawFeeBP","internalType":"uint16"},{"type":"uint8","name":"_externalProtocol","internalType":"enum EMISSIONS.ExternalProtocol"},{"type":"address","name":"_externalFarm","internalType":"address"},{"type":"uint256","name":"_externalPid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deposit","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_referrer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"depositOnBehalfOf","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_referrer","internalType":"address"},{"type":"address","name":"_staker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"devAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"devPercent","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"emergencyWithdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IEMIT"}],"name":"emitToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"emittersNft","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"feeAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"feePercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct EMISSIONS.PoolView[]","components":[{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"allocPoint","internalType":"uint256"},{"type":"uint256","name":"lastRewardTime","internalType":"uint256"},{"type":"uint16","name":"depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"withdrawFeeBP","internalType":"uint16"},{"type":"uint256","name":"accTokensPerShare","internalType":"uint256"},{"type":"bool","name":"isStarted","internalType":"bool"},{"type":"uint8","name":"externalProtocol","internalType":"enum EMISSIONS.ExternalProtocol"},{"type":"address","name":"externalFarm","internalType":"address"},{"type":"uint256","name":"lpBalance","internalType":"uint256"},{"type":"uint256","name":"rewardsPerSecond","internalType":"uint256"}]}],"name":"getAllPoolViews","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getExternalReward","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMultiplier","inputs":[{"type":"uint256","name":"_from","internalType":"uint256"},{"type":"uint256","name":"_to","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct EMISSIONS.PoolView","components":[{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"allocPoint","internalType":"uint256"},{"type":"uint256","name":"lastRewardTime","internalType":"uint256"},{"type":"uint16","name":"depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"withdrawFeeBP","internalType":"uint16"},{"type":"uint256","name":"accTokensPerShare","internalType":"uint256"},{"type":"bool","name":"isStarted","internalType":"bool"},{"type":"uint8","name":"externalProtocol","internalType":"enum EMISSIONS.ExternalProtocol"},{"type":"address","name":"externalFarm","internalType":"address"},{"type":"uint256","name":"lpBalance","internalType":"uint256"},{"type":"uint256","name":"rewardsPerSecond","internalType":"uint256"}]}],"name":"getPoolView","inputs":[{"type":"uint256","name":"pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct EMISSIONS.UserView","components":[{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"uint256","name":"stakedAmount","internalType":"uint256"},{"type":"uint256","name":"unclaimedRewards","internalType":"uint256"},{"type":"uint256","name":"lpBalance","internalType":"uint256"},{"type":"uint256","name":"allowance","internalType":"uint256"}]}],"name":"getUserView","inputs":[{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct EMISSIONS.UserView[]","components":[{"type":"uint256","name":"pid","internalType":"uint256"},{"type":"uint256","name":"stakedAmount","internalType":"uint256"},{"type":"uint256","name":"unclaimedRewards","internalType":"uint256"},{"type":"uint256","name":"lpBalance","internalType":"uint256"},{"type":"uint256","name":"allowance","internalType":"uint256"}]}],"name":"getUserViews","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"massUpdatePools","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingShare","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"token","internalType":"contract IERC20"},{"type":"uint256","name":"allocPoint","internalType":"uint256"},{"type":"uint256","name":"lastRewardTime","internalType":"uint256"},{"type":"uint16","name":"depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"withdrawFeeBP","internalType":"uint16"},{"type":"uint256","name":"accTokensPerShare","internalType":"uint256"},{"type":"bool","name":"isStarted","internalType":"bool"},{"type":"uint8","name":"externalProtocol","internalType":"enum EMISSIONS.ExternalProtocol"},{"type":"address","name":"externalFarm","internalType":"address"},{"type":"uint256","name":"lpBalance","internalType":"uint256"},{"type":"uint256","name":"externalPid","internalType":"uint256"}],"name":"poolInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"referral","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"referralEarned","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"referralRate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeExternalFarm","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsPerSec","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"set","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_allocPoint","internalType":"uint256"},{"type":"uint16","name":"_depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"_withdrawFeeBP","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDevAddress","inputs":[{"type":"address","name":"_devAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDevPercent","inputs":[{"type":"uint256","name":"_devPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeAddress","inputs":[{"type":"address","name":"_feeAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeePercent","inputs":[{"type":"uint256","name":"_feePercent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setReferralRate","inputs":[{"type":"uint256","name":"_referralRate","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalAllocPoint","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateEmissionRate","inputs":[{"type":"uint256","name":"_rewardsPerSec","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePool","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"rewardDebt","internalType":"uint256"}],"name":"userInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x608060405260006007556101f4600e553480156200001c57600080fd5b506040516200446e3803806200446e8339810160408190526200003f91620002a0565b60016000556200004f3362000235565b68015af1d78b58c40000831115620000995760405162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b60448201526064015b60405180910390fd5b814210620000dc5760405162461bcd60e51b815260206004820152600f60248201526e454d495353494f4e533a206c61746560881b604482015260640162000090565b6001600160a01b03871615801590620000fd57506001600160a01b03861615155b80156200011257506001600160a01b03881615155b6200016c5760405162461bcd60e51b815260206004820152602360248201527f454d495353494f4e533a205a65726f2061646472657373206e6f7420616c6c6f6044820152621dd95960ea1b606482015260840162000090565b6103e884111580156200018157506103e88511155b620001cf5760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a20496e76616c69642070657263656e74616765730000604482015260640162000090565b600280546001600160a01b03998a166001600160a01b03199182161790915560098054988a1698821698909817909755600a805496891696881696909617909555600b93909355600c91909155600d556008556011805491909316911617905562000332565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03811681146200029d57600080fd5b50565b600080600080600080600080610100898b031215620002be57600080fd5b8851620002cb8162000287565b60208a0151909850620002de8162000287565b60408a0151909750620002f18162000287565b80965050606089015194506080890151935060a0890151925060c0890151915060e0890151620003218162000287565b809150509295985092959890939650565b61412c80620003426000396000f3fe608060405234801561001057600080fd5b50600436106102895760003560e01c806378e979251161015c578063a2822cef116100ce578063d0d41fe111610087578063d0d41fe114610617578063e4932abe1461062a578063eaaf110b14610645578063f2fde38b14610658578063f743e5291461066b578063fc3c28af1461067e57600080fd5b8063a2822cef1461058e578063a327bde41461059e578063ac9650d8146105b1578063ca4863fd146105d1578063cf4b55cb146105e4578063d0c9bb59146105f757600080fd5b80638da5cb5b116101205780638da5cb5b146104e75780638dbb1e3a146104f85780638dbdbe6d1461050b578063900ea5871461051e57806393f1a40b1461053e578063a053ce1f1461058557600080fd5b806378e97925146104945780637ce3489b1461049d5780637f00ca1a146104b05780637fd6f15c146104cb5780638705fcd4146104d457600080fd5b8063441a3e701161020057806364757332116101b95780636475733214610405578063662d6d761461041a5780636eaddad214610435578063715018a6146104485780637247959a14610450578063767cb3871461047957600080fd5b8063441a3e701461039e578063457b3437146103b157806345e4e867146103c457806351eb05a6146103d75780635312ea8e146103ea578063630b5ba1146103fd57600080fd5b806317caf6f11161025257806317caf6f114610304578063225b87c41461030d5780632fe1bc1c1461032d57806331cd6179146103405780633ad10ef614610360578063412753581461038b57600080fd5b80628934521461028e578063081e3eda146102aa5780630ba84cd2146102b25780630d336591146102c75780631526fe27146102da575b600080fd5b610297600d5481565b6040519081526020015b60405180910390f35b600354610297565b6102c56102c036600461387e565b610687565b005b6102c56102d53660046138ac565b6106e5565b6102ed6102e836600461387e565b610709565b6040516102a19b9a9998979695949392919061392e565b61029760075481565b61032061031b3660046139a3565b610790565b6040516102a191906139c0565b6102c561033b36600461387e565b610865565b61029761034e3660046139a3565b60106020526000908152604090205481565b600a54610373906001600160a01b031681565b6040516001600160a01b0390911681526020016102a1565b600954610373906001600160a01b031681565b6102c56103ac366004613a39565b610aec565b6102c56103bf366004613a72565b610b0c565b601154610373906001600160a01b031681565b6102c56103e536600461387e565b610c3e565b6102c56103f836600461387e565b610f78565b6102c5611264565b61040d61128b565b6040516102a19190613b75565b610373738b4cfb020af9acad95ad80020ce8f67fbb2c700e81565b6102c561044336600461387e565b611334565b6102c5611363565b61037361045e3660046139a3565b600f602052600090815260409020546001600160a01b031681565b61037373444775ae2c82560337c86f6d62909a63381de4fd81565b61029760085481565b6102c56104ab36600461387e565b611377565b61037373b2ca4a66d3e57a5a9a12043b6bad28249fe302d481565b610297600b5481565b6102c56104e23660046139a3565b6113cf565b6001546001600160a01b0316610373565b610297610506366004613a39565b61141f565b6102c5610519366004613bb8565b61146f565b61053161052c366004613bf1565b611494565b6040516102a19190613c21565b61057061054c366004613bf1565b60066020908152600092835260408084209091529082529020805460019091015482565b604080519283526020830191909152016102a1565b610297600e5481565b61029768015af1d78b58c4000081565b6102c56105ac36600461387e565b611719565b6105c46105bf366004613c5a565b6118f6565b6040516102a19190613d1f565b6102c56105df36600461387e565b6119e9565b6102976105f2366004613bf1565b611a3e565b61060a61060536600461387e565b611b86565b6040516102a19190613d81565b6102c56106253660046139a3565b611de5565b610373732fa878ab3f87cc1c9737fc071108f904c0b0c95d81565b6102c5610653366004613d9e565b611e65565b6102c56106663660046139a3565b6126bb565b600254610373906001600160a01b031681565b610297600c5481565b61068f612731565b68015af1d78b58c400008111156106d85760405162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b60448201526064015b60405180910390fd5b6106e0611264565b600d55565b6106ed61278b565b6106f9848484846127e4565b6107036001600055565b50505050565b6003818154811061071957600080fd5b6000918252602090912060089091020180546001820154600283015460038401546004850154600586015460068701546007909701546001600160a01b0396871698509496939561ffff80851696620100009586900490911695939460ff808516956101008604909116949190910490921691908b565b60035460609060009067ffffffffffffffff8111156107b1576107b1613e3f565b60405190808252806020026020018201604052801561081457816020015b6108016040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816107cf5790505b50905060005b60035481101561085e5761082e8185611494565b82828151811061084057610840613e55565b6020026020010181905250808061085690613e81565b91505061081a565b5092915050565b61086d612731565b60006003828154811061088257610882613e55565b600091825260209091206005600890920201908101549091506201000090046001600160a01b03161515806108f95760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a204e6f2065787465726e616c4661726d20736574000060448201526064016106cf565b600060016005840154610100900460ff16600281111561091b5761091b6138f6565b036109ae5760058301546007840154604051631c57762b60e31b8152600481019190915260006024820152620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b15801561097a57600080fd5b505af115801561098e573d6000803e3d6000fd5b50505050732fa878ab3f87cc1c9737fc071108f904c0b0c95d9050610a5d565b60026005840154610100900460ff1660028111156109ce576109ce6138f6565b03610a5d5760058301546007840154604051631c57762b60e31b8152600481019190915260006024820152620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015610a2d57600080fd5b505af1158015610a41573d6000803e3d6000fd5b50505050738b4cfb020af9acad95ad80020ce8f67fbb2c700e90505b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac89190613e9a565b600954909150610ae5906001600160a01b03848116911683612e1f565b5050505050565b610af461278b565b610afe8282612e82565b610b086001600055565b5050565b610b14612731565b6101908261ffff1611158015610b3057506101908161ffff1611155b610b4c5760405162461bcd60e51b81526004016106cf90613eb3565b610b54611264565b600060038581548110610b6957610b69613e55565b60009182526020909120600890910201600581015490915060ff1615610bb057610bac84610ba6836001015460075461332590919063ffffffff16565b90613338565b6007555b8381600101819055508260038681548110610bcd57610bcd613e55565b906000526020600020906008020160030160006101000a81548161ffff021916908361ffff1602179055508160038681548110610c0c57610c0c613e55565b906000526020600020906008020160030160026101000a81548161ffff021916908361ffff1602179055505050505050565b600060038281548110610c5357610c53613e55565b9060005260206000209060080201905080600201544211610c72575050565b600581015460ff16610ca35760058101805460ff19166001908117909155810154600754610c9f91613338565b6007555b60068101546000819003610cbc57504260029091015550565b60075415610f6d576000610cd483600201544261141f565b90506000610ced600d548361334490919063ffffffff16565b90506000610d14600754610d0e87600101548561334490919063ffffffff16565b90613350565b90506000600b54600c54612710610d2b9190613f10565b610d359190613f10565b600254600a54600c549293506001600160a01b039182169263da1919b39290911690610d6a9061271090610d0e908890613344565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610db5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd99190613f23565b50600254600954600b546001600160a01b039283169263da1919b3921690610e0a9061271090610d0e908890613344565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e799190613f23565b50600254600e546001600160a01b039091169063da1919b3903090610ea79061271090610d0e908890613344565b610eb7612710610d0e8888613344565b610ec19190613f40565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f309190613f23565b50610f63610f58612710610d0e84610f528a8389670de0b6b3a7640000613344565b90613344565b600488015490613338565b6004870155505050505b504260029091015550565b610f8061278b565b600060038281548110610f9557610f95613e55565b60009182526020808320858452600690915260408320600890920201925081610fbb3390565b6001600160a01b039081168252602082019290925260400160002060058401548154919350620100009004909116151590806110395760405162461bcd60e51b815260206004820152601d60248201527f454d495353494f4e533a205573657220686173206e6f20616d6f756e7400000060448201526064016106cf565b60008084556001840155811561116f5760016005850154610100900460ff166002811115611069576110696138f6565b036110de5760058401546007850154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b5050505061116f565b60026005850154610100900460ff1660028111156110fe576110fe6138f6565b0361116f5760058401546007850154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b15801561115657600080fd5b505af115801561116a573d6000803e3d6000fd5b505050505b600384015462010000900461ffff16156111ed5760038401546000906111a89061271090610d0e90859062010000900461ffff16613344565b60095486549192506111c7916001600160a01b03908116911683612e1f565b6111e7336111d58484613325565b87546001600160a01b03169190612e1f565b50611203565b6112033385546001600160a01b03169083612e1f565b808460060160008282546112179190613f10565b9091555050604051818152859033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a3505050506112616001600055565b50565b60035460005b81811015610b085761127b81610c3e565b61128481613e81565b905061126a565b60035460609060009067ffffffffffffffff8111156112ac576112ac613e3f565b6040519080825280602002602001820160405280156112e557816020015b6112d2613813565b8152602001906001900390816112ca5790505b50905060005b60035481101561132e576112fe81611b86565b82828151811061131057611310613e55565b6020026020010181905250808061132690613e81565b9150506112eb565b50919050565b61133c612731565b6103e881111561135e5760405162461bcd60e51b81526004016106cf90613f53565b600c55565b61136b612731565b611375600061335c565b565b61137f612731565b6103e88111156113ca5760405162461bcd60e51b8152602060048201526016602482015275454d495353494f4e533a20696e76616c69642066656560501b60448201526064016106cf565b600b55565b6113d7612731565b6001600160a01b0381166113fd5760405162461bcd60e51b81526004016106cf90613f53565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600081831061143057506000611469565b600854821161144157506000611469565b600854831061145b576114548284613325565b9050611469565b600854611454908390613325565b92915050565b61147761278b565b33611484848484846127e4565b5061148f6001600055565b505050565b6114c66040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000600384815481106114db576114db613e55565b60009182526020918290206040805161016081018252600890930290910180546001600160a01b0316835260018101549383019390935260028084015491830191909152600383015461ffff808216606085015262010000909104166080830152600483015460a0830152600583015460ff808216151560c085015292939260e08501926101009092041690811115611576576115766138f6565b6002811115611587576115876138f6565b815260058201546001600160a01b03620100009091048116602080840191909152600680850154604080860191909152600790950154606090940193909352600089815292815283832091881683529081528282208351808501909452805484526001015490830152919250906115fe8686611a3e565b83516040516370a0823160e01b81526001600160a01b038881166004830152929350600092909116906370a0823190602401602060405180830381865afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190613e9a565b6040805160a081018252898152855160208201528082018590526060810183905286519151636eb1769f60e11b81526001600160a01b038a8116600483015230602483015293945090926080840192169063dd62ed3e90604401602060405180830381865afa1580156116e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170c9190613e9a565b9052979650505050505050565b611721612731565b61172961278b565b60006003828154811061173e5761173e613e55565b600091825260209091206005600890920201908101549091506201000090046001600160a01b03161515806117b55760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a204e6f2065787465726e616c4661726d20736574000060448201526064016106cf565b60016005830154610100900460ff1660028111156117d5576117d56138f6565b0361184a5760058201546007830154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b15801561182d57600080fd5b505af1158015611841573d6000803e3d6000fd5b505050506118db565b60026005830154610100900460ff16600281111561186a5761186a6138f6565b036118db5760058201546007830154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b1580156118c257600080fd5b505af11580156118d6573d6000803e3d6000fd5b505050505b506005018054610100600160b01b0319169055600160005550565b6040805160008152602081019091526060908267ffffffffffffffff81111561192157611921613e3f565b60405190808252806020026020018201604052801561195457816020015b606081526020019060019003908161193f5790505b50915060005b838110156119e1576119b13086868481811061197857611978613e55565b905060200281019061198a9190613f96565b8560405160200161199d93929190613fe4565b6040516020818303038152906040526133ae565b8382815181106119c3576119c3613e55565b602002602001018190525080806119d990613e81565b91505061195a565b505092915050565b6119f1612731565b6101f4811115611a395760405162461bcd60e51b815260206004820152601360248201527208a9a92a6a6929e9ca67440a8dede40d0d2ced606b1b60448201526064016106cf565b600e55565b60008060038481548110611a5457611a54613e55565b60009182526020808320878452600680835260408086206001600160a01b038a168752909352919093206004600890930290930191820154908201546002830154929450909142118015611aa757508015155b15611b4a576000611abc85600201544261141f565b90506000600b54600c54612710611ad39190613f10565b611add9190613f10565b90506000611af6600d548461334490919063ffffffff16565b90506000611b21612710610d0e85610f52600754610d0e8e600101548961334490919063ffffffff16565b9050611b43611b3c86610d0e84670de0b6b3a7640000613344565b8790613338565b9550505050505b611b7b8360010154611b75670de0b6b3a7640000610d0e86886000015461334490919063ffffffff16565b90613325565b979650505050505050565b611b8e613813565b6003548210611bdf5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a20706964206f7574206f662072616e6765000000000060448201526064016106cf565b600060038381548110611bf457611bf4613e55565b60009182526020918290206040805161016081018252600890930290910180546001600160a01b0316835260018101549383019390935260028084015491830191909152600383015461ffff808216606085015262010000909104166080830152600483015460a0830152600583015460ff808216151560c085015292939260e08501926101009092041690811115611c8f57611c8f6138f6565b6002811115611ca057611ca06138f6565b815260058201546201000090046001600160a01b0316602082015260068201546040820152600790910154606090910152600b54600c54919250600091611ce990612710613f10565b611cf39190613f10565b90506000600754600003611d0957506000611d35565b611d32612710610d0e84610f52600754610d0e600d548a6020015161334490919063ffffffff16565b90505b60405180610180016040528086815260200184600001516001600160a01b031681526020018460200151815260200184604001518152602001846060015161ffff168152602001846080015161ffff1681526020018460a0015181526020018460c00151151581526020018460e001516002811115611db657611db66138f6565b81526101008501516001600160a01b031660208201526101209094015160408501526060909301525092915050565b611ded612731565b6001600160a01b038116611e435760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a20496e76616c69642070657263656e7461676573000060448201526064016106cf565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b611e6d612731565b60008890506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed6919061400b565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3c919061400b565b90506000866002811115611f5257611f526138f6565b03611fc5576001600160a01b03851615611fc05760405162461bcd60e51b815260206004820152602960248201527f454d495353494f4e533a20496e76616c6964206661726d20666f72204e4f4e45604482015268081c1c9bdd1bd8dbdb60ba1b60648201526084016106cf565b61212e565b6001866002811115611fd957611fd96138f6565b03612055576001600160a01b03851673b2ca4a66d3e57a5a9a12043b6bad28249fe302d414611fc05760405162461bcd60e51b815260206004820152602260248201527f454d495353494f4e533a20496e76616c6964206661726d20666f722050554c5360448201526108ab60f31b60648201526084016106cf565b6002866002811115612069576120696138f6565b036120e6576001600160a01b03851673444775ae2c82560337c86f6d62909a63381de4fd14611fc05760405162461bcd60e51b8152602060048201526024808201527f454d495353494f4e533a20496e76616c6964206661726d20666f72204e494e456044820152630929c86960e31b60648201526084016106cf565b60405162461bcd60e51b815260206004820181905260248201527f454d495353494f4e533a20496e76616c69642070726f746f636f6c207479706560448201526064016106cf565b6001600160a01b0382161580159061214e57506001600160a01b03811615155b61219a5760405162461bcd60e51b815260206004820152601a60248201527f454d495353494f4e533a204f6e6c79204c5020746f6b656e732000000000000060448201526064016106cf565b6001600160a01b038b163b6122065760405162461bcd60e51b815260206004820152602c60248201527f454d495353494f4e533a204c5020746f6b656e206d757374206265206120766160448201526b1b1a590818dbdb9d1c9858dd60a21b60648201526084016106cf565b600186600281111561221a5761221a6138f6565b0361230e57604051631526fe2760e01b81526004810185905260009073b2ca4a66d3e57a5a9a12043b6bad28249fe302d490631526fe2790602401608060405180830381865afa158015612272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122969190614028565b5050509050806001600160a01b03168c6001600160a01b0316146123085760405162461bcd60e51b815260206004820152602360248201527f454d495353494f4e533a2050756c736558206661726d206973206e6f742076616044820152621b1a5960ea1b60648201526084016106cf565b5061240e565b6002866002811115612322576123226138f6565b0361240e576040516378ed5d1f60e01b81526004810185905260009073444775ae2c82560337c86f6d62909a63381de4fd906378ed5d1f90602401602060405180830381865afa15801561237a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239e919061400b565b9050806001600160a01b03168c6001600160a01b03161461240c5760405162461bcd60e51b815260206004820152602260248201527f454d495353494f4e533a2039696e6368206661726d206973206e6f742076616c6044820152611a5960f21b60648201526084016106cf565b505b6101908861ffff161115801561242a57506101908761ffff1611155b6124465760405162461bcd60e51b81526004016106cf90613eb3565b61245160048c6133d3565b1561249e5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a204c5020616c7265616479206164646564000000000060448201526064016106cf565b89156124ac576124ac611264565b6008544210156124cb576008548910156124c65760085498505b6124d7565b428910156124d7574298505b600060085442101580156124eb5750894210155b905060036040518061016001604052808e6001600160a01b031681526020018f81526020018c81526020018b61ffff1681526020018a61ffff16815260200160008152602001831515815260200189600281111561254b5761254b6138f6565b81526001600160a01b03808a166020808401919091526000604080850182905260609485018c90528654600181810189559783529183902086516008909302018054929094166001600160a01b031990921691909117835590840151948201949094559282015160028085019190915590820151600384018054608085015161ffff908116620100000263ffffffff1990921693169290921791909117905560a0820151600484015560c082015160058401805491151560ff1983168117825560e085015194959493919261ff001990911661ffff1991909116179061010090849081111561263c5761263c6138f6565b02179055506101008201516005820180546001600160a01b03909216620100000262010000600160b01b031990921691909117905561012082015160068201556101409091015160079091015580156126a05760075461269c908e613338565b6007555b6126ab60048d6133f5565b5050505050505050505050505050565b6126c3612731565b6001600160a01b0381166127285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106cf565b6112618161335c565b6001546001600160a01b031633146113755760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106cf565b6002600054036127dd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106cf565b6002600055565b6001600160a01b038181166000908152600f6020526040902054166128c1576001600160a01b0382161580159061282d5750806001600160a01b0316826001600160a01b031614155b801561284257506001600160a01b0382163014155b61288e5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a20496e76616c6964207265666572726572000000000060448201526064016106cf565b6001600160a01b038181166000908152600f6020526040902080546001600160a01b0319169184169190911790556128df565b6001600160a01b038082166000908152600f60205260409020541691505b6000600385815481106128f4576128f4613e55565b600091825260208083208884526006825260408085206001600160a01b038816865290925292206008909102909101915061292e86610c3e565b805415612a2b5760006129668260010154611b75670de0b6b3a7640000610d0e8760040154876000015461334490919063ffffffff16565b90508015612a29576000612710600e54836129819190614067565b61298b919061407e565b905080156129da576001600160a01b0386166000908152601060205260409020546129b7908290613f40565b6001600160a01b0387166000908152601060205260409020556129da868261340a565b6129e4858361340a565b846001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051612a1f91815260200190565b60405180910390a2505b505b8415612a4857612a483383546001600160a01b03169030886134b5565b6011546040516370a0823160e01b81526001600160a01b03858116600483015260009283929116906370a0823190602401602060405180830381865afa158015612a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aba9190613e9a565b60038501549110915061ffff1615801590612ad3575080155b15612b4a576003830154600090612af79061271090610d0e908a9061ffff16613344565b6009548554919250612b16916001600160a01b03908116911683612e1f565b8254612b28908290611b75908a613338565b83556006840154612b3f908290611b75908a613338565b600685015550612b6d565b8154612b569087613338565b82556006830154612b679087613338565b60068401555b60048301548254612b8b91670de0b6b3a764000091610d0e91613344565b600183015560058301546201000090046001600160a01b031615612dd25782546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612bf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c159190613e9a565b6005850154855460405163095ea7b360e01b8152620100009092046001600160a01b039081166004840181905260248401859052939450169063095ea7b3906044016020604051808303816000875af1158015612c76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9a9190613f23565b5060016005860154610100900460ff166002811115612cbb57612cbb6138f6565b03612d375760058501546007860154604051631c57762b60e31b8152600481019190915260248101849052620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015612d1a57600080fd5b505af1158015612d2e573d6000803e3d6000fd5b50505050612dcf565b60026005860154610100900460ff166002811115612d5757612d576138f6565b03612dcf5760058501546007860154604051631c57762b60e31b8152600481019190915260248101849052620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015612db657600080fd5b505af1158015612dca573d6000803e3d6000fd5b505050505b50505b86846001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051612e0e91815260200190565b60405180910390a350505050505050565b6040516001600160a01b03831660248201526044810182905261148f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526134ed565b6000339050600060038481548110612e9c57612e9c613e55565b600091825260208083208784526006825260408085206001600160a01b03881686529092529220805460089092029092019250841115612f1e5760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a205573657220616d6f756e7420746f6f206c6f77000060448201526064016106cf565b612f2785610c3e565b6001600160a01b038084166000908152600f60205260408120546001840154600486015485549290941693612f6d92611b7591670de0b6b3a764000091610d0e91613344565b90508015613030576000612710600e5483612f889190614067565b612f92919061407e565b90508015612fe1576001600160a01b038316600090815260106020526040902054612fbe908290613f40565b6001600160a01b038416600090815260106020526040902055612fe1838261340a565b612feb868361340a565b856001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868360405161302691815260200190565b60405180910390a2505b85156132a95782546130429087613325565b835560058401546201000090046001600160a01b0316156131915760016005850154610100900460ff16600281111561307d5761307d6138f6565b036130f95760058401546007850154604051630441a3e760e41b8152600481019190915260248101889052620100009091046001600160a01b03169063441a3e7090604401600060405180830381600087803b1580156130dc57600080fd5b505af11580156130f0573d6000803e3d6000fd5b50505050613191565b60026005850154610100900460ff166002811115613119576131196138f6565b036131915760058401546007850154604051630441a3e760e41b8152600481019190915260248101889052620100009091046001600160a01b03169063441a3e7090604401600060405180830381600087803b15801561317857600080fd5b505af115801561318c573d6000803e3d6000fd5b505050505b6011546040516370a0823160e01b81526001600160a01b03878116600483015260009283929116906370a0823190602401602060405180830381865afa1580156131df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132039190613e9a565b60038701549110915062010000900461ffff1615801590613222575080155b1561329157600385015460009061324c9061271090610d0e908b9062010000900461ffff16613344565b600954875491925061326b916001600160a01b03908116911683612e1f565b61328b876132798a84613325565b88546001600160a01b03169190612e1f565b506132a7565b84546132a7906001600160a01b03168789612e1f565b505b600484015483546132c791670de0b6b3a764000091610d0e91613344565b8360010181905550858460060160008282546132e39190613f10565b909155505060405186815287906001600160a01b038716907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56890602001612e0e565b60006133318284613f10565b9392505050565b60006133318284613f40565b60006133318284614067565b6000613331828461407e565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606061333183836040518060600160405280602781526020016140d0602791396135c2565b6001600160a01b03811660009081526001830160205260408120541515613331565b6000613331836001600160a01b03841661363a565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015613453573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134779190613e9a565b9050801561148f578082111561349e5760025461148f906001600160a01b03168483612e1f565b60025461148f906001600160a01b03168484612e1f565b6040516001600160a01b03808516602483015283166044820152606481018290526107039085906323b872dd60e01b90608401612e4b565b6000613542826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136899092919063ffffffff16565b90508051600014806135635750808060200190518101906135639190613f23565b61148f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106cf565b6060600080856001600160a01b0316856040516135df91906140a0565b600060405180830381855af49150503d806000811461361a576040519150601f19603f3d011682016040523d82523d6000602084013e61361f565b606091505b5091509150613630868383876136a0565b9695505050505050565b600081815260018301602052604081205461368157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611469565b506000611469565b60606136988484600085613719565b949350505050565b6060831561370f578251600003613708576001600160a01b0385163b6137085760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106cf565b5081613698565b61369883836137e9565b60608247101561377a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106cf565b600080866001600160a01b0316858760405161379691906140a0565b60006040518083038185875af1925050503d80600081146137d3576040519150601f19603f3d011682016040523d82523d6000602084013e6137d8565b606091505b5091509150611b7b878383876136a0565b8151156137f95781518083602001fd5b8060405162461bcd60e51b81526004016106cf91906140bc565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905290610100820190815260200160006001600160a01b0316815260200160008152602001600081525090565b60006020828403121561389057600080fd5b5035919050565b6001600160a01b038116811461126157600080fd5b600080600080608085870312156138c257600080fd5b843593506020850135925060408501356138db81613897565b915060608501356138eb81613897565b939692955090935050565b634e487b7160e01b600052602160045260246000fd5b6003811061392a57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b038c81168252602082018c9052604082018b905261ffff8a811660608401528916608083015260a0820188905286151560c083015261016082019061397d60e084018861390c565b949094166101008201526101208101929092526101409091015298975050505050505050565b6000602082840312156139b557600080fd5b813561333181613897565b6020808252825182820181905260009190848201906040850190845b81811015613a2d57613a1a83855180518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b9284019260a092909201916001016139dc565b50909695505050505050565b60008060408385031215613a4c57600080fd5b50508035926020909101359150565b803561ffff81168114613a6d57600080fd5b919050565b60008060008060808587031215613a8857600080fd5b8435935060208501359250613a9f60408601613a5b565b9150613aad60608601613a5b565b905092959194509250565b805182526020810151613ad660208401826001600160a01b03169052565b5060408101516040830152606081015160608301526080810151613b00608084018261ffff169052565b5060a0810151613b1660a084018261ffff169052565b5060c081015160c083015260e0810151613b3460e084018215159052565b5061010080820151613b488285018261390c565b5050610120818101516001600160a01b031690830152610140808201519083015261016090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015613a2d57613ba4838551613ab8565b928401926101809290920191600101613b91565b600080600060608486031215613bcd57600080fd5b83359250602084013591506040840135613be681613897565b809150509250925092565b60008060408385031215613c0457600080fd5b823591506020830135613c1681613897565b809150509250929050565b60a08101611469828480518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b60008060208385031215613c6d57600080fd5b823567ffffffffffffffff80821115613c8557600080fd5b818501915085601f830112613c9957600080fd5b813581811115613ca857600080fd5b8660208260051b8501011115613cbd57600080fd5b60209290920196919550909350505050565b60005b83811015613cea578181015183820152602001613cd2565b50506000910152565b60008151808452613d0b816020860160208601613ccf565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613d7457603f19888603018452613d62858351613cf3565b94509285019290850190600101613d46565b5092979650505050505050565b61018081016114698284613ab8565b801515811461126157600080fd5b60008060008060008060008060006101208a8c031215613dbd57600080fd5b8935985060208a0135613dcf81613897565b975060408a0135613ddf81613d90565b965060608a01359550613df460808b01613a5b565b9450613e0260a08b01613a5b565b935060c08a013560038110613e1657600080fd5b925060e08a0135613e2681613897565b809250506101008a013590509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613e9357613e93613e6b565b5060010190565b600060208284031215613eac57600080fd5b5051919050565b60208082526037908201527f454d495353494f4e533a20496e76616c6964206465706f736974206f7220776960408201527f7468647261772066656520626173697320706f696e7473000000000000000000606082015260800190565b8181038181111561146957611469613e6b565b600060208284031215613f3557600080fd5b815161333181613d90565b8082018082111561146957611469613e6b565b60208082526023908201527f454d495353494f4e533a205a65726f2061646472657373206e6f7420616c6c6f6040820152621dd95960ea1b606082015260800190565b6000808335601e19843603018112613fad57600080fd5b83018035915067ffffffffffffffff821115613fc857600080fd5b602001915036819003821315613fdd57600080fd5b9250929050565b828482376000838201600081528351614001818360208801613ccf565b0195945050505050565b60006020828403121561401d57600080fd5b815161333181613897565b6000806000806080858703121561403e57600080fd5b845161404981613897565b60208601516040870151606090970151919890975090945092505050565b808202811582820484141761146957611469613e6b565b60008261409b57634e487b7160e01b600052601260045260246000fd5b500490565b600082516140b2818460208701613ccf565b9190910192915050565b6020815260006133316020830184613cf356fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220bd56b1537a499c3e4b09b16c205a8fef7be2e62532f4da1a6c1dfa0bc973e76264736f6c6343000814003300000000000000000000000032fb5663619a657839a80133994e45c5e5cdf42700000000000000000000000047ba83b133071b2d0674ea54c0c6f7a011963d7f00000000000000000000000032463b4cc953e43c18f46e01859a0f64b20ca78e00000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000d1c091338a0000000000000000000000000000000000000000000000000000000000067ec27fa000000000000000000000000133f4205141d869a72724910331c0f0b7235df7b

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106102895760003560e01c806378e979251161015c578063a2822cef116100ce578063d0d41fe111610087578063d0d41fe114610617578063e4932abe1461062a578063eaaf110b14610645578063f2fde38b14610658578063f743e5291461066b578063fc3c28af1461067e57600080fd5b8063a2822cef1461058e578063a327bde41461059e578063ac9650d8146105b1578063ca4863fd146105d1578063cf4b55cb146105e4578063d0c9bb59146105f757600080fd5b80638da5cb5b116101205780638da5cb5b146104e75780638dbb1e3a146104f85780638dbdbe6d1461050b578063900ea5871461051e57806393f1a40b1461053e578063a053ce1f1461058557600080fd5b806378e97925146104945780637ce3489b1461049d5780637f00ca1a146104b05780637fd6f15c146104cb5780638705fcd4146104d457600080fd5b8063441a3e701161020057806364757332116101b95780636475733214610405578063662d6d761461041a5780636eaddad214610435578063715018a6146104485780637247959a14610450578063767cb3871461047957600080fd5b8063441a3e701461039e578063457b3437146103b157806345e4e867146103c457806351eb05a6146103d75780635312ea8e146103ea578063630b5ba1146103fd57600080fd5b806317caf6f11161025257806317caf6f114610304578063225b87c41461030d5780632fe1bc1c1461032d57806331cd6179146103405780633ad10ef614610360578063412753581461038b57600080fd5b80628934521461028e578063081e3eda146102aa5780630ba84cd2146102b25780630d336591146102c75780631526fe27146102da575b600080fd5b610297600d5481565b6040519081526020015b60405180910390f35b600354610297565b6102c56102c036600461387e565b610687565b005b6102c56102d53660046138ac565b6106e5565b6102ed6102e836600461387e565b610709565b6040516102a19b9a9998979695949392919061392e565b61029760075481565b61032061031b3660046139a3565b610790565b6040516102a191906139c0565b6102c561033b36600461387e565b610865565b61029761034e3660046139a3565b60106020526000908152604090205481565b600a54610373906001600160a01b031681565b6040516001600160a01b0390911681526020016102a1565b600954610373906001600160a01b031681565b6102c56103ac366004613a39565b610aec565b6102c56103bf366004613a72565b610b0c565b601154610373906001600160a01b031681565b6102c56103e536600461387e565b610c3e565b6102c56103f836600461387e565b610f78565b6102c5611264565b61040d61128b565b6040516102a19190613b75565b610373738b4cfb020af9acad95ad80020ce8f67fbb2c700e81565b6102c561044336600461387e565b611334565b6102c5611363565b61037361045e3660046139a3565b600f602052600090815260409020546001600160a01b031681565b61037373444775ae2c82560337c86f6d62909a63381de4fd81565b61029760085481565b6102c56104ab36600461387e565b611377565b61037373b2ca4a66d3e57a5a9a12043b6bad28249fe302d481565b610297600b5481565b6102c56104e23660046139a3565b6113cf565b6001546001600160a01b0316610373565b610297610506366004613a39565b61141f565b6102c5610519366004613bb8565b61146f565b61053161052c366004613bf1565b611494565b6040516102a19190613c21565b61057061054c366004613bf1565b60066020908152600092835260408084209091529082529020805460019091015482565b604080519283526020830191909152016102a1565b610297600e5481565b61029768015af1d78b58c4000081565b6102c56105ac36600461387e565b611719565b6105c46105bf366004613c5a565b6118f6565b6040516102a19190613d1f565b6102c56105df36600461387e565b6119e9565b6102976105f2366004613bf1565b611a3e565b61060a61060536600461387e565b611b86565b6040516102a19190613d81565b6102c56106253660046139a3565b611de5565b610373732fa878ab3f87cc1c9737fc071108f904c0b0c95d81565b6102c5610653366004613d9e565b611e65565b6102c56106663660046139a3565b6126bb565b600254610373906001600160a01b031681565b610297600c5481565b61068f612731565b68015af1d78b58c400008111156106d85760405162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b60448201526064015b60405180910390fd5b6106e0611264565b600d55565b6106ed61278b565b6106f9848484846127e4565b6107036001600055565b50505050565b6003818154811061071957600080fd5b6000918252602090912060089091020180546001820154600283015460038401546004850154600586015460068701546007909701546001600160a01b0396871698509496939561ffff80851696620100009586900490911695939460ff808516956101008604909116949190910490921691908b565b60035460609060009067ffffffffffffffff8111156107b1576107b1613e3f565b60405190808252806020026020018201604052801561081457816020015b6108016040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816107cf5790505b50905060005b60035481101561085e5761082e8185611494565b82828151811061084057610840613e55565b6020026020010181905250808061085690613e81565b91505061081a565b5092915050565b61086d612731565b60006003828154811061088257610882613e55565b600091825260209091206005600890920201908101549091506201000090046001600160a01b03161515806108f95760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a204e6f2065787465726e616c4661726d20736574000060448201526064016106cf565b600060016005840154610100900460ff16600281111561091b5761091b6138f6565b036109ae5760058301546007840154604051631c57762b60e31b8152600481019190915260006024820152620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b15801561097a57600080fd5b505af115801561098e573d6000803e3d6000fd5b50505050732fa878ab3f87cc1c9737fc071108f904c0b0c95d9050610a5d565b60026005840154610100900460ff1660028111156109ce576109ce6138f6565b03610a5d5760058301546007840154604051631c57762b60e31b8152600481019190915260006024820152620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015610a2d57600080fd5b505af1158015610a41573d6000803e3d6000fd5b50505050738b4cfb020af9acad95ad80020ce8f67fbb2c700e90505b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac89190613e9a565b600954909150610ae5906001600160a01b03848116911683612e1f565b5050505050565b610af461278b565b610afe8282612e82565b610b086001600055565b5050565b610b14612731565b6101908261ffff1611158015610b3057506101908161ffff1611155b610b4c5760405162461bcd60e51b81526004016106cf90613eb3565b610b54611264565b600060038581548110610b6957610b69613e55565b60009182526020909120600890910201600581015490915060ff1615610bb057610bac84610ba6836001015460075461332590919063ffffffff16565b90613338565b6007555b8381600101819055508260038681548110610bcd57610bcd613e55565b906000526020600020906008020160030160006101000a81548161ffff021916908361ffff1602179055508160038681548110610c0c57610c0c613e55565b906000526020600020906008020160030160026101000a81548161ffff021916908361ffff1602179055505050505050565b600060038281548110610c5357610c53613e55565b9060005260206000209060080201905080600201544211610c72575050565b600581015460ff16610ca35760058101805460ff19166001908117909155810154600754610c9f91613338565b6007555b60068101546000819003610cbc57504260029091015550565b60075415610f6d576000610cd483600201544261141f565b90506000610ced600d548361334490919063ffffffff16565b90506000610d14600754610d0e87600101548561334490919063ffffffff16565b90613350565b90506000600b54600c54612710610d2b9190613f10565b610d359190613f10565b600254600a54600c549293506001600160a01b039182169263da1919b39290911690610d6a9061271090610d0e908890613344565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610db5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd99190613f23565b50600254600954600b546001600160a01b039283169263da1919b3921690610e0a9061271090610d0e908890613344565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e799190613f23565b50600254600e546001600160a01b039091169063da1919b3903090610ea79061271090610d0e908890613344565b610eb7612710610d0e8888613344565b610ec19190613f40565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f309190613f23565b50610f63610f58612710610d0e84610f528a8389670de0b6b3a7640000613344565b90613344565b600488015490613338565b6004870155505050505b504260029091015550565b610f8061278b565b600060038281548110610f9557610f95613e55565b60009182526020808320858452600690915260408320600890920201925081610fbb3390565b6001600160a01b039081168252602082019290925260400160002060058401548154919350620100009004909116151590806110395760405162461bcd60e51b815260206004820152601d60248201527f454d495353494f4e533a205573657220686173206e6f20616d6f756e7400000060448201526064016106cf565b60008084556001840155811561116f5760016005850154610100900460ff166002811115611069576110696138f6565b036110de5760058401546007850154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b5050505061116f565b60026005850154610100900460ff1660028111156110fe576110fe6138f6565b0361116f5760058401546007850154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b15801561115657600080fd5b505af115801561116a573d6000803e3d6000fd5b505050505b600384015462010000900461ffff16156111ed5760038401546000906111a89061271090610d0e90859062010000900461ffff16613344565b60095486549192506111c7916001600160a01b03908116911683612e1f565b6111e7336111d58484613325565b87546001600160a01b03169190612e1f565b50611203565b6112033385546001600160a01b03169083612e1f565b808460060160008282546112179190613f10565b9091555050604051818152859033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a3505050506112616001600055565b50565b60035460005b81811015610b085761127b81610c3e565b61128481613e81565b905061126a565b60035460609060009067ffffffffffffffff8111156112ac576112ac613e3f565b6040519080825280602002602001820160405280156112e557816020015b6112d2613813565b8152602001906001900390816112ca5790505b50905060005b60035481101561132e576112fe81611b86565b82828151811061131057611310613e55565b6020026020010181905250808061132690613e81565b9150506112eb565b50919050565b61133c612731565b6103e881111561135e5760405162461bcd60e51b81526004016106cf90613f53565b600c55565b61136b612731565b611375600061335c565b565b61137f612731565b6103e88111156113ca5760405162461bcd60e51b8152602060048201526016602482015275454d495353494f4e533a20696e76616c69642066656560501b60448201526064016106cf565b600b55565b6113d7612731565b6001600160a01b0381166113fd5760405162461bcd60e51b81526004016106cf90613f53565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600081831061143057506000611469565b600854821161144157506000611469565b600854831061145b576114548284613325565b9050611469565b600854611454908390613325565b92915050565b61147761278b565b33611484848484846127e4565b5061148f6001600055565b505050565b6114c66040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000600384815481106114db576114db613e55565b60009182526020918290206040805161016081018252600890930290910180546001600160a01b0316835260018101549383019390935260028084015491830191909152600383015461ffff808216606085015262010000909104166080830152600483015460a0830152600583015460ff808216151560c085015292939260e08501926101009092041690811115611576576115766138f6565b6002811115611587576115876138f6565b815260058201546001600160a01b03620100009091048116602080840191909152600680850154604080860191909152600790950154606090940193909352600089815292815283832091881683529081528282208351808501909452805484526001015490830152919250906115fe8686611a3e565b83516040516370a0823160e01b81526001600160a01b038881166004830152929350600092909116906370a0823190602401602060405180830381865afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190613e9a565b6040805160a081018252898152855160208201528082018590526060810183905286519151636eb1769f60e11b81526001600160a01b038a8116600483015230602483015293945090926080840192169063dd62ed3e90604401602060405180830381865afa1580156116e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170c9190613e9a565b9052979650505050505050565b611721612731565b61172961278b565b60006003828154811061173e5761173e613e55565b600091825260209091206005600890920201908101549091506201000090046001600160a01b03161515806117b55760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a204e6f2065787465726e616c4661726d20736574000060448201526064016106cf565b60016005830154610100900460ff1660028111156117d5576117d56138f6565b0361184a5760058201546007830154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b15801561182d57600080fd5b505af1158015611841573d6000803e3d6000fd5b505050506118db565b60026005830154610100900460ff16600281111561186a5761186a6138f6565b036118db5760058201546007830154604051632989754760e11b81526004810191909152620100009091046001600160a01b031690635312ea8e90602401600060405180830381600087803b1580156118c257600080fd5b505af11580156118d6573d6000803e3d6000fd5b505050505b506005018054610100600160b01b0319169055600160005550565b6040805160008152602081019091526060908267ffffffffffffffff81111561192157611921613e3f565b60405190808252806020026020018201604052801561195457816020015b606081526020019060019003908161193f5790505b50915060005b838110156119e1576119b13086868481811061197857611978613e55565b905060200281019061198a9190613f96565b8560405160200161199d93929190613fe4565b6040516020818303038152906040526133ae565b8382815181106119c3576119c3613e55565b602002602001018190525080806119d990613e81565b91505061195a565b505092915050565b6119f1612731565b6101f4811115611a395760405162461bcd60e51b815260206004820152601360248201527208a9a92a6a6929e9ca67440a8dede40d0d2ced606b1b60448201526064016106cf565b600e55565b60008060038481548110611a5457611a54613e55565b60009182526020808320878452600680835260408086206001600160a01b038a168752909352919093206004600890930290930191820154908201546002830154929450909142118015611aa757508015155b15611b4a576000611abc85600201544261141f565b90506000600b54600c54612710611ad39190613f10565b611add9190613f10565b90506000611af6600d548461334490919063ffffffff16565b90506000611b21612710610d0e85610f52600754610d0e8e600101548961334490919063ffffffff16565b9050611b43611b3c86610d0e84670de0b6b3a7640000613344565b8790613338565b9550505050505b611b7b8360010154611b75670de0b6b3a7640000610d0e86886000015461334490919063ffffffff16565b90613325565b979650505050505050565b611b8e613813565b6003548210611bdf5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a20706964206f7574206f662072616e6765000000000060448201526064016106cf565b600060038381548110611bf457611bf4613e55565b60009182526020918290206040805161016081018252600890930290910180546001600160a01b0316835260018101549383019390935260028084015491830191909152600383015461ffff808216606085015262010000909104166080830152600483015460a0830152600583015460ff808216151560c085015292939260e08501926101009092041690811115611c8f57611c8f6138f6565b6002811115611ca057611ca06138f6565b815260058201546201000090046001600160a01b0316602082015260068201546040820152600790910154606090910152600b54600c54919250600091611ce990612710613f10565b611cf39190613f10565b90506000600754600003611d0957506000611d35565b611d32612710610d0e84610f52600754610d0e600d548a6020015161334490919063ffffffff16565b90505b60405180610180016040528086815260200184600001516001600160a01b031681526020018460200151815260200184604001518152602001846060015161ffff168152602001846080015161ffff1681526020018460a0015181526020018460c00151151581526020018460e001516002811115611db657611db66138f6565b81526101008501516001600160a01b031660208201526101209094015160408501526060909301525092915050565b611ded612731565b6001600160a01b038116611e435760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a20496e76616c69642070657263656e7461676573000060448201526064016106cf565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b611e6d612731565b60008890506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed6919061400b565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3c919061400b565b90506000866002811115611f5257611f526138f6565b03611fc5576001600160a01b03851615611fc05760405162461bcd60e51b815260206004820152602960248201527f454d495353494f4e533a20496e76616c6964206661726d20666f72204e4f4e45604482015268081c1c9bdd1bd8dbdb60ba1b60648201526084016106cf565b61212e565b6001866002811115611fd957611fd96138f6565b03612055576001600160a01b03851673b2ca4a66d3e57a5a9a12043b6bad28249fe302d414611fc05760405162461bcd60e51b815260206004820152602260248201527f454d495353494f4e533a20496e76616c6964206661726d20666f722050554c5360448201526108ab60f31b60648201526084016106cf565b6002866002811115612069576120696138f6565b036120e6576001600160a01b03851673444775ae2c82560337c86f6d62909a63381de4fd14611fc05760405162461bcd60e51b8152602060048201526024808201527f454d495353494f4e533a20496e76616c6964206661726d20666f72204e494e456044820152630929c86960e31b60648201526084016106cf565b60405162461bcd60e51b815260206004820181905260248201527f454d495353494f4e533a20496e76616c69642070726f746f636f6c207479706560448201526064016106cf565b6001600160a01b0382161580159061214e57506001600160a01b03811615155b61219a5760405162461bcd60e51b815260206004820152601a60248201527f454d495353494f4e533a204f6e6c79204c5020746f6b656e732000000000000060448201526064016106cf565b6001600160a01b038b163b6122065760405162461bcd60e51b815260206004820152602c60248201527f454d495353494f4e533a204c5020746f6b656e206d757374206265206120766160448201526b1b1a590818dbdb9d1c9858dd60a21b60648201526084016106cf565b600186600281111561221a5761221a6138f6565b0361230e57604051631526fe2760e01b81526004810185905260009073b2ca4a66d3e57a5a9a12043b6bad28249fe302d490631526fe2790602401608060405180830381865afa158015612272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122969190614028565b5050509050806001600160a01b03168c6001600160a01b0316146123085760405162461bcd60e51b815260206004820152602360248201527f454d495353494f4e533a2050756c736558206661726d206973206e6f742076616044820152621b1a5960ea1b60648201526084016106cf565b5061240e565b6002866002811115612322576123226138f6565b0361240e576040516378ed5d1f60e01b81526004810185905260009073444775ae2c82560337c86f6d62909a63381de4fd906378ed5d1f90602401602060405180830381865afa15801561237a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239e919061400b565b9050806001600160a01b03168c6001600160a01b03161461240c5760405162461bcd60e51b815260206004820152602260248201527f454d495353494f4e533a2039696e6368206661726d206973206e6f742076616c6044820152611a5960f21b60648201526084016106cf565b505b6101908861ffff161115801561242a57506101908761ffff1611155b6124465760405162461bcd60e51b81526004016106cf90613eb3565b61245160048c6133d3565b1561249e5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a204c5020616c7265616479206164646564000000000060448201526064016106cf565b89156124ac576124ac611264565b6008544210156124cb576008548910156124c65760085498505b6124d7565b428910156124d7574298505b600060085442101580156124eb5750894210155b905060036040518061016001604052808e6001600160a01b031681526020018f81526020018c81526020018b61ffff1681526020018a61ffff16815260200160008152602001831515815260200189600281111561254b5761254b6138f6565b81526001600160a01b03808a166020808401919091526000604080850182905260609485018c90528654600181810189559783529183902086516008909302018054929094166001600160a01b031990921691909117835590840151948201949094559282015160028085019190915590820151600384018054608085015161ffff908116620100000263ffffffff1990921693169290921791909117905560a0820151600484015560c082015160058401805491151560ff1983168117825560e085015194959493919261ff001990911661ffff1991909116179061010090849081111561263c5761263c6138f6565b02179055506101008201516005820180546001600160a01b03909216620100000262010000600160b01b031990921691909117905561012082015160068201556101409091015160079091015580156126a05760075461269c908e613338565b6007555b6126ab60048d6133f5565b5050505050505050505050505050565b6126c3612731565b6001600160a01b0381166127285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106cf565b6112618161335c565b6001546001600160a01b031633146113755760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106cf565b6002600054036127dd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106cf565b6002600055565b6001600160a01b038181166000908152600f6020526040902054166128c1576001600160a01b0382161580159061282d5750806001600160a01b0316826001600160a01b031614155b801561284257506001600160a01b0382163014155b61288e5760405162461bcd60e51b815260206004820152601b60248201527f454d495353494f4e533a20496e76616c6964207265666572726572000000000060448201526064016106cf565b6001600160a01b038181166000908152600f6020526040902080546001600160a01b0319169184169190911790556128df565b6001600160a01b038082166000908152600f60205260409020541691505b6000600385815481106128f4576128f4613e55565b600091825260208083208884526006825260408085206001600160a01b038816865290925292206008909102909101915061292e86610c3e565b805415612a2b5760006129668260010154611b75670de0b6b3a7640000610d0e8760040154876000015461334490919063ffffffff16565b90508015612a29576000612710600e54836129819190614067565b61298b919061407e565b905080156129da576001600160a01b0386166000908152601060205260409020546129b7908290613f40565b6001600160a01b0387166000908152601060205260409020556129da868261340a565b6129e4858361340a565b846001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051612a1f91815260200190565b60405180910390a2505b505b8415612a4857612a483383546001600160a01b03169030886134b5565b6011546040516370a0823160e01b81526001600160a01b03858116600483015260009283929116906370a0823190602401602060405180830381865afa158015612a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aba9190613e9a565b60038501549110915061ffff1615801590612ad3575080155b15612b4a576003830154600090612af79061271090610d0e908a9061ffff16613344565b6009548554919250612b16916001600160a01b03908116911683612e1f565b8254612b28908290611b75908a613338565b83556006840154612b3f908290611b75908a613338565b600685015550612b6d565b8154612b569087613338565b82556006830154612b679087613338565b60068401555b60048301548254612b8b91670de0b6b3a764000091610d0e91613344565b600183015560058301546201000090046001600160a01b031615612dd25782546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612bf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c159190613e9a565b6005850154855460405163095ea7b360e01b8152620100009092046001600160a01b039081166004840181905260248401859052939450169063095ea7b3906044016020604051808303816000875af1158015612c76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9a9190613f23565b5060016005860154610100900460ff166002811115612cbb57612cbb6138f6565b03612d375760058501546007860154604051631c57762b60e31b8152600481019190915260248101849052620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015612d1a57600080fd5b505af1158015612d2e573d6000803e3d6000fd5b50505050612dcf565b60026005860154610100900460ff166002811115612d5757612d576138f6565b03612dcf5760058501546007860154604051631c57762b60e31b8152600481019190915260248101849052620100009091046001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015612db657600080fd5b505af1158015612dca573d6000803e3d6000fd5b505050505b50505b86846001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1588604051612e0e91815260200190565b60405180910390a350505050505050565b6040516001600160a01b03831660248201526044810182905261148f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526134ed565b6000339050600060038481548110612e9c57612e9c613e55565b600091825260208083208784526006825260408085206001600160a01b03881686529092529220805460089092029092019250841115612f1e5760405162461bcd60e51b815260206004820152601e60248201527f454d495353494f4e533a205573657220616d6f756e7420746f6f206c6f77000060448201526064016106cf565b612f2785610c3e565b6001600160a01b038084166000908152600f60205260408120546001840154600486015485549290941693612f6d92611b7591670de0b6b3a764000091610d0e91613344565b90508015613030576000612710600e5483612f889190614067565b612f92919061407e565b90508015612fe1576001600160a01b038316600090815260106020526040902054612fbe908290613f40565b6001600160a01b038416600090815260106020526040902055612fe1838261340a565b612feb868361340a565b856001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868360405161302691815260200190565b60405180910390a2505b85156132a95782546130429087613325565b835560058401546201000090046001600160a01b0316156131915760016005850154610100900460ff16600281111561307d5761307d6138f6565b036130f95760058401546007850154604051630441a3e760e41b8152600481019190915260248101889052620100009091046001600160a01b03169063441a3e7090604401600060405180830381600087803b1580156130dc57600080fd5b505af11580156130f0573d6000803e3d6000fd5b50505050613191565b60026005850154610100900460ff166002811115613119576131196138f6565b036131915760058401546007850154604051630441a3e760e41b8152600481019190915260248101889052620100009091046001600160a01b03169063441a3e7090604401600060405180830381600087803b15801561317857600080fd5b505af115801561318c573d6000803e3d6000fd5b505050505b6011546040516370a0823160e01b81526001600160a01b03878116600483015260009283929116906370a0823190602401602060405180830381865afa1580156131df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132039190613e9a565b60038701549110915062010000900461ffff1615801590613222575080155b1561329157600385015460009061324c9061271090610d0e908b9062010000900461ffff16613344565b600954875491925061326b916001600160a01b03908116911683612e1f565b61328b876132798a84613325565b88546001600160a01b03169190612e1f565b506132a7565b84546132a7906001600160a01b03168789612e1f565b505b600484015483546132c791670de0b6b3a764000091610d0e91613344565b8360010181905550858460060160008282546132e39190613f10565b909155505060405186815287906001600160a01b038716907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56890602001612e0e565b60006133318284613f10565b9392505050565b60006133318284613f40565b60006133318284614067565b6000613331828461407e565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606061333183836040518060600160405280602781526020016140d0602791396135c2565b6001600160a01b03811660009081526001830160205260408120541515613331565b6000613331836001600160a01b03841661363a565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015613453573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134779190613e9a565b9050801561148f578082111561349e5760025461148f906001600160a01b03168483612e1f565b60025461148f906001600160a01b03168484612e1f565b6040516001600160a01b03808516602483015283166044820152606481018290526107039085906323b872dd60e01b90608401612e4b565b6000613542826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136899092919063ffffffff16565b90508051600014806135635750808060200190518101906135639190613f23565b61148f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106cf565b6060600080856001600160a01b0316856040516135df91906140a0565b600060405180830381855af49150503d806000811461361a576040519150601f19603f3d011682016040523d82523d6000602084013e61361f565b606091505b5091509150613630868383876136a0565b9695505050505050565b600081815260018301602052604081205461368157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611469565b506000611469565b60606136988484600085613719565b949350505050565b6060831561370f578251600003613708576001600160a01b0385163b6137085760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106cf565b5081613698565b61369883836137e9565b60608247101561377a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106cf565b600080866001600160a01b0316858760405161379691906140a0565b60006040518083038185875af1925050503d80600081146137d3576040519150601f19603f3d011682016040523d82523d6000602084013e6137d8565b606091505b5091509150611b7b878383876136a0565b8151156137f95781518083602001fd5b8060405162461bcd60e51b81526004016106cf91906140bc565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905290610100820190815260200160006001600160a01b0316815260200160008152602001600081525090565b60006020828403121561389057600080fd5b5035919050565b6001600160a01b038116811461126157600080fd5b600080600080608085870312156138c257600080fd5b843593506020850135925060408501356138db81613897565b915060608501356138eb81613897565b939692955090935050565b634e487b7160e01b600052602160045260246000fd5b6003811061392a57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b038c81168252602082018c9052604082018b905261ffff8a811660608401528916608083015260a0820188905286151560c083015261016082019061397d60e084018861390c565b949094166101008201526101208101929092526101409091015298975050505050505050565b6000602082840312156139b557600080fd5b813561333181613897565b6020808252825182820181905260009190848201906040850190845b81811015613a2d57613a1a83855180518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b9284019260a092909201916001016139dc565b50909695505050505050565b60008060408385031215613a4c57600080fd5b50508035926020909101359150565b803561ffff81168114613a6d57600080fd5b919050565b60008060008060808587031215613a8857600080fd5b8435935060208501359250613a9f60408601613a5b565b9150613aad60608601613a5b565b905092959194509250565b805182526020810151613ad660208401826001600160a01b03169052565b5060408101516040830152606081015160608301526080810151613b00608084018261ffff169052565b5060a0810151613b1660a084018261ffff169052565b5060c081015160c083015260e0810151613b3460e084018215159052565b5061010080820151613b488285018261390c565b5050610120818101516001600160a01b031690830152610140808201519083015261016090810151910152565b6020808252825182820181905260009190848201906040850190845b81811015613a2d57613ba4838551613ab8565b928401926101809290920191600101613b91565b600080600060608486031215613bcd57600080fd5b83359250602084013591506040840135613be681613897565b809150509250925092565b60008060408385031215613c0457600080fd5b823591506020830135613c1681613897565b809150509250929050565b60a08101611469828480518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b60008060208385031215613c6d57600080fd5b823567ffffffffffffffff80821115613c8557600080fd5b818501915085601f830112613c9957600080fd5b813581811115613ca857600080fd5b8660208260051b8501011115613cbd57600080fd5b60209290920196919550909350505050565b60005b83811015613cea578181015183820152602001613cd2565b50506000910152565b60008151808452613d0b816020860160208601613ccf565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613d7457603f19888603018452613d62858351613cf3565b94509285019290850190600101613d46565b5092979650505050505050565b61018081016114698284613ab8565b801515811461126157600080fd5b60008060008060008060008060006101208a8c031215613dbd57600080fd5b8935985060208a0135613dcf81613897565b975060408a0135613ddf81613d90565b965060608a01359550613df460808b01613a5b565b9450613e0260a08b01613a5b565b935060c08a013560038110613e1657600080fd5b925060e08a0135613e2681613897565b809250506101008a013590509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613e9357613e93613e6b565b5060010190565b600060208284031215613eac57600080fd5b5051919050565b60208082526037908201527f454d495353494f4e533a20496e76616c6964206465706f736974206f7220776960408201527f7468647261772066656520626173697320706f696e7473000000000000000000606082015260800190565b8181038181111561146957611469613e6b565b600060208284031215613f3557600080fd5b815161333181613d90565b8082018082111561146957611469613e6b565b60208082526023908201527f454d495353494f4e533a205a65726f2061646472657373206e6f7420616c6c6f6040820152621dd95960ea1b606082015260800190565b6000808335601e19843603018112613fad57600080fd5b83018035915067ffffffffffffffff821115613fc857600080fd5b602001915036819003821315613fdd57600080fd5b9250929050565b828482376000838201600081528351614001818360208801613ccf565b0195945050505050565b60006020828403121561401d57600080fd5b815161333181613897565b6000806000806080858703121561403e57600080fd5b845161404981613897565b60208601516040870151606090970151919890975090945092505050565b808202811582820484141761146957611469613e6b565b60008261409b57634e487b7160e01b600052601260045260246000fd5b500490565b600082516140b2818460208701613ccf565b9190910192915050565b6020815260006133316020830184613cf356fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220bd56b1537a499c3e4b09b16c205a8fef7be2e62532f4da1a6c1dfa0bc973e76264736f6c63430008140033