Contract 0x41bee92bcffea517deb87777e59271c88b31116f

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x8fc3f1afb2b74015c79890b28fd4b3a656471ddd9b8730a1a91b6bc270a900d90x60806040130286092022-04-05 15:12:49241 days 14 hrs ago0xcd7874f7430f9f62129c3fef1bc8cb8ef7bad224 IN  Create: MasterPlatypusV30 AVAX0.8150024200
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MasterPlatypusV3

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 21 : MasterPlatypusV3.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import './libraries/Math.sol';
import './libraries/SafeOwnableUpgradeable.sol';
import './interfaces/IAsset.sol';
import './interfaces/IVePtp.sol';
import './interfaces/IPtp.sol';
import './interfaces/IMasterPlatypusV2.sol';
import './interfaces/IRewarder.sol';

/// MasterPlatypus is a boss. He says "go f your blocks maki boy, I'm gonna use timestamp instead"
/// In addition, he feeds himself from Venom. So, vePtp holders boost their (non-dialuting) emissions.
/// This contract rewards users in function of their amount of lp staked (dialuting pool) factor (non-dialuting pool)
/// Factor and sumOfFactors are updated by contract VePtp.sol after any vePtp minting/burning (veERC20Upgradeable hook).
/// Note that it's ownable and the owner wields tremendous power. The ownership
/// will be transferred to a governance smart contract once Platypus is sufficiently
/// distributed and the community can show to govern itself.
contract MasterPlatypusV3 is
    Initializable,
    SafeOwnableUpgradeable,
    ReentrancyGuardUpgradeable,
    PausableUpgradeable,
    IMasterPlatypusV2
{
    using SafeERC20 for IERC20;
    using SafeERC20 for IAsset;
    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.
        uint256 factor; // non-dialuting factor = sqrt (lpAmount * vePtp.balanceOf())
        //
        // We do some fancy math here. Basically, any point in time, the amount of PTPs
        // entitled to a user but is pending to be distributed is:
        //
        //   ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12) -
        //        user.rewardDebt
        //
        // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
        //   1. The pool's `accPtpPerShare`, `accPtpPerFactorShare` (and `lastRewardTimestamp`) gets updated.
        //   2. User receives the pending reward sent to his/her address.
        //   3. User's `amount` gets updated.
        //   4. User's `rewardDebt` gets updated.
    }

    // Info of each pool.
    struct PoolInfo {
        IAsset lpToken; // Address of LP token contract.
        uint256 baseAllocPoint; // How many base allocation points assigned to this pool
        uint256 lastRewardTimestamp; // Last timestamp that PTPs distribution occurs.
        uint256 accPtpPerShare; // Accumulated PTPs per share, times 1e12.
        IRewarder rewarder;
        uint256 sumOfFactors; // the sum of all non dialuting factors by all of the users in the pool
        uint256 accPtpPerFactorShare; // accumulated ptp per factor share
        uint256 adjustedAllocPoint; // Adjusted allocation points for this pool. PTPs to distribute per second.
    }

    // The strongest platypus out there (ptp token).
    IERC20 public ptp;
    // Venom does not seem to hurt the Platypus, it only makes it stronger.
    IVePtp public vePtp;
    // New Master Platypus address for future migrations
    IMasterPlatypusV2 public newMasterPlatypus;
    // PTP tokens created per second.
    uint256 public ptpPerSec;
    // Emissions: both must add to 1000 => 100%
    // Dialuting emissions repartition (e.g. 300 for 30%)
    uint256 public dialutingRepartition;
    // Non-dialuting emissions repartition (e.g. 500 for 50%)
    uint256 public nonDialutingRepartition;
    // Total allocation points. Must be the sum of all allocation points in all pools.
    uint256 public totalBaseAllocPoint;
    // The timestamp when PTP mining starts.
    uint256 public startTimestamp;
    // Info of each pool.
    PoolInfo[] public poolInfo;
    // Set of all LP tokens that have been added as pools
    EnumerableSet.AddressSet private lpTokens;
    // Info of each user that stakes LP tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;
    // Amount of claimable ptp the user has
    mapping(uint256 => mapping(address => uint256)) public claimablePtp;
    // Total adjusted allocation points. Must be the sum of adjusted allocation points in all pools.
    uint256 public totalAdjustedAllocPoint;
    // The maximum number of pools, in case updateFactor() exceeds block gas limit
    uint256 public maxPoolLength;

    event Add(uint256 indexed pid, uint256 baseAllocPoint, IAsset indexed lpToken, IRewarder indexed rewarder);
    event Set(uint256 indexed pid, uint256 baseAllocPoint, IRewarder indexed rewarder, bool overwrite);
    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event DepositFor(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event UpdatePool(uint256 indexed pid, uint256 lastRewardTimestamp, uint256 lpSupply, uint256 accPtpPerShare);
    event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event UpdateEmissionRate(address indexed user, uint256 ptpPerSec);
    event UpdateEmissionRepartition(
        address indexed user,
        uint256 dialutingRepartition,
        uint256 nonDialutingRepartition
    );
    event UpdateVePTP(address indexed user, address oldVePTP, address newVePTP);

    /// @dev Modifier ensuring that certain function can only be called by VePtp
    modifier onlyVePtp() {
        require(address(vePtp) == msg.sender, 'notVePtp: wut?');
        _;
    }

    function initialize(
        IERC20 _ptp,
        IVePtp _vePtp,
        uint256 _ptpPerSec,
        uint256 _dialutingRepartition,
        uint256 _startTimestamp
    ) public initializer {
        require(address(_ptp) != address(0), 'ptp address cannot be zero');
        require(address(_vePtp) != address(0), 'vePtp address cannot be zero');
        require(_ptpPerSec != 0, 'ptp per sec cannot be zero');
        require(_dialutingRepartition <= 1000, 'dialuting repartition must be in range 0, 1000');

        __Ownable_init();
        __ReentrancyGuard_init_unchained();
        __Pausable_init_unchained();

        ptp = _ptp;
        vePtp = _vePtp;
        ptpPerSec = _ptpPerSec;
        dialutingRepartition = _dialutingRepartition;
        nonDialutingRepartition = 1000 - _dialutingRepartition;
        startTimestamp = _startTimestamp;
        maxPoolLength = 50;
    }

    /**
     * @dev pause pool, restricting certain operations
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev unpause pool, enabling certain operations
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    function setNewMasterPlatypus(IMasterPlatypusV2 _newMasterPlatypus) external onlyOwner {
        newMasterPlatypus = _newMasterPlatypus;
    }

    function setMaxPoolLength(uint256 _maxPoolLength) external onlyOwner {
        require(poolInfo.length <= _maxPoolLength);
        maxPoolLength = _maxPoolLength;
    }

    /// @notice returns pool length
    function poolLength() external view override returns (uint256) {
        return poolInfo.length;
    }

    /// @notice Add a new lp to the pool. Can only be called by the owner.
    /// @dev Reverts if the same LP token is added more than once.
    /// @param _baseAllocPoint allocation points for this LP
    /// @param _lpToken the corresponding lp token
    /// @param _rewarder the rewarder
    function add(
        uint256 _baseAllocPoint,
        IAsset _lpToken,
        IRewarder _rewarder
    ) public onlyOwner {
        require(Address.isContract(address(_lpToken)), 'add: LP token must be a valid contract');
        require(
            Address.isContract(address(_rewarder)) || address(_rewarder) == address(0),
            'add: rewarder must be contract or zero'
        );
        require(!lpTokens.contains(address(_lpToken)), 'add: LP already added');
        require(poolInfo.length < maxPoolLength, 'add: exceed max pool');

        // update all pools
        massUpdatePools();

        // update last time rewards were calculated to now
        uint256 lastRewardTimestamp = block.timestamp > startTimestamp ? block.timestamp : startTimestamp;

        // update alloc point
        uint256 adjustedAllocPoint = _baseAllocPoint * _assetAdjustFactor(_lpToken);
        totalBaseAllocPoint += _baseAllocPoint;
        totalAdjustedAllocPoint += adjustedAllocPoint;

        // update PoolInfo with the new LP
        poolInfo.push(
            PoolInfo({
                lpToken: _lpToken,
                baseAllocPoint: _baseAllocPoint,
                lastRewardTimestamp: lastRewardTimestamp,
                accPtpPerShare: 0,
                rewarder: _rewarder,
                sumOfFactors: 0,
                accPtpPerFactorShare: 0,
                adjustedAllocPoint: adjustedAllocPoint
            })
        );

        // add lpToken to the lpTokens enumerable set
        lpTokens.add(address(_lpToken));
        emit Add(poolInfo.length - 1, _baseAllocPoint, _lpToken, _rewarder);
    }

    /// @notice Update the given pool's PTP allocation point. Can only be called by the owner.
    /// @param _pid the pool id
    /// @param _baseAllocPoint allocation points
    /// @param _rewarder the rewarder
    /// @param overwrite overwrite rewarder?
    function set(
        uint256 _pid,
        uint256 _baseAllocPoint,
        IRewarder _rewarder,
        bool overwrite
    ) public onlyOwner {
        require(
            Address.isContract(address(_rewarder)) || address(_rewarder) == address(0),
            'set: rewarder must be contract or zero'
        );
        massUpdatePools();

        PoolInfo storage pool = poolInfo[_pid];

        totalBaseAllocPoint = totalBaseAllocPoint - pool.baseAllocPoint + _baseAllocPoint;
        pool.baseAllocPoint = _baseAllocPoint;
        // update adjustedAllocPoint point after baseAllocPoint
        _updateAdjustedAllocPoint(pool);

        if (overwrite) {
            pool.rewarder = _rewarder;
        }
        emit Set(_pid, _baseAllocPoint, overwrite ? _rewarder : pool.rewarder, overwrite);
    }

    /// @notice View function to see pending PTPs on frontend.
    /// @param _pid the pool id
    /// @param _user the user address
    /// TODO include factor operations
    function pendingTokens(uint256 _pid, address _user)
        external
        view
        override
        returns (
            uint256 pendingPtp,
            address bonusTokenAddress,
            string memory bonusTokenSymbol,
            uint256 pendingBonusToken
        )
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accPtpPerShare = pool.accPtpPerShare;
        uint256 accPtpPerFactorShare = pool.accPtpPerFactorShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (block.timestamp > pool.lastRewardTimestamp && lpSupply != 0) {
            uint256 secondsElapsed = block.timestamp - pool.lastRewardTimestamp;
            uint256 ptpReward = (secondsElapsed * ptpPerSec * pool.adjustedAllocPoint) / totalAdjustedAllocPoint;
            accPtpPerShare += (ptpReward * 1e12 * dialutingRepartition) / (lpSupply * 1000);
            if (pool.sumOfFactors != 0) {
                accPtpPerFactorShare += (ptpReward * 1e12 * nonDialutingRepartition) / (pool.sumOfFactors * 1000);
            }
        }
        pendingPtp =
            ((user.amount * accPtpPerShare + user.factor * accPtpPerFactorShare) / 1e12) +
            claimablePtp[_pid][_user] -
            user.rewardDebt;
        // If it's a double reward farm, we return info about the bonus token
        if (address(pool.rewarder) != address(0)) {
            (bonusTokenAddress, bonusTokenSymbol) = rewarderBonusTokenInfo(_pid);
            pendingBonusToken = pool.rewarder.pendingTokens(_user);
        }
    }

    /// @notice Get bonus token info from the rewarder contract for a given pool, if it is a double reward farm
    /// @param _pid the pool id
    function rewarderBonusTokenInfo(uint256 _pid)
        public
        view
        override
        returns (address bonusTokenAddress, string memory bonusTokenSymbol)
    {
        PoolInfo storage pool = poolInfo[_pid];
        if (address(pool.rewarder) != address(0)) {
            bonusTokenAddress = address(pool.rewarder.rewardToken());
            bonusTokenSymbol = IERC20Metadata(pool.rewarder.rewardToken()).symbol();
        }
    }

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

    /// @notice Update reward variables of the given pool to be up-to-date.
    /// @param _pid the pool id
    function updatePool(uint256 _pid) external override {
        _updatePool(_pid);
    }

    function _updatePool(uint256 _pid) private {
        PoolInfo storage pool = poolInfo[_pid];
        // update only if now > last time we updated rewards
        if (block.timestamp > pool.lastRewardTimestamp) {
            uint256 lpSupply = pool.lpToken.balanceOf(address(this));

            // if balance of lp supply is 0, update lastRewardTime and quit function
            if (lpSupply == 0) {
                pool.lastRewardTimestamp = block.timestamp;
                return;
            }
            // calculate seconds elapsed since last update
            uint256 secondsElapsed = block.timestamp - pool.lastRewardTimestamp;

            // calculate ptp reward
            uint256 ptpReward = (secondsElapsed * ptpPerSec * pool.adjustedAllocPoint) / totalAdjustedAllocPoint;
            // update accPtpPerShare to reflect dialuting rewards
            pool.accPtpPerShare += (ptpReward * 1e12 * dialutingRepartition) / (lpSupply * 1000);

            // update accPtpPerFactorShare to reflect non-dialuting rewards
            if (pool.sumOfFactors == 0) {
                pool.accPtpPerFactorShare = 0;
            } else {
                pool.accPtpPerFactorShare += (ptpReward * 1e12 * nonDialutingRepartition) / (pool.sumOfFactors * 1000);
            }

            // update allocation point
            _updateAdjustedAllocPoint(pool);

            // update lastRewardTimestamp to now
            pool.lastRewardTimestamp = block.timestamp;
            emit UpdatePool(_pid, pool.lastRewardTimestamp, lpSupply, pool.accPtpPerShare);
        }
    }

    /// @notice Helper function to migrate fund from multiple pools to the new MasterPlatypus.
    /// @notice user must initiate transaction from masterchef
    /// @dev Assume the orginal MasterPlatypus has stopped emisions
    /// hence we can skip updatePool() to save gas cost
    function migrate(uint256[] calldata _pids) external override nonReentrant {
        require(address(newMasterPlatypus) != (address(0)), 'to where?');

        _multiClaim(_pids);
        for (uint256 i; i < _pids.length; ++i) {
            uint256 pid = _pids[i];
            UserInfo storage user = userInfo[pid][msg.sender];

            if (user.amount > 0) {
                PoolInfo storage pool = poolInfo[pid];
                pool.lpToken.approve(address(newMasterPlatypus), user.amount);
                newMasterPlatypus.depositFor(pid, user.amount, msg.sender);

                pool.sumOfFactors -= user.factor;
                delete userInfo[pid][msg.sender];
            }
        }
    }

    /// @notice Deposit LP tokens to MasterChef for PTP allocation on behalf of user
    /// @dev user must initiate transaction from masterchef
    /// @param _pid the pool id
    /// @param _amount amount to deposit
    /// @param _user the user being represented
    function depositFor(
        uint256 _pid,
        uint256 _amount,
        address _user
    ) external override nonReentrant whenNotPaused {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];

        // update pool in case user has deposited
        _updatePool(_pid);
        if (user.amount > 0) {
            // Harvest PTP
            uint256 pending = ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12) +
                claimablePtp[_pid][_user] -
                user.rewardDebt;
            claimablePtp[_pid][_user] = 0;

            pending = safePtpTransfer(payable(_user), pending);
            emit Harvest(_user, _pid, pending);
        }

        // update amount of lp staked by user
        user.amount += _amount;

        // update non-dialuting factor
        uint256 oldFactor = user.factor;
        user.factor = Math.sqrt(user.amount * vePtp.balanceOf(_user));
        pool.sumOfFactors = pool.sumOfFactors + user.factor - oldFactor;

        // update reward debt
        user.rewardDebt = (user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12;

        IRewarder rewarder = poolInfo[_pid].rewarder;
        if (address(rewarder) != address(0)) {
            rewarder.onPtpReward(_user, user.amount);
        }

        pool.lpToken.safeTransferFrom(msg.sender, address(this), _amount);
        emit DepositFor(_user, _pid, _amount);
    }

    /// @notice update adjusted allocation point for the corresponding pool
    /// @param pool the pool to update
    function _updateAdjustedAllocPoint(PoolInfo storage pool) internal {
        uint256 latestAdjustedAllocPoint = pool.baseAllocPoint * _assetAdjustFactor(pool.lpToken);
        totalAdjustedAllocPoint = totalAdjustedAllocPoint + latestAdjustedAllocPoint - pool.adjustedAllocPoint;
        pool.adjustedAllocPoint = latestAdjustedAllocPoint;
    }

    /// @notice get the interest adjust factor for the pool
    /// @param pid the pool id to query
    function poolAdjustFactor(uint256 pid) external view override returns (uint256) {
        PoolInfo memory pool = poolInfo[pid];
        return _assetAdjustFactor(pool.lpToken);
    }

    /// @notice Get the interest adjust factor for an asset
    /// @param asset the address of asset
    function _assetAdjustFactor(IAsset asset) internal view returns (uint256) {
        uint256 liability = asset.liability();
        // if liability is 0, the default adjust factor is 0
        uint256 r = liability == 0 ? 1 ether : (1 ether * asset.cash()) / liability;
        return _adjustFactor(r);
    }

    /// @notice Get the interest adjust factor by coverage ratio
    /// @param r coverage ratio
    function _adjustFactor(uint256 r) internal pure returns (uint256) {
        if (r == 0) {
            // return an infinite small number in case of division of 0;
            return 1;
        }
        return Math.wdiv(1 ether, 0.2 ether + Math.wdiv(1 ether, r));
    }

    /// @notice Deposit LP tokens to MasterChef for PTP allocation.
    /// @dev it is possible to call this function with _amount == 0 to claim current rewards
    /// @param _pid the pool id
    /// @param _amount amount to deposit
    function deposit(uint256 _pid, uint256 _amount)
        external
        override
        nonReentrant
        whenNotPaused
        returns (uint256, uint256)
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        _updatePool(_pid);
        uint256 pending;
        if (user.amount > 0) {
            // Harvest PTP
            pending =
                ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12) +
                claimablePtp[_pid][msg.sender] -
                user.rewardDebt;
            claimablePtp[_pid][msg.sender] = 0;

            pending = safePtpTransfer(payable(msg.sender), pending);
            emit Harvest(msg.sender, _pid, pending);
        }

        // update amount of lp staked by user
        user.amount += _amount;

        // update non-dialuting factor
        uint256 oldFactor = user.factor;
        user.factor = Math.sqrt(user.amount * vePtp.balanceOf(msg.sender));
        pool.sumOfFactors = pool.sumOfFactors + user.factor - oldFactor;

        // update reward debt
        user.rewardDebt = (user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12;

        IRewarder rewarder = poolInfo[_pid].rewarder;
        uint256 additionalRewards;
        if (address(rewarder) != address(0)) {
            additionalRewards = rewarder.onPtpReward(msg.sender, user.amount);
        }

        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        emit Deposit(msg.sender, _pid, _amount);
        return (pending, additionalRewards);
    }

    /// @notice claims rewards for multiple pids
    /// @param _pids array pids, pools to claim
    function multiClaim(uint256[] memory _pids)
        external
        override
        nonReentrant
        whenNotPaused
        returns (
            uint256,
            uint256[] memory,
            uint256[] memory
        )
    {
        return _multiClaim(_pids);
    }

    /// @notice private function to claim rewards for multiple pids
    /// @param _pids array pids, pools to claim
    function _multiClaim(uint256[] memory _pids)
        private
        returns (
            uint256,
            uint256[] memory,
            uint256[] memory
        )
    {
        // accumulate rewards for each one of the pids in pending
        uint256 pending;
        uint256[] memory amounts = new uint256[](_pids.length);
        uint256[] memory additionalRewards = new uint256[](_pids.length);
        for (uint256 i; i < _pids.length; ++i) {
            _updatePool(_pids[i]);
            PoolInfo storage pool = poolInfo[_pids[i]];
            UserInfo storage user = userInfo[_pids[i]][msg.sender];
            if (user.amount > 0) {
                // increase pending to send all rewards once
                uint256 poolRewards = ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) /
                    1e12) +
                    claimablePtp[_pids[i]][msg.sender] -
                    user.rewardDebt;

                claimablePtp[_pids[i]][msg.sender] = 0;

                // update reward debt
                user.rewardDebt = (user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12;

                // increase pending
                pending += poolRewards;

                amounts[i] = poolRewards;
                // if existant, get external rewarder rewards for pool
                IRewarder rewarder = pool.rewarder;
                if (address(rewarder) != address(0)) {
                    additionalRewards[i] = rewarder.onPtpReward(msg.sender, user.amount);
                }
            }
        }
        // transfer all remaining rewards
        uint256 transfered = safePtpTransfer(payable(msg.sender), pending);
        if (transfered != pending) {
            for (uint256 i; i < _pids.length; ++i) {
                amounts[i] = (transfered * amounts[i]) / pending;
                emit Harvest(msg.sender, _pids[i], amounts[i]);
            }
        } else {
            for (uint256 i; i < _pids.length; ++i) {
                // emit event for pool
                emit Harvest(msg.sender, _pids[i], amounts[i]);
            }
        }

        return (transfered, amounts, additionalRewards);
    }

    /// @notice Withdraw LP tokens from MasterPlatypus.
    /// @notice Automatically harvest pending rewards and sends to user
    /// @param _pid the pool id
    /// @param _amount the amount to withdraw
    function withdraw(uint256 _pid, uint256 _amount)
        external
        override
        nonReentrant
        whenNotPaused
        returns (uint256, uint256)
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount >= _amount, 'withdraw: not good');

        _updatePool(_pid);

        // Harvest PTP
        uint256 pending = ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12) +
            claimablePtp[_pid][msg.sender] -
            user.rewardDebt;
        claimablePtp[_pid][msg.sender] = 0;

        pending = safePtpTransfer(payable(msg.sender), pending);
        emit Harvest(msg.sender, _pid, pending);

        // for non-dialuting factor
        uint256 oldFactor = user.factor;

        // update amount of lp staked
        user.amount = user.amount - _amount;

        // update non-dialuting factor
        user.factor = Math.sqrt(user.amount * vePtp.balanceOf(msg.sender));
        pool.sumOfFactors = pool.sumOfFactors + user.factor - oldFactor;

        // update reward debt
        user.rewardDebt = (user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12;

        IRewarder rewarder = poolInfo[_pid].rewarder;
        uint256 additionalRewards;
        if (address(rewarder) != address(0)) {
            additionalRewards = rewarder.onPtpReward(msg.sender, user.amount);
        }

        pool.lpToken.safeTransfer(address(msg.sender), _amount);
        emit Withdraw(msg.sender, _pid, _amount);
        return (pending, additionalRewards);
    }

    /// @notice Withdraw without caring about rewards. EMERGENCY ONLY.
    /// @param _pid the pool id
    function emergencyWithdraw(uint256 _pid) public nonReentrant {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        pool.lpToken.safeTransfer(address(msg.sender), user.amount);

        // update non-dialuting factor
        pool.sumOfFactors = pool.sumOfFactors - user.factor;
        user.factor = 0;

        // update dialuting factors
        user.amount = 0;
        user.rewardDebt = 0;

        // reset rewarder
        IRewarder rewarder = pool.rewarder;
        if (address(rewarder) != address(0)) {
            rewarder.onPtpReward(msg.sender, 0);
        }

        emit EmergencyWithdraw(msg.sender, _pid, user.amount);
    }

    /// @notice Safe ptp transfer function, just in case if rounding error causes pool to not have enough PTPs.
    /// @param _to beneficiary
    /// @param _amount the amount to transfer
    function safePtpTransfer(address payable _to, uint256 _amount) private returns (uint256) {
        uint256 ptpBal = ptp.balanceOf(address(this));

        // perform additional check in case there are no more ptp tokens to distribute.
        // emergency withdraw would be necessary
        require(ptpBal > 0, 'No tokens to distribute');

        if (_amount > ptpBal) {
            ptp.transfer(_to, ptpBal);
            return ptpBal;
        } else {
            ptp.transfer(_to, _amount);
            return _amount;
        }
    }

    /// @notice updates emission rate
    /// @param _ptpPerSec ptp amount to be updated
    /// @dev Pancake has to add hidden dummy pools inorder to alter the emission,
    /// @dev here we make it simple and transparent to all.
    function updateEmissionRate(uint256 _ptpPerSec) external onlyOwner {
        massUpdatePools();
        ptpPerSec = _ptpPerSec;
        emit UpdateEmissionRate(msg.sender, _ptpPerSec);
    }

    /// @notice updates emission repartition
    /// @param _dialutingRepartition the future dialuting repartition
    function updateEmissionRepartition(uint256 _dialutingRepartition) external onlyOwner {
        require(_dialutingRepartition <= 1000);
        massUpdatePools();
        dialutingRepartition = _dialutingRepartition;
        nonDialutingRepartition = 1000 - _dialutingRepartition;
        emit UpdateEmissionRepartition(msg.sender, _dialutingRepartition, 1000 - _dialutingRepartition);
    }

    /// @notice updates vePtp address
    /// @param _newVePtp the new VePtp address
    function setVePtp(IVePtp _newVePtp) external onlyOwner {
        require(address(_newVePtp) != address(0));
        massUpdatePools();
        IVePtp oldVePtp = vePtp;
        vePtp = _newVePtp;
        emit UpdateVePTP(msg.sender, address(oldVePtp), address(_newVePtp));
    }

    /// @notice updates factor after any vePtp token operation (minting/burning)
    /// @param _user the user to update
    /// @param _newVePtpBalance the amount of vePTP
    /// @dev can only be called by vePtp
    function updateFactor(address _user, uint256 _newVePtpBalance) external override onlyVePtp {
        // loop over each pool : beware gas cost!
        uint256 length = poolInfo.length;

        for (uint256 pid = 0; pid < length; ++pid) {
            UserInfo storage user = userInfo[pid][_user];

            // skip if user doesn't have any deposit in the pool
            if (user.amount == 0) {
                continue;
            }

            PoolInfo storage pool = poolInfo[pid];

            // first, update pool
            _updatePool(pid);
            // calculate pending
            uint256 pending = ((user.amount * pool.accPtpPerShare + user.factor * pool.accPtpPerFactorShare) / 1e12) -
                user.rewardDebt;
            // increase claimablePtp
            claimablePtp[pid][_user] += pending;
            // get oldFactor
            uint256 oldFactor = user.factor; // get old factor
            // calculate newFactor using
            uint256 newFactor = Math.sqrt(_newVePtpBalance * user.amount);
            // update user factor
            user.factor = newFactor;
            // update reward debt, take into account newFactor
            user.rewardDebt = (user.amount * pool.accPtpPerShare + newFactor * pool.accPtpPerFactorShare) / 1e12;
            // also, update sumOfFactors
            pool.sumOfFactors = pool.sumOfFactors + newFactor - oldFactor;
        }
    }

    /// @notice In case we need to manually migrate PTP funds from MasterChef
    /// Sends all remaining ptp from the contract to the owner
    function emergencyPtpWithdraw() external onlyOwner {
        ptp.safeTransfer(address(msg.sender), ptp.balanceOf(address(this)));
    }

    function version() external pure returns (uint256) {
        return 3;
    }
}

File 2 of 21 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal initializer {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 3 of 21 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal initializer {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 4 of 21 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 5 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 6 of 21 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 7 of 21 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

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.
 *
 * ```
 * 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.
 */
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) {
        return _values(set._inner);
    }

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

        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 on 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;

        assembly {
            result := store
        }

        return result;
    }
}

