AVAX Price: $22.80 (+11.32%)
Gas: 1 nAVAX
 

Overview

AVAX Balance

Avalanche C-Chain LogoAvalanche C-Chain LogoAvalanche C-Chain Logo0 AVAX

AVAX Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw564394672025-01-27 18:07:4685 days ago1738001266IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.008275812.5
Withdraw498689332024-08-29 16:05:15236 days ago1724947515IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1823809726.5
Withdraw469286232024-06-19 21:48:47307 days ago1718833727IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0527289226.97420296
Withdraw468402282024-06-17 18:36:21309 days ago1718649381IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1735902225
Withdraw445116412024-04-22 5:46:46366 days ago1713764806IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.3724702860
Withdraw438718632024-04-06 21:15:29381 days ago1712438129IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0561581626.5
Withdraw436043242024-03-31 11:31:02388 days ago1711884662IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1605659326.5
Withdraw434115702024-03-26 20:54:25392 days ago1711486465IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0629342626.5
Withdraw428524682024-03-13 15:32:22405 days ago1710343942IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.4210889275
Withdraw428520792024-03-13 15:18:58405 days ago1710343138IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0427875
Withdraw428519032024-03-13 15:13:05405 days ago1710342785IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0427875
Withdraw428312272024-03-13 3:09:24406 days ago1710299364IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1546111827.425
Withdraw426363112024-03-08 13:00:04410 days ago1709902804IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1555283426.5
Withdraw424406402024-03-03 22:45:57415 days ago1709505957IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1233919827.35224999
Withdraw422996862024-02-29 14:56:44418 days ago1709218604IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.009812626.5
Withdraw422578802024-02-28 15:20:19419 days ago1709133619IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1533457226.5
Withdraw411987382024-02-03 13:46:08444 days ago1706967968IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1310905126.5
Withdraw410433232024-01-30 21:57:28448 days ago1706651848IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1304481526.5
Withdraw408700662024-01-26 18:28:02452 days ago1706293682IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0019118426.5
Withdraw408700562024-01-26 18:27:40452 days ago1706293660IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1624880326.5
Withdraw408195712024-01-25 13:29:08453 days ago1706189348IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0685439426.5
Withdraw404625452024-01-17 2:38:07462 days ago1705459087IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.0225123826.5
Withdraw404290472024-01-16 7:37:50463 days ago1705390670IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1480409226.5
Withdraw403478552024-01-14 10:00:44465 days ago1705226444IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1503063526.5
Withdraw402919502024-01-13 2:44:06466 days ago1705113846IN
Pendle: OT-PA/PENDLE Liquidity Mining
0 AVAX0.1415520226.5
View all transactions

Latest 1 internal transaction

Parent Transaction Hash Block From To
67913262021-11-11 2:52:271259 days ago1636599147
Pendle: OT-PA/PENDLE Liquidity Mining
 Contract Creation0 AVAX
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PendleLiquidityMiningBaseV2Multi

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

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

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

