ETH Price: $3,453.91 (-0.68%)
Gas: 3 Gwei

Contract

0x2c09fd74e80cE12bEbBC8f56FAB8633eA41C2bCc
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw180001512023-08-26 16:51:47331 days ago1693068707IN
0x2c09fd74...eA41C2bCc
0 ETH0.0317008816
Withdraw176979612023-07-15 9:39:35373 days ago1689413975IN
0x2c09fd74...eA41C2bCc
0 ETH0.0029188813.58820738
Withdraw176147422023-07-03 16:52:35385 days ago1688403155IN
0x2c09fd74...eA41C2bCc
0 ETH0.0062327829.01532944
Withdraw170342402023-04-12 20:20:11467 days ago1681330811IN
0x2c09fd74...eA41C2bCc
0 ETH0.0740223325.95838467
Withdraw170222142023-04-11 3:29:35469 days ago1681183775IN
0x2c09fd74...eA41C2bCc
0 ETH0.0372485318.8
Withdraw168967012023-03-24 10:15:23486 days ago1679652923IN
0x2c09fd74...eA41C2bCc
0 ETH0.0036620617.04792551
Withdraw168880082023-03-23 4:55:35488 days ago1679547335IN
0x2c09fd74...eA41C2bCc
0 ETH0.0024394911.35652923
Withdraw164916522023-01-26 14:41:23543 days ago1674744083IN
0x2c09fd74...eA41C2bCc
0 ETH0.0528669822.2889503
Withdraw164134002023-01-15 16:29:47554 days ago1673800187IN
0x2c09fd74...eA41C2bCc
0 ETH0.0058292324.9908156
Withdraw164115472023-01-15 10:16:11554 days ago1673777771IN
0x2c09fd74...eA41C2bCc
0 ETH0.003711915.91512338
Withdraw158518682022-10-29 6:16:11633 days ago1667024171IN
0x2c09fd74...eA41C2bCc
0 ETH0.018826148.475852
Withdraw157946712022-10-21 6:24:59640 days ago1666333499IN
0x2c09fd74...eA41C2bCc
0 ETH0.0260058220.07969019
Withdraw157311232022-10-12 9:25:47649 days ago1665566747IN
0x2c09fd74...eA41C2bCc
0 ETH0.0305910712.56982907
Withdraw156429262022-09-30 1:38:59662 days ago1664501939IN
0x2c09fd74...eA41C2bCc
0 ETH0.0028027112.01628379
Withdraw155033262022-09-09 14:50:29682 days ago1662735029IN
0x2c09fd74...eA41C2bCc
0 ETH0.0562850223.10916305
Withdraw153645032022-08-18 10:36:39704 days ago1660818999IN
0x2c09fd74...eA41C2bCc
0 ETH0.013462628.00371258
Withdraw152233722022-07-27 8:14:46726 days ago1658909686IN
0x2c09fd74...eA41C2bCc
0 ETH0.015170976.40763951
Withdraw151656122022-07-18 8:38:09735 days ago1658133489IN
0x2c09fd74...eA41C2bCc
0 ETH0.0307634215
Withdraw150934732022-07-07 5:15:58747 days ago1657170958IN
0x2c09fd74...eA41C2bCc
0 ETH0.0033327214.28865009
Withdraw150343472022-06-27 12:24:53756 days ago1656332693IN
0x2c09fd74...eA41C2bCc
0 ETH0.0536032832.59844703
Withdraw149936742022-06-20 0:36:52764 days ago1655685412IN
0x2c09fd74...eA41C2bCc
0 ETH0.0312965815
Withdraw146061902022-04-18 1:16:29827 days ago1650244589IN
0x2c09fd74...eA41C2bCc
0 ETH0.0301005526.25194366
Withdraw145972172022-04-16 15:42:22828 days ago1650123742IN
0x2c09fd74...eA41C2bCc
0 ETH0.0277489314.38658836
Withdraw145412872022-04-07 21:48:28837 days ago1649368108IN
0x2c09fd74...eA41C2bCc
0 ETH0.0647590335
Withdraw145392792022-04-07 14:27:34837 days ago1649341654IN
0x2c09fd74...eA41C2bCc
0 ETH0.0470075473
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PendleSLPLiquidityMining

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 17 : PendleSLPLiquidityMining.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;

import "..//abstractV2/PendleLiquidityMiningBaseV2.sol";
import "../../interfaces/IMasterChef.sol";
import "../../libraries/TokenUtilsLib.sol";

contract PendleSLPLiquidityMining is PendleLiquidityMiningBaseV2 {
    using SafeERC20 for IERC20;
    IMasterChef public immutable masterChef;
    uint256 public immutable pid;

    constructor(
        address _governanceManager,
        address _pausingManager,
        address _whitelist,
        address _pendleTokenAddress,
        address _stakeToken,
        address _yieldToken,
        uint256 _startTime,
        uint256 _epochDuration,
        uint256 _vestingEpochs,
        address _masterChef,
        uint256 _pid
    )
        PendleLiquidityMiningBaseV2(
            _governanceManager,
            _pausingManager,
            _whitelist,
            _pendleTokenAddress,
            _stakeToken,
            _yieldToken,
            _startTime,
            _epochDuration,
            _vestingEpochs
        )
    {
        require(_masterChef != address(0), "ZERO_ADDRESS");
        TokenUtils.requireERC20(_yieldToken);
        require(
            address(IMasterChef(_masterChef).poolInfo(_pid).lpToken) == _stakeToken,
            "INVALID_TOKEN_INFO"
        );

        masterChef = IMasterChef(_masterChef);
        pid = _pid;
        IERC20(_stakeToken).safeApprove(address(_masterChef), type(uint256).max);
    }

    function setUpEmergencyMode(address spender, bool useEmergencyWithdraw)
        external
        virtual
        override
    {
        (, bool emergencyMode) = pausingManager.checkLiqMiningStatus(address(this));
        require(emergencyMode, "NOT_EMERGENCY");

        (address liqMiningEmergencyHandler, , ) = pausingManager.liqMiningEmergencyHandler();
        require(msg.sender == liqMiningEmergencyHandler, "NOT_EMERGENCY_HANDLER");

        if (useEmergencyWithdraw) {
            masterChef.emergencyWithdraw(pid);
        } else {
            masterChef.withdraw(pid, masterChef.userInfo(pid, address(this)).amount);
        }

        IERC20(pendleTokenAddress).safeApprove(spender, type(uint256).max);
        IERC20(stakeToken).safeApprove(spender, type(uint256).max);
        IERC20(yieldToken).safeApprove(spender, type(uint256).max);
    }

    /**
    @dev there is no caching for paramL, unlike V1
    */
    function _checkNeedUpdateParamL() internal virtual override returns (bool) {
        return true;
    }

    /**
    @dev Sushi only allows users to redeem rewards when they stake / withdraw
    */
    function _redeemExternalInterests() internal virtual override {
        masterChef.withdraw(pid, 0);
    }

    /**
    @dev after tokens are pulled in they will be deposited into MasterChef
     */
    function _pullStakeToken(address from, uint256 amount) internal virtual override {
        IERC20(stakeToken).safeTransferFrom(from, address(this), amount);
        masterChef.deposit(pid, amount);
    }

    /**
    @dev tokens will be pulled from MasterChef before being transfered to users. MasterChefV1
    doesn't allow direct transfer
     */
    function _pushStakeToken(address to, uint256 amount) internal virtual override {
        masterChef.withdraw(pid, amount);
        IERC20(stakeToken).safeTransfer(to, amount);
    }
}

File 2 of 17 : PendleLiquidityMiningBaseV2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "../../periphery/WithdrawableV2.sol";
import "../../interfaces/IPendleLiquidityMiningV2.sol";
import "../../interfaces/IPendlePausingManager.sol";
import "../../interfaces/IPendleWhitelist.sol";
import "../../libraries/MathLib.sol";
import "../../libraries/TokenUtilsLib.sol";