File 8 of 21 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 9 of 21 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

// a library for performing various math operations

library Math {
    uint256 public constant WAD = 10**18;

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint256 y) internal pure returns (uint256 z) {
        if (y > 3) {
            z = y;
            uint256 x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }

    //rounds to zero if x*y < WAD / 2
    function wmul(uint256 x, uint256 y) internal pure returns (uint256) {
        return ((x * y) + (WAD / 2)) / WAD;
    }

    //rounds to zero if x*y < WAD / 2
    function wdiv(uint256 x, uint256 y) internal pure returns (uint256) {
        return ((x * WAD) + (y / 2)) / y;
    }
}

File 10 of 21 : SafeOwnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import '@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 *
 * Note: This contract is backward compatible to OwnableUpgradeable of OZ except from that
 * transferOwnership is dropped.
 * __gap[0] is used as ownerCandidate, as changing storage is not supported yet
 * See https://forum.openzeppelin.com/t/storage-layout-upgrade-with-hardhat-upgrades/14567
 */
contract SafeOwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        _setOwner(_msgSender());
    }

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

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

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

    function ownerCandidate() public view returns (address) {
        return address(uint160(__gap[0]));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function proposeOwner(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0x0)) revert('ZeroAddress');
        // __gap[0] is used as ownerCandidate
        __gap[0] = uint256(uint160(newOwner));
    }

    function acceptOwnership() external {
        if (ownerCandidate() != msg.sender) revert('Unauthorized');
        _setOwner(msg.sender);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    uint256[49] private __gap;
}