/*
- stakeToken is the token to be used to stake into this contract to receive rewards
- yieldTokens are tokens 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 yieldTokens, it should be set to address(0) to save gas
*/
contract PendleLiquidityMiningBaseV2Multi is
    IPendleLiquidityMiningV2Multi,
    WithdrawableV2,
    ReentrancyGuard
{
    using Math for uint256;
    using SafeMath for uint256;
    using PairTokensLib for PairUints;
    using PairTokensLib for PairTokens;
    using TokenUtils for IERC20;

    struct ConstructorArgs {
        address governanceManager;
        address pausingManager;
        address whitelist;
        PairTokens rewardTokens;
        address stakeToken;
        PairTokens yieldTokens;
        uint256 startTime;
        uint256 epochDuration;
        uint256 vestingEpochs;
        IWETH weth;
    }

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

    IPendleWhitelist public immutable whitelist;
    IPendlePausingManager public immutable pausingManager;
    IWETH public immutable weth;

    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;

    PairTokens public rewardTokens;
    address public immutable override stakeToken;
    PairTokens public yieldTokens;
    address public immutable rewardTokensHolder;
    uint256 public immutable override startTime;
    uint256 public immutable override epochDuration;
    uint256 public immutable override vestingEpochs;
    uint256 public constant MULTIPLIER = 10**20;

    // yieldTokens-related
    mapping(address => PairUints) public dueInterests;
    mapping(address => PairUints) public lastParamL;
    PairUints public lastNYield;
    PairUints public 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(ConstructorArgs memory args) PermissionsV2(args.governanceManager) {
        require(args.startTime > block.timestamp, "INVALID_START_TIME");
        require(args.vestingEpochs > 0, "INVALID_VESTING_EPOCHS");
        args.rewardTokens.verify();
        args.yieldTokens.verify();

        weth = args.weth;
        pausingManager = IPendlePausingManager(args.pausingManager);
        whitelist = IPendleWhitelist(args.whitelist);
        rewardTokens = args.rewardTokens;

        stakeToken = args.stakeToken;
        yieldTokens = args.yieldTokens;
        startTime = args.startTime;
        epochDuration = args.epochDuration;
        vestingEpochs = args.vestingEpochs;
        paramL = PairUints(1, 1);

        rewardTokensHolder = address(
            new PendleSimpleERC20TokenHolder(args.rewardTokens.toArr(), address(this))
        );
    }

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

        //pulling our rewardTokens back
        rewardTokens.safeTransferFrom(
            rewardTokensHolder,
            address(this),
            rewardTokens.balanceOf(rewardTokensHolder)
        );
        rewardTokens.infinityApprove(spender);
        IERC20(stakeToken).safeApprove(spender, type(uint256).max);
        yieldTokens.infinityApprove(spender);
    }

    /**
    @notice create new epochs & fund rewards for them
    @dev same logic as the function in V1
    */
    function fund(PairUints[] 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;
        PairUints memory 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);
        rewardTokens.safeTransferFrom(msg.sender, rewardTokensHolder, 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, PairUints[] calldata rewards)
        external
        virtual
        override
        onlyGovernance
    {
        require(epochIds.length == rewards.length, "INVALID_ARRAYS");

        uint256 curEpoch = getCurrentEpochId();
        uint256 endEpoch = numberOfEpochs;
        PairUints memory 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]
            );
        }

        rewardTokens.safeTransferFrom(msg.sender, rewardTokensHolder, 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 (PairUints memory rewards)
    {
        require(user != address(0), "ZERO_ADDRESS");

        rewards = _beforeTransferPendingRewards(user);
        rewardTokens.safeTransferFrom(rewardTokensHolder, 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 (PairUints memory amountOut)
    {
        if (yieldTokens.allZero()) return amountOut;
        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,
            PairUints memory totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            PairUints memory availableRewardsForUser
        )
    {
        _updatePendingRewards(user);
        return readEpochData(epochId, user);
    }

    function readYieldTokens() external view override returns (PairTokens memory tokens) {
        tokens = yieldTokens;
    }

    function readRewardTokens() external view override returns (PairTokens memory tokens) {
        tokens = rewardTokens;
    }

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

    function getCurrentEpochId() public view returns (uint256) {
        return _epochOfTimestamp(block.timestamp);
    }

    /**
    @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
            PairUints memory 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 (yieldTokens.allZero()) return;

        _updateParamL();

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

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

        PairUints memory interestFromStakeToken = interestValuePerStakeToken.mul(principal).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 (yieldTokens.allZero() || !_checkNeedUpdateParamL()) return;

        _redeemExternalInterests();

        PairUints memory currentNYield = yieldTokens.balanceOf(address(this));
        (PairUints memory firstTerm, PairUints memory paramR) = _getFirstTermAndParamR(
            currentNYield
        );

        PairUints memory 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(PairUints memory currentNYield)
        internal
        virtual
        returns (PairUints memory firstTerm, PairUints memory paramR)
    {
        firstTerm = paramL;
        paramR = currentNYield.sub(lastNYield);
    }

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

    /**
    @dev function is empty because by default yieldTokens==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 (PairUints memory amountOut)
    {
        _updatePendingRewards(user);

        uint256 _lastEpoch = Math.min(getCurrentEpochId(), numberOfEpochs + vestingEpochs);
        for (uint256 i = lastEpochClaimed[user]; i <= _lastEpoch; i++) {
            if (!epochData[i].availableRewardsForUser[user].allZero()) {
                amountOut = amountOut.add(epochData[i].availableRewardsForUser[user]);
                epochData[i].availableRewardsForUser[user] = PairUints(0, 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 (PairUints memory amountOut)
    {
        if (yieldTokens.allZero()) return amountOut;

        _updateDueInterests(user);
        amountOut = dueInterests[user].min(lastNYield);
        dueInterests[user] = PairUints(0, 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, PairUints memory amount)
        internal
        virtual
        returns (PairUints memory outAmount)
    {
        outAmount = amount.min(yieldTokens.balanceOf(address(this)));
        yieldTokens.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 (PairUints memory 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 _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 =
            (rewardTokens.contains(_token) == false) &&
            stakeToken != _token &&
            (yieldTokens.contains(_token) == false);
    }
}

File 2 of 18 : 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 3 of 18 : 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 4 of 18 : IPendleLiquidityMiningV2Multi.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 "../libraries/PairTokensLib.sol";
import "../interfaces/IWETH.sol";

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

    function fund(PairUints[] calldata rewards) external;

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

    function stake(address forAddr, uint256 amount) external;

    function withdraw(address toAddr, uint256 amount) external;

    function redeemRewards(address user) external returns (PairUints memory rewards);

    function redeemDueInterests(address user) external returns (PairUints memory amountOut);

    function setUpEmergencyMode(address spender, bool) external;

    function updateAndReadEpochData(uint256 epochId, address user)
        external
        returns (
            uint256 totalStakeUnits,
            PairUints memory totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            PairUints memory 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,
            PairUints memory totalRewards,
            uint256 lastUpdated,
            uint256 stakeUnitsForUser,
            PairUints memory availableRewardsForUser
        );

    function numberOfEpochs() external view returns (uint256);

    function vestingEpochs() external view returns (uint256);

    function stakeToken() external view returns (address);

    function totalStake() external view returns (uint256);

    function readYieldTokens() external view returns (PairTokens memory);

    function readRewardTokens() external view returns (PairTokens memory);
}

File 5 of 18 : 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 6 of 18 : 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 7 of 18 : 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 8 of 18 : TokenUtilsLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

library TokenUtils {
    using SafeERC20 for IERC20;

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        token.safeTransfer(to, value);
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        token.safeTransferFrom(from, to, value);
    }

    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        token.approve(spender, 0);
        token.approve(spender, value);
    }
}

File 9 of 18 : PendleSimpleERC20TokenHolder.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

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

contract PendleSimpleERC20TokenHolder {
    using TokenUtils for IERC20;

    constructor(address[] memory tokens, address spender) {
        for (uint256 i = 0; i < tokens.length; i++) {
            if (tokens[i] == address(0)) continue;
            IERC20(tokens[i]).safeApprove(spender, type(uint256).max);
        }
    }

    receive() external payable {
        revert("ETH_NOT_ALLOWED");
    }
}

File 10 of 18 : 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 11 of 18 : 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 12 of 18 : 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 13 of 18 : 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 14 of 18 : 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 15 of 18 : 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 16 of 18 : 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);
}

File 17 of 18 : PairTokensLib.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;

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

struct PairUints {
    uint256 uintA;
    uint256 uintB;
}

struct PairTokens {
    address tokenA;
    address tokenB;
}

struct PairTokenUints {
    PairTokens tokens;
    PairUints uints;
}

library PairTokensLib {
    using SafeMath for uint256;
    using Math for uint256;
    using TokenUtils for IERC20;

    address internal constant ZERO = address(0);

    function verify(PairTokens memory a) internal pure {
        if (a.tokenA != ZERO) require(a.tokenA != a.tokenB, "DUPLICATED_TOKENS");
    }

    function safeTransferFrom(
        PairTokens memory tokens,
        address from,
        address to,
        PairUints memory amounts
    ) internal {
        if (tokens.tokenA != ZERO && amounts.uintA != 0)
            IERC20(tokens.tokenA).safeTransferFrom(from, to, amounts.uintA);
        if (tokens.tokenB != ZERO && amounts.uintB != 0)
            IERC20(tokens.tokenB).safeTransferFrom(from, to, amounts.uintB);
    }

    function safeTransfer(
        PairTokens memory tokens,
        address to,
        PairUints memory amounts
    ) internal {
        if (tokens.tokenA != ZERO && amounts.uintA != 0)
            IERC20(tokens.tokenA).safeTransfer(to, amounts.uintA);
        if (tokens.tokenB != ZERO && amounts.uintB != 0)
            IERC20(tokens.tokenB).safeTransfer(to, amounts.uintB);
    }

    function infinityApprove(PairTokens memory tokens, address to) internal {
        if (tokens.tokenA != ZERO) IERC20(tokens.tokenA).safeApprove(to, type(uint256).max);
        if (tokens.tokenB != ZERO) IERC20(tokens.tokenB).safeApprove(to, type(uint256).max);
    }

    function allowance(PairTokens memory tokens, address spender)
        internal
        view
        returns (PairUints memory res)
    {
        if (tokens.tokenA != ZERO)
            res.uintA = IERC20(tokens.tokenA).allowance(address(this), spender);
        if (tokens.tokenB != ZERO)
            res.uintB = IERC20(tokens.tokenB).allowance(address(this), spender);
    }

    function balanceOf(PairTokens memory tokens, address account)
        internal
        view
        returns (PairUints memory balances)
    {
        if (tokens.tokenA != ZERO) balances.uintA = IERC20(tokens.tokenA).balanceOf(account);
        if (tokens.tokenB != ZERO) balances.uintB = IERC20(tokens.tokenB).balanceOf(account);
    }

    function add(PairUints memory a, PairUints memory b)
        internal
        pure
        returns (PairUints memory res)
    {
        res.uintA = a.uintA.add(b.uintA);
        res.uintB = a.uintB.add(b.uintB);
    }

    function sub(PairUints memory a, PairUints memory b)
        internal
        pure
        returns (PairUints memory res)
    {
        res.uintA = a.uintA.sub(b.uintA);
        res.uintB = a.uintB.sub(b.uintB);
    }

    function eq(PairUints memory a, PairUints memory b) internal pure returns (bool) {
        return a.uintA == b.uintA && a.uintB == b.uintB;
    }

    function eq(PairTokens memory a, PairTokens memory b) internal pure returns (bool) {
        return a.tokenA == b.tokenA && a.tokenB == b.tokenB;
    }

    function min(PairUints memory a, PairUints memory b) internal pure returns (PairUints memory) {
        return PairUints(Math.min(a.uintA, b.uintA), Math.min(a.uintB, b.uintB));
    }

    function mul(PairUints memory a, uint256 b) internal pure returns (PairUints memory res) {
        res.uintA = a.uintA.mul(b);
        res.uintB = a.uintB.mul(b);
    }

    function div(PairUints memory a, uint256 b) internal pure returns (PairUints memory res) {
        res.uintA = a.uintA.div(b);
        res.uintB = a.uintB.div(b);
    }

    function allZero(PairUints memory a) internal pure returns (bool) {
        return a.uintA == 0 && a.uintB == 0;
    }

    function allZero(PairTokens memory a) internal pure returns (bool) {
        return a.tokenA == ZERO && a.tokenB == ZERO;
    }

    function contains(PairTokens memory tokens, address _token) internal pure returns (bool) {
        if (_token == ZERO) return false;
        return (_token == tokens.tokenA || _token == tokens.tokenB);
    }

    function toArr(PairTokens memory tokens) internal pure returns (address[] memory res) {
        res = new address[](2);
        res[0] = tokens.tokenA;
        res[1] = tokens.tokenB;
    }

    function add(PairTokenUints memory a, PairTokenUints memory b)
        internal
        pure
        returns (PairTokenUints memory res)
    {
        require(eq(a.tokens, b.tokens), "PAIR_MISMATCH");
        res.tokens = a.tokens;
        res.uints = add(a.uints, b.uints);
    }

    function mul(PairTokenUints memory a, uint256 b)
        internal
        pure
        returns (PairTokenUints memory res)
    {
        res.tokens = a.tokens;
        res.uints = mul(a.uints, b);
    }

    function div(PairTokenUints memory a, uint256 b)
        internal
        pure
        returns (PairTokenUints memory res)
    {
        res.tokens = a.tokens;
        res.uints = div(a.uints, b);
    }
}

File 18 of 18 : IWETH.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;

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

interface IWETH is IERC20 {
    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"components":[{"internalType":"address","name":"governanceManager","type":"address"},{"internalType":"address","name":"pausingManager","type":"address"},{"internalType":"address","name":"whitelist","type":"address"},{"components":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"internalType":"struct PairTokens","name":"rewardTokens","type":"tuple"},{"internalType":"address","name":"stakeToken","type":"address"},{"components":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"internalType":"struct PairTokens","name":"yieldTokens","type":"tuple"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"epochDuration","type":"uint256"},{"internalType":"uint256","name":"vestingEpochs","type":"uint256"},{"internalType":"contract IWETH","name":"weth","type":"address"}],"internalType":"struct PendleLiquidityMiningBaseV2Multi.ConstructorArgs","name":"args","type":"tuple"}],"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":[{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"indexed":false,"internalType":"struct PairUints[]","name":"rewards","type":"tuple[]"},{"indexed":false,"internalType":"uint256","name":"numberOfEpochs","type":"uint256"}],"name":"Funded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"indexed":false,"internalType":"struct PairUints","name":"amount","type":"tuple"}],"name":"PendleRewardsSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"epochIds","type":"uint256[]"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"indexed":false,"internalType":"struct PairUints[]","name":"rewards","type":"tuple[]"}],"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":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints[]","name":"rewards","type":"tuple[]"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentEpochId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastParamL","outputs":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","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":"numberOfEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paramL","outputs":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pausingManager","outputs":[{"internalType":"contract IPendlePausingManager","name":"","type":"address"}],"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"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"totalRewards","type":"tuple"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"stakeUnitsForUser","type":"uint256"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"availableRewardsForUser","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"readRewardTokens","outputs":[{"components":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"internalType":"struct PairTokens","name":"tokens","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"readYieldTokens","outputs":[{"components":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"internalType":"struct PairTokens","name":"tokens","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemDueInterests","outputs":[{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"amountOut","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemRewards","outputs":[{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"rewards","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardTokens","outputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardTokensHolder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"bool","name":"","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[]"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints[]","name":"rewards","type":"tuple[]"}],"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"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"totalRewards","type":"tuple"},{"internalType":"uint256","name":"lastUpdated","type":"uint256"},{"internalType":"uint256","name":"stakeUnitsForUser","type":"uint256"},{"components":[{"internalType":"uint256","name":"uintA","type":"uint256"},{"internalType":"uint256","name":"uintB","type":"uint256"}],"internalType":"struct PairUints","name":"availableRewardsForUser","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vestingEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"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":"yieldTokens","outputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"stateMutability":"view","type":"function"}]

6101a06040523480156200001257600080fd5b50604051620045b0380380620045b08339810160408190526200003591620003db565b80516001600160a01b03811662000082576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b60008054336001600160a01b031990911617905560601b6001600160601b0319166080526001805560c08101514210620000d95760405162461bcd60e51b8152600401620000d09062000505565b60405180910390fd5b600081610100015111620001015760405162461bcd60e51b8152600401620000d09062000531565b6200011b81606001516200027c60201b62001a561760201c565b620001358160a001516200027c60201b62001a561760201c565b610120810151606090811b6001600160601b031990811660e0908152602080850151841b831660c0908152604080870151861b851660a090815286880180518051600880546001600160a01b03199081166001600160a01b03938416179091559187015160098054841691831691909117905560808b015190991b909716610100908152918901518051600a80548a16918b16919091179055850151600b805490981698169790971790955590860151610140529185015161016052918401516101805280518082019091526001808252908201819052601081905560115590516200022a91620002cd811b62001aa317901c565b30604051620002399062000358565b62000246929190620004a6565b604051809103906000f08015801562000263573d6000803e3d6000fd5b5060601b6001600160601b0319166101205250620005cd565b80516001600160a01b031615620002ca5780602001516001600160a01b031681600001516001600160a01b03161415620002ca5760405162461bcd60e51b8152600401620000d09062000568565b50565b60408051600280825260608083018452926020830190803683370190505090508160000151816000815181106200030057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508160200151816001815181106200033357fe5b60200260200101906001600160a01b031690816001600160a01b031681525050919050565b6103ee80620041c283390190565b80516200037381620005b7565b919050565b6000604082840312156200038a578081fd5b604080519081016001600160401b0381118282101715620003a757fe5b80604052508091508251620003bc81620005b7565b81526020830151620003ce81620005b7565b6020919091015292915050565b60006101808284031215620003ee578081fd5b610140620003fc8162000593565b620004078462000366565b8152620004176020850162000366565b60208201526200042a6040850162000366565b60408201526200043e856060860162000378565b60608201526200045160a0850162000366565b6080820152620004658560c0860162000378565b60a08201526101008085015160c08301526101208086015160e0840152838601518284015262000499610160870162000366565b9083015250949350505050565b604080825283519082018190526000906020906060840190828701845b82811015620004ea5781516001600160a01b031684529284019290840190600101620004c3565b5050506001600160a01b039490941692019190915250919050565b602080825260129082015271494e56414c49445f53544152545f54494d4560701b604082015260600190565b60208082526016908201527f494e56414c49445f56455354494e475f45504f43485300000000000000000000604082015260600190565b6020808252601190820152704455504c4943415445445f544f4b454e5360781b604082015260600190565b6040518181016001600160401b0381118282101715620005af57fe5b604052919050565b6001600160a01b0381168114620002ca57600080fd5b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c610140516101605161018051613af9620006c9600039806110485280611c9c52806121fe52806128e252508061094f52806123ba5280612e035280612e58525080610ba3528061238252806123df5280612e2952508061075e5280610d8c5280610fdb5280611440528061178452508061097352806118155280611f845280612d965280612dd152508061092b5250806104c45280610a215280610c4152806111b7528061141c52806115f5528061169f52806118d6525080610db452806110fc5250806115b95280611d995250613af96000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c80638b0e9f3f11610125578063b3cccfe3116100ad578063c2b18aa01161007c578063c2b18aa014610401578063ce56c45414610409578063d2e6d1c31461041c578063dd254a6a14610424578063f3fef3a31461043757610211565b8063b3cccfe3146103d6578063b40310c9146103de578063be66c60f146103f1578063c1a4b33f146103f957610211565b806396b973c0116100f457806396b973c01461038d57806396eeffaa146103a05780639a51d2d1146103b3578063a29a839f146103bb578063adc9772e146103c357610211565b80638b0e9f3f146103625780638f373bf31461036a5780639262187b1461037257806393e59dc11461038557610211565b80633ccdbb28116101a8578063541a7ca611610177578063541a7ca6146103095780635ce58c89146103115780636304a6bc14610327578063738573f41461034757806378e979251461035a57610211565b80633ccdbb28146102d15780633fc8cef3146102e45780634ff0876a146102f957806351ed6a301461030157610211565b80631be03f0f116101e45780631be03f0f14610281578063248169fe1461029657806327e235e3146102ab5780632936ada7146102be57610211565b806304f917af14610216578063059f8b161461024357806316676632146102585780631736884114610279575b600080fd5b610229610224366004613609565b61044a565b60405161023a9594939291906139b8565b60405180910390f35b61024b6105e8565b60405161023a91906139af565b61026b61026636600461338a565b6105f5565b60405161023a9291906139ef565b61024b61060e565b61029461028f36600461344b565b610614565b005b61029e6107c6565b60405161023a919061397e565b61024b6102b936600461338a565b6107f5565b61024b6102cc36600461338a565b610807565b6102946102df366004613568565b610819565b6102ec610929565b60405161023a919061367c565b61024b61094d565b6102ec610971565b61026b610995565b61031961099e565b60405161023a9291906136a9565b61033a61033536600461338a565b6109b4565b60405161023a91906139a1565b61024b61035536600461338a565b610b8f565b61024b610ba1565b61024b610bc5565b61026b610bcb565b61033a61038036600461338a565b610bd4565b6102ec610db2565b61026b61039b36600461338a565b610dd6565b6102946103ae36600461348b565b610def565b61024b611046565b61024b61106a565b6102946103d1366004613420565b61107a565b61029e611361565b6102296103ec366004613609565b611390565b6102ec61141a565b6102ec61143e565b610319611462565b610294610417366004613609565b611478565b6102ec6115b7565b6102946104323660046133e8565b6115db565b610294610445366004613420565b611871565b600061045461330f565b60008061045f61330f565b600260015414156104a5576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c1906104f990309060040161367c565b6040805180830381600087803b15801561051257600080fd5b505af1158015610526573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054a919061353a565b50905080156105745760405162461bcd60e51b815260040161056b906138da565b60405180910390fd5b6000600254116105965760405162461bcd60e51b815260040161056b9061392f565b60006105a061106a565b116105bd5760405162461bcd60e51b815260040161056b906138b5565b6105c687611b2c565b6105d08888611390565b60018055939c929b5090995097509095509350505050565b68056bc75e2d6310000081565b600d602052600090815260409020805460019091015482565b60025481565b61061c611d95565b6001600160a01b0316336001600160a01b031614610673576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60025461067e61106a565b111561069c5760405162461bcd60e51b815260040161056b906137ab565b806106a561330f565b60005b82811015610723576106dc8585838181106106bf57fe5b9050604002018036038101906106d591906135a9565b8390611e21565b91508484828181106106ea57fe5b9050604002016004600083600254016001018152602001908152602001600020600101818161071991906139fd565b50506001016106a8565b506002546107319083611e56565b600255604080518082019091526008546001600160a01b03908116825260095416602082015261078390337f000000000000000000000000000000000000000000000000000000000000000084611eb9565b7f2a8c58d10abc188dedbf373509adf27a451db729e76176e6aba0dea783889e4184846002546040516107b8939291906136e0565b60405180910390a150505050565b6107ce613329565b50604080518082019091526008546001600160a01b03908116825260095416602082015290565b60056020526000908152604090205481565b60076020526000908152604090205481565b610821611d95565b6001600160a01b0316336001600160a01b031614610878576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b61088183611f40565b6108c6576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b6108da6001600160a01b0384168284611fea565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60105460115482565b600a54600b546001600160a01b03918216911682565b6109bc61330f565b60026001541415610a02576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c190610a5690309060040161367c565b6040805180830381600087803b158015610a6f57600080fd5b505af1158015610a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa7919061353a565b5090508015610ac85760405162461bcd60e51b815260040161056b906138da565b600060025411610aea5760405162461bcd60e51b815260040161056b9061392f565b6000610af461106a565b11610b115760405162461bcd60e51b815260040161056b906138b5565b60408051808201909152600a546001600160a01b039081168252600b54166020820152610b3d90612041565b15610b4757610b85565b6001600160a01b038316610b6d5760405162461bcd60e51b815260040161056b906137d4565b610b768361206d565b9150610b82838361216d565b91505b5060018055919050565b60066020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b600e54600f5482565b610bdc61330f565b60026001541415610c22576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c190610c7690309060040161367c565b6040805180830381600087803b158015610c8f57600080fd5b505af1158015610ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc7919061353a565b5090508015610ce85760405162461bcd60e51b815260040161056b906138da565b600060025411610d0a5760405162461bcd60e51b815260040161056b9061392f565b6000610d1461106a565b11610d315760405162461bcd60e51b815260040161056b906138b5565b6001600160a01b038316610d575760405162461bcd60e51b815260040161056b906137d4565b610d60836121de565b604080518082019091526008546001600160a01b039081168252600954166020820152909250610b85907f00000000000000000000000000000000000000000000000000000000000000008585611eb9565b7f000000000000000000000000000000000000000000000000000000000000000081565b600c602052600090815260409020805460019091015482565b610df7611d95565b6001600160a01b0316336001600160a01b031614610e4e576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b828114610e6d5760405162461bcd60e51b815260040161056b9061375c565b6000610e7761106a565b600254909150610e8561330f565b60005b86811015610fb057878782818110610e9c57fe5b9050602002013584108015610ec3575082888883818110610eb957fe5b9050602002013511155b610edf5760405162461bcd60e51b815260040161056b90613905565b610eee8686838181106106bf57fe5b9150610f6a868683818110610eff57fe5b905060400201803603810190610f1591906135a9565b600460008b8b86818110610f2557fe5b90506020020135815260200190815260200160002060010160405180604001604052908160008201548152602001600182015481525050611e2190919063ffffffff16565b600460008a8a85818110610f7a57fe5b60209081029290920135835250818101929092526040016000208251600180830191909155929091015160029091015501610e88565b50604080518082019091526008546001600160a01b03908116825260095416602082015261100090337f000000000000000000000000000000000000000000000000000000000000000084611eb9565b7f0bb3e533df8edd2ab3c21173cdac3dffecef1b8ba101783a6e7b2220dc52e8d6878787876040516110359493929190613704565b60405180910390a150505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006110754261237e565b905090565b600260015414156110c0576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b600260015560006110d03361240f565b1580156110dc57503233145b905080806111815750604051636c9b2a3f60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d936547e9061113190339060040161367c565b60206040518083038186803b15801561114957600080fd5b505afa15801561115d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611181919061351e565b61119d5760405162461bcd60e51b815260040161056b90613859565b604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c1906111ec90309060040161367c565b6040805180830381600087803b15801561120557600080fd5b505af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d919061353a565b509050801561125e5760405162461bcd60e51b815260040161056b906138da565b6000600254116112805760405162461bcd60e51b815260040161056b9061392f565b600061128a61106a565b116112a75760405162461bcd60e51b815260040161056b906138b5565b6001600160a01b0384166112cd5760405162461bcd60e51b815260040161056b906137d4565b826112ea5760405162461bcd60e51b815260040161056b90613890565b6002546112f561106a565b11156113135760405162461bcd60e51b815260040161056b906137fa565b61131e843385612415565b7f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d848460405161134f929190613690565b60405180910390a15050600180555050565b611369613329565b5060408051808201909152600a546001600160a01b039081168252600b5416602082015290565b600061139a61330f565b6000806113a561330f565b50505060009384525050600460208181526040808520805482518084018452600180840154825260028401548287015260038401546001600160a01b03909816808a52968401865284892054968952600590930185529683902083518085019094528054845290910154928201929092529094565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6008546009546001600160a01b03918216911682565b611480611d95565b6001600160a01b0316336001600160a01b0316146114d7576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d8060008114611522576040519150601f19603f3d011682016040523d82523d6000602084013e611527565b606091505b505090508061156f576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c19061162a90309060040161367c565b6040805180830381600087803b15801561164357600080fd5b505af1158015611657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167b919061353a565b9150508061169b5760405162461bcd60e51b815260040161056b90613784565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f87c24cd6040518163ffffffff1660e01b815260040160606040518083038186803b1580156116f657600080fd5b505afa15801561170a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172e91906133a6565b5090915050336001600160a01b0382161461175b5760405162461bcd60e51b815260040161056b9061382a565b604080518082019091526008546001600160a01b0390811682526009541660208201526117db907f00000000000000000000000000000000000000000000000000000000000000009030906117b0908361247d565b604080518082019091526008546001600160a01b039081168252600954166020820152929190611eb9565b604080518082019091526008546001600160a01b03908116825260095416602082015261180890856125aa565b61183e6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685600019612604565b60408051808201909152600a546001600160a01b039081168252600b5416602082015261186b90856125aa565b50505050565b600260015414156118b7576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636f11e6c19061190b90309060040161367c565b6040805180830381600087803b15801561192457600080fd5b505af1158015611938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195c919061353a565b509050801561197d5760405162461bcd60e51b815260040161056b906138da565b60006002541161199f5760405162461bcd60e51b815260040161056b9061392f565b60006119a961106a565b116119c65760405162461bcd60e51b815260040161056b906138b5565b816119e35760405162461bcd60e51b815260040161056b90613890565b6001600160a01b038316611a095760405162461bcd60e51b815260040161056b906137d4565b611a1433848461270c565b7f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d53383604051611a45929190613690565b60405180910390a150506001805550565b80516001600160a01b031615611aa05780602001516001600160a01b031681600001516001600160a01b03161415611aa05760405162461bcd60e51b815260040161056b90613953565b50565b6040805160028082526060808301845292602083019080368337019050509050816000015181600081518110611ad557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050816020015181600181518110611b0757fe5b60200260200101906001600160a01b031690816001600160a01b031681525050919050565b611b34612774565b6001600160a01b038116600090815260066020526040902054611b71576001600160a01b0381166000908152600660205260409020429055611aa0565b6000611b7b61106a565b90506000611b8b60025483612821565b6002546001600160a01b038516600090815260056020908152604080832054600690925282205460035494955092861193909291611bc88361237e565b9050805b868111611d6f57600081815260046020526040902054611bf55782611bf057611d6f565b611d67565b611c4b611c03868684612837565b6004600084815260200190815260200160002060040160008c6001600160a01b03166001600160a01b0316815260200190815260200160002054611e5690919063ffffffff16565b60008281526004602081815260408084206001600160a01b038f16855290920190529020558681148015611c7d575085155b15611c8757611d6f565b6000611c938a8361288b565b9050600182015b7f000000000000000000000000000000000000000000000000000000000000000083018111611d645760008181526004602090815260408083206001600160a01b038f1684526005018252918290208251808401909352805483526001015490820152611d079083611e21565b6004600083815260200190815260200160002060050160008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000155602082015181600101559050508080600101915050611c9a565b50505b600101611bcc565b5050506001600160a01b0386166000908152600660205260409020429055505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611df057600080fd5b505afa158015611e04573d6000803e3d6000fd5b505050506040513d6020811015611e1a57600080fd5b5051905090565b611e2961330f565b81518351611e3691611e56565b815260208083015190840151611e4b91611e56565b602082015292915050565b600082820183811015611eb0576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b83516001600160a01b031615801590611ed25750805115155b15611ef45780518451611ef4916001600160a01b039091169085908590612916565b60208401516001600160a01b031615801590611f135750602081015115155b1561186b5761186b8383836020015187602001516001600160a01b0316612916909392919063ffffffff16565b604080518082019091526008546001600160a01b039081168252600954166020820152600090611f70908361292b565b158015611faf5750816001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031614155b8015611eb3575060408051808201909152600a546001600160a01b039081168252600b54166020820152611fe3908361292b565b1592915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261203c908490612971565b505050565b80516000906001600160a01b0316158015611eb357505060208101516001600160a01b0316155b919050565b61207561330f565b60408051808201909152600a546001600160a01b039081168252600b541660208201526120a190612041565b156120ab57612068565b6120b482612a22565b604080518082018252600e548152600f546020808301919091526001600160a01b0385166000908152600c825283902083518085019094528054845260010154908301526121029190612bbd565b604080518082018252600080825260208083018281526001600160a01b0388168352600c8252918490209251835590516001909201919091558151808301909252600e548252600f549082015290915061215c9082612c02565b8051600e5560200151600f55919050565b61217561330f565b60408051808201909152600a546001600160a01b039081168252600b541660208201526121ad906121a6903061247d565b8390612bbd565b60408051808201909152600a546001600160a01b039081168252600b54166020820152909150611eb3908483612c2c565b6121e661330f565b6121ef82611b2c565b60006122266121fc61106a565b7f000000000000000000000000000000000000000000000000000000000000000060025401612821565b6001600160a01b0384166000908152600760205260409020549091505b8181116123225760008181526004602090815260408083206001600160a01b0388168452600501825291829020825180840190935280548352600101549082015261228d90612caf565b61231a5760008181526004602090815260408083206001600160a01b038816845260050182529182902082518084019093528054835260010154908201526122d6908490611e21565b60408051808201825260008082526020808301828152868352600482528483206001600160a01b038b16845260050190915292902090518155905160019091015592505b600101612243565b506001600160a01b03831660009081526007602052604090819020829055517f04e98a5a05a405118338cc7a2a3473388ea422bee4f982d332f92effbe2cbafc9061237090859085906136c3565b60405180910390a150919050565b60007f00000000000000000000000000000000000000000000000000000000000000008210156123b057506000612068565b611eb360016124097f0000000000000000000000000000000000000000000000000000000000000000612403867f0000000000000000000000000000000000000000000000000000000000000000612cc5565b90612d22565b90611e56565b3b151590565b61241e83611b2c565b61242783612a22565b6001600160a01b03831660009081526005602052604090205461244a9082611e56565b6001600160a01b0384166000908152600560205260409020556003546124709082611e56565b60035561203c8282612d89565b61248561330f565b82516001600160a01b0316156125175782516040516370a0823160e01b81526001600160a01b03909116906370a08231906124c490859060040161367c565b60206040518083038186803b1580156124dc57600080fd5b505afa1580156124f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251491906135f1565b81525b60208301516001600160a01b031615611eb35782602001516001600160a01b03166370a08231836040518263ffffffff1660e01b815260040161255a919061367c565b60206040518083038186803b15801561257257600080fd5b505afa158015612586573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4b91906135f1565b81516001600160a01b0316156125d25781516125d2906001600160a01b031682600019612604565b60208201516001600160a01b031615612600576020820151612600906001600160a01b031682600019612604565b5050565b826001600160a01b031663095ea7b38360006040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561265c57600080fd5b505af1158015612670573d6000803e3d6000fd5b505050506040513d602081101561268657600080fd5b50506040805163095ea7b360e01b81526001600160a01b0384811660048301526024820184905291519185169163095ea7b3916044808201926020929091908290030181600087803b1580156126db57600080fd5b505af11580156126ef573d6000803e3d6000fd5b505050506040513d602081101561270557600080fd5b5050505050565b61271583611b2c565b61271e83612a22565b6001600160a01b0383166000908152600560205260409020546127419082612cc5565b6001600160a01b0384166000908152600560205260409020556003546127679082612cc5565b60035561203c8282612dbe565b600061277e61106a565b9050600061278e82600254612821565b90505b80156126005760006127a282612df8565b600083815260046020526040902060030154909150808214156127c6575050612600565b6127eb6127d66003548386612837565b60008581526004602052604090205490611e56565b6000848152600460205260409020556128044283612821565b600084815260046020526040902060030155505060001901612791565b60008183106128305781611eb0565b5090919050565b6000428161284d8561284886612e4e565b612e88565b905060006128638361285e87612df8565b612821565b905060006128718284612e98565b905061287d8882612ea9565b9450505050505b9392505050565b61289361330f565b600082815260046020818152604080842080546001600160a01b0389168652818501845282862054958890529383528151808301909252600181015482526002015491810191909152611eb0927f000000000000000000000000000000000000000000000000000000000000000092612910929091839190612f02565b90612f27565b61186b6001600160a01b038516848484612f4c565b60006001600160a01b03821661294357506000611eb3565b82516001600160a01b0383811691161480611eb05750506020909101516001600160a01b0391821691161490565b60006129c6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fa69092919063ffffffff16565b80519091501561203c578080602001905160208110156129e557600080fd5b505161203c5760405162461bcd60e51b815260040180806020018281038252602a815260200180613a9a602a913960400191505060405180910390fd5b60408051808201909152600a546001600160a01b039081168252600b54166020820152612a4e90612041565b15612a5857611aa0565b612a60612fbd565b6001600160a01b0381166000908152600d60209081526040918290208251808401909352805483526001015490820152612a9990612caf565b15612ac9576001600160a01b0381166000908152600d602052604090206010548155601154600190910155611aa0565b6001600160a01b038116600090815260056020908152604080832054600d835281842082518084018452815481526001909101548185015282518084019093526010548352601154938301939093529291612b249190612c02565b90506000612b3f68056bc75e2d631000006129108486612f02565b6001600160a01b0385166000908152600c60209081526040918290208251808401909352805483526001015490820152909150612b7c9082611e21565b6001600160a01b0385166000908152600c602090815260408083208451815593820151600194850155600d9091529020601054815560115491015550505050565b612bc561330f565b6040518060400160405280612be285600001518560000151612821565b8152602001612bf985602001518560200151612821565b90529392505050565b612c0a61330f565b81518351612c1791612cc5565b815260208083015190840151611e4b91612cc5565b82516001600160a01b031615801590612c455750805115155b15612c655780518351612c65916001600160a01b039091169084906130a5565b60208301516001600160a01b031615801590612c845750602081015115155b1561203c5761203c82826020015185602001516001600160a01b03166130a59092919063ffffffff16565b8051600090158015611eb3575050602001511590565b600082821115612d1c576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000808211612d78576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381612d8157fe5b049392505050565b6126006001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016833084612916565b8015612600576126006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683836130a5565b6000611eb3612e27837f0000000000000000000000000000000000000000000000000000000000000000612ea9565b7f000000000000000000000000000000000000000000000000000000000000000090611e56565b6000611eb3612e277f0000000000000000000000000000000000000000000000000000000000000000612e82856001612cc5565b90612ea9565b6000818310156128305781611eb0565b600081831015612d1c576000611eb0565b600082612eb857506000611eb3565b82820282848281612ec557fe5b0414611eb05760405162461bcd60e51b8152600401808060200182810382526021815260200180613a796021913960400191505060405180910390fd5b612f0a61330f565b8251612f169083612ea9565b81526020830151611e4b9083612ea9565b612f2f61330f565b8251612f3b9083612d22565b81526020830151611e4b9083612d22565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261186b908590612971565b6060612fb584846000856130b9565b949350505050565b60408051808201909152600a546001600160a01b039081168252600b54166020820152612fe990612041565b80612ff95750612ff7613214565b155b15613003576130a3565b61300b6130a3565b60408051808201909152600a546001600160a01b039081168252600b5416602082015260009061303b903061247d565b905060008061304983613219565b9150915061305561330f565b6003541561307a57600354613077906129108468056bc75e2d63100000612f02565b90505b6130848382611e21565b80516010556020908101516011558451600e559390930151600f555050505b565b61203c6001600160a01b0384168383611fea565b6060824710156130fa5760405162461bcd60e51b8152600401808060200182810382526026815260200180613a536026913960400191505060405180910390fd5b6131038561240f565b613154576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106131925780518252601f199092019160209182019101613173565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146131f4576040519150601f19603f3d011682016040523d82523d6000602084013e6131f9565b606091505b509150915061320982828661326b565b979650505050505050565b600090565b61322161330f565b61322961330f565b60408051808201825260105481526011546020808301919091528251808401909352600e548352600f54908301529250613264908490612c02565b9050915091565b6060831561327a575081612884565b82511561328a5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156132d45781810151838201526020016132bc565b50505050905090810190601f1680156133015780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806040016040528060008152602001600081525090565b604080518082019091526000808252602082015290565b60008083601f840112613351578182fd5b50813567ffffffffffffffff811115613368578182fd5b60208301915083602060408302850101111561338357600080fd5b9250929050565b60006020828403121561339b578081fd5b8135611eb081613a0f565b6000806000606084860312156133ba578182fd5b83516133c581613a0f565b60208501519093506133d681613a0f565b80925050604084015190509250925092565b600080604083850312156133fa578182fd5b823561340581613a0f565b9150602083013561341581613a24565b809150509250929050565b60008060408385031215613432578182fd5b823561343d81613a0f565b946020939093013593505050565b6000806020838503121561345d578182fd5b823567ffffffffffffffff811115613473578283fd5b61347f85828601613340565b90969095509350505050565b600080600080604085870312156134a0578081fd5b843567ffffffffffffffff808211156134b7578283fd5b818701915087601f8301126134ca578283fd5b8135818111156134d8578384fd5b88602080830285010111156134eb578384fd5b602092830196509450908601359080821115613505578283fd5b5061351287828801613340565b95989497509550505050565b60006020828403121561352f578081fd5b8151611eb081613a24565b6000806040838503121561354c578182fd5b825161355781613a24565b602084015190925061341581613a24565b60008060006060848603121561357c578283fd5b833561358781613a0f565b925060208401359150604084013561359e81613a0f565b809150509250925092565b6000604082840312156135ba578081fd5b6040516040810181811067ffffffffffffffff821117156135d757fe5b604052823581526020928301359281019290925250919050565b600060208284031215613602578081fd5b5051919050565b6000806040838503121561361b578182fd5b82359150602083013561341581613a0f565b60008284526020808501945082825b85811015613662578135875282820135838801526040968701969091019060010161363c565b509495945050505050565b80518252602090810151910152565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b038316815260608101612884602083018461366d565b6000604082526136f460408301858761362d565b9050826020830152949350505050565b6040808252810184905260006001600160fb1b03851115613723578081fd5b6020850280876060850137808301905060608101828152606084830301602085015261375081868861362d565b98975050505050505050565b6020808252600e908201526d494e56414c49445f41525241595360901b604082015260600190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252600f908201526e2620a9aa2fa2a827a1a42fa7ab22a960891b604082015260600190565b6020808252600c908201526b5a45524f5f4144445245535360a01b604082015260600190565b60208082526016908201527524a721a2a72a24ab22a9afa822a924a7a22fa7ab22a960511b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b60208082526018908201527f434f4e54524143545f4e4f545f57484954454c49535445440000000000000000604082015260600190565b6020808252600b908201526a16915493d7d05353d5539560aa1b604082015260600190565b6020808252600b908201526a1393d517d4d5105495115160aa1b604082015260600190565b60208082526011908201527013125457d35253925391d7d4105554d151607a1b604082015260600190565b60208082526010908201526f1253959053125117d15413d0d217d25160821b604082015260600190565b6020808252600a90820152691393d517d1955391115160b21b604082015260600190565b6020808252601190820152704455504c4943415445445f544f4b454e5360781b604082015260600190565b81516001600160a01b039081168252602092830151169181019190915260400190565b60408101611eb3828461366d565b90815260200190565b85815260e081016139cc602083018761366d565b8460608301528360808301526139e560a083018461366d565b9695505050505050565b918252602082015260400190565b81358155602082013560018201555050565b6001600160a01b0381168114611aa057600080fd5b8015158114611aa057600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220e25ccd78e12ab0c9bd7f682869d2b8e73039ad4456e2efc67b52a7acba4ce67664736f6c63430007060033608060405234801561001057600080fd5b506040516103ee3803806103ee8339818101604052604081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825186602082028301116401000000008211171561008557600080fd5b82525081516020918201928201910280838360005b838110156100b257818101518382015260200161009a565b505050509190910160405250602001519150600090505b82518110156101445760006001600160a01b03168382815181106100e957fe5b60200260200101516001600160a01b031614156101055761013c565b61013c8260001985848151811061011857fe5b60200260200101516001600160a01b031661014c60201b61004d179092919060201c565b6001016100c9565b505050610254565b826001600160a01b031663095ea7b38360006040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156101a457600080fd5b505af11580156101b8573d6000803e3d6000fd5b505050506040513d60208110156101ce57600080fd5b50506040805163095ea7b360e01b81526001600160a01b0384811660048301526024820184905291519185169163095ea7b3916044808201926020929091908290030181600087803b15801561022357600080fd5b505af1158015610237573d6000803e3d6000fd5b505050506040513d602081101561024d57600080fd5b5050505050565b61018b806102636000396000f3fe608060405236610048576040805162461bcd60e51b815260206004820152600f60248201526e11551217d393d517d0531313d5d151608a1b604482015290519081900360640190fd5b600080fd5b826001600160a01b031663095ea7b38360006040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156100a557600080fd5b505af11580156100b9573d6000803e3d6000fd5b505050506040513d60208110156100cf57600080fd5b50506040805163095ea7b360e01b81526001600160a01b0384811660048301526024820184905291519185169163095ea7b3916044808201926020929091908290030181600087803b15801561012457600080fd5b505af1158015610138573d6000803e3d6000fd5b505050506040513d602081101561014e57600080fd5b505050505056fea26469706673582212200276b7673b55263f7651ce2e55066ab6bd5906cd258deabd06bc2bbb99ec3e4764736f6c634300070600330000000000000000000000009e8b9ec2454bcab6128231d9fd405e864acd3cf9000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab34000000000000000000000000d5889758bb9a661482f9e2cced35ce1057081e64000000000000000000000000fb98b335551a418cd0737375a2ea0ded62ea213b000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000082922e6fbe83547c5e2e0229815942a2108e46240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000618d05c00000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000005000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102115760003560e01c80638b0e9f3f11610125578063b3cccfe3116100ad578063c2b18aa01161007c578063c2b18aa014610401578063ce56c45414610409578063d2e6d1c31461041c578063dd254a6a14610424578063f3fef3a31461043757610211565b8063b3cccfe3146103d6578063b40310c9146103de578063be66c60f146103f1578063c1a4b33f146103f957610211565b806396b973c0116100f457806396b973c01461038d57806396eeffaa146103a05780639a51d2d1146103b3578063a29a839f146103bb578063adc9772e146103c357610211565b80638b0e9f3f146103625780638f373bf31461036a5780639262187b1461037257806393e59dc11461038557610211565b80633ccdbb28116101a8578063541a7ca611610177578063541a7ca6146103095780635ce58c89146103115780636304a6bc14610327578063738573f41461034757806378e979251461035a57610211565b80633ccdbb28146102d15780633fc8cef3146102e45780634ff0876a146102f957806351ed6a301461030157610211565b80631be03f0f116101e45780631be03f0f14610281578063248169fe1461029657806327e235e3146102ab5780632936ada7146102be57610211565b806304f917af14610216578063059f8b161461024357806316676632146102585780631736884114610279575b600080fd5b610229610224366004613609565b61044a565b60405161023a9594939291906139b8565b60405180910390f35b61024b6105e8565b60405161023a91906139af565b61026b61026636600461338a565b6105f5565b60405161023a9291906139ef565b61024b61060e565b61029461028f36600461344b565b610614565b005b61029e6107c6565b60405161023a919061397e565b61024b6102b936600461338a565b6107f5565b61024b6102cc36600461338a565b610807565b6102946102df366004613568565b610819565b6102ec610929565b60405161023a919061367c565b61024b61094d565b6102ec610971565b61026b610995565b61031961099e565b60405161023a9291906136a9565b61033a61033536600461338a565b6109b4565b60405161023a91906139a1565b61024b61035536600461338a565b610b8f565b61024b610ba1565b61024b610bc5565b61026b610bcb565b61033a61038036600461338a565b610bd4565b6102ec610db2565b61026b61039b36600461338a565b610dd6565b6102946103ae36600461348b565b610def565b61024b611046565b61024b61106a565b6102946103d1366004613420565b61107a565b61029e611361565b6102296103ec366004613609565b611390565b6102ec61141a565b6102ec61143e565b610319611462565b610294610417366004613609565b611478565b6102ec6115b7565b6102946104323660046133e8565b6115db565b610294610445366004613420565b611871565b600061045461330f565b60008061045f61330f565b600260015414156104a5576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c1906104f990309060040161367c565b6040805180830381600087803b15801561051257600080fd5b505af1158015610526573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054a919061353a565b50905080156105745760405162461bcd60e51b815260040161056b906138da565b60405180910390fd5b6000600254116105965760405162461bcd60e51b815260040161056b9061392f565b60006105a061106a565b116105bd5760405162461bcd60e51b815260040161056b906138b5565b6105c687611b2c565b6105d08888611390565b60018055939c929b5090995097509095509350505050565b68056bc75e2d6310000081565b600d602052600090815260409020805460019091015482565b60025481565b61061c611d95565b6001600160a01b0316336001600160a01b031614610673576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60025461067e61106a565b111561069c5760405162461bcd60e51b815260040161056b906137ab565b806106a561330f565b60005b82811015610723576106dc8585838181106106bf57fe5b9050604002018036038101906106d591906135a9565b8390611e21565b91508484828181106106ea57fe5b9050604002016004600083600254016001018152602001908152602001600020600101818161071991906139fd565b50506001016106a8565b506002546107319083611e56565b600255604080518082019091526008546001600160a01b03908116825260095416602082015261078390337f00000000000000000000000080228b1c8799efa30f99f4a6fdfd2b2652b86e3084611eb9565b7f2a8c58d10abc188dedbf373509adf27a451db729e76176e6aba0dea783889e4184846002546040516107b8939291906136e0565b60405180910390a150505050565b6107ce613329565b50604080518082019091526008546001600160a01b03908116825260095416602082015290565b60056020526000908152604090205481565b60076020526000908152604090205481565b610821611d95565b6001600160a01b0316336001600160a01b031614610878576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b61088183611f40565b6108c6576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b6108da6001600160a01b0384168284611fea565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b7f000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c781565b7f0000000000000000000000000000000000000000000000000000000000093a8081565b7f00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e462481565b60105460115482565b600a54600b546001600160a01b03918216911682565b6109bc61330f565b60026001541415610a02576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c190610a5690309060040161367c565b6040805180830381600087803b158015610a6f57600080fd5b505af1158015610a83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa7919061353a565b5090508015610ac85760405162461bcd60e51b815260040161056b906138da565b600060025411610aea5760405162461bcd60e51b815260040161056b9061392f565b6000610af461106a565b11610b115760405162461bcd60e51b815260040161056b906138b5565b60408051808201909152600a546001600160a01b039081168252600b54166020820152610b3d90612041565b15610b4757610b85565b6001600160a01b038316610b6d5760405162461bcd60e51b815260040161056b906137d4565b610b768361206d565b9150610b82838361216d565b91505b5060018055919050565b60066020526000908152604090205481565b7f00000000000000000000000000000000000000000000000000000000618d05c081565b60035481565b600e54600f5482565b610bdc61330f565b60026001541415610c22576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c190610c7690309060040161367c565b6040805180830381600087803b158015610c8f57600080fd5b505af1158015610ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc7919061353a565b5090508015610ce85760405162461bcd60e51b815260040161056b906138da565b600060025411610d0a5760405162461bcd60e51b815260040161056b9061392f565b6000610d1461106a565b11610d315760405162461bcd60e51b815260040161056b906138b5565b6001600160a01b038316610d575760405162461bcd60e51b815260040161056b906137d4565b610d60836121de565b604080518082019091526008546001600160a01b039081168252600954166020820152909250610b85907f00000000000000000000000080228b1c8799efa30f99f4a6fdfd2b2652b86e308585611eb9565b7f000000000000000000000000d5889758bb9a661482f9e2cced35ce1057081e6481565b600c602052600090815260409020805460019091015482565b610df7611d95565b6001600160a01b0316336001600160a01b031614610e4e576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b828114610e6d5760405162461bcd60e51b815260040161056b9061375c565b6000610e7761106a565b600254909150610e8561330f565b60005b86811015610fb057878782818110610e9c57fe5b9050602002013584108015610ec3575082888883818110610eb957fe5b9050602002013511155b610edf5760405162461bcd60e51b815260040161056b90613905565b610eee8686838181106106bf57fe5b9150610f6a868683818110610eff57fe5b905060400201803603810190610f1591906135a9565b600460008b8b86818110610f2557fe5b90506020020135815260200190815260200160002060010160405180604001604052908160008201548152602001600182015481525050611e2190919063ffffffff16565b600460008a8a85818110610f7a57fe5b60209081029290920135835250818101929092526040016000208251600180830191909155929091015160029091015501610e88565b50604080518082019091526008546001600160a01b03908116825260095416602082015261100090337f00000000000000000000000080228b1c8799efa30f99f4a6fdfd2b2652b86e3084611eb9565b7f0bb3e533df8edd2ab3c21173cdac3dffecef1b8ba101783a6e7b2220dc52e8d6878787876040516110359493929190613704565b60405180910390a150505050505050565b7f000000000000000000000000000000000000000000000000000000000000000581565b60006110754261237e565b905090565b600260015414156110c0576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b600260015560006110d03361240f565b1580156110dc57503233145b905080806111815750604051636c9b2a3f60e11b81526001600160a01b037f000000000000000000000000d5889758bb9a661482f9e2cced35ce1057081e64169063d936547e9061113190339060040161367c565b60206040518083038186803b15801561114957600080fd5b505afa15801561115d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611181919061351e565b61119d5760405162461bcd60e51b815260040161056b90613859565b604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c1906111ec90309060040161367c565b6040805180830381600087803b15801561120557600080fd5b505af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d919061353a565b509050801561125e5760405162461bcd60e51b815260040161056b906138da565b6000600254116112805760405162461bcd60e51b815260040161056b9061392f565b600061128a61106a565b116112a75760405162461bcd60e51b815260040161056b906138b5565b6001600160a01b0384166112cd5760405162461bcd60e51b815260040161056b906137d4565b826112ea5760405162461bcd60e51b815260040161056b90613890565b6002546112f561106a565b11156113135760405162461bcd60e51b815260040161056b906137fa565b61131e843385612415565b7f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d848460405161134f929190613690565b60405180910390a15050600180555050565b611369613329565b5060408051808201909152600a546001600160a01b039081168252600b5416602082015290565b600061139a61330f565b6000806113a561330f565b50505060009384525050600460208181526040808520805482518084018452600180840154825260028401548287015260038401546001600160a01b03909816808a52968401865284892054968952600590930185529683902083518085019094528054845290910154928201929092529094565b7f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab3481565b7f00000000000000000000000080228b1c8799efa30f99f4a6fdfd2b2652b86e3081565b6008546009546001600160a01b03918216911682565b611480611d95565b6001600160a01b0316336001600160a01b0316146114d7576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d8060008114611522576040519150601f19603f3d011682016040523d82523d6000602084013e611527565b606091505b505090508061156f576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b7f0000000000000000000000009e8b9ec2454bcab6128231d9fd405e864acd3cf981565b604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c19061162a90309060040161367c565b6040805180830381600087803b15801561164357600080fd5b505af1158015611657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167b919061353a565b9150508061169b5760405162461bcd60e51b815260040161056b90613784565b60007f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab346001600160a01b031663f87c24cd6040518163ffffffff1660e01b815260040160606040518083038186803b1580156116f657600080fd5b505afa15801561170a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172e91906133a6565b5090915050336001600160a01b0382161461175b5760405162461bcd60e51b815260040161056b9061382a565b604080518082019091526008546001600160a01b0390811682526009541660208201526117db907f00000000000000000000000080228b1c8799efa30f99f4a6fdfd2b2652b86e309030906117b0908361247d565b604080518082019091526008546001600160a01b039081168252600954166020820152929190611eb9565b604080518082019091526008546001600160a01b03908116825260095416602082015261180890856125aa565b61183e6001600160a01b037f00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e46241685600019612604565b60408051808201909152600a546001600160a01b039081168252600b5416602082015261186b90856125aa565b50505050565b600260015414156118b7576040805162461bcd60e51b815260206004820152601f6024820152600080516020613a33833981519152604482015290519081900360640190fd5b6002600155604051636f11e6c160e01b81526000906001600160a01b037f000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab341690636f11e6c19061190b90309060040161367c565b6040805180830381600087803b15801561192457600080fd5b505af1158015611938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195c919061353a565b509050801561197d5760405162461bcd60e51b815260040161056b906138da565b60006002541161199f5760405162461bcd60e51b815260040161056b9061392f565b60006119a961106a565b116119c65760405162461bcd60e51b815260040161056b906138b5565b816119e35760405162461bcd60e51b815260040161056b90613890565b6001600160a01b038316611a095760405162461bcd60e51b815260040161056b906137d4565b611a1433848461270c565b7f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d53383604051611a45929190613690565b60405180910390a150506001805550565b80516001600160a01b031615611aa05780602001516001600160a01b031681600001516001600160a01b03161415611aa05760405162461bcd60e51b815260040161056b90613953565b50565b6040805160028082526060808301845292602083019080368337019050509050816000015181600081518110611ad557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050816020015181600181518110611b0757fe5b60200260200101906001600160a01b031690816001600160a01b031681525050919050565b611b34612774565b6001600160a01b038116600090815260066020526040902054611b71576001600160a01b0381166000908152600660205260409020429055611aa0565b6000611b7b61106a565b90506000611b8b60025483612821565b6002546001600160a01b038516600090815260056020908152604080832054600690925282205460035494955092861193909291611bc88361237e565b9050805b868111611d6f57600081815260046020526040902054611bf55782611bf057611d6f565b611d67565b611c4b611c03868684612837565b6004600084815260200190815260200160002060040160008c6001600160a01b03166001600160a01b0316815260200190815260200160002054611e5690919063ffffffff16565b60008281526004602081815260408084206001600160a01b038f16855290920190529020558681148015611c7d575085155b15611c8757611d6f565b6000611c938a8361288b565b9050600182015b7f000000000000000000000000000000000000000000000000000000000000000583018111611d645760008181526004602090815260408083206001600160a01b038f1684526005018252918290208251808401909352805483526001015490820152611d079083611e21565b6004600083815260200190815260200160002060050160008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000155602082015181600101559050508080600101915050611c9a565b50505b600101611bcc565b5050506001600160a01b0386166000908152600660205260409020429055505050505050565b60007f0000000000000000000000009e8b9ec2454bcab6128231d9fd405e864acd3cf96001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611df057600080fd5b505afa158015611e04573d6000803e3d6000fd5b505050506040513d6020811015611e1a57600080fd5b5051905090565b611e2961330f565b81518351611e3691611e56565b815260208083015190840151611e4b91611e56565b602082015292915050565b600082820183811015611eb0576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b83516001600160a01b031615801590611ed25750805115155b15611ef45780518451611ef4916001600160a01b039091169085908590612916565b60208401516001600160a01b031615801590611f135750602081015115155b1561186b5761186b8383836020015187602001516001600160a01b0316612916909392919063ffffffff16565b604080518082019091526008546001600160a01b039081168252600954166020820152600090611f70908361292b565b158015611faf5750816001600160a01b03167f00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e46246001600160a01b031614155b8015611eb3575060408051808201909152600a546001600160a01b039081168252600b54166020820152611fe3908361292b565b1592915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261203c908490612971565b505050565b80516000906001600160a01b0316158015611eb357505060208101516001600160a01b0316155b919050565b61207561330f565b60408051808201909152600a546001600160a01b039081168252600b541660208201526120a190612041565b156120ab57612068565b6120b482612a22565b604080518082018252600e548152600f546020808301919091526001600160a01b0385166000908152600c825283902083518085019094528054845260010154908301526121029190612bbd565b604080518082018252600080825260208083018281526001600160a01b0388168352600c8252918490209251835590516001909201919091558151808301909252600e548252600f549082015290915061215c9082612c02565b8051600e5560200151600f55919050565b61217561330f565b60408051808201909152600a546001600160a01b039081168252600b541660208201526121ad906121a6903061247d565b8390612bbd565b60408051808201909152600a546001600160a01b039081168252600b54166020820152909150611eb3908483612c2c565b6121e661330f565b6121ef82611b2c565b60006122266121fc61106a565b7f000000000000000000000000000000000000000000000000000000000000000560025401612821565b6001600160a01b0384166000908152600760205260409020549091505b8181116123225760008181526004602090815260408083206001600160a01b0388168452600501825291829020825180840190935280548352600101549082015261228d90612caf565b61231a5760008181526004602090815260408083206001600160a01b038816845260050182529182902082518084019093528054835260010154908201526122d6908490611e21565b60408051808201825260008082526020808301828152868352600482528483206001600160a01b038b16845260050190915292902090518155905160019091015592505b600101612243565b506001600160a01b03831660009081526007602052604090819020829055517f04e98a5a05a405118338cc7a2a3473388ea422bee4f982d332f92effbe2cbafc9061237090859085906136c3565b60405180910390a150919050565b60007f00000000000000000000000000000000000000000000000000000000618d05c08210156123b057506000612068565b611eb360016124097f0000000000000000000000000000000000000000000000000000000000093a80612403867f00000000000000000000000000000000000000000000000000000000618d05c0612cc5565b90612d22565b90611e56565b3b151590565b61241e83611b2c565b61242783612a22565b6001600160a01b03831660009081526005602052604090205461244a9082611e56565b6001600160a01b0384166000908152600560205260409020556003546124709082611e56565b60035561203c8282612d89565b61248561330f565b82516001600160a01b0316156125175782516040516370a0823160e01b81526001600160a01b03909116906370a08231906124c490859060040161367c565b60206040518083038186803b1580156124dc57600080fd5b505afa1580156124f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251491906135f1565b81525b60208301516001600160a01b031615611eb35782602001516001600160a01b03166370a08231836040518263ffffffff1660e01b815260040161255a919061367c565b60206040518083038186803b15801561257257600080fd5b505afa158015612586573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4b91906135f1565b81516001600160a01b0316156125d25781516125d2906001600160a01b031682600019612604565b60208201516001600160a01b031615612600576020820151612600906001600160a01b031682600019612604565b5050565b826001600160a01b031663095ea7b38360006040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561265c57600080fd5b505af1158015612670573d6000803e3d6000fd5b505050506040513d602081101561268657600080fd5b50506040805163095ea7b360e01b81526001600160a01b0384811660048301526024820184905291519185169163095ea7b3916044808201926020929091908290030181600087803b1580156126db57600080fd5b505af11580156126ef573d6000803e3d6000fd5b505050506040513d602081101561270557600080fd5b5050505050565b61271583611b2c565b61271e83612a22565b6001600160a01b0383166000908152600560205260409020546127419082612cc5565b6001600160a01b0384166000908152600560205260409020556003546127679082612cc5565b60035561203c8282612dbe565b600061277e61106a565b9050600061278e82600254612821565b90505b80156126005760006127a282612df8565b600083815260046020526040902060030154909150808214156127c6575050612600565b6127eb6127d66003548386612837565b60008581526004602052604090205490611e56565b6000848152600460205260409020556128044283612821565b600084815260046020526040902060030155505060001901612791565b60008183106128305781611eb0565b5090919050565b6000428161284d8561284886612e4e565b612e88565b905060006128638361285e87612df8565b612821565b905060006128718284612e98565b905061287d8882612ea9565b9450505050505b9392505050565b61289361330f565b600082815260046020818152604080842080546001600160a01b0389168652818501845282862054958890529383528151808301909252600181015482526002015491810191909152611eb0927f000000000000000000000000000000000000000000000000000000000000000592612910929091839190612f02565b90612f27565b61186b6001600160a01b038516848484612f4c565b60006001600160a01b03821661294357506000611eb3565b82516001600160a01b0383811691161480611eb05750506020909101516001600160a01b0391821691161490565b60006129c6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fa69092919063ffffffff16565b80519091501561203c578080602001905160208110156129e557600080fd5b505161203c5760405162461bcd60e51b815260040180806020018281038252602a815260200180613a9a602a913960400191505060405180910390fd5b60408051808201909152600a546001600160a01b039081168252600b54166020820152612a4e90612041565b15612a5857611aa0565b612a60612fbd565b6001600160a01b0381166000908152600d60209081526040918290208251808401909352805483526001015490820152612a9990612caf565b15612ac9576001600160a01b0381166000908152600d602052604090206010548155601154600190910155611aa0565b6001600160a01b038116600090815260056020908152604080832054600d835281842082518084018452815481526001909101548185015282518084019093526010548352601154938301939093529291612b249190612c02565b90506000612b3f68056bc75e2d631000006129108486612f02565b6001600160a01b0385166000908152600c60209081526040918290208251808401909352805483526001015490820152909150612b7c9082611e21565b6001600160a01b0385166000908152600c602090815260408083208451815593820151600194850155600d9091529020601054815560115491015550505050565b612bc561330f565b6040518060400160405280612be285600001518560000151612821565b8152602001612bf985602001518560200151612821565b90529392505050565b612c0a61330f565b81518351612c1791612cc5565b815260208083015190840151611e4b91612cc5565b82516001600160a01b031615801590612c455750805115155b15612c655780518351612c65916001600160a01b039091169084906130a5565b60208301516001600160a01b031615801590612c845750602081015115155b1561203c5761203c82826020015185602001516001600160a01b03166130a59092919063ffffffff16565b8051600090158015611eb3575050602001511590565b600082821115612d1c576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000808211612d78576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381612d8157fe5b049392505050565b6126006001600160a01b037f00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e462416833084612916565b8015612600576126006001600160a01b037f00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e46241683836130a5565b6000611eb3612e27837f0000000000000000000000000000000000000000000000000000000000093a80612ea9565b7f00000000000000000000000000000000000000000000000000000000618d05c090611e56565b6000611eb3612e277f0000000000000000000000000000000000000000000000000000000000093a80612e82856001612cc5565b90612ea9565b6000818310156128305781611eb0565b600081831015612d1c576000611eb0565b600082612eb857506000611eb3565b82820282848281612ec557fe5b0414611eb05760405162461bcd60e51b8152600401808060200182810382526021815260200180613a796021913960400191505060405180910390fd5b612f0a61330f565b8251612f169083612ea9565b81526020830151611e4b9083612ea9565b612f2f61330f565b8251612f3b9083612d22565b81526020830151611e4b9083612d22565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261186b908590612971565b6060612fb584846000856130b9565b949350505050565b60408051808201909152600a546001600160a01b039081168252600b54166020820152612fe990612041565b80612ff95750612ff7613214565b155b15613003576130a3565b61300b6130a3565b60408051808201909152600a546001600160a01b039081168252600b5416602082015260009061303b903061247d565b905060008061304983613219565b9150915061305561330f565b6003541561307a57600354613077906129108468056bc75e2d63100000612f02565b90505b6130848382611e21565b80516010556020908101516011558451600e559390930151600f555050505b565b61203c6001600160a01b0384168383611fea565b6060824710156130fa5760405162461bcd60e51b8152600401808060200182810382526026815260200180613a536026913960400191505060405180910390fd5b6131038561240f565b613154576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106131925780518252601f199092019160209182019101613173565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146131f4576040519150601f19603f3d011682016040523d82523d6000602084013e6131f9565b606091505b509150915061320982828661326b565b979650505050505050565b600090565b61322161330f565b61322961330f565b60408051808201825260105481526011546020808301919091528251808401909352600e548352600f54908301529250613264908490612c02565b9050915091565b6060831561327a575081612884565b82511561328a5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156132d45781810151838201526020016132bc565b50505050905090810190601f1680156133015780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806040016040528060008152602001600081525090565b604080518082019091526000808252602082015290565b60008083601f840112613351578182fd5b50813567ffffffffffffffff811115613368578182fd5b60208301915083602060408302850101111561338357600080fd5b9250929050565b60006020828403121561339b578081fd5b8135611eb081613a0f565b6000806000606084860312156133ba578182fd5b83516133c581613a0f565b60208501519093506133d681613a0f565b80925050604084015190509250925092565b600080604083850312156133fa578182fd5b823561340581613a0f565b9150602083013561341581613a24565b809150509250929050565b60008060408385031215613432578182fd5b823561343d81613a0f565b946020939093013593505050565b6000806020838503121561345d578182fd5b823567ffffffffffffffff811115613473578283fd5b61347f85828601613340565b90969095509350505050565b600080600080604085870312156134a0578081fd5b843567ffffffffffffffff808211156134b7578283fd5b818701915087601f8301126134ca578283fd5b8135818111156134d8578384fd5b88602080830285010111156134eb578384fd5b602092830196509450908601359080821115613505578283fd5b5061351287828801613340565b95989497509550505050565b60006020828403121561352f578081fd5b8151611eb081613a24565b6000806040838503121561354c578182fd5b825161355781613a24565b602084015190925061341581613a24565b60008060006060848603121561357c578283fd5b833561358781613a0f565b925060208401359150604084013561359e81613a0f565b809150509250925092565b6000604082840312156135ba578081fd5b6040516040810181811067ffffffffffffffff821117156135d757fe5b604052823581526020928301359281019290925250919050565b600060208284031215613602578081fd5b5051919050565b6000806040838503121561361b578182fd5b82359150602083013561341581613a0f565b60008284526020808501945082825b85811015613662578135875282820135838801526040968701969091019060010161363c565b509495945050505050565b80518252602090810151910152565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b038316815260608101612884602083018461366d565b6000604082526136f460408301858761362d565b9050826020830152949350505050565b6040808252810184905260006001600160fb1b03851115613723578081fd5b6020850280876060850137808301905060608101828152606084830301602085015261375081868861362d565b98975050505050505050565b6020808252600e908201526d494e56414c49445f41525241595360901b604082015260600190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252600f908201526e2620a9aa2fa2a827a1a42fa7ab22a960891b604082015260600190565b6020808252600c908201526b5a45524f5f4144445245535360a01b604082015260600190565b60208082526016908201527524a721a2a72a24ab22a9afa822a924a7a22fa7ab22a960511b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b60208082526018908201527f434f4e54524143545f4e4f545f57484954454c49535445440000000000000000604082015260600190565b6020808252600b908201526a16915493d7d05353d5539560aa1b604082015260600190565b6020808252600b908201526a1393d517d4d5105495115160aa1b604082015260600190565b60208082526011908201527013125457d35253925391d7d4105554d151607a1b604082015260600190565b60208082526010908201526f1253959053125117d15413d0d217d25160821b604082015260600190565b6020808252600a90820152691393d517d1955391115160b21b604082015260600190565b6020808252601190820152704455504c4943415445445f544f4b454e5360781b604082015260600190565b81516001600160a01b039081168252602092830151169181019190915260400190565b60408101611eb3828461366d565b90815260200190565b85815260e081016139cc602083018761366d565b8460608301528360808301526139e560a083018461366d565b9695505050505050565b918252602082015260400190565b81358155602082013560018201555050565b6001600160a01b0381168114611aa057600080fd5b8015158114611aa057600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220e25ccd78e12ab0c9bd7f682869d2b8e73039ad4456e2efc67b52a7acba4ce67664736f6c63430007060033

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

0000000000000000000000009e8b9ec2454bcab6128231d9fd405e864acd3cf9000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab34000000000000000000000000d5889758bb9a661482f9e2cced35ce1057081e64000000000000000000000000fb98b335551a418cd0737375a2ea0ded62ea213b000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c700000000000000000000000082922e6fbe83547c5e2e0229815942a2108e46240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000618d05c00000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000005000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7

-----Decoded View---------------
Arg [0] : args (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 0000000000000000000000009e8b9ec2454bcab6128231d9fd405e864acd3cf9
Arg [1] : 000000000000000000000000d4016bd5ebf2a46c7923348ab47ef8531a6aab34
Arg [2] : 000000000000000000000000d5889758bb9a661482f9e2cced35ce1057081e64
Arg [3] : 000000000000000000000000fb98b335551a418cd0737375a2ea0ded62ea213b
Arg [4] : 000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [5] : 00000000000000000000000082922e6fbe83547c5e2e0229815942a2108e4624
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 00000000000000000000000000000000000000000000000000000000618d05c0
Arg [9] : 0000000000000000000000000000000000000000000000000000000000093a80
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [11] : 000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7


Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

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

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