/*
- stakeToken is the token to be used to stake into this contract to receive rewards
- yieldToken is the token generated by stakeToken while it's being staked. For example, Sushi's LP
token generates SUSHI(if it's in Onsen program), or Pendle's Aave LP generates aToken
- If there is no yieldToken, it should be set to address(0) to save gas
*/
contract PendleLiquidityMiningBaseV2 is IPendleLiquidityMiningV2, WithdrawableV2, ReentrancyGuard {
    using Math for uint256;
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    struct EpochData {
        uint256 totalStakeUnits;
        uint256 totalRewards;
        uint256 lastUpdated;
        mapping(address => uint256) stakeUnitsForUser;
        mapping(address => uint256) availableRewardsForUser;
    }

    IPendleWhitelist public immutable whitelist;
    IPendlePausingManager public immutable pausingManager;

    uint256 public override numberOfEpochs;
    uint256 public override totalStake;
    mapping(uint256 => EpochData) internal epochData;
    mapping(address => uint256) public override balances;
    mapping(address => uint256) public lastTimeUserStakeUpdated;
    mapping(address => uint256) public lastEpochClaimed;

    address public immutable override pendleTokenAddress;
    address public immutable override stakeToken;
    address public immutable override yieldToken;
    uint256 public immutable override startTime;
    uint256 public immutable override epochDuration;
    uint256 public immutable override vestingEpochs;
    uint256 public constant MULTIPLIER = 10**20;

    // yieldToken-related
    mapping(address => uint256) public override dueInterests;
    mapping(address => uint256) public override lastParamL;
    uint256 public override lastNYield;
    uint256 public override paramL;

    modifier hasStarted() {
        require(_getCurrentEpochId() > 0, "NOT_STARTED");
        _;
    }

    modifier nonContractOrWhitelisted() {
        bool isEOA = !Address.isContract(msg.sender) && tx.origin == msg.sender;
        require(isEOA || whitelist.whitelisted(msg.sender), "CONTRACT_NOT_WHITELISTED");
        _;
    }

    modifier isUserAllowedToUse() {
        (bool paused, ) = pausingManager.checkLiqMiningStatus(address(this));
        require(!paused, "LIQ_MINING_PAUSED");
        require(numberOfEpochs > 0, "NOT_FUNDED");
        require(_getCurrentEpochId() > 0, "NOT_STARTED");
        _;
    }

    constructor(
        address _governanceManager,
        address _pausingManager,
        address _whitelist,
        address _pendleTokenAddress,
        address _stakeToken,
        address _yieldToken,
        uint256 _startTime,
        uint256 _epochDuration,
        uint256 _vestingEpochs
    ) PermissionsV2(_governanceManager) {
        require(_startTime > block.timestamp, "INVALID_START_TIME");
        TokenUtils.requireERC20(_pendleTokenAddress);
        TokenUtils.requireERC20(_stakeToken);
        require(_vestingEpochs > 0, "INVALID_VESTING_EPOCHS");
        // yieldToken can be zero address
        pausingManager = IPendlePausingManager(_pausingManager);
        whitelist = IPendleWhitelist(_whitelist);
        pendleTokenAddress = _pendleTokenAddress;

        stakeToken = _stakeToken;
        yieldToken = _yieldToken;
        startTime = _startTime;
        epochDuration = _epochDuration;
        vestingEpochs = _vestingEpochs;
        paramL = 1;
    }

    /**
    @notice set up emergencyMode by pulling all tokens back to this contract & approve spender to
    spend infinity amount
    */
    function setUpEmergencyMode(address spender, bool) external virtual override {
        (, bool emergencyMode) = pausingManager.checkLiqMiningStatus(address(this));
        require(emergencyMode, "NOT_EMERGENCY");

        (address liqMiningEmergencyHandler, , ) = pausingManager.liqMiningEmergencyHandler();
        require(msg.sender == liqMiningEmergencyHandler, "NOT_EMERGENCY_HANDLER");

        // because we are not staking our tokens anywhere else, we can just approve
        IERC20(pendleTokenAddress).safeApprove(spender, type(uint256).max);
        IERC20(stakeToken).safeApprove(spender, type(uint256).max);
        if (yieldToken != address(0)) IERC20(yieldToken).safeApprove(spender, type(uint256).max);
    }

    /**
    @notice create new epochs & fund rewards for them
    @dev same logic as the function in V1
    */
    function fund(uint256[] calldata rewards) external virtual override onlyGovernance {
        // Once the program is over, it cannot be extended
        require(_getCurrentEpochId() <= numberOfEpochs, "LAST_EPOCH_OVER");

        uint256 nNewEpochs = rewards.length;
        uint256 totalFunded;
        // all the funding will be used for new epochs
        for (uint256 i = 0; i < nNewEpochs; i++) {
            totalFunded = totalFunded.add(rewards[i]);
            epochData[numberOfEpochs + i + 1].totalRewards = rewards[i];
        }

        numberOfEpochs = numberOfEpochs.add(nNewEpochs);
        IERC20(pendleTokenAddress).safeTransferFrom(msg.sender, address(this), totalFunded);
        emit Funded(rewards, numberOfEpochs);
    }

    /**
    @notice top up rewards of exisiting epochs
    @dev almost same logic as the function in V1 without the redundant isFunded check
    */
    function topUpRewards(uint256[] calldata epochIds, uint256[] calldata rewards)
        external
        virtual
        override
        onlyGovernance
    {
        require(epochIds.length == rewards.length, "INVALID_ARRAYS");

        uint256 curEpoch = _getCurrentEpochId();
        uint256 endEpoch = numberOfEpochs;
        uint256 totalTopUp;

        for (uint256 i = 0; i < epochIds.length; i++) {
            require(curEpoch < epochIds[i] && epochIds[i] <= endEpoch, "INVALID_EPOCH_ID");
            totalTopUp = totalTopUp.add(rewards[i]);
            epochData[epochIds[i]].totalRewards = epochData[epochIds[i]].totalRewards.add(
                rewards[i]
            );
        }

        IERC20(pendleTokenAddress).safeTransferFrom(msg.sender, address(this), totalTopUp);
        emit RewardsToppedUp(epochIds, rewards);
    }

    /**
    @notice stake tokens in to receive rewards. It's allowed to stake for others
    @param forAddr the address to stake for
    @dev all staking data will be updated for `forAddr`, but msg.sender will be the one transferring
    tokens in
     */
    function stake(address forAddr, uint256 amount)
        external
        virtual
        override
        nonReentrant
        nonContractOrWhitelisted
        isUserAllowedToUse
    {
        require(forAddr != address(0), "ZERO_ADDRESS");
        require(amount != 0, "ZERO_AMOUNT");
        require(_getCurrentEpochId() <= numberOfEpochs, "INCENTIVES_PERIOD_OVER");

        _settleStake(forAddr, msg.sender, amount);
        emit Staked(forAddr, amount);
    }

    /**
    @notice withdraw tokens from the staking contract. It's allowed to withdraw to an address
    different from msg.sender
    @param toAddr the address to receive all tokens
    @dev all staking data will be updated for msg.sender, but `toAddr` will be the one receiving
    all tokens
    */
    function withdraw(address toAddr, uint256 amount)
        external
        virtual
        override
        nonReentrant
        isUserAllowedToUse
    {
        require(amount != 0, "ZERO_AMOUNT");
        require(toAddr != address(0), "ZERO_ADDRESS");

        _settleWithdraw(msg.sender, toAddr, amount);
        emit Withdrawn(msg.sender, amount);
    }

    /**
    @notice redeem all available rewards from expired epochs. It's allowed to redeem for others
    @param user the address whose data will be updated & receive rewards
    */
    function redeemRewards(address user)
        external
        virtual
        override
        nonReentrant
        isUserAllowedToUse
        returns (uint256 rewards)
    {
        require(user != address(0), "ZERO_ADDRESS");

        rewards = _beforeTransferPendingRewards(user);
        if (rewards != 0) IERC20(pendleTokenAddress).safeTransfer(user, rewards);
    }

    /**
    @notice redeem all due interests. It's allowed to redeem for others
    @param user the address whose data will be updated & receive due interests
    */
    function redeemDueInterests(address user)
        external
        virtual
        override
        nonReentrant
        isUserAllowedToUse
        returns (uint256 amountOut)
    {
        if (yieldToken == address(0)) return 0;
        require(user != address(0), "ZERO_ADDRESS");

        amountOut = _beforeTransferDueInterests(user);
        amountOut = _pushYieldToken(user, amountOut);
    }

    function updateAndReadEpochData(uint256 epochId, address user)
        external
        override
        nonReentrant
        isUserAllowedToUse
        returns (
            uint256 totalStakeUnits,
            uint256 totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            uint256 availableRewardsForUser
        )
    {
        _updatePendingRewards(user);
        return readEpochData(epochId, user);
    }

    function readEpochData(uint256 epochId, address user)
        public
        view
        override
        returns (
            uint256 totalStakeUnits,
            uint256 totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            uint256 availableRewardsForUser
        )
    {
        totalStakeUnits = epochData[epochId].totalStakeUnits;
        totalRewards = epochData[epochId].totalRewards;
        lastUpdated = epochData[epochId].lastUpdated;
        stakeUnitsForUser = epochData[epochId].stakeUnitsForUser[user];
        availableRewardsForUser = epochData[epochId].availableRewardsForUser[user];
    }

    /**
    @notice update all reward-related data for user
    @dev to be called before user's stakeToken balance changes
    @dev same logic as the function in V1
    */
    function _updatePendingRewards(address user) internal virtual {
        _updateStakeData();

        // user has not staked before, no need to do anything
        if (lastTimeUserStakeUpdated[user] == 0) {
            lastTimeUserStakeUpdated[user] = block.timestamp;
            return;
        }

        uint256 _curEpoch = _getCurrentEpochId();
        uint256 _endEpoch = Math.min(numberOfEpochs, _curEpoch);

        // if _curEpoch<=numberOfEpochs => the endEpoch hasn't ended yet (since endEpoch=curEpoch)
        bool _isEndEpochOver = (_curEpoch > numberOfEpochs);

        // caching
        uint256 _balance = balances[user];
        uint256 _lastTimeUserStakeUpdated = lastTimeUserStakeUpdated[user];
        uint256 _totalStake = totalStake;
        uint256 _startEpoch = _epochOfTimestamp(_lastTimeUserStakeUpdated);

        // Go through all epochs until now to update stakeUnitsForUser and availableRewardsForEpoch
        for (uint256 epochId = _startEpoch; epochId <= _endEpoch; epochId++) {
            if (epochData[epochId].totalStakeUnits == 0) {
                // in the extreme case of zero staked tokens for this expiry even now,
                // => nothing to do from this epoch onwards
                if (_totalStake == 0) break;
                // nobody stakes anything in this epoch
                continue;
            }
            // updating stakeUnits for users. The logic of this is similar to _updateStakeDataForExpiry
            epochData[epochId].stakeUnitsForUser[user] = epochData[epochId]
            .stakeUnitsForUser[user]
            .add(_calcUnitsStakeInEpoch(_balance, _lastTimeUserStakeUpdated, epochId));

            // all epochs prior to the endEpoch must have ended
            // if epochId == _endEpoch, we must check if the epoch has ended or not
            if (epochId == _endEpoch && !_isEndEpochOver) {
                break;
            }

            // Now this epoch has ended,let's distribute its reward to this user
            // calc the amount of rewards the user is eligible to receive from this epoch
            uint256 rewardsPerVestingEpoch = _calcAmountRewardsForUserInEpoch(user, epochId);

            // Now we distribute this rewards over the vestingEpochs starting from epochId + 1
            // to epochId + vestingEpochs
            for (uint256 i = epochId + 1; i <= epochId + vestingEpochs; i++) {
                epochData[i].availableRewardsForUser[user] = epochData[i]
                .availableRewardsForUser[user]
                .add(rewardsPerVestingEpoch);
            }
        }

        lastTimeUserStakeUpdated[user] = block.timestamp;
    }

    /**
    @notice update staking data for the current epoch
    @dev same logic as the function in V1
    */
    function _updateStakeData() internal virtual {
        uint256 _curEpoch = _getCurrentEpochId();

        // loop through all epochData in descending order
        for (uint256 i = Math.min(_curEpoch, numberOfEpochs); i > 0; i--) {
            uint256 epochEndTime = _endTimeOfEpoch(i);
            uint256 lastUpdatedForEpoch = epochData[i].lastUpdated;

            if (lastUpdatedForEpoch == epochEndTime) {
                break; // its already updated until this epoch, our job here is done
            }

            // if the epoch hasn't been fully updated yet, we will update it
            // just add the amount of units contributed by users since lastUpdatedForEpoch -> now
            // by calling _calcUnitsStakeInEpoch
            epochData[i].totalStakeUnits = epochData[i].totalStakeUnits.add(
                _calcUnitsStakeInEpoch(totalStake, lastUpdatedForEpoch, i)
            );
            // If the epoch has ended, lastUpdated = epochEndTime
            // If not yet, lastUpdated = block.timestamp (aka now)
            epochData[i].lastUpdated = Math.min(block.timestamp, epochEndTime);
        }
    }

    /**
    @notice update all interest-related data for user
    @dev to be called before user's stakeToken balance changes or when user wants to update his
    interests
    @dev same logic as the function in CompoundLiquidityMiningV1
    */
    function _updateDueInterests(address user) internal virtual {
        if (yieldToken == address(0)) return;

        _updateParamL();

        if (lastParamL[user] == 0) {
            lastParamL[user] = paramL;
            return;
        }

        uint256 principal = balances[user];
        uint256 interestValuePerStakeToken = paramL.sub(lastParamL[user]);

        uint256 interestFromStakeToken = principal.mul(interestValuePerStakeToken).div(MULTIPLIER);

        dueInterests[user] = dueInterests[user].add(interestFromStakeToken);
        lastParamL[user] = paramL;
    }

    /**
    @notice update paramL, lastNYield & redeem interest from external sources
    @dev to be called only from _updateDueInterests
    @dev same logic as the function in V1
    */
    function _updateParamL() internal virtual {
        if (yieldToken == address(0) || !_checkNeedUpdateParamL()) return;

        _redeemExternalInterests();

        uint256 currentNYield = IERC20(yieldToken).balanceOf(address(this));
        (uint256 firstTerm, uint256 paramR) = _getFirstTermAndParamR(currentNYield);

        uint256 secondTerm;

        if (totalStake != 0) secondTerm = paramR.mul(MULTIPLIER).div(totalStake);

        // Update new states
        paramL = firstTerm.add(secondTerm);
        lastNYield = currentNYield;
    }

    /**
    @dev same logic as the function in CompoundLiquidityMining
    @dev to be called only from _updateParamL
    */
    function _getFirstTermAndParamR(uint256 currentNYield)
        internal
        virtual
        returns (uint256 firstTerm, uint256 paramR)
    {
        firstTerm = paramL;
        paramR = currentNYield.sub(lastNYield);
    }

    /**
    @dev function is empty because by default yieldToken==0
    */
    function _checkNeedUpdateParamL() internal virtual returns (bool) {}

    /**
    @dev function is empty because by default yieldToken==0
    */
    function _redeemExternalInterests() internal virtual {}

    /**
    @notice Calc the amount of rewards that the user can receive now & clear all the pending
    rewards
    @dev To be called before any rewards is transferred out
    @dev same logic as the function in V1
    */
    function _beforeTransferPendingRewards(address user)
        internal
        virtual
        returns (uint256 amountOut)
    {
        _updatePendingRewards(user);

        uint256 _lastEpoch = Math.min(_getCurrentEpochId(), numberOfEpochs + vestingEpochs);
        for (uint256 i = lastEpochClaimed[user]; i <= _lastEpoch; i++) {
            if (epochData[i].availableRewardsForUser[user] > 0) {
                amountOut = amountOut.add(epochData[i].availableRewardsForUser[user]);
                epochData[i].availableRewardsForUser[user] = 0;
            }
        }

        lastEpochClaimed[user] = _lastEpoch;
        emit PendleRewardsSettled(user, amountOut);
    }

    /**
    @notice Calc the amount of interests that the user can receive now & clear all the due
    interests
    @dev To be called before any interests is transferred out
    @dev same logic as the function in V1
    */
    function _beforeTransferDueInterests(address user)
        internal
        virtual
        returns (uint256 amountOut)
    {
        if (yieldToken == address(0)) return 0;

        _updateDueInterests(user);
        amountOut = Math.min(dueInterests[user], lastNYield);
        dueInterests[user] = 0;
        lastNYield = lastNYield.sub(amountOut);
    }

    /**
    @param user the address whose all stake data will be updated
    @param payer the address which tokens will be pulled from
    @param amount amount of tokens to be staked
    @dev payer is only used to pass to _pullStakeToken
     */
    function _settleStake(
        address user,
        address payer,
        uint256 amount
    ) internal virtual {
        _updatePendingRewards(user);
        _updateDueInterests(user);

        balances[user] = balances[user].add(amount);
        totalStake = totalStake.add(amount);

        _pullStakeToken(payer, amount);
    }

    /**
    @param user the address whose all stake data will be updated
    @param receiver the address which tokens will be pushed to
    @param amount amount of tokens to be withdrawn
    @dev receiver is only used to pass to _pullStakeToken
     */
    function _settleWithdraw(
        address user,
        address receiver,
        uint256 amount
    ) internal virtual {
        _updatePendingRewards(user);
        _updateDueInterests(user);

        balances[user] = balances[user].sub(amount);
        totalStake = totalStake.sub(amount);

        _pushStakeToken(receiver, amount);
    }

    function _pullStakeToken(address from, uint256 amount) internal virtual {
        // For the case that we don't need to stake the stakeToken anywhere else, just pull it
        // into the current contract
        IERC20(stakeToken).safeTransferFrom(from, address(this), amount);
    }

    function _pushStakeToken(address to, uint256 amount) internal virtual {
        // For the case that we don't need to stake the stakeToken anywhere else, just transfer out
        // from the current contract
        if (amount != 0) IERC20(stakeToken).safeTransfer(to, amount);
    }

    function _pushYieldToken(address to, uint256 amount)
        internal
        virtual
        returns (uint256 outAmount)
    {
        outAmount = Math.min(amount, IERC20(yieldToken).balanceOf(address(this)));
        if (outAmount != 0) IERC20(yieldToken).safeTransfer(to, outAmount);
    }

    /**
     @notice returns the stakeUnits in the _epochId(th) epoch of an user if he stake from _startTime to now
     @dev to calculate durationStakeThisEpoch:
       user will stake from _startTime -> _endTime, while the epoch last from _startTimeOfEpoch -> _endTimeOfEpoch
       => the stakeDuration of user will be min(_endTime,_endTimeOfEpoch) - max(_startTime,_startTimeOfEpoch)
     @dev same logic as in V1
     */
    function _calcUnitsStakeInEpoch(
        uint256 _tokenAmount,
        uint256 _startTime,
        uint256 _epochId
    ) internal view returns (uint256 stakeUnitsForUser) {
        uint256 _endTime = block.timestamp;

        uint256 _l = Math.max(_startTime, _startTimeOfEpoch(_epochId));
        uint256 _r = Math.min(_endTime, _endTimeOfEpoch(_epochId));
        uint256 durationStakeThisEpoch = _r.subMax0(_l);

        return _tokenAmount.mul(durationStakeThisEpoch);
    }

    /**
    @notice calc the amount of rewards the user is eligible to receive from this epoch, but we will
    return the amount per vestingEpoch instead
    @dev same logic as in V1
     */
    function _calcAmountRewardsForUserInEpoch(address user, uint256 epochId)
        internal
        view
        returns (uint256 rewardsPerVestingEpoch)
    {
        rewardsPerVestingEpoch = epochData[epochId]
        .totalRewards
        .mul(epochData[epochId].stakeUnitsForUser[user])
        .div(epochData[epochId].totalStakeUnits)
        .div(vestingEpochs);
    }

    function _startTimeOfEpoch(uint256 t) internal view returns (uint256) {
        // epoch id starting from 1
        return startTime.add((t.sub(1)).mul(epochDuration));
    }

    function _getCurrentEpochId() internal view returns (uint256) {
        return _epochOfTimestamp(block.timestamp);
    }

    function _epochOfTimestamp(uint256 t) internal view returns (uint256) {
        if (t < startTime) return 0;
        return (t.sub(startTime)).div(epochDuration).add(1);
    }

    // Although the name of this function is endTimeOfEpoch, it's actually the beginning of the next epoch
    function _endTimeOfEpoch(uint256 t) internal view returns (uint256) {
        // epoch id starting from 1
        return startTime.add(t.mul(epochDuration));
    }

    function _allowedToWithdraw(address _token) internal view override returns (bool allowed) {
        allowed = _token != pendleTokenAddress && _token != stakeToken && _token != yieldToken;
    }
}