File 11 of 21 : IAsset.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

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

/**
 * @dev Interface of Asset
 */
interface IAsset is IERC20 {
    function cash() external view returns (uint256);

    function liability() external view returns (uint256);
}

File 12 of 21 : IVePtp.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import './IVeERC20.sol';

/**
 * @dev Interface of the VePtp
 */
interface IVePtp is IVeERC20 {
    function isUser(address _addr) external view returns (bool);

    function deposit(uint256 _amount) external;

    function claim() external;

    function claimable(address _addr) external view returns (uint256);

    function withdraw(uint256 _amount) external;

    function vePtpBurnedOnWithdraw(address _addr, uint256 _amount) external view returns (uint256);

    function stakeNft(uint256 _tokenId) external;

    function unstakeNft() external;

    function getStakedNft(address _addr) external view returns (uint256);

    function getStakedPtp(address _addr) external view returns (uint256);

    function levelUp(uint256[] memory platypusBurned) external;

    function levelDown() external;

    function getVotes(address _account) external view returns (uint256);
}

File 13 of 21 : IPtp.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

interface IPtp {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Transfer(address indexed from, address indexed to, uint256 value);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);

    function totalSupply() external view returns (uint256);

    function balanceOf(address owner) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function PERMIT_TYPEHASH() external pure returns (bytes32);

    function nonces(address owner) external view returns (uint256);

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