File 3 of 17 : IMasterChef.sol
// SPDX-License-Identifier: MIT
/*
 * MIT License
 * ===========
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 */
pragma solidity 0.7.6;
pragma abicoder v2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMasterChef {
    struct UserInfo {
        uint256 amount;
        int256 rewardDebt;
    }

    struct PoolInfo {
        IERC20 lpToken;
        uint256 allocPoint;
        uint256 lastRewardBlock;
        uint256 accSushiPerShare;
    }

    function userInfo(uint256 pid, address user) external view returns (UserInfo calldata);

    function poolInfo(uint256 pid) external view returns (PoolInfo calldata);

    function deposit(uint256 pid, uint256 amount) external;

    function withdraw(uint256 pid, uint256 amount) external;

    function emergencyWithdraw(uint256 pid) external;
}

File 4 of 17 : TokenUtilsLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

library TokenUtils {
    function requireERC20(address tokenAddr) internal view {
        require(IERC20(tokenAddr).totalSupply() > 0, "INVALID_ERC20");
    }

    function requireERC20(IERC20 token) internal view {
        require(token.totalSupply() > 0, "INVALID_ERC20");
    }
}

File 5 of 17 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

    uint256 private _status;

    constructor () internal {
        _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;
    }
}

File 6 of 17 : WithdrawableV2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

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

abstract contract WithdrawableV2 is PermissionsV2 {
    using SafeERC20 for IERC20;

    event EtherWithdraw(uint256 amount, address sendTo);
    event TokenWithdraw(IERC20 token, uint256 amount, address sendTo);

    /**
     * @dev Allows governance to withdraw Ether in a Pendle contract
     *      in case of accidental ETH transfer into the contract.
     * @param amount The amount of Ether to withdraw.
     * @param sendTo The recipient address.
     */
    function withdrawEther(uint256 amount, address payable sendTo) external onlyGovernance {
        (bool success, ) = sendTo.call{value: amount}("");
        require(success, "WITHDRAW_FAILED");
        emit EtherWithdraw(amount, sendTo);
    }

    /**
     * @dev Allows governance to withdraw all IERC20 compatible tokens in a Pendle
     *      contract in case of accidental token transfer into the contract.
     * @param token IERC20 The address of the token contract.
     * @param amount The amount of IERC20 tokens to withdraw.
     * @param sendTo The recipient address.
     */
    function withdrawToken(
        IERC20 token,
        uint256 amount,
        address sendTo
    ) external onlyGovernance {
        require(_allowedToWithdraw(address(token)), "TOKEN_NOT_ALLOWED");
        token.safeTransfer(sendTo, amount);
        emit TokenWithdraw(token, amount, sendTo);
    }

    // must be overridden by the sub contracts, so we must consider explicitly
    // in each and every contract which tokens are allowed to be withdrawn
    function _allowedToWithdraw(address) internal view virtual returns (bool allowed);
}

File 7 of 17 : IPendleLiquidityMiningV2.sol
// SPDX-License-Identifier: MIT
/*
 * MIT License
 * ===========
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 */

pragma solidity 0.7.6;

interface IPendleLiquidityMiningV2 {
    event Funded(uint256[] rewards, uint256 numberOfEpochs);
    event RewardsToppedUp(uint256[] epochIds, uint256[] rewards);
    event Staked(address user, uint256 amount);
    event Withdrawn(address user, uint256 amount);
    event PendleRewardsSettled(address user, uint256 amount);

    function fund(uint256[] calldata rewards) external;

    function topUpRewards(uint256[] calldata epochIds, uint256[] calldata rewards) external;

    function stake(address forAddr, uint256 amount) external;

    function withdraw(address toAddr, uint256 amount) external;

    function redeemRewards(address user) external returns (uint256 rewards);

    function redeemDueInterests(address user) external returns (uint256 amountOut);

    function setUpEmergencyMode(address spender, bool) external;

    function updateAndReadEpochData(uint256 epochId, address user)
        external
        returns (
            uint256 totalStakeUnits,
            uint256 totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            uint256 availableRewardsForUser
        );

    function balances(address user) external view returns (uint256);

    function startTime() external view returns (uint256);

    function epochDuration() external view returns (uint256);

    function readEpochData(uint256 epochId, address user)
        external
        view
        returns (
            uint256 totalStakeUnits,
            uint256 totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            uint256 availableRewardsForUser
        );

    function numberOfEpochs() external view returns (uint256);

    function vestingEpochs() external view returns (uint256);

    function stakeToken() external view returns (address);

    function yieldToken() external view returns (address);

    function pendleTokenAddress() external view returns (address);

    function totalStake() external view returns (uint256);

    function dueInterests(address) external view returns (uint256);

    function lastParamL(address) external view returns (uint256);

    function lastNYield() external view returns (uint256);

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

File 8 of 17 : IPendlePausingManager.sol
// SPDX-License-Identifier: MIT
/*
 * MIT License
 * ===========
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 */
pragma solidity 0.7.6;

interface IPendlePausingManager {
    event AddPausingAdmin(address admin);
    event RemovePausingAdmin(address admin);
    event PendingForgeEmergencyHandler(address _pendingForgeHandler);
    event PendingMarketEmergencyHandler(address _pendingMarketHandler);
    event PendingLiqMiningEmergencyHandler(address _pendingLiqMiningHandler);
    event ForgeEmergencyHandlerSet(address forgeEmergencyHandler);
    event MarketEmergencyHandlerSet(address marketEmergencyHandler);
    event LiqMiningEmergencyHandlerSet(address liqMiningEmergencyHandler);

    event PausingManagerLocked();
    event ForgeHandlerLocked();
    event MarketHandlerLocked();
    event LiqMiningHandlerLocked();

    event SetForgePaused(bytes32 forgeId, bool settingToPaused);
    event SetForgeAssetPaused(bytes32 forgeId, address underlyingAsset, bool settingToPaused);
    event SetForgeAssetExpiryPaused(
        bytes32 forgeId,
        address underlyingAsset,
        uint256 expiry,
        bool settingToPaused
    );

    event SetForgeLocked(bytes32 forgeId);
    event SetForgeAssetLocked(bytes32 forgeId, address underlyingAsset);
    event SetForgeAssetExpiryLocked(bytes32 forgeId, address underlyingAsset, uint256 expiry);

    event SetMarketFactoryPaused(bytes32 marketFactoryId, bool settingToPaused);
    event SetMarketPaused(bytes32 marketFactoryId, address market, bool settingToPaused);

    event SetMarketFactoryLocked(bytes32 marketFactoryId);
    event SetMarketLocked(bytes32 marketFactoryId, address market);

    event SetLiqMiningPaused(address liqMiningContract, bool settingToPaused);
    event SetLiqMiningLocked(address liqMiningContract);

    function forgeEmergencyHandler()
        external
        view
        returns (
            address handler,
            address pendingHandler,
            uint256 timelockDeadline
        );

    function marketEmergencyHandler()
        external
        view
        returns (
            address handler,
            address pendingHandler,
            uint256 timelockDeadline
        );

    function liqMiningEmergencyHandler()
        external
        view
        returns (
            address handler,
            address pendingHandler,
            uint256 timelockDeadline
        );

    function permLocked() external view returns (bool);

    function permForgeHandlerLocked() external view returns (bool);

    function permMarketHandlerLocked() external view returns (bool);

    function permLiqMiningHandlerLocked() external view returns (bool);

    function isPausingAdmin(address) external view returns (bool);

    function setPausingAdmin(address admin, bool isAdmin) external;

    function requestForgeHandlerChange(address _pendingForgeHandler) external;

    function requestMarketHandlerChange(address _pendingMarketHandler) external;

    function requestLiqMiningHandlerChange(address _pendingLiqMiningHandler) external;

    function applyForgeHandlerChange() external;

    function applyMarketHandlerChange() external;

    function applyLiqMiningHandlerChange() external;

    function lockPausingManagerPermanently() external;

    function lockForgeHandlerPermanently() external;

    function lockMarketHandlerPermanently() external;

    function lockLiqMiningHandlerPermanently() external;

    function setForgePaused(bytes32 forgeId, bool paused) external;

    function setForgeAssetPaused(
        bytes32 forgeId,
        address underlyingAsset,
        bool paused
    ) external;

    function setForgeAssetExpiryPaused(
        bytes32 forgeId,
        address underlyingAsset,
        uint256 expiry,
        bool paused
    ) external;

    function setForgeLocked(bytes32 forgeId) external;

    function setForgeAssetLocked(bytes32 forgeId, address underlyingAsset) external;

    function setForgeAssetExpiryLocked(
        bytes32 forgeId,
        address underlyingAsset,
        uint256 expiry
    ) external;

    function checkYieldContractStatus(
        bytes32 forgeId,
        address underlyingAsset,
        uint256 expiry
    ) external returns (bool _paused, bool _locked);

    function setMarketFactoryPaused(bytes32 marketFactoryId, bool paused) external;

    function setMarketPaused(
        bytes32 marketFactoryId,
        address market,
        bool paused
    ) external;

    function setMarketFactoryLocked(bytes32 marketFactoryId) external;

    function setMarketLocked(bytes32 marketFactoryId, address market) external;

    function checkMarketStatus(bytes32 marketFactoryId, address market)
        external
        returns (bool _paused, bool _locked);

    function setLiqMiningPaused(address liqMiningContract, bool settingToPaused) external;

    function setLiqMiningLocked(address liqMiningContract) external;

    function checkLiqMiningStatus(address liqMiningContract)
        external
        returns (bool _paused, bool _locked);
}

File 9 of 17 : IPendleWhitelist.sol
// SPDX-License-Identifier: MIT
/*
 * MIT License
 * ===========
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 */
pragma solidity 0.7.6;

interface IPendleWhitelist {
    event AddedToWhiteList(address);
    event RemovedFromWhiteList(address);

    function whitelisted(address) external view returns (bool);

    function addToWhitelist(address[] calldata _addresses) external;

    function removeFromWhitelist(address[] calldata _addresses) external;

    function getWhitelist() external view returns (address[] memory list);
}

File 10 of 17 : MathLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.0;
pragma abicoder v2;

import "@openzeppelin/contracts/math/SafeMath.sol";

library Math {
    using SafeMath for uint256;

    uint256 internal constant BIG_NUMBER = (uint256(1) << uint256(200));
    uint256 internal constant PRECISION_BITS = 40;
    uint256 internal constant RONE = uint256(1) << PRECISION_BITS;
    uint256 internal constant PI = (314 * RONE) / 10**2;
    uint256 internal constant PI_PLUSONE = (414 * RONE) / 10**2;
    uint256 internal constant PRECISION_POW = 1e2;

    function checkMultOverflow(uint256 _x, uint256 _y) internal pure returns (bool) {
        if (_y == 0) return false;
        return (((_x * _y) / _y) != _x);
    }

    /**
    @notice find the integer part of log2(p/q)
        => find largest x s.t p >= q * 2^x
        => find largest x s.t 2^x <= p / q
     */
    function log2Int(uint256 _p, uint256 _q) internal pure returns (uint256) {
        uint256 res = 0;
        uint256 remain = _p / _q;
        while (remain > 0) {
            res++;
            remain /= 2;
        }
        return res - 1;
    }

    /**
    @notice log2 for a number that it in [1,2)
    @dev _x is FP, return a FP
    @dev function is from Kyber. Long modified the condition to be (_x >= one) && (_x < two)
    to avoid the case where x = 2 may lead to incorrect result
     */
    function log2ForSmallNumber(uint256 _x) internal pure returns (uint256) {
        uint256 res = 0;
        uint256 one = (uint256(1) << PRECISION_BITS);
        uint256 two = 2 * one;
        uint256 addition = one;

        require((_x >= one) && (_x < two), "MATH_ERROR");
        require(PRECISION_BITS < 125, "MATH_ERROR");

        for (uint256 i = PRECISION_BITS; i > 0; i--) {
            _x = (_x * _x) / one;
            addition = addition / 2;
            if (_x >= two) {
                _x = _x / 2;
                res += addition;
            }
        }

        return res;
    }

    /**
    @notice log2 of (p/q). returns result in FP form
    @dev function is from Kyber.
    @dev _p & _q is FP, return a FP
     */
    function logBase2(uint256 _p, uint256 _q) internal pure returns (uint256) {
        uint256 n = 0;

        if (_p > _q) {
            n = log2Int(_p, _q);
        }

        require(n * RONE <= BIG_NUMBER, "MATH_ERROR");
        require(!checkMultOverflow(_p, RONE), "MATH_ERROR");
        require(!checkMultOverflow(n, RONE), "MATH_ERROR");
        require(!checkMultOverflow(uint256(1) << n, _q), "MATH_ERROR");

        uint256 y = (_p * RONE) / (_q * (uint256(1) << n));
        uint256 log2Small = log2ForSmallNumber(y);

        assert(log2Small <= BIG_NUMBER);

        return n * RONE + log2Small;
    }

    /**
    @notice calculate ln(p/q). returned result >= 0
    @dev function is from Kyber.
    @dev _p & _q is FP, return a FP
    */
    function ln(uint256 p, uint256 q) internal pure returns (uint256) {
        uint256 ln2Numerator = 6931471805599453094172;
        uint256 ln2Denomerator = 10000000000000000000000;

        uint256 log2x = logBase2(p, q);

        require(!checkMultOverflow(ln2Numerator, log2x), "MATH_ERROR");

        return (ln2Numerator * log2x) / ln2Denomerator;
    }

    /**
    @notice extract the fractional part of a FP
    @dev value is a FP, return a FP
     */
    function fpart(uint256 value) internal pure returns (uint256) {
        return value % RONE;
    }

    /**
    @notice convert a FP to an Int
    @dev value is a FP, return an Int
     */
    function toInt(uint256 value) internal pure returns (uint256) {
        return value / RONE;
    }

    /**
    @notice convert an Int to a FP
    @dev value is an Int, return a FP
     */
    function toFP(uint256 value) internal pure returns (uint256) {
        return value * RONE;
    }

    /**
    @notice return e^exp in FP form
    @dev estimation by formula at http://pages.mtu.edu/~shene/COURSES/cs201/NOTES/chap04/exp.html
        the function is based on exp function of:
        https://github.com/NovakDistributed/macroverse/blob/master/contracts/RealMath.sol
    @dev the function is expected to converge quite fast, after about 20 iteration
    @dev exp is a FP, return a FP
     */
    function rpowe(uint256 exp) internal pure returns (uint256) {
        uint256 res = 0;

        uint256 curTerm = RONE;

        for (uint256 n = 0; ; n++) {
            res += curTerm;
            curTerm = rmul(curTerm, rdiv(exp, toFP(n + 1)));
            if (curTerm == 0) {
                break;
            }
            if (n == 500) {
                /*
                testing shows that in the most extreme case, it will take 430 turns to converge.
                however, it's expected that the numbers will not exceed 2^120 in normal situation
                the most extreme case is rpow((1<<256)-1,(1<<40)-1) (equal to rpow((2^256-1)/2^40,0.99..9))
                */
                revert("RPOWE_SLOW_CONVERGE");
            }
        }

        return res;
    }

    /**
    @notice calculate base^exp with base and exp being FP int
    @dev to improve accuracy, base^exp = base^(int(exp)+frac(exp))
                                       = base^int(exp) * base^frac
    @dev base & exp are FP, return a FP
     */
    function rpow(uint256 base, uint256 exp) internal pure returns (uint256) {
        if (exp == 0) {
            // Anything to the 0 is 1
            return RONE;
        }
        if (base == 0) {
            // 0 to anything except 0 is 0
            return 0;
        }

        uint256 frac = fpart(exp); // get the fractional part
        uint256 whole = exp - frac;

        uint256 wholePow = rpowi(base, toInt(whole)); // whole is a FP, convert to Int
        uint256 fracPow;

        // instead of calculating base ^ frac, we will calculate e ^ (frac*ln(base))
        if (base < RONE) {
            /* since the base is smaller than 1.0, ln(base) < 0.
            Since 1 / (e^(frac*ln(1/base))) = e ^ (frac*ln(base)),
            we will calculate 1 / (e^(frac*ln(1/base))) instead.
            */
            uint256 newExp = rmul(frac, ln(rdiv(RONE, base), RONE));
            fracPow = rdiv(RONE, rpowe(newExp));
        } else {
            /* base is greater than 1, calculate normally */
            uint256 newExp = rmul(frac, ln(base, RONE));
            fracPow = rpowe(newExp);
        }
        return rmul(wholePow, fracPow);
    }

    /**
    @notice return base^exp with base in FP form and exp in Int
    @dev this function use a technique called: exponentiating by squaring
        complexity O(log(q))
    @dev function is from Kyber.
    @dev base is a FP, exp is an Int, return a FP
     */
    function rpowi(uint256 base, uint256 exp) internal pure returns (uint256) {
        uint256 res = exp % 2 != 0 ? base : RONE;

        for (exp /= 2; exp != 0; exp /= 2) {
            base = rmul(base, base);

            if (exp % 2 != 0) {
                res = rmul(res, base);
            }
        }
        return res;
    }

    /**
    @dev y is an Int, returns an Int
    @dev babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    @dev from Uniswap
     */
    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;
        }
    }

    /**
    @notice divide 2 FP, return a FP
    @dev function is from Balancer.
    @dev x & y are FP, return a FP
     */
    function rdiv(uint256 x, uint256 y) internal pure returns (uint256) {
        return (y / 2).add(x.mul(RONE)).div(y);
    }

    /**
    @notice multiply 2 FP, return a FP
    @dev function is from Balancer.
    @dev x & y are FP, return a FP
     */
    function rmul(uint256 x, uint256 y) internal pure returns (uint256) {
        return (RONE / 2).add(x.mul(y)).div(RONE);
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    function subMax0(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a - b : 0;
    }
}

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

pragma solidity >=0.6.0 <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 12 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    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'
        // solhint-disable-next-line max-line-length
        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).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 13 of 17 : PermissionsV2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../core/PendleGovernanceManager.sol";
import "../interfaces/IPermissionsV2.sol";

abstract contract PermissionsV2 is IPermissionsV2 {
    PendleGovernanceManager public immutable override governanceManager;
    address internal initializer;

    constructor(address _governanceManager) {
        require(_governanceManager != address(0), "ZERO_ADDRESS");
        initializer = msg.sender;
        governanceManager = PendleGovernanceManager(_governanceManager);
    }

    modifier initialized() {
        require(initializer == address(0), "NOT_INITIALIZED");
        _;
    }

    modifier onlyGovernance() {
        require(msg.sender == _governance(), "ONLY_GOVERNANCE");
        _;
    }

    function _governance() internal view returns (address) {
        return governanceManager.governance();
    }
}

File 14 of 17 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 15 of 17 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <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;
        // solhint-disable-next-line no-inline-assembly
        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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 17 : PendleGovernanceManager.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

contract PendleGovernanceManager {
    address public governance;
    address public pendingGovernance;

    event GovernanceClaimed(address newGovernance, address previousGovernance);

    event TransferGovernancePending(address pendingGovernance);

    constructor(address _governance) {
        require(_governance != address(0), "ZERO_ADDRESS");
        governance = _governance;
    }

    modifier onlyGovernance() {
        require(msg.sender == governance, "ONLY_GOVERNANCE");
        _;
    }

    /**
     * @dev Allows the pendingGovernance address to finalize the change governance process.
     */
    function claimGovernance() external {
        require(pendingGovernance == msg.sender, "WRONG_GOVERNANCE");
        emit GovernanceClaimed(pendingGovernance, governance);
        governance = pendingGovernance;
        pendingGovernance = address(0);
    }

    /**
     * @dev Allows the current governance to set the pendingGovernance address.
     * @param _governance The address to transfer ownership to.
     */
    function transferGovernance(address _governance) external onlyGovernance {
        require(_governance != address(0), "ZERO_ADDRESS");
        pendingGovernance = _governance;

        emit TransferGovernancePending(pendingGovernance);
    }
}