File 14 of 21 : IMasterPlatypusV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

/**
 * @dev Interface of the MasterPlatypusV2
 */
interface IMasterPlatypusV2 {
    function poolLength() external view returns (uint256);

    function pendingTokens(uint256 _pid, address _user)
        external
        view
        returns (
            uint256 pendingPtp,
            address bonusTokenAddress,
            string memory bonusTokenSymbol,
            uint256 pendingBonusToken
        );

    function rewarderBonusTokenInfo(uint256 _pid)
        external
        view
        returns (address bonusTokenAddress, string memory bonusTokenSymbol);

    function massUpdatePools() external;

    function updatePool(uint256 _pid) external;

    function poolAdjustFactor(uint256 pid) external view returns (uint256);

    function deposit(uint256 _pid, uint256 _amount) external returns (uint256, uint256);

    function multiClaim(uint256[] memory _pids)
        external
        returns (
            uint256,
            uint256[] memory,
            uint256[] memory
        );

    function withdraw(uint256 _pid, uint256 _amount) external returns (uint256, uint256);

    function emergencyWithdraw(uint256 _pid) external;

    function migrate(uint256[] calldata _pids) external;

    function depositFor(
        uint256 _pid,
        uint256 _amount,
        address _user
    ) external;

    function updateFactor(address _user, uint256 _newVePtpBalance) external;
}

File 15 of 21 : IRewarder.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

import '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol';

interface IRewarder {
    function onPtpReward(address user, uint256 newLpAmount) external returns (uint256);

    function pendingTokens(address user) external view returns (uint256 pending);

    function rewardToken() external view returns (IERC20Metadata);
}

File 16 of 21 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 17 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 18 of 21 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 19 of 21 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

File 20 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 21 of 21 : IVeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

interface IVeERC20 {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseAllocPoint","type":"uint256"},{"indexed":true,"internalType":"contract IAsset","name":"lpToken","type":"address"},{"indexed":true,"internalType":"contract IRewarder","name":"rewarder","type":"address"}],"name":"Add","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseAllocPoint","type":"uint256"},{"indexed":true,"internalType":"contract IRewarder","name":"rewarder","type":"address"},{"indexed":false,"internalType":"bool","name":"overwrite","type":"bool"}],"name":"Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"ptpPerSec","type":"uint256"}],"name":"UpdateEmissionRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"dialutingRepartition","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonDialutingRepartition","type":"uint256"}],"name":"UpdateEmissionRepartition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastRewardTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accPtpPerShare","type":"uint256"}],"name":"UpdatePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"oldVePTP","type":"address"},{"indexed":false,"internalType":"address","name":"newVePTP","type":"address"}],"name":"UpdateVePTP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_baseAllocPoint","type":"uint256"},{"internalType":"contract IAsset","name":"_lpToken","type":"address"},{"internalType":"contract IRewarder","name":"_rewarder","type":"address"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"claimablePtp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dialutingRepartition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyPtpWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_ptp","type":"address"},{"internalType":"contract IVePtp","name":"_vePtp","type":"address"},{"internalType":"uint256","name":"_ptpPerSec","type":"uint256"},{"internalType":"uint256","name":"_dialutingRepartition","type":"uint256"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxPoolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_pids","type":"uint256[]"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_pids","type":"uint256[]"}],"name":"multiClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"newMasterPlatypus","outputs":[{"internalType":"contract IMasterPlatypusV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonDialutingRepartition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ownerCandidate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingTokens","outputs":[{"internalType":"uint256","name":"pendingPtp","type":"uint256"},{"internalType":"address","name":"bonusTokenAddress","type":"address"},{"internalType":"string","name":"bonusTokenSymbol","type":"string"},{"internalType":"uint256","name":"pendingBonusToken","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"poolAdjustFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"contract IAsset","name":"lpToken","type":"address"},{"internalType":"uint256","name":"baseAllocPoint","type":"uint256"},{"internalType":"uint256","name":"lastRewardTimestamp","type":"uint256"},{"internalType":"uint256","name":"accPtpPerShare","type":"uint256"},{"internalType":"contract IRewarder","name":"rewarder","type":"address"},{"internalType":"uint256","name":"sumOfFactors","type":"uint256"},{"internalType":"uint256","name":"accPtpPerFactorShare","type":"uint256"},{"internalType":"uint256","name":"adjustedAllocPoint","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"proposeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ptp","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ptpPerSec","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"rewarderBonusTokenInfo","outputs":[{"internalType":"address","name":"bonusTokenAddress","type":"address"},{"internalType":"string","name":"bonusTokenSymbol","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_baseAllocPoint","type":"uint256"},{"internalType":"contract IRewarder","name":"_rewarder","type":"address"},{"internalType":"bool","name":"overwrite","type":"bool"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPoolLength","type":"uint256"}],"name":"setMaxPoolLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMasterPlatypusV2","name":"_newMasterPlatypus","type":"address"}],"name":"setNewMasterPlatypus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IVePtp","name":"_newVePtp","type":"address"}],"name":"setVePtp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAdjustedAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBaseAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ptpPerSec","type":"uint256"}],"name":"updateEmissionRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dialutingRepartition","type":"uint256"}],"name":"updateEmissionRepartition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_newVePtpBalance","type":"uint256"}],"name":"updateFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"factor","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vePtp","outputs":[{"internalType":"contract IVePtp","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506148d3806100206000396000f3fe608060405234801561001057600080fd5b50600436106102f45760003560e01c80637b62a738116101915780639702d3e2116100e3578063d93bf4fe11610097578063e6fd48bc11610071578063e6fd48bc14610677578063f87bbc5614610680578063ffcd42631461068957600080fd5b8063d93bf4fe1461063e578063e0a4ed4314610651578063e2bbb1581461066457600080fd5b8063b5ed298a116100c8578063b5ed298a146105f7578063bc70fdbc1461060a578063d13f90b41461062b57600080fd5b80639702d3e2146105db578063ab7de098146105e457600080fd5b80638b4d83a31161014557806390d9c1c31161011f57806390d9c1c31461056a57806391ea1d681461057d57806393f1a40b1461058657600080fd5b80638b4d83a31461051b5780638da5cb5b1461054657806390210d7e1461055757600080fd5b806382c780a11161017657806382c780a1146104ed5780638456cb591461050057806388bba42f1461050857600080fd5b80637b62a738146104dc5780637dd38dcc146104e557600080fd5b806351eb05a61161024a5780635f504a82116101fe578063715018a6116101d8578063715018a6146104b957806379ba5097146104c15780637b261591146104c957600080fd5b80635f504a8214610496578063630b5ba11461049e5780636af66772146104a657600080fd5b806353c5eb441161022f57806353c5eb441461046657806354fd4d50146104795780635c975abb1461048057600080fd5b806351eb05a6146104405780635312ea8e1461045357600080fd5b80632b685580116102ac578063441a3e7011610286578063441a3e70146103e35780634ed73d281461040b5780634f00a93e1461042d57600080fd5b80632b685580146103bf57806333e045fc146103d25780633f4ba83a146103db57600080fd5b8063081e3eda116102dd578063081e3eda146103405780630ba84cd2146103485780631526fe271461035d57600080fd5b806301126816146102f957806305ed1de414610329575b600080fd5b60cb5461030c906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61033260cd5481565b604051908152602001610320565b60d154610332565b61035b610356366004614249565b6106ac565b005b61037061036b366004614249565b61073f565b604080516001600160a01b03998a168152602081019890985287019590955260608601939093529416608084015260a083019390935260c082019290925260e081019190915261010001610320565b6103326103cd366004614249565b6107a1565b61033260cf5481565b61035b610843565b6103f66103f1366004614262565b610895565b60408051928352602083019190915201610320565b61041e6104193660046142cb565b610ce4565b604051610320939291906143ac565b61035b61043b3660046143f6565b610da2565b61035b61044e366004614249565b610f94565b61035b610461366004614249565b610fa0565b61035b610474366004614249565b611159565b6003610332565b60975460ff166040519015158152602001610320565b60345461030c565b61035b6111b5565b60c95461030c906001600160a01b031681565b61035b6111e0565b61035b611232565b61035b6104d7366004614422565b61129b565b61033260d75481565b61035b611305565b60ca5461030c906001600160a01b031681565b61035b6113e1565b61035b61051636600461444d565b611431565b610332610529366004614497565b60d560209081526000928352604080842090915290825290205481565b6033546001600160a01b031661030c565b61035b6105653660046144c7565b6115da565b61035b610578366004614422565b611a04565b61033260d65481565b6105c0610594366004614497565b60d460209081526000928352604080842090915290825290208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610320565b61033260cc5481565b61035b6105f2366004614500565b611aca565b61035b610605366004614422565b611f21565b61061d610618366004614249565b611fcd565b60405161032092919061458f565b61035b6106393660046145b1565b6121a8565b61035b61064c366004614602565b61243c565b61035b61065f366004614249565b61272e565b6103f6610672366004614262565b6127e5565b61033260d05481565b61033260ce5481565b61069c610697366004614497565b612b80565b6040516103209493929190614677565b6033546001600160a01b031633146106f95760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064015b60405180910390fd5b6107016111b5565b60cc81905560405181815233907fe2492e003bbe8afa53088b406f0c1cb5d9e280370fc72a74cf116ffd343c4053906020015b60405180910390a250565b60d1818154811061074f57600080fd5b6000918252602090912060089091020180546001820154600283015460038401546004850154600586015460068701546007909701546001600160a01b03968716985094969395929491909216929088565b60008060d183815481106107b7576107b76146b0565b60009182526020918290206040805161010081018252600890930290910180546001600160a01b039081168085526001830154958501959095526002820154928401929092526003810154606084015260048101549091166080830152600581015460a0830152600681015460c08301526007015460e0820152915061083c90612e7e565b9392505050565b6033546001600160a01b0316331461088b5760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b610893612fac565b565b600080600260655414156108eb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b600260655560975460ff16156109365760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106f0565b600060d1858154811061094b5761094b6146b0565b6000918252602080832088845260d48252604080852033865290925292208054600890920290920192508511156109c45760405162461bcd60e51b815260206004820152601260248201527f77697468647261773a206e6f7420676f6f64000000000000000000000000000060448201526064016106f0565b6109cd86613048565b6001810154600087815260d5602090815260408083203384529091528120546006850154600285015492939264e8d4a5100091610a09916146dc565b60038701548654610a1a91906146dc565b610a2491906146fb565b610a2e9190614713565b610a3891906146fb565b610a429190614735565b600088815260d560209081526040808320338085529252822091909155909150610a6c9082613254565b905086336001600160a01b03167f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae066092495483604051610aaa91815260200190565b60405180910390a360028201548254610ac4908890614735565b835560ca546040516370a0823160e01b8152336004820152610b55916001600160a01b0316906370a08231906024015b60206040518083038186803b158015610b0c57600080fd5b505afa158015610b20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b44919061474c565b8454610b5091906146dc565b61344e565b6002840181905560058501548291610b6c916146fb565b610b769190614735565b60058501556006840154600284015464e8d4a5100091610b95916146dc565b60038601548554610ba691906146dc565b610bb091906146fb565b610bba9190614713565b8360010181905550600060d18981548110610bd757610bd76146b0565b600091825260208220600460089092020101546001600160a01b031691508115610c81578454604051637135edff60e11b815233600482015260248101919091526001600160a01b0383169063e26bdbfe90604401602060405180830381600087803b158015610c4657600080fd5b505af1158015610c5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7e919061474c565b90505b8554610c97906001600160a01b0316338b6134be565b6040518981528a9033907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568906020015b60405180910390a360016065559299929850919650505050505050565b600060608060026065541415610d3c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b600260655560975460ff1615610d875760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106f0565b610d9084613553565b92509250925060016065559193909250565b60ca546001600160a01b03163314610dfc5760405162461bcd60e51b815260206004820152600e60248201527f6e6f7456655074703a207775743f00000000000000000000000000000000000060448201526064016106f0565b60d15460005b81811015610f8e57600081815260d4602090815260408083206001600160a01b038816845290915290208054610e385750610f7e565b600060d18381548110610e4d57610e4d6146b0565b90600052602060002090600802019050610e6683613048565b6000826001015464e8d4a5100083600601548560020154610e8791906146dc565b60038501548654610e9891906146dc565b610ea291906146fb565b610eac9190614713565b610eb69190614735565b600085815260d5602090815260408083206001600160a01b038c168452909152812080549293508392909190610eed9084906146fb565b909155505060028301548354600090610f0a90610b50908a6146dc565b60028601819055600685015490915064e8d4a5100090610f2a90836146dc565b60038601548754610f3b91906146dc565b610f4591906146fb565b610f4f9190614713565b600186015560058401548290610f669083906146fb565b610f709190614735565b846005018190555050505050505b610f8781614765565b9050610e02565b50505050565b610f9d81613048565b50565b60026065541415610ff35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b6002606581905550600060d18281548110611010576110106146b0565b6000918252602080832085845260d482526040808520338087529352909320805460089093029093018054909450611055926001600160a01b039190911691906134be565b806002015482600501546110699190614735565b6005830155600060028201819055808255600182015560048201546001600160a01b0316801561111557604051637135edff60e11b8152336004820152600060248201526001600160a01b0382169063e26bdbfe90604401602060405180830381600087803b1580156110db57600080fd5b505af11580156110ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611113919061474c565b505b8154604051908152849033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a3505060016065555050565b6033546001600160a01b031633146111a15760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b60d1548110156111b057600080fd5b60d755565b60d15460005b818110156111dc576111cc81613048565b6111d581614765565b90506111bb565b5050565b6033546001600160a01b031633146112285760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b6108936000613a60565b3361123c60345490565b6001600160a01b0316146112925760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a6564000000000000000000000000000000000000000060448201526064016106f0565b61089333613a60565b6033546001600160a01b031633146112e35760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b60cb80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b0316331461134d5760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b60c9546040516370a0823160e01b81523060048201526108939133916001600160a01b03909116906370a082319060240160206040518083038186803b15801561139657600080fd5b505afa1580156113aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ce919061474c565b60c9546001600160a01b031691906134be565b6033546001600160a01b031633146114295760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b610893613ab2565b6033546001600160a01b031633146114795760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b813b15158061148f57506001600160a01b038216155b6114ea5760405162461bcd60e51b815260206004820152602660248201527f7365743a207265776172646572206d75737420626520636f6e7472616374206f60448201526572207a65726f60d01b60648201526084016106f0565b6114f26111b5565b600060d18581548110611507576115076146b0565b9060005260206000209060080201905083816001015460cf5461152a9190614735565b61153491906146fb565b60cf556001810184905561154781613b2d565b811561156b576004810180546001600160a01b0319166001600160a01b0385161790555b816115835760048101546001600160a01b0316611585565b825b6001600160a01b0316857fa54644aae5c48c5971516f334e4fe8ecbc7930e23f34877d4203c6551e67ffaa86856040516115cb9291909182521515602082015260400190565b60405180910390a35050505050565b6002606554141561162d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b600260655560975460ff16156116785760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106f0565b600060d1848154811061168d5761168d6146b0565b6000918252602080832087845260d4825260408085206001600160a01b03881686529092529220600890910290910191506116c785613048565b8054156117c3576001810154600086815260d5602090815260408083206001600160a01b03881684529091528120546006850154600285015492939264e8d4a5100091611713916146dc565b6003870154865461172491906146dc565b61172e91906146fb565b6117389190614713565b61174291906146fb565b61174c9190614735565b600087815260d5602090815260408083206001600160a01b0389168452909152812055905061177b8482613254565b905085846001600160a01b03167f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae0660924954836040516117b991815260200190565b60405180910390a3505b838160000160008282546117d791906146fb565b9091555050600281015460ca546040516370a0823160e01b81526001600160a01b03868116600483015261186c9216906370a082319060240160206040518083038186803b15801561182857600080fd5b505afa15801561183c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611860919061474c565b8354610b5091906146dc565b6002830181905560058401548291611883916146fb565b61188d9190614735565b60058401556006830154600283015464e8d4a51000916118ac916146dc565b600385015484546118bd91906146dc565b6118c791906146fb565b6118d19190614713565b8260010181905550600060d187815481106118ee576118ee6146b0565b60009182526020909120600460089092020101546001600160a01b03169050801561199b578254604051637135edff60e11b81526001600160a01b03878116600483015260248201929092529082169063e26bdbfe90604401602060405180830381600087803b15801561196157600080fd5b505af1158015611975573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611999919061474c565b505b83546119b2906001600160a01b0316333089613b7d565b86856001600160a01b03167f16f3fbfd4bcc50a5cecb2e53e398a1ad77d89f63288ef540d862b264ed57eb1f886040516119ee91815260200190565b60405180910390a3505060016065555050505050565b6033546001600160a01b03163314611a4c5760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b6001600160a01b038116611a5f57600080fd5b611a676111b5565b60ca80546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935233917fcdc066eb512c135b027caebc803aa836c938e3e26bb2756b395da32ce0139e47910160405180910390a25050565b6033546001600160a01b03163314611b125760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b813b611b865760405162461bcd60e51b815260206004820152602660248201527f6164643a204c5020746f6b656e206d75737420626520612076616c696420636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016106f0565b803b151580611b9c57506001600160a01b038116155b611bf75760405162461bcd60e51b815260206004820152602660248201527f6164643a207265776172646572206d75737420626520636f6e7472616374206f60448201526572207a65726f60d01b60648201526084016106f0565b611c0260d283613bce565b15611c4f5760405162461bcd60e51b815260206004820152601560248201527f6164643a204c5020616c7265616479206164646564000000000000000000000060448201526064016106f0565b60d75460d15410611ca25760405162461bcd60e51b815260206004820152601460248201527f6164643a20657863656564206d617820706f6f6c00000000000000000000000060448201526064016106f0565b611caa6111b5565b600060d0544211611cbd5760d054611cbf565b425b90506000611ccc84612e7e565b611cd690866146dc565b90508460cf6000828254611cea91906146fb565b925050819055508060d66000828254611d0391906146fb565b909155505060408051610100810182526001600160a01b038087168252602082018881529282018581526000606084018181528884166080860190815260a0860183815260c0870184815260e088018a815260d180546001810182559652975160089095027f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce3810180549689166001600160a01b031997881617905598517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce48a015594517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce589015591517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce6880155517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce7870180549190951692169190911790925590517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce8840155517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327ce9830155517f695fb3134ad82c3b8022bc5464edd0bcc9424ef672b52245dcb6ab2374327cea90910155611ec060d285613bf0565b50826001600160a01b0316846001600160a01b0316600160d180549050611ee79190614735565b6040518881527f4b16bd2431ad24dc020ab0e1de7fcb6563dead6a24fb10089d6c23e97a70381f9060200160405180910390a45050505050565b6033546001600160a01b03163314611f695760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b6001600160a01b038116611fbf5760405162461bcd60e51b815260206004820152600b60248201527f5a65726f4164647265737300000000000000000000000000000000000000000060448201526064016106f0565b6001600160a01b0316603455565b60006060600060d18481548110611fe657611fe66146b0565b6000918252602090912060089091020160048101549091506001600160a01b0316156121a257600480820154604080517ff7c618c100000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169263f7c618c1928282019260209290829003018186803b15801561206957600080fd5b505afa15801561207d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a19190614780565b92508060040160009054906101000a90046001600160a01b03166001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b1580156120f357600080fd5b505afa158015612107573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061212b9190614780565b6001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561216357600080fd5b505afa158015612177573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261219f919081019061479d565b91505b50915091565b600054610100900460ff16806121c1575060005460ff16155b6122245760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015612246576000805461ffff19166101011790555b6001600160a01b03861661229c5760405162461bcd60e51b815260206004820152601a60248201527f70747020616464726573732063616e6e6f74206265207a65726f00000000000060448201526064016106f0565b6001600160a01b0385166122f25760405162461bcd60e51b815260206004820152601c60248201527f766550747020616464726573732063616e6e6f74206265207a65726f0000000060448201526064016106f0565b8361233f5760405162461bcd60e51b815260206004820152601a60248201527f70747020706572207365632063616e6e6f74206265207a65726f00000000000060448201526064016106f0565b6103e88311156123b75760405162461bcd60e51b815260206004820152602e60248201527f6469616c7574696e67207265706172746974696f6e206d75737420626520696e60448201527f2072616e676520302c203130303000000000000000000000000000000000000060648201526084016106f0565b6123bf613c05565b6123c7613cc7565b6123cf613d7e565b60c980546001600160a01b038089166001600160a01b03199283161790925560ca80549288169290911691909117905560cc84905560cd839055612415836103e8614735565b60ce5560d0829055603260d7558015612434576000805461ff00191690555b505050505050565b6002606554141561248f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b600260655560cb546001600160a01b03166124ec5760405162461bcd60e51b815260206004820152600960248201527f746f2077686572653f000000000000000000000000000000000000000000000060448201526064016106f0565b61252882828080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061355392505050565b50505060005b8181101561272457600083838381811061254a5761254a6146b0565b60209081029290920135600081815260d4845260408082203383529094529290922080549293509115905061271157600060d1838154811061258e5761258e6146b0565b60009182526020909120600890910201805460cb5484546040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0392831660048201526024810191909152929350169063095ea7b390604401602060405180830381600087803b15801561260b57600080fd5b505af115801561261f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126439190614831565b5060cb5482546040517f90210d7e0000000000000000000000000000000000000000000000000000000081526004810186905260248101919091523360448201526001600160a01b03909116906390210d7e90606401600060405180830381600087803b1580156126b357600080fd5b505af11580156126c7573d6000803e3d6000fd5b5050505081600201548160050160008282546126e39190614735565b909155505050600082815260d460209081526040808320338452909152812081815560018101829055600201555b50508061271d90614765565b905061252e565b5050600160655550565b6033546001600160a01b031633146127765760405162461bcd60e51b8152602060048201819052602482015260008051602061487e83398151915260448201526064016106f0565b6103e881111561278557600080fd5b61278d6111b5565b60cd81905561279e816103e8614735565b60ce55337fb24c3afbe477581b073ec4a6f19df34024e917cee6bb519129629defa718f630826127d0816103e8614735565b60408051928352602083019190915201610734565b6000806002606554141561283b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f0565b600260655560975460ff16156128865760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106f0565b600060d1858154811061289b5761289b6146b0565b6000918252602080832088845260d4825260408085203386529092529220600890910290910191506128cc86613048565b8054600090156129b9576001820154600088815260d5602090815260408083203384529091529020546006850154600285015464e8d4a510009161290f916146dc565b6003870154865461292091906146dc565b61292a91906146fb565b6129349190614713565b61293e91906146fb565b6129489190614735565b600088815260d5602090815260408083203380855292528220919091559091506129729082613254565b905086336001600160a01b03167f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae0660924954836040516129b091815260200190565b60405180910390a35b858260000160008282546129cd91906146fb565b9091555050600282015460ca546040516370a0823160e01b8152336004820152612a09916001600160a01b0316906370a0823190602401610af4565b6002840181905560058501548291612a20916146fb565b612a2a9190614735565b60058501556006840154600284015464e8d4a5100091612a49916146dc565b60038601548554612a5a91906146dc565b612a6491906146fb565b612a6e9190614713565b8360010181905550600060d18981548110612a8b57612a8b6146b0565b600091825260208220600460089092020101546001600160a01b031691508115612b35578454604051637135edff60e11b815233600482015260248101919091526001600160a01b0383169063e26bdbfe90604401602060405180830381600087803b158015612afa57600080fd5b505af1158015612b0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b32919061474c565b90505b8554612b4c906001600160a01b031633308c613b7d565b6040518981528a9033907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1590602001610cc7565b600080606060008060d18781548110612b9b57612b9b6146b0565b600091825260208083208a845260d4825260408085206001600160a01b038c81168752935280852060089490940290910160038101546006820154825493516370a0823160e01b81523060048201529297509495909493909216906370a082319060240160206040518083038186803b158015612c1757600080fd5b505afa158015612c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4f919061474c565b9050846002015442118015612c6357508015155b15612d3b576000856002015442612c7a9190614735565b9050600060d654876007015460cc5484612c9491906146dc565b612c9e91906146dc565b612ca89190614713565b9050612cb6836103e86146dc565b60cd54612cc88364e8d4a510006146dc565b612cd291906146dc565b612cdc9190614713565b612ce690866146fb565b94508660050154600014612d38576005870154612d05906103e86146dc565b60ce54612d178364e8d4a510006146dc565b612d2191906146dc565b612d2b9190614713565b612d3590856146fb565b93505b50505b600184015460008c815260d5602090815260408083206001600160a01b038f168452909152902054600286015464e8d4a5100090612d7a9086906146dc565b8754612d879088906146dc565b612d9191906146fb565b612d9b9190614713565b612da591906146fb565b612daf9190614735565b60048601549099506001600160a01b031615612e7057612dce8b611fcd565b6004878101546040517fc031a66f0000000000000000000000000000000000000000000000000000000081526001600160a01b038f811693820193909352939b50919950169063c031a66f9060240160206040518083038186803b158015612e3557600080fd5b505afa158015612e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6d919061474c565b95505b505050505092959194509250565b600080826001600160a01b031663705727b56040518163ffffffff1660e01b815260040160206040518083038186803b158015612eba57600080fd5b505afa158015612ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef2919061474c565b905060008115612f8f5781846001600160a01b031663961be3916040518163ffffffff1660e01b815260040160206040518083038186803b158015612f3657600080fd5b505afa158015612f4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6e919061474c565b612f8090670de0b6b3a76400006146dc565b612f8a9190614713565b612f99565b670de0b6b3a76400005b9050612fa481613e3a565b949350505050565b60975460ff16612ffe5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016106f0565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600060d1828154811061305d5761305d6146b0565b9060005260206000209060080201905080600201544211156111dc5780546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b1580156130bc57600080fd5b505afa1580156130d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f4919061474c565b90508061310657504260029091015550565b60008260020154426131189190614735565b9050600060d654846007015460cc548461313291906146dc565b61313c91906146dc565b6131469190614713565b9050613154836103e86146dc565b60cd546131668364e8d4a510006146dc565b61317091906146dc565b61317a9190614713565b84600301600082825461318d91906146fb565b909155505060058401546131a757600060068501556131f7565b60058401546131b8906103e86146dc565b60ce546131ca8364e8d4a510006146dc565b6131d491906146dc565b6131de9190614713565b8460060160008282546131f191906146fb565b90915550505b61320084613b2d565b42600285018190556003850154604080519283526020830186905282015285907f3be3541fc42237d611b30329040bfa4569541d156560acdbbae57640d20b8f469060600160405180910390a25050505050565b60c9546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a082319060240160206040518083038186803b15801561329c57600080fd5b505afa1580156132b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132d4919061474c565b9050600081116133265760405162461bcd60e51b815260206004820152601760248201527f4e6f20746f6b656e7320746f206469737472696275746500000000000000000060448201526064016106f0565b808311156133bc5760c95460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b15801561337c57600080fd5b505af1158015613390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b49190614831565b509050613448565b60c95460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529091169063a9059cbb90604401602060405180830381600087803b15801561340a57600080fd5b505af115801561341e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134429190614831565b50829150505b92915050565b600060038211156134af5750806000613468600283614713565b6134739060016146fb565b90505b818110156134a95790508060028161348e8186614713565b61349891906146fb565b6134a29190614713565b9050613476565b50919050565b81156134b9575060015b919050565b6040516001600160a01b03831660248201526044810182905261354e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613e7e565b505050565b6000606080600080855167ffffffffffffffff81111561357557613575614284565b60405190808252806020026020018201604052801561359e578160200160208202803683370190505b5090506000865167ffffffffffffffff8111156135bd576135bd614284565b6040519080825280602002602001820160405280156135e6578160200160208202803683370190505b50905060005b87518110156138c45761361788828151811061360a5761360a6146b0565b6020026020010151613048565b600060d189838151811061362d5761362d6146b0565b602002602001015181548110613645576136456146b0565b90600052602060002090600802019050600060d460008b858151811061366d5761366d6146b0565b6020908102919091018101518252818101929092526040908101600090812033825290925290208054909150156138b1576000816001015460d560008d87815181106136bb576136bb6146b0565b602002602001015181526020019081526020016000206000336001600160a01b03166001600160a01b031681526020019081526020016000205464e8d4a510008560060154856002015461370f91906146dc565b6003870154865461372091906146dc565b61372a91906146fb565b6137349190614713565b61373e91906146fb565b6137489190614735565b9050600060d560008d8781518110613762576137626146b0565b602090810291909101810151825281810192909252604090810160009081203382529092529020556006830154600283015464e8d4a51000916137a4916146dc565b600385015484546137b591906146dc565b6137bf91906146fb565b6137c99190614713565b60018301556137d881886146fb565b9650808685815181106137ed576137ed6146b0565b602090810291909101015260048301546001600160a01b031680156138ae578254604051637135edff60e11b815233600482015260248101919091526001600160a01b0382169063e26bdbfe90604401602060405180830381600087803b15801561385757600080fd5b505af115801561386b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388f919061474c565b8686815181106138a1576138a16146b0565b6020026020010181815250505b50505b5050806138bd90614765565b90506135ec565b5060006138d13385613254565b90508381146139c05760005b88518110156139ba57848482815181106138f9576138f96146b0565b60200260200101518361390c91906146dc565b6139169190614713565b848281518110613928576139286146b0565b602002602001018181525050888181518110613946576139466146b0565b6020026020010151336001600160a01b03167f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae066092495486848151811061398b5761398b6146b0565b60200260200101516040516139a291815260200190565b60405180910390a36139b381614765565b90506138dd565b50613a54565b60005b8851811015613a52578881815181106139de576139de6146b0565b6020026020010151336001600160a01b03167f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae0660924954868481518110613a2357613a236146b0565b6020026020010151604051613a3a91815260200190565b60405180910390a3613a4b81614765565b90506139c3565b505b97919650945092505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60975460ff1615613af85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106f0565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861302b3390565b8054600090613b44906001600160a01b0316612e7e565b8260010154613b5391906146dc565b905081600701548160d654613b6891906146fb565b613b729190614735565b60d655600790910155565b6040516001600160a01b0380851660248301528316604482015260648101829052610f8e9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016134ea565b6001600160a01b0381166000908152600183016020526040812054151561083c565b600061083c836001600160a01b038416613f63565b600054610100900460ff1680613c1e575060005460ff16155b613c815760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015613ca3576000805461ffff19166101011790555b613cab613fb2565b613cb3614063565b8015610f9d576000805461ff001916905550565b600054610100900460ff1680613ce0575060005460ff16155b613d435760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015613d65576000805461ffff19166101011790555b60016065558015610f9d576000805461ff001916905550565b600054610100900460ff1680613d97575060005460ff16155b613dfa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015613e1c576000805461ffff19166101011790555b6097805460ff191690558015610f9d576000805461ff001916905550565b600081613e4957506001919050565b613448670de0b6b3a7640000613e67670de0b6b3a76400008561410a565b613e79906702c68af0bb1400006146fb565b61410a565b6000613ed3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661413e9092919063ffffffff16565b80519091501561354e5780806020019051810190613ef19190614831565b61354e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106f0565b6000818152600183016020526040812054613faa57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155613448565b506000613448565b600054610100900460ff1680613fcb575060005460ff16155b61402e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015613cb3576000805461ffff19166101011790558015610f9d576000805461ff001916905550565b600054610100900460ff168061407c575060005460ff16155b6140df5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016106f0565b600054610100900460ff16158015614101576000805461ffff19166101011790555b613cb333613a60565b600081614118600282614713565b61412a670de0b6b3a7640000866146dc565b61413491906146fb565b61083c9190614713565b6060612fa4848460008585843b6141975760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106f0565b600080866001600160a01b031685876040516141b3919061484e565b60006040518083038185875af1925050503d80600081146141f0576040519150601f19603f3d011682016040523d82523d6000602084013e6141f5565b606091505b5091509150614205828286614210565b979650505050505050565b6060831561421f57508161083c565b82511561422f5782518084602001fd5b8160405162461bcd60e51b81526004016106f0919061486a565b60006020828403121561425b57600080fd5b5035919050565b6000806040838503121561427557600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156142c3576142c3614284565b604052919050565b600060208083850312156142de57600080fd5b823567ffffffffffffffff808211156142f657600080fd5b818501915085601f83011261430a57600080fd5b81358181111561431c5761431c614284565b8060051b915061432d84830161429a565b818152918301840191848101908884111561434757600080fd5b938501935b838510156143655784358252938501939085019061434c565b98975050505050505050565b600081518084526020808501945080840160005b838110156143a157815187529582019590820190600101614385565b509495945050505050565b8381526060602082015260006143c56060830185614371565b82810360408401526143d78185614371565b9695505050505050565b6001600160a01b0381168114610f9d57600080fd5b6000806040838503121561440957600080fd5b8235614414816143e1565b946020939093013593505050565b60006020828403121561443457600080fd5b813561083c816143e1565b8015158114610f9d57600080fd5b6000806000806080858703121561446357600080fd5b8435935060208501359250604085013561447c816143e1565b9150606085013561448c8161443f565b939692955090935050565b600080604083850312156144aa57600080fd5b8235915060208301356144bc816143e1565b809150509250929050565b6000806000606084860312156144dc57600080fd5b833592506020840135915060408401356144f5816143e1565b809150509250925092565b60008060006060848603121561451557600080fd5b833592506020840135614527816143e1565b915060408401356144f5816143e1565b60005b8381101561455257818101518382015260200161453a565b83811115610f8e5750506000910152565b6000815180845261457b816020860160208601614537565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201526000612fa46040830184614563565b600080600080600060a086880312156145c957600080fd5b85356145d4816143e1565b945060208601356145e4816143e1565b94979496505050506040830135926060810135926080909101359150565b6000806020838503121561461557600080fd5b823567ffffffffffffffff8082111561462d57600080fd5b818501915085601f83011261464157600080fd5b81358181111561465057600080fd5b8660208260051b850101111561466557600080fd5b60209290920196919550909350505050565b8481526001600160a01b038416602082015260806040820152600061469f6080830185614563565b905082606083015295945050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156146f6576146f66146c6565b500290565b6000821982111561470e5761470e6146c6565b500190565b60008261473057634e487b7160e01b600052601260045260246000fd5b500490565b600082821015614747576147476146c6565b500390565b60006020828403121561475e57600080fd5b5051919050565b6000600019821415614779576147796146c6565b5060010190565b60006020828403121561479257600080fd5b815161083c816143e1565b6000602082840312156147af57600080fd5b815167ffffffffffffffff808211156147c757600080fd5b818401915084601f8301126147db57600080fd5b8151818111156147ed576147ed614284565b614800601f8201601f191660200161429a565b915080825285602082850101111561481757600080fd5b614828816020840160208601614537565b50949350505050565b60006020828403121561484357600080fd5b815161083c8161443f565b60008251614860818460208701614537565b9190910192915050565b60208152600061083c602083018461456356fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220260ecbaf8198bfc4cfb0dc802542d5d7d21b2fa0a14df685473fc6d0a65e0a7464736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.