File 17 of 17 : IPermissionsV2.sol
// SPDX-License-Identifier: MIT
/*
 * MIT License
 * ===========
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 */

pragma solidity 0.7.6;
pragma abicoder v2;

import "../core/PendleGovernanceManager.sol";

interface IPermissionsV2 {
    function governanceManager() external returns (PendleGovernanceManager);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_governanceManager","type":"address"},{"internalType":"address","name":"_pausingManager","type":"address"},{"internalType":"address","name":"_whitelist","type":"address"},{"internalType":"address","name":"_pendleTokenAddress","type":"address"},{"internalType":"address","name":"_stakeToken","type":"address"},{"internalType":"address","name":"_yieldToken","type":"address"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"uint256","name":"_epochDuration","type":"uint256"},{"internalType":"uint256","name":"_vestingEpochs","type":"uint256"},{"internalType":"address","name":"_masterChef","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"EtherWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"rewards","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"Funded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PendleRewardsSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"epochIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"rewards","type":"uint256[]"}],"name":"RewardsToppedUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"TokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"MULTIPLIER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"dueInterests","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"rewards","type":"uint256[]"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"governanceManager","outputs":[{"internalType":"contract PendleGovernanceManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastEpochClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastNYield","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastParamL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastTimeUserStakeUpdated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"masterChef","outputs":[{"internalType":"contract IMasterChef","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paramL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pausingManager","outputs":[{"internalType":"contract IPendlePausingManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendleTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epochId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"readEpochData","outputs":[{"internalType":"uint256","name":"totalStakeUnits","type":"uint256"},{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"stakeUnitsForUser","type":"uint256"},{"internalType":"uint256","name":"availableRewardsForUser","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemDueInterests","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemRewards","outputs":[{"internalType":"uint256","name":"rewards","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"bool","name":"useEmergencyWithdraw","type":"bool"}],"name":"setUpEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"epochIds","type":"uint256[]"},{"internalType":"uint256[]","name":"rewards","type":"uint256[]"}],"name":"topUpRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epochId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"updateAndReadEpochData","outputs":[{"internalType":"uint256","name":"totalStakeUnits","type":"uint256"},{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"stakeUnitsForUser","type":"uint256"},{"internalType":"uint256","name":"availableRewardsForUser","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vestingEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelist","outputs":[{"internalType":"contract IPendleWhitelist","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"toAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"sendTo","type":"address"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"sendTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101e06040523480156200001257600080fd5b5060405162004344380380620043448339810160408190526200003591620007d6565b8a8a8a8a8a8a8a8a8a886001600160a01b0381166200008a576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b60008054336001600160a01b031990911617905560601b6001600160601b03191660805260018055428311620000fc576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f53544152545f54494d4560701b604482015290519081900360640190fd5b62000112866200031460201b62001deb1760201c565b62000128856200031460201b62001deb1760201c565b600081116200017e576040805162461bcd60e51b815260206004820152601660248201527f494e56414c49445f56455354494e475f45504f43485300000000000000000000604482015290519081900360640190fd5b6001600160601b0319606098891b811660c05296881b871660a05294871b861660e05292861b851661010052941b90921661012052610140929092526101605261018052506001600b556001600160a01b038216620001fa5760405162461bcd60e51b8152600401620001f19062000942565b60405180910390fd5b62000210866200031460201b62001deb1760201c565b866001600160a01b0316826001600160a01b0316631526fe27836040518263ffffffff1660e01b815260040162000248919062000968565b60806040518083038186803b1580156200026157600080fd5b505afa15801562000276573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029c9190620008ab565b516001600160a01b031614620002c65760405162461bcd60e51b8152600401620001f19062000916565b606082901b6001600160601b0319166101a0526101c0819052620003036001600160a01b03881683600019620003c4602090811b62001e9717901c565b505050505050505050505062000987565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200035057600080fd5b505afa15801562000365573d6000803e3d6000fd5b505050506040513d60208110156200037c57600080fd5b505111620003c1576040805162461bcd60e51b815260206004820152600d60248201526c0494e56414c49445f455243323609c1b604482015290519081900360640190fd5b50565b8015806200044e575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156200041e57600080fd5b505afa15801562000433573d6000803e3d6000fd5b505050506040513d60208110156200044a57600080fd5b5051155b6200048b5760405162461bcd60e51b81526004018080602001828103825260368152602001806200430e6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620004e3918591620004e816565b505050565b600062000544826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620005a460201b62001faf179092919060201c565b805190915015620004e3578080602001905160208110156200056557600080fd5b5051620004e35760405162461bcd60e51b815260040180806020018281038252602a815260200180620042e4602a913960400191505060405180910390fd5b6060620005b58484600085620005bf565b90505b9392505050565b606082471015620006025760405162461bcd60e51b8152600401808060200182810382526026815260200180620042be6026913960400191505060405180910390fd5b6200060d8562000726565b6200065f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106200069f5780518252601f1990920191602091820191016200067e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811462000703576040519150601f19603f3d011682016040523d82523d6000602084013e62000708565b606091505b5090925090506200071b8282866200072c565b979650505050505050565b3b151590565b606083156200073d575081620005b8565b8251156200074e5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156200079a57818101518382015260200162000780565b50505050905090810190601f168015620007c85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008060008060008060008060008060006101608c8e031215620007f8578687fd5b8b51620008058162000971565b60208d0151909b50620008188162000971565b60408d0151909a506200082b8162000971565b60608d01519099506200083e8162000971565b60808d0151909850620008518162000971565b60a08d0151909750620008648162000971565b8096505060c08c0151945060e08c015193506101008c015192506101208c01516200088f8162000971565b809250506101408c015190509295989b509295989b9093969950565b600060808284031215620008bd578081fd5b604051608081016001600160401b0381118282101715620008da57fe5b6040528251620008ea8162000971565b808252506020830151602082015260408301516040820152606083015160608201528091505092915050565b602080825260129082015271494e56414c49445f544f4b454e5f494e464f60701b604082015260600190565b6020808252600c908201526b5a45524f5f4144445245535360a01b604082015260600190565b90815260200190565b6001600160a01b0381168114620003c157600080fd5b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c6101405161016051610180516101a05160601c6101c0516137c062000afe6000398061191652806119b55280611b3c5280612e165280612eba52806132e352508061076b52806118e9528061198c5280612de95280612e8d52806132b652508061113e528061212d52806125fa5280612bf452508061071d5280612a4a528061306252806130b7525080610cd45280612a125280612a6f52806130885250806109455280610cb05280611b0b528061232652806123b7528061245452806125055280612c24528061316352806131b25250806107415280611ad552806122e85280612daa5280612f23525080610bd85280610e1a52806110df52806111625280611a9f52806122ab52508061045152806107fd5280610f3152806112f652806115be528061175d52806118105280611bcc525080611108528061120f525080611721528061221f52506137c06000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c806383bbfde11161010f578063adc9772e116100a2578063d2e6d1c311610071578063d2e6d1c3146103a5578063dd254a6a146103ad578063f1068454146103c0578063f3fef3a3146103c8576101f0565b8063adc9772e14610364578063b40310c914610377578063be66c60f1461038a578063ce56c45414610392576101f0565b806393e59dc1116100de57806393e59dc11461033957806396b973c0146103415780639a51d2d114610354578063a81e457c1461035c576101f0565b806383bbfde1146103035780638b0e9f3f146103165780638f373bf31461031e5780639262187b14610326576101f0565b806351ed6a301161018757806370b66cd01161015657806370b66cd0146102cd578063738573f4146102e057806376d5de85146102f357806378e97925146102fb576101f0565b806351ed6a3014610295578063541a7ca6146102aa578063575a86b2146102b25780636304a6bc146102ba576101f0565b806327e235e3116101c357806327e235e3146102525780632936ada7146102655780633ccdbb28146102785780634ff0876a1461028d576101f0565b806304f917af146101f5578063059f8b16146102225780631667663214610237578063173688411461024a575b600080fd5b6102086102033660046135c1565b6103db565b60405161021995949392919061367d565b60405180910390f35b61022a6105c2565b604051610219919061364f565b61022a6102453660046133a0565b6105cf565b61022a6105e1565b61022a6102603660046133a0565b6105e7565b61022a6102733660046133a0565b6105f9565b61028b610286366004613538565b61060b565b005b61022a61071b565b61029d61073f565b60405161021991906135e5565b61022a610763565b61029d610769565b61022a6102c83660046133a0565b61078d565b61028b6102db3660046134a1565b6109e6565b61022a6102ee3660046133a0565b610c9c565b61029d610cae565b61022a610cd2565b61028b610311366004613461565b610cf6565b61022a610eb5565b61022a610ebb565b61022a6103343660046133a0565b610ec1565b61029d611106565b61022a61034f3660046133a0565b61112a565b61022a61113c565b61029d611160565b61028b610372366004613436565b611184565b6102086103853660046135c1565b611576565b61029d6115bc565b61028b6103a03660046135c1565b6115e0565b61029d61171f565b61028b6103bb3660046133fe565b611743565b61022a611b3a565b61028b6103d6366004613436565b611b5e565b600080600080600060026001541415610429576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692636f11e6c1926024808301939282900301818787803b15801561049457600080fd5b505af11580156104a8573d6000803e3d6000fd5b505050506040513d60408110156104be57600080fd5b505190508015610509576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b60006002541161054d576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000610557611fc8565b11610597576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6105a087611fd8565b6105aa8888611576565b60018055939c929b5090995097509095509350505050565b68056bc75e2d6310000081565b60096020526000908152604090205481565b60025481565b60056020526000908152604090205481565b60076020526000908152604090205481565b61061361221b565b6001600160a01b0316336001600160a01b03161461066a576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b610673836122a7565b6106b8576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b6106cc6001600160a01b0384168284612361565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600b5481565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260015414156107d5576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692636f11e6c1926024808301939282900301818787803b15801561084057600080fd5b505af1158015610854573d6000803e3d6000fd5b505050506040513d604081101561086a57600080fd5b5051905080156108b5576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b6000600254116108f9576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000610903611fc8565b11610943576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661097a57600091506109dc565b6001600160a01b0383166109c4576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b6109cd836123b3565b91506109d9838361244c565b91505b5060018055919050565b6109ee61221b565b6001600160a01b0316336001600160a01b031614610a45576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b828114610a8a576040805162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f41525241595360901b604482015290519081900360640190fd5b6000610a94611fc8565b6002549091506000805b86811015610bca57878782818110610ab257fe5b9050602002013584108015610ad9575082888883818110610acf57fe5b9050602002013511155b610b1d576040805162461bcd60e51b815260206004820152601060248201526f1253959053125117d15413d0d217d25160821b604482015290519081900360640190fd5b610b42868683818110610b2c57fe5b905060200201358361252c90919063ffffffff16565b9150610b91868683818110610b5357fe5b90506020020135600460008b8b86818110610b6a57fe5b9050602002013581526020019081526020016000206001015461252c90919063ffffffff16565b600460008a8a85818110610ba157fe5b905060200201358152602001908152602001600020600101819055508080600101915050610a9e565b50610c006001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084612586565b7f44ee104780547f0cb2026486d8f9456b9f11497ce52f217ddac1ba7a5a951696878787876040518080602001806020018381038352878782818152602001925060200280828437600083820152601f01601f19169091018481038352858152602090810191508690860280828437600083820152604051601f909101601f19169092018290039850909650505050505050a150505050505050565b60066020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b610cfe61221b565b6001600160a01b0316336001600160a01b031614610d55576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b600254610d60611fc8565b1115610da5576040805162461bcd60e51b815260206004820152600f60248201526e2620a9aa2fa2a827a1a42fa7ab22a960891b604482015290519081900360640190fd5b806000805b82811015610dfc57610dc1858583818110610b2c57fe5b9150848482818110610dcf57fe5b60025460019085018101600090815260046020908152604090912092029390930135908301555001610daa565b50600254610e0a908361252c565b600255610e426001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084612586565b7ff05c668e041316911f2707c63743bfaf789a193675ffe04e46d93dbc448e642e848460025460405180806020018381526020018281038252858582818152602001925060200280828437600083820152604051601f909101601f1916909201829003965090945050505050a150505050565b60035481565b600a5481565b600060026001541415610f09576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692636f11e6c1926024808301939282900301818787803b158015610f7457600080fd5b505af1158015610f88573d6000803e3d6000fd5b505050506040513d6040811015610f9e57600080fd5b505190508015610fe9576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b60006002541161102d576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000611037611fc8565b11611077576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6001600160a01b0383166110c1576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b6110ca836125e0565b915081156109dc576109dc6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168484612361565b7f000000000000000000000000000000000000000000000000000000000000000081565b60086020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260015414156111ca576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560006111da3361272c565b1580156111e657503233145b90508080611282575060408051636c9b2a3f60e11b815233600482015290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163d936547e916024808301926020929190829003018186803b15801561125557600080fd5b505afa158015611269573d6000803e3d6000fd5b505050506040513d602081101561127f57600080fd5b50515b6112d3576040805162461bcd60e51b815260206004820152601860248201527f434f4e54524143545f4e4f545f57484954454c49535445440000000000000000604482015290519081900360640190fd5b60408051636f11e6c160e01b815230600482015281516000926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692636f11e6c1926024808301939282900301818787803b15801561133957600080fd5b505af115801561134d573d6000803e3d6000fd5b505050506040513d604081101561136357600080fd5b5051905080156113ae576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b6000600254116113f2576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b60006113fc611fc8565b1161143c576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6001600160a01b038416611486576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b826114c6576040805162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b604482015290519081900360640190fd5b6002546114d1611fc8565b111561151d576040805162461bcd60e51b815260206004820152601660248201527524a721a2a72a24ab22a9afa822a924a7a22fa7ab22a960511b604482015290519081900360640190fd5b611528843385612732565b604080516001600160a01b03861681526020810185905281517f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d929181900390910190a15050600180555050565b60009182526004602081815260408085208054600182015460028301546001600160a01b0397909716885260038301855283882054929095019093529420549094919391565b7f000000000000000000000000000000000000000000000000000000000000000081565b6115e861221b565b6001600160a01b0316336001600160a01b03161461163f576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d806000811461168a576040519150601f19603f3d011682016040523d82523d6000602084013e61168f565b606091505b50509050806116d7576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c1906117929030906004016135e5565b6040805180830381600087803b1580156117ab57600080fd5b505af11580156117bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e3919061350a565b9150508061180c5760405162461bcd60e51b8152600401611803906135f9565b60405180910390fd5b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f87c24cd6040518163ffffffff1660e01b815260040160606040518083038186803b15801561186757600080fd5b505afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906133bc565b5090915050336001600160a01b038216146118cc5760405162461bcd60e51b815260040161180390613620565b821561197557604051632989754760e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635312ea8e9061193e907f00000000000000000000000000000000000000000000000000000000000000009060040161364f565b600060405180830381600087803b15801561195857600080fd5b505af115801561196c573d6000803e3d6000fd5b50505050611a92565b6040516393f1a40b60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063441a3e70907f00000000000000000000000000000000000000000000000000000000000000009083906393f1a40b906119ed9084903090600401613658565b604080518083038186803b158015611a0457600080fd5b505afa158015611a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3c9190613579565b516040516001600160e01b031960e085901b168152611a5f92919060040161366f565b600060405180830381600087803b158015611a7957600080fd5b505af1158015611a8d573d6000803e3d6000fd5b505050505b611ac86001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685600019611e97565b611afe6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685600019611e97565b611b346001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685600019611e97565b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60026001541415611ba4576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692636f11e6c1926024808301939282900301818787803b158015611c0f57600080fd5b505af1158015611c23573d6000803e3d6000fd5b505050506040513d6040811015611c3957600080fd5b505190508015611c84576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b600060025411611cc8576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000611cd2611fc8565b11611d12576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b81611d52576040805162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b604482015290519081900360640190fd5b6001600160a01b038316611d9c576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b611da733848461279a565b604080513381526020810184905281517f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5929181900390910190a150506001805550565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e2657600080fd5b505afa158015611e3a573d6000803e3d6000fd5b505050506040513d6020811015611e5057600080fd5b505111611e94576040805162461bcd60e51b815260206004820152600d60248201526c0494e56414c49445f455243323609c1b604482015290519081900360640190fd5b50565b801580611f1d575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611eef57600080fd5b505afa158015611f03573d6000803e3d6000fd5b505050506040513d6020811015611f1957600080fd5b5051155b611f585760405162461bcd60e51b81526004018080602001828103825260368152602001806137556036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611faa908490612802565b505050565b6060611fbe84846000856128b3565b90505b9392505050565b6000611fd342612a0e565b905090565b611fe0612a9f565b6001600160a01b03811660009081526006602052604090205461201d576001600160a01b0381166000908152600660205260409020429055611e94565b6000612027611fc8565b9050600061203760025483612b50565b6002546001600160a01b03851660009081526005602090815260408083205460069092528220546003549495509286119390929161207483612a0e565b9050805b8681116121f5576000818152600460205260409020546120a1578261209c576121f5565b6121ed565b6120db6120af868684612b66565b60008381526004602090815260408083206001600160a01b038f1684526003019091529020549061252c565b60008281526004602090815260408083206001600160a01b038e168452600301909152902055868114801561210e575085155b15612118576121f5565b60006121248a83612bb8565b9050600182015b7f0000000000000000000000000000000000000000000000000000000000000000830181116121ea576121a0826004600084815260200190815260200160002060040160008e6001600160a01b03166001600160a01b031681526020019081526020016000205461252c90919063ffffffff16565b6004600083815260200190815260200160002060040160008d6001600160a01b03166001600160a01b0316815260200190815260200160002081905550808060010191505061212b565b50505b600101612078565b5050506001600160a01b0386166000908152600660205260409020429055505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561227657600080fd5b505afa15801561228a573d6000803e3d6000fd5b505050506040513d60208110156122a057600080fd5b5051905090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415801561231d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b801561235b57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611faa908490612802565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166123eb57506000612447565b6123f482612c22565b6001600160a01b038216600090815260086020526040902054600a5461241a9190612b50565b6001600160a01b038316600090815260086020526040812055600a549091506124439082612d40565b600a555b919050565b60006124f0827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156124bf57600080fd5b505afa1580156124d3573d6000803e3d6000fd5b505050506040513d60208110156124e957600080fd5b5051612b50565b9050801561235b5761235b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168483612361565b600082820183811015611fc1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611b34908590612802565b60006125eb82611fd8565b60006126226125f8611fc8565b7f000000000000000000000000000000000000000000000000000000000000000060025401612b50565b6001600160a01b0384166000908152600760205260409020549091505b8181116126d05760008181526004602081815260408084206001600160a01b03891685529092019052902054156126c85760008181526004602081815260408084206001600160a01b038916855290920190529020546126a090849061252c565b60008281526004602081815260408084206001600160a01b038a168552909201905281205592505b60010161263f565b506001600160a01b0383166000818152600760209081526040918290208490558151928352820184905280517f5891c6cf1c6ad6a35a9ba7097b8c5f9a780d2d6783bb7f9f41ac4ecbdcf4a1269281900390910190a150919050565b3b151590565b61273b83611fd8565b61274483612c22565b6001600160a01b038316600090815260056020526040902054612767908261252c565b6001600160a01b03841660009081526005602052604090205560035461278d908261252c565b600355611faa8282612d9d565b6127a383611fd8565b6127ac83612c22565b6001600160a01b0383166000908152600560205260409020546127cf9082612d40565b6001600160a01b0384166000908152600560205260409020556003546127f59082612d40565b600355611faa8282612e76565b6000612857826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611faf9092919063ffffffff16565b805190915015611faa5780806020019051602081101561287657600080fd5b5051611faa5760405162461bcd60e51b815260040180806020018281038252602a81526020018061372b602a913960400191505060405180910390fd5b6060824710156128f45760405162461bcd60e51b81526004018080602001828103825260268152602001806136e46026913960400191505060405180910390fd5b6128fd8561272c565b61294e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061298c5780518252601f19909201916020918201910161296d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146129ee576040519150601f19603f3d011682016040523d82523d6000602084013e6129f3565b606091505b5091509150612a03828286612f4c565b979650505050505050565b60007f0000000000000000000000000000000000000000000000000000000000000000821015612a4057506000612447565b61235b6001612a997f0000000000000000000000000000000000000000000000000000000000000000612a93867f0000000000000000000000000000000000000000000000000000000000000000612d40565b90612ff0565b9061252c565b6000612aa9611fc8565b90506000612ab982600254612b50565b90505b8015612b4c576000612acd82613057565b60008381526004602052604090206002015490915080821415612af1575050612b4c565b612b16612b016003548386612b66565b6000858152600460205260409020549061252c565b600084815260046020526040902055612b2f4283612b50565b600084815260046020526040902060020155505060001901612abc565b5050565b6000818310612b5f5781611fc1565b5090919050565b60004281612b7c85612b77866130ad565b6130e7565b90506000612b9283612b8d87613057565b612b50565b90506000612ba082846130f7565b9050612bac8882613108565b98975050505050505050565b600081815260046020818152604080842080546001600160a01b03881686526003820184529185205486865293909252600190910154611fc1927f000000000000000000000000000000000000000000000000000000000000000092612a93929091839190613108565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612c5557611e94565b612c5d613161565b6001600160a01b038116600090815260096020526040902054612c9b57600b546001600160a01b038216600090815260096020526040902055611e94565b6001600160a01b0381166000908152600560209081526040808320546009909252822054600b54919291612cce91612d40565b90506000612ce968056bc75e2d63100000612a938585613108565b6001600160a01b038516600090815260086020526040902054909150612d0f908261252c565b6001600160a01b038516600090815260086020908152604080832093909355600b5460099091529190205550505050565b600082821115612d97576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b612dd26001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016833084612586565b604051631c57762b60e31b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e2bbb15890612e40907f000000000000000000000000000000000000000000000000000000000000000090859060040161366f565b600060405180830381600087803b158015612e5a57600080fd5b505af1158015612e6e573d6000803e3d6000fd5b505050505050565b604051630441a3e760e41b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063441a3e7090612ee4907f000000000000000000000000000000000000000000000000000000000000000090859060040161366f565b600060405180830381600087803b158015612efe57600080fd5b505af1158015612f12573d6000803e3d6000fd5b50612b4c9250506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690508383612361565b60608315612f5b575081611fc1565b825115612f6b5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612fb5578181015183820152602001612f9d565b50505050905090810190601f168015612fe25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000808211613046576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161304f57fe5b049392505050565b600061235b613086837f0000000000000000000000000000000000000000000000000000000000000000613108565b7f00000000000000000000000000000000000000000000000000000000000000009061252c565b600061235b6130867f00000000000000000000000000000000000000000000000000000000000000006130e1856001612d40565b90613108565b600081831015612b5f5781611fc1565b600081831015612d97576000611fc1565b6000826131175750600061235b565b8282028284828161312457fe5b0414611fc15760405162461bcd60e51b815260040180806020018281038252602181526020018061370a6021913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316158061319c575061319a61329a565b155b156131a657613298565b6131ae61329f565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561321d57600080fd5b505afa158015613231573d6000803e3d6000fd5b505050506040513d602081101561324757600080fd5b505190506000806132578361333c565b9150915060006003546000146132845760035461328190612a938468056bc75e2d63100000613108565b90505b61328e838261252c565b600b55505050600a555b565b600190565b604051630441a3e760e41b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063441a3e709061330e907f00000000000000000000000000000000000000000000000000000000000000009060009060040161366f565b600060405180830381600087803b15801561332857600080fd5b505af1158015611b34573d6000803e3d6000fd5b600b54600a54600090613350908490612d40565b9050915091565b60008083601f840112613368578182fd5b50813567ffffffffffffffff81111561337f578182fd5b602083019150836020808302850101111561339957600080fd5b9250929050565b6000602082840312156133b1578081fd5b8135611fc1816136a0565b6000806000606084860312156133d0578182fd5b83516133db816136a0565b60208501519093506133ec816136a0565b80925050604084015190509250925092565b60008060408385031215613410578182fd5b823561341b816136a0565b9150602083013561342b816136b5565b809150509250929050565b60008060408385031215613448578182fd5b8235613453816136a0565b946020939093013593505050565b60008060208385031215613473578182fd5b823567ffffffffffffffff811115613489578283fd5b61349585828601613357565b90969095509350505050565b600080600080604085870312156134b6578081fd5b843567ffffffffffffffff808211156134cd578283fd5b6134d988838901613357565b909650945060208701359150808211156134f1578283fd5b506134fe87828801613357565b95989497509550505050565b6000806040838503121561351c578182fd5b8251613527816136b5565b602084015190925061342b816136b5565b60008060006060848603121561354c578283fd5b8335613557816136a0565b925060208401359150604084013561356e816136a0565b809150509250925092565b60006040828403121561358a578081fd5b6040516040810181811067ffffffffffffffff821117156135a757fe5b604052825181526020928301519281019290925250919050565b600080604083850312156135d3578182fd5b82359150602083013561342b816136a0565b6001600160a01b0391909116815260200190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b948552602085019390935260408401919091526060830152608082015260a00190565b6001600160a01b0381168114611e9457600080fd5b8015158114611e9457600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a264697066735822122030832874c5707d795dc8151119e08f64081aceb244a7577443f63c4f3908f5b464736f6c63430007060033416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000000005a05a64115bd86f220a26461fde3a011c71424760000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d10000000000000000000000006fa13469428e85e6ac12c84b73a19aef7c53332a000000000000000000000000808507121b80c02388fad14726482e061b8da827000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef40000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe20000000000000000000000000000000000000000000000000000000061394e800000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000005000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd0000000000000000000000000000000000000000000000000000000000000123

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806383bbfde11161010f578063adc9772e116100a2578063d2e6d1c311610071578063d2e6d1c3146103a5578063dd254a6a146103ad578063f1068454146103c0578063f3fef3a3146103c8576101f0565b8063adc9772e14610364578063b40310c914610377578063be66c60f1461038a578063ce56c45414610392576101f0565b806393e59dc1116100de57806393e59dc11461033957806396b973c0146103415780639a51d2d114610354578063a81e457c1461035c576101f0565b806383bbfde1146103035780638b0e9f3f146103165780638f373bf31461031e5780639262187b14610326576101f0565b806351ed6a301161018757806370b66cd01161015657806370b66cd0146102cd578063738573f4146102e057806376d5de85146102f357806378e97925146102fb576101f0565b806351ed6a3014610295578063541a7ca6146102aa578063575a86b2146102b25780636304a6bc146102ba576101f0565b806327e235e3116101c357806327e235e3146102525780632936ada7146102655780633ccdbb28146102785780634ff0876a1461028d576101f0565b806304f917af146101f5578063059f8b16146102225780631667663214610237578063173688411461024a575b600080fd5b6102086102033660046135c1565b6103db565b60405161021995949392919061367d565b60405180910390f35b61022a6105c2565b604051610219919061364f565b61022a6102453660046133a0565b6105cf565b61022a6105e1565b61022a6102603660046133a0565b6105e7565b61022a6102733660046133a0565b6105f9565b61028b610286366004613538565b61060b565b005b61022a61071b565b61029d61073f565b60405161021991906135e5565b61022a610763565b61029d610769565b61022a6102c83660046133a0565b61078d565b61028b6102db3660046134a1565b6109e6565b61022a6102ee3660046133a0565b610c9c565b61029d610cae565b61022a610cd2565b61028b610311366004613461565b610cf6565b61022a610eb5565b61022a610ebb565b61022a6103343660046133a0565b610ec1565b61029d611106565b61022a61034f3660046133a0565b61112a565b61022a61113c565b61029d611160565b61028b610372366004613436565b611184565b6102086103853660046135c1565b611576565b61029d6115bc565b61028b6103a03660046135c1565b6115e0565b61029d61171f565b61028b6103bb3660046133fe565b611743565b61022a611b3a565b61028b6103d6366004613436565b611b5e565b600080600080600060026001541415610429576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11692636f11e6c1926024808301939282900301818787803b15801561049457600080fd5b505af11580156104a8573d6000803e3d6000fd5b505050506040513d60408110156104be57600080fd5b505190508015610509576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b60006002541161054d576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000610557611fc8565b11610597576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6105a087611fd8565b6105aa8888611576565b60018055939c929b5090995097509095509350505050565b68056bc75e2d6310000081565b60096020526000908152604090205481565b60025481565b60056020526000908152604090205481565b60076020526000908152604090205481565b61061361221b565b6001600160a01b0316336001600160a01b03161461066a576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b610673836122a7565b6106b8576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b6106cc6001600160a01b0384168284612361565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b7f0000000000000000000000000000000000000000000000000000000000093a8081565b7f000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef481565b600b5481565b7f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd81565b6000600260015414156107d5576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11692636f11e6c1926024808301939282900301818787803b15801561084057600080fd5b505af1158015610854573d6000803e3d6000fd5b505050506040513d604081101561086a57600080fd5b5051905080156108b5576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b6000600254116108f9576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000610903611fc8565b11610943576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b7f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b031661097a57600091506109dc565b6001600160a01b0383166109c4576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b6109cd836123b3565b91506109d9838361244c565b91505b5060018055919050565b6109ee61221b565b6001600160a01b0316336001600160a01b031614610a45576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b828114610a8a576040805162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f41525241595360901b604482015290519081900360640190fd5b6000610a94611fc8565b6002549091506000805b86811015610bca57878782818110610ab257fe5b9050602002013584108015610ad9575082888883818110610acf57fe5b9050602002013511155b610b1d576040805162461bcd60e51b815260206004820152601060248201526f1253959053125117d15413d0d217d25160821b604482015290519081900360640190fd5b610b42868683818110610b2c57fe5b905060200201358361252c90919063ffffffff16565b9150610b91868683818110610b5357fe5b90506020020135600460008b8b86818110610b6a57fe5b9050602002013581526020019081526020016000206001015461252c90919063ffffffff16565b600460008a8a85818110610ba157fe5b905060200201358152602001908152602001600020600101819055508080600101915050610a9e565b50610c006001600160a01b037f000000000000000000000000808507121b80c02388fad14726482e061b8da82716333084612586565b7f44ee104780547f0cb2026486d8f9456b9f11497ce52f217ddac1ba7a5a951696878787876040518080602001806020018381038352878782818152602001925060200280828437600083820152601f01601f19169091018481038352858152602090810191508690860280828437600083820152604051601f909101601f19169092018290039850909650505050505050a150505050505050565b60066020526000908152604090205481565b7f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe281565b7f0000000000000000000000000000000000000000000000000000000061394e8081565b610cfe61221b565b6001600160a01b0316336001600160a01b031614610d55576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b600254610d60611fc8565b1115610da5576040805162461bcd60e51b815260206004820152600f60248201526e2620a9aa2fa2a827a1a42fa7ab22a960891b604482015290519081900360640190fd5b806000805b82811015610dfc57610dc1858583818110610b2c57fe5b9150848482818110610dcf57fe5b60025460019085018101600090815260046020908152604090912092029390930135908301555001610daa565b50600254610e0a908361252c565b600255610e426001600160a01b037f000000000000000000000000808507121b80c02388fad14726482e061b8da82716333084612586565b7ff05c668e041316911f2707c63743bfaf789a193675ffe04e46d93dbc448e642e848460025460405180806020018381526020018281038252858582818152602001925060200280828437600083820152604051601f909101601f1916909201829003965090945050505050a150505050565b60035481565b600a5481565b600060026001541415610f09576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11692636f11e6c1926024808301939282900301818787803b158015610f7457600080fd5b505af1158015610f88573d6000803e3d6000fd5b505050506040513d6040811015610f9e57600080fd5b505190508015610fe9576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b60006002541161102d576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000611037611fc8565b11611077576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6001600160a01b0383166110c1576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b6110ca836125e0565b915081156109dc576109dc6001600160a01b037f000000000000000000000000808507121b80c02388fad14726482e061b8da827168484612361565b7f0000000000000000000000006fa13469428e85e6ac12c84b73a19aef7c53332a81565b60086020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000581565b7f000000000000000000000000808507121b80c02388fad14726482e061b8da82781565b600260015414156111ca576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560006111da3361272c565b1580156111e657503233145b90508080611282575060408051636c9b2a3f60e11b815233600482015290516001600160a01b037f0000000000000000000000006fa13469428e85e6ac12c84b73a19aef7c53332a169163d936547e916024808301926020929190829003018186803b15801561125557600080fd5b505afa158015611269573d6000803e3d6000fd5b505050506040513d602081101561127f57600080fd5b50515b6112d3576040805162461bcd60e51b815260206004820152601860248201527f434f4e54524143545f4e4f545f57484954454c49535445440000000000000000604482015290519081900360640190fd5b60408051636f11e6c160e01b815230600482015281516000926001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11692636f11e6c1926024808301939282900301818787803b15801561133957600080fd5b505af115801561134d573d6000803e3d6000fd5b505050506040513d604081101561136357600080fd5b5051905080156113ae576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b6000600254116113f2576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b60006113fc611fc8565b1161143c576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b6001600160a01b038416611486576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b826114c6576040805162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b604482015290519081900360640190fd5b6002546114d1611fc8565b111561151d576040805162461bcd60e51b815260206004820152601660248201527524a721a2a72a24ab22a9afa822a924a7a22fa7ab22a960511b604482015290519081900360640190fd5b611528843385612732565b604080516001600160a01b03861681526020810185905281517f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d929181900390910190a15050600180555050565b60009182526004602081815260408085208054600182015460028301546001600160a01b0397909716885260038301855283882054929095019093529420549094919391565b7f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d181565b6115e861221b565b6001600160a01b0316336001600160a01b03161461163f576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d806000811461168a576040519150601f19603f3d011682016040523d82523d6000602084013e61168f565b606091505b50509050806116d7576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b7f0000000000000000000000005a05a64115bd86f220a26461fde3a011c714247681565b604051636f11e6c160e01b81526000906001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11690636f11e6c1906117929030906004016135e5565b6040805180830381600087803b1580156117ab57600080fd5b505af11580156117bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e3919061350a565b9150508061180c5760405162461bcd60e51b8152600401611803906135f9565b60405180910390fd5b60007f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d16001600160a01b031663f87c24cd6040518163ffffffff1660e01b815260040160606040518083038186803b15801561186757600080fd5b505afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906133bc565b5090915050336001600160a01b038216146118cc5760405162461bcd60e51b815260040161180390613620565b821561197557604051632989754760e11b81526001600160a01b037f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd1690635312ea8e9061193e907f00000000000000000000000000000000000000000000000000000000000001239060040161364f565b600060405180830381600087803b15801561195857600080fd5b505af115801561196c573d6000803e3d6000fd5b50505050611a92565b6040516393f1a40b60e01b81526001600160a01b037f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd169063441a3e70907f00000000000000000000000000000000000000000000000000000000000001239083906393f1a40b906119ed9084903090600401613658565b604080518083038186803b158015611a0457600080fd5b505afa158015611a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3c9190613579565b516040516001600160e01b031960e085901b168152611a5f92919060040161366f565b600060405180830381600087803b158015611a7957600080fd5b505af1158015611a8d573d6000803e3d6000fd5b505050505b611ac86001600160a01b037f000000000000000000000000808507121b80c02388fad14726482e061b8da8271685600019611e97565b611afe6001600160a01b037f000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef41685600019611e97565b611b346001600160a01b037f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe21685600019611e97565b50505050565b7f000000000000000000000000000000000000000000000000000000000000012381565b60026001541415611ba4576040805162461bcd60e51b815260206004820152601f60248201526000805160206136c4833981519152604482015290519081900360640190fd5b600260015560408051636f11e6c160e01b815230600482015281516000926001600160a01b037f0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d11692636f11e6c1926024808301939282900301818787803b158015611c0f57600080fd5b505af1158015611c23573d6000803e3d6000fd5b505050506040513d6040811015611c3957600080fd5b505190508015611c84576040805162461bcd60e51b815260206004820152601160248201527013125457d35253925391d7d4105554d151607a1b604482015290519081900360640190fd5b600060025411611cc8576040805162461bcd60e51b815260206004820152600a6024820152691393d517d1955391115160b21b604482015290519081900360640190fd5b6000611cd2611fc8565b11611d12576040805162461bcd60e51b815260206004820152600b60248201526a1393d517d4d5105495115160aa1b604482015290519081900360640190fd5b81611d52576040805162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b604482015290519081900360640190fd5b6001600160a01b038316611d9c576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b611da733848461279a565b604080513381526020810184905281517f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5929181900390910190a150506001805550565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e2657600080fd5b505afa158015611e3a573d6000803e3d6000fd5b505050506040513d6020811015611e5057600080fd5b505111611e94576040805162461bcd60e51b815260206004820152600d60248201526c0494e56414c49445f455243323609c1b604482015290519081900360640190fd5b50565b801580611f1d575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611eef57600080fd5b505afa158015611f03573d6000803e3d6000fd5b505050506040513d6020811015611f1957600080fd5b5051155b611f585760405162461bcd60e51b81526004018080602001828103825260368152602001806137556036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611faa908490612802565b505050565b6060611fbe84846000856128b3565b90505b9392505050565b6000611fd342612a0e565b905090565b611fe0612a9f565b6001600160a01b03811660009081526006602052604090205461201d576001600160a01b0381166000908152600660205260409020429055611e94565b6000612027611fc8565b9050600061203760025483612b50565b6002546001600160a01b03851660009081526005602090815260408083205460069092528220546003549495509286119390929161207483612a0e565b9050805b8681116121f5576000818152600460205260409020546120a1578261209c576121f5565b6121ed565b6120db6120af868684612b66565b60008381526004602090815260408083206001600160a01b038f1684526003019091529020549061252c565b60008281526004602090815260408083206001600160a01b038e168452600301909152902055868114801561210e575085155b15612118576121f5565b60006121248a83612bb8565b9050600182015b7f0000000000000000000000000000000000000000000000000000000000000005830181116121ea576121a0826004600084815260200190815260200160002060040160008e6001600160a01b03166001600160a01b031681526020019081526020016000205461252c90919063ffffffff16565b6004600083815260200190815260200160002060040160008d6001600160a01b03166001600160a01b0316815260200190815260200160002081905550808060010191505061212b565b50505b600101612078565b5050506001600160a01b0386166000908152600660205260409020429055505050505050565b60007f0000000000000000000000005a05a64115bd86f220a26461fde3a011c71424766001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561227657600080fd5b505afa15801561228a573d6000803e3d6000fd5b505050506040513d60208110156122a057600080fd5b5051905090565b60007f000000000000000000000000808507121b80c02388fad14726482e061b8da8276001600160a01b0316826001600160a01b03161415801561231d57507f000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef46001600160a01b0316826001600160a01b031614155b801561235b57507f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b0316826001600160a01b031614155b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611faa908490612802565b60007f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b03166123eb57506000612447565b6123f482612c22565b6001600160a01b038216600090815260086020526040902054600a5461241a9190612b50565b6001600160a01b038316600090815260086020526040812055600a549091506124439082612d40565b600a555b919050565b60006124f0827f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156124bf57600080fd5b505afa1580156124d3573d6000803e3d6000fd5b505050506040513d60208110156124e957600080fd5b5051612b50565b9050801561235b5761235b6001600160a01b037f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2168483612361565b600082820183811015611fc1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611b34908590612802565b60006125eb82611fd8565b60006126226125f8611fc8565b7f000000000000000000000000000000000000000000000000000000000000000560025401612b50565b6001600160a01b0384166000908152600760205260409020549091505b8181116126d05760008181526004602081815260408084206001600160a01b03891685529092019052902054156126c85760008181526004602081815260408084206001600160a01b038916855290920190529020546126a090849061252c565b60008281526004602081815260408084206001600160a01b038a168552909201905281205592505b60010161263f565b506001600160a01b0383166000818152600760209081526040918290208490558151928352820184905280517f5891c6cf1c6ad6a35a9ba7097b8c5f9a780d2d6783bb7f9f41ac4ecbdcf4a1269281900390910190a150919050565b3b151590565b61273b83611fd8565b61274483612c22565b6001600160a01b038316600090815260056020526040902054612767908261252c565b6001600160a01b03841660009081526005602052604090205560035461278d908261252c565b600355611faa8282612d9d565b6127a383611fd8565b6127ac83612c22565b6001600160a01b0383166000908152600560205260409020546127cf9082612d40565b6001600160a01b0384166000908152600560205260409020556003546127f59082612d40565b600355611faa8282612e76565b6000612857826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611faf9092919063ffffffff16565b805190915015611faa5780806020019051602081101561287657600080fd5b5051611faa5760405162461bcd60e51b815260040180806020018281038252602a81526020018061372b602a913960400191505060405180910390fd5b6060824710156128f45760405162461bcd60e51b81526004018080602001828103825260268152602001806136e46026913960400191505060405180910390fd5b6128fd8561272c565b61294e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061298c5780518252601f19909201916020918201910161296d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146129ee576040519150601f19603f3d011682016040523d82523d6000602084013e6129f3565b606091505b5091509150612a03828286612f4c565b979650505050505050565b60007f0000000000000000000000000000000000000000000000000000000061394e80821015612a4057506000612447565b61235b6001612a997f0000000000000000000000000000000000000000000000000000000000093a80612a93867f0000000000000000000000000000000000000000000000000000000061394e80612d40565b90612ff0565b9061252c565b6000612aa9611fc8565b90506000612ab982600254612b50565b90505b8015612b4c576000612acd82613057565b60008381526004602052604090206002015490915080821415612af1575050612b4c565b612b16612b016003548386612b66565b6000858152600460205260409020549061252c565b600084815260046020526040902055612b2f4283612b50565b600084815260046020526040902060020155505060001901612abc565b5050565b6000818310612b5f5781611fc1565b5090919050565b60004281612b7c85612b77866130ad565b6130e7565b90506000612b9283612b8d87613057565b612b50565b90506000612ba082846130f7565b9050612bac8882613108565b98975050505050505050565b600081815260046020818152604080842080546001600160a01b03881686526003820184529185205486865293909252600190910154611fc1927f000000000000000000000000000000000000000000000000000000000000000592612a93929091839190613108565b7f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b0316612c5557611e94565b612c5d613161565b6001600160a01b038116600090815260096020526040902054612c9b57600b546001600160a01b038216600090815260096020526040902055611e94565b6001600160a01b0381166000908152600560209081526040808320546009909252822054600b54919291612cce91612d40565b90506000612ce968056bc75e2d63100000612a938585613108565b6001600160a01b038516600090815260086020526040902054909150612d0f908261252c565b6001600160a01b038516600090815260086020908152604080832093909355600b5460099091529190205550505050565b600082821115612d97576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b612dd26001600160a01b037f000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef416833084612586565b604051631c57762b60e31b81526001600160a01b037f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd169063e2bbb15890612e40907f000000000000000000000000000000000000000000000000000000000000012390859060040161366f565b600060405180830381600087803b158015612e5a57600080fd5b505af1158015612e6e573d6000803e3d6000fd5b505050505050565b604051630441a3e760e41b81526001600160a01b037f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd169063441a3e7090612ee4907f000000000000000000000000000000000000000000000000000000000000012390859060040161366f565b600060405180830381600087803b158015612efe57600080fd5b505af1158015612f12573d6000803e3d6000fd5b50612b4c9250506001600160a01b037f000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef41690508383612361565b60608315612f5b575081611fc1565b825115612f6b5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612fb5578181015183820152602001612f9d565b50505050905090810190601f168015612fe25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000808211613046576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161304f57fe5b049392505050565b600061235b613086837f0000000000000000000000000000000000000000000000000000000000093a80613108565b7f0000000000000000000000000000000000000000000000000000000061394e809061252c565b600061235b6130867f0000000000000000000000000000000000000000000000000000000000093a806130e1856001612d40565b90613108565b600081831015612b5f5781611fc1565b600081831015612d97576000611fc1565b6000826131175750600061235b565b8282028284828161312457fe5b0414611fc15760405162461bcd60e51b815260040180806020018281038252602181526020018061370a6021913960400191505060405180910390fd5b7f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b0316158061319c575061319a61329a565b155b156131a657613298565b6131ae61329f565b60007f0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe26001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561321d57600080fd5b505afa158015613231573d6000803e3d6000fd5b505050506040513d602081101561324757600080fd5b505190506000806132578361333c565b9150915060006003546000146132845760035461328190612a938468056bc75e2d63100000613108565b90505b61328e838261252c565b600b55505050600a555b565b600190565b604051630441a3e760e41b81526001600160a01b037f000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd169063441a3e709061330e907f00000000000000000000000000000000000000000000000000000000000001239060009060040161366f565b600060405180830381600087803b15801561332857600080fd5b505af1158015611b34573d6000803e3d6000fd5b600b54600a54600090613350908490612d40565b9050915091565b60008083601f840112613368578182fd5b50813567ffffffffffffffff81111561337f578182fd5b602083019150836020808302850101111561339957600080fd5b9250929050565b6000602082840312156133b1578081fd5b8135611fc1816136a0565b6000806000606084860312156133d0578182fd5b83516133db816136a0565b60208501519093506133ec816136a0565b80925050604084015190509250925092565b60008060408385031215613410578182fd5b823561341b816136a0565b9150602083013561342b816136b5565b809150509250929050565b60008060408385031215613448578182fd5b8235613453816136a0565b946020939093013593505050565b60008060208385031215613473578182fd5b823567ffffffffffffffff811115613489578283fd5b61349585828601613357565b90969095509350505050565b600080600080604085870312156134b6578081fd5b843567ffffffffffffffff808211156134cd578283fd5b6134d988838901613357565b909650945060208701359150808211156134f1578283fd5b506134fe87828801613357565b95989497509550505050565b6000806040838503121561351c578182fd5b8251613527816136b5565b602084015190925061342b816136b5565b60008060006060848603121561354c578283fd5b8335613557816136a0565b925060208401359150604084013561356e816136a0565b809150509250925092565b60006040828403121561358a578081fd5b6040516040810181811067ffffffffffffffff821117156135a757fe5b604052825181526020928301519281019290925250919050565b600080604083850312156135d3578182fd5b82359150602083013561342b816136a0565b6001600160a01b0391909116815260200190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b948552602085019390935260408401919091526060830152608082015260a00190565b6001600160a01b0381168114611e9457600080fd5b8015158114611e9457600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a264697066735822122030832874c5707d795dc8151119e08f64081aceb244a7577443f63c4f3908f5b464736f6c63430007060033

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

0000000000000000000000005a05a64115bd86f220a26461fde3a011c71424760000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d10000000000000000000000006fa13469428e85e6ac12c84b73a19aef7c53332a000000000000000000000000808507121b80c02388fad14726482e061b8da827000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef40000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe20000000000000000000000000000000000000000000000000000000061394e800000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000005000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd0000000000000000000000000000000000000000000000000000000000000123

-----Decoded View---------------
Arg [0] : _governanceManager (address): 0x5a05a64115bd86f220a26461fDe3A011c7142476
Arg [1] : _pausingManager (address): 0x4dc6b6374e812E029937129a156Eec6344cDE8D1
Arg [2] : _whitelist (address): 0x6fa13469428e85E6aC12c84B73A19aeF7c53332A
Arg [3] : _pendleTokenAddress (address): 0x808507121B80c02388fAd14726482e061B8da827
Arg [4] : _stakeToken (address): 0xb124C4e18A282143D362a066736FD60d22393Ef4
Arg [5] : _yieldToken (address): 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2
Arg [6] : _startTime (uint256): 1631145600
Arg [7] : _epochDuration (uint256): 604800
Arg [8] : _vestingEpochs (uint256): 5
Arg [9] : _masterChef (address): 0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd
Arg [10] : _pid (uint256): 291

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 0000000000000000000000005a05a64115bd86f220a26461fde3a011c7142476
Arg [1] : 0000000000000000000000004dc6b6374e812e029937129a156eec6344cde8d1
Arg [2] : 0000000000000000000000006fa13469428e85e6ac12c84b73a19aef7c53332a
Arg [3] : 000000000000000000000000808507121b80c02388fad14726482e061b8da827
Arg [4] : 000000000000000000000000b124c4e18a282143d362a066736fd60d22393ef4
Arg [5] : 0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2
Arg [6] : 0000000000000000000000000000000000000000000000000000000061394e80
Arg [7] : 0000000000000000000000000000000000000000000000000000000000093a80
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [9] : 000000000000000000000000c2edad668740f1aa35e4d8f227fb8e17dca888cd
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000123


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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