ETH Price: $1,971.54 (+0.15%)
 

Overview

Max Total Supply

1,119,596.127927210632457584 PLP-srNUSD-28MAY2026

Holders

129

Market

Onchain Market Cap

-

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Filtered by Token Holder
kurapon.eth
Balance
279.12284908012679538 PLP-srNUSD-28MAY2026

Value
$0.00
0x057048197ff499d1f3111b05a1c6e9db9b27eea9
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
PendleMarketV7

Compiler Version
v0.8.33+commit.64118f21

Optimization Enabled:
Yes with 50000 runs

Other Settings:
shanghai EvmVersion
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;

import "../../interfaces/IPMarket.sol";
import "../../interfaces/IPMarketFactory.sol";
import "../../interfaces/IPMarketSwapCallback.sol";

import "../erc20/PendleERC20.sol";
import "../libraries/StringLib.sol";
import "./OracleLib.sol";
import "./PendleGauge.sol";

/**
 * Invariance to maintain:
 * - Internal balances totalPt & totalSy not interfered by people transferring tokens in directly
 * - address(0) & address(this) should never have any rewards & activeBalance accounting done. This is
 *     guaranteed by address(0) & address(this) check in each updateForTwo function
 */
contract PendleMarketV7 is PendleERC20, PendleGauge, IPMarket {
    using PMath for uint256;
    using PMath for int256;
    using MarketMathCore for MarketState;
    using SafeERC20 for IERC20;
    using PYIndexLib for IPYieldToken;
    using PYIndexLib for PYIndex;
    using OracleLib for OracleLib.Observation[65_535];
    using StringLib for string;
    using StringLib for StringLib.slice;

    struct MarketStorage {
        int128 totalPt;
        int128 totalSy;
        // 1 SLOT = 256 bits
        uint96 lastLnImpliedRate;
        uint16 observationIndex;
        uint16 observationCardinality;
        uint16 observationCardinalityNext;
        // 1 SLOT = 144 bits
    }

    string private constant PT_NAME_PREF = "PT ";
    string private constant PT_SYMBOL_PREF = "PT-";

    string private constant LP_NAME_PREF = "PLP ";
    string private constant LP_SYMBOL_PREF = "PLP-";

    uint256 public constant VERSION = 7;

    IPPrincipalToken internal immutable PT;
    IStandardizedYield internal immutable SY;
    IPYieldToken internal immutable YT;

    address public immutable factory;
    uint256 public immutable expiry;

    int256 internal immutable scalarRoot;
    int256 internal immutable initialAnchor;
    uint80 internal immutable lnFeeRateRoot;

    MarketStorage public _storage;

    OracleLib.Observation[65_535] public observations;

    modifier notExpired() {
        if (isExpired()) revert Errors.MarketExpired();
        _;
    }

    constructor(address _PT, int256 _scalarRoot, int256 _initialAnchor, uint80 _lnFeeRateRoot, address _gaugeController)
        PendleERC20(_getLPName(_PT), _getLPSymbol(_PT), 18)
        PendleGauge(IPPrincipalToken(_PT).SY(), _gaugeController)
    {
        PT = IPPrincipalToken(_PT);
        SY = IStandardizedYield(PT.SY());
        YT = IPYieldToken(PT.YT());

        (_storage.observationCardinality, _storage.observationCardinalityNext) =
            observations.initialize(uint32(block.timestamp));

        if (_scalarRoot <= 0) revert Errors.MarketScalarRootBelowZero(_scalarRoot);

        scalarRoot = _scalarRoot;
        initialAnchor = _initialAnchor;
        lnFeeRateRoot = _lnFeeRateRoot;
        expiry = IPPrincipalToken(_PT).expiry();
        factory = msg.sender;
    }

    function _getLPName(address _PT) internal view returns (string memory) {
        return LP_NAME_PREF.toSlice().concat(IPPrincipalToken(_PT).name().stripPrefixSlice(PT_NAME_PREF));
    }

    function _getLPSymbol(address _PT) internal view returns (string memory) {
        return LP_SYMBOL_PREF.toSlice().concat(IPPrincipalToken(_PT).symbol().stripPrefixSlice(PT_SYMBOL_PREF));
    }

    /**
     * @notice PendleMarket allows users to provide in PT & SY in exchange for LPs, which
     * will grant LP holders more exchange fee over time
     * @dev will mint as much LP as possible such that the corresponding SY and PT used do
     * not exceed `netSyDesired` and `netPtDesired`, respectively
     * @dev PT and SY should be transferred to this contract prior to calling
     * @dev will revert if PT is expired
     */
    function mint(address receiver, uint256 netSyDesired, uint256 netPtDesired)
        external
        nonReentrant
        notExpired
        returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed)
    {
        MarketState memory market = readState(msg.sender);
        PYIndex index = YT.newIndex();

        uint256 lpToReserve;

        (lpToReserve, netLpOut, netSyUsed, netPtUsed) = market.addLiquidity(netSyDesired, netPtDesired, block.timestamp);

        // initializing the market
        if (lpToReserve != 0) {
            market.setInitialLnImpliedRate(index, initialAnchor, block.timestamp);
            _mint(address(1), lpToReserve);
        }

        _mint(receiver, netLpOut);

        _writeState(market);

        if (_selfBalance(SY) < market.totalSy.Uint()) {
            revert Errors.MarketInsufficientSyReceived(_selfBalance(SY), market.totalSy.Uint());
        }
        if (_selfBalance(PT) < market.totalPt.Uint()) {
            revert Errors.MarketInsufficientPtReceived(_selfBalance(PT), market.totalPt.Uint());
        }

        emit Mint(receiver, netLpOut, netSyUsed, netPtUsed);
    }

    /**
     * @notice LP Holders can burn their LP to receive back SY & PT proportionally
     * to their share of the market
     */
    function burn(address receiverSy, address receiverPt, uint256 netLpToBurn)
        external
        nonReentrant
        returns (uint256 netSyOut, uint256 netPtOut)
    {
        MarketState memory market = readState(msg.sender);

        _burn(address(this), netLpToBurn);

        (netSyOut, netPtOut) = market.removeLiquidity(netLpToBurn);

        if (receiverSy != address(this)) IERC20(SY).safeTransfer(receiverSy, netSyOut);
        if (receiverPt != address(this)) IERC20(PT).safeTransfer(receiverPt, netPtOut);

        _writeState(market);

        emit Burn(receiverSy, receiverPt, netLpToBurn, netSyOut, netPtOut);
    }

    /**
     * @notice Pendle Market allows swaps between PT & SY it is holding. This function
     * aims to swap an exact amount of PT to SY.
     * @dev steps working of this contract
     *    - The outcome amount of SY will be precomputed by MarketMathLib
     *    - Release the calculated amount of SY to receiver
     *    - Callback to msg.sender if data.length > 0
     *    - Ensure exactPtIn amount of PT has been transferred to this address
     * @dev will revert if PT is expired
     * @param data bytes data to be sent in the callback (if any)
     */
    function swapExactPtForSy(address receiver, uint256 exactPtIn, bytes calldata data)
        external
        nonReentrant
        notExpired
        returns (uint256 netSyOut, uint256 netSyFee)
    {
        MarketState memory market = readState(msg.sender);
        PYIndex index = YT.newIndex();

        uint256 netSyToReserve;
        (netSyOut, netSyFee, netSyToReserve) = market.swapExactPtForSy(index, exactPtIn, block.timestamp);

        if (receiver != address(this)) IERC20(SY).safeTransfer(receiver, netSyOut);
        IERC20(SY).safeTransfer(market.treasury, netSyToReserve);

        _writeState(market);

        if (data.length > 0) {
            IPMarketSwapCallback(msg.sender).swapCallback(exactPtIn.neg(), netSyOut.Int(), data);
        }

        if (_selfBalance(PT) < market.totalPt.Uint()) {
            revert Errors.MarketInsufficientPtReceived(_selfBalance(PT), market.totalPt.Uint());
        }

        if (index.syToAsset(netSyFee - netSyToReserve) == 0) {
            revert Errors.MarketZeroNetLPFee();
        }

        emit Swap(msg.sender, receiver, exactPtIn.neg(), netSyOut.Int(), netSyFee, netSyToReserve);
    }

    /**
     * @notice Pendle Market allows swaps between PT & SY it is holding. This function
     * aims to swap SY for an exact amount of PT.
     * @dev steps working of this function
     *    - The exact outcome amount of PT will be transferred to receiver
     *    - Callback to msg.sender if data.length > 0
     *    - Ensure the calculated required amount of SY is transferred to this address
     * @dev will revert if PT is expired
     * @param data bytes data to be sent in the callback (if any)
     */
    function swapSyForExactPt(address receiver, uint256 exactPtOut, bytes calldata data)
        external
        nonReentrant
        notExpired
        returns (uint256 netSyIn, uint256 netSyFee)
    {
        MarketState memory market = readState(msg.sender);

        PYIndex index = YT.newIndex();

        uint256 netSyToReserve;
        (netSyIn, netSyFee, netSyToReserve) = market.swapSyForExactPt(index, exactPtOut, block.timestamp);

        if (receiver != address(this)) IERC20(PT).safeTransfer(receiver, exactPtOut);
        IERC20(SY).safeTransfer(market.treasury, netSyToReserve);

        _writeState(market);

        if (data.length > 0) {
            IPMarketSwapCallback(msg.sender).swapCallback(exactPtOut.Int(), netSyIn.neg(), data);
        }

        // have received enough SY
        if (_selfBalance(SY) < market.totalSy.Uint()) {
            revert Errors.MarketInsufficientSyReceived(_selfBalance(SY), market.totalSy.Uint());
        }

        if (index.syToAsset(netSyFee - netSyToReserve) == 0) {
            revert Errors.MarketZeroNetLPFee();
        }

        emit Swap(msg.sender, receiver, exactPtOut.Int(), netSyIn.neg(), netSyFee, netSyToReserve);
    }

    /// @notice forces balances to match reserves
    function skim() external nonReentrant {
        MarketState memory market = readState(msg.sender);
        uint256 excessPt = _selfBalance(PT) - market.totalPt.Uint();
        uint256 excessSy = _selfBalance(SY) - market.totalSy.Uint();
        if (excessPt != 0) IERC20(PT).safeTransfer(market.treasury, excessPt);
        if (excessSy != 0) IERC20(SY).safeTransfer(market.treasury, excessSy);
    }

    /**
     * @notice redeems the user's reward
     * @return amount of reward token redeemed, in the same order as `getRewardTokens()`
     */
    function redeemRewards(address user) external nonReentrant returns (uint256[] memory) {
        return _redeemRewards(user);
    }

    /// @notice returns the list of reward tokens
    function getRewardTokens() external view returns (address[] memory) {
        return _getRewardTokens();
    }

    /*///////////////////////////////////////////////////////////////
                                ORACLE
    //////////////////////////////////////////////////////////////*/

    function observe(uint32[] memory secondsAgos) external view returns (uint216[] memory lnImpliedRateCumulative) {
        return observations.observe(
            uint32(block.timestamp),
            secondsAgos,
            _storage.lastLnImpliedRate,
            _storage.observationIndex,
            _storage.observationCardinality
        );
    }

    function increaseObservationsCardinalityNext(uint16 cardinalityNext) external nonReentrant {
        uint16 cardinalityNextOld = _storage.observationCardinalityNext;
        uint16 cardinalityNextNew = observations.grow(cardinalityNextOld, cardinalityNext);
        if (cardinalityNextOld != cardinalityNextNew) {
            _storage.observationCardinalityNext = cardinalityNextNew;
            emit IncreaseObservationCardinalityNext(cardinalityNextOld, cardinalityNextNew);
        }
    }

    /*///////////////////////////////////////////////////////////////
                                READ/WRITE STATES
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice read the state of the market from storage into memory for gas-efficient manipulation
     */
    function readState(address router) public view returns (MarketState memory market) {
        market.totalPt = _storage.totalPt;
        market.totalSy = _storage.totalSy;
        market.totalLp = totalSupply().Int();

        uint80 overriddenFee;

        (market.treasury, overriddenFee, market.reserveFeePercent) =
            IPMarketFactory(factory).getMarketConfig(address(this), router);

        market.lnFeeRateRoot = overriddenFee == 0 ? lnFeeRateRoot : overriddenFee;
        market.scalarRoot = scalarRoot;
        market.expiry = expiry;

        market.lastLnImpliedRate = _storage.lastLnImpliedRate;
    }

    /// @notice write back the state of the market from memory to storage
    function _writeState(MarketState memory market) internal {
        uint96 lastLnImpliedRate96 = market.lastLnImpliedRate.Uint96();
        int128 totalPt128 = market.totalPt.Int128();
        int128 totalSy128 = market.totalSy.Int128();

        (uint16 observationIndex, uint16 observationCardinality) = observations.write(
            _storage.observationIndex,
            uint32(block.timestamp),
            _storage.lastLnImpliedRate,
            _storage.observationCardinality,
            _storage.observationCardinalityNext
        );

        _storage.totalPt = totalPt128;
        _storage.totalSy = totalSy128;
        _storage.lastLnImpliedRate = lastLnImpliedRate96;
        _storage.observationIndex = observationIndex;
        _storage.observationCardinality = observationCardinality;

        emit UpdateImpliedRate(block.timestamp, market.lastLnImpliedRate);
    }

    function getNonOverrideLnFeeRateRoot() external view returns (uint80) {
        return lnFeeRateRoot;
    }

    /*///////////////////////////////////////////////////////////////
                            TRIVIAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function readTokens() external view returns (IStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT) {
        _SY = SY;
        _PT = PT;
        _YT = YT;
    }

    function isExpired() public view returns (bool) {
        return MiniHelpers.isCurrentlyExpired(expiry);
    }

    function reentrancyGuardEntered() external view override(PendleERC20, IPMarket) returns (bool) {
        return _reentrancyGuardEntered();
    }

    /*///////////////////////////////////////////////////////////////
                    PENDLE GAUGE - RELATED
    //////////////////////////////////////////////////////////////*/

    function _rewardSharesUser(address user) internal view override returns (uint256) {
        return balanceOf(user);
    }

    function _rewardSharesTotal() internal view override returns (uint256) {
        return totalSupply();
    }

    // solhint-disable-next-line ordering
    function _beforeTokenTransfer(address from, address to, uint256 amount)
        internal
        override(PendleERC20, PendleGauge)
    {
        PendleGauge._beforeTokenTransfer(from, to, amount);
    }

    /*///////////////////////////////////////////////////////////////
                            LEGACY FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function totalActiveSupply() external view returns (uint256) {
        return totalSupply();
    }

    function activeBalance(address user) external view returns (uint256) {
        return balanceOf(user);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

// SPDX-License-Identifier: GPL-3.0-or-later
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/Context.sol";

/**
 * @dev Pendle's ERC20 implementation, modified from @openzeppelin implementation
 * Changes are:
 * - comes with built-in reentrancy protection, storage-packed with totalSupply variable
 * - delete increaseAllowance / decreaseAllowance
 * - add nonReentrancy protection to transfer / transferFrom functions
 * - allow decimals to be passed in
 * - block self-transfer by default
 */
// solhint-disable
contract PendleERC20 is Context, IERC20, IERC20Metadata {
    uint8 private constant _NOT_ENTERED = 1;
    uint8 private constant _ENTERED = 2;

    mapping(address => uint256) private _balances;

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

    uint248 private _totalSupply;
    uint8 private _status;

    string private _name;
    string private _symbol;
    uint8 public immutable decimals;

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

    function reentrancyGuardEntered() external view virtual returns (bool) {
        return _reentrancyGuardEntered();
    }

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

    /**
     * @dev Sets the values for {name}, {symbol} and {decimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_, uint8 decimals_) {
        _name = name_;
        _symbol = symbol_;
        decimals = decimals_;
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) external virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount)
        external
        virtual
        override
        nonReentrant
        returns (bool)
    {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

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

    function toUint248(uint256 x) internal virtual returns (uint248) {
        require(x <= type(uint248).max); // signed, lim = bit-1
        return uint248(x);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library ArrayLib {
    function sum(uint256[] memory input) internal pure returns (uint256) {
        uint256 value = 0;
        for (uint256 i = 0; i < input.length;) {
            value += input[i];
            unchecked {
                i++;
            }
        }
        return value;
    }

    /// @notice return index of the element if found, else return uint256.max
    function find(address[] memory array, address element) internal pure returns (uint256 index) {
        uint256 length = array.length;
        for (uint256 i = 0; i < length;) {
            if (array[i] == element) return i;
            unchecked {
                i++;
            }
        }
        return type(uint256).max;
    }

    function append(address[] memory inp, address element) internal pure returns (address[] memory out) {
        uint256 length = inp.length;
        out = new address[](length + 1);
        for (uint256 i = 0; i < length;) {
            out[i] = inp[i];
            unchecked {
                i++;
            }
        }
        out[length] = element;
    }

    function appendHead(address[] memory inp, address element) internal pure returns (address[] memory out) {
        uint256 length = inp.length;
        out = new address[](length + 1);
        out[0] = element;
        for (uint256 i = 1; i <= length;) {
            out[i] = inp[i - 1];
            unchecked {
                i++;
            }
        }
    }

    /**
     * @dev This function assumes a and b each contains unidentical elements
     * @param a array of addresses a
     * @param b array of addresses b
     * @return out Concatenation of a and b containing unidentical elements
     */
    function merge(address[] memory a, address[] memory b) internal pure returns (address[] memory out) {
        unchecked {
            uint256 countUnidenticalB = 0;
            bool[] memory isUnidentical = new bool[](b.length);
            for (uint256 i = 0; i < b.length; ++i) {
                if (!contains(a, b[i])) {
                    countUnidenticalB++;
                    isUnidentical[i] = true;
                }
            }

            out = new address[](a.length + countUnidenticalB);
            for (uint256 i = 0; i < a.length; ++i) {
                out[i] = a[i];
            }
            uint256 id = a.length;
            for (uint256 i = 0; i < b.length; ++i) {
                if (isUnidentical[i]) {
                    out[id++] = b[i];
                }
            }
        }
    }

    // various version of contains
    function contains(address[] memory array, address element) internal pure returns (bool) {
        uint256 length = array.length;
        for (uint256 i = 0; i < length;) {
            if (array[i] == element) return true;
            unchecked {
                i++;
            }
        }
        return false;
    }

    function contains(bytes4[] memory array, bytes4 element) internal pure returns (bool) {
        uint256 length = array.length;
        for (uint256 i = 0; i < length;) {
            if (array[i] == element) return true;
            unchecked {
                i++;
            }
        }
        return false;
    }

    function create(address a) internal pure returns (address[] memory res) {
        res = new address[](1);
        res[0] = a;
    }

    function create(address a, address b) internal pure returns (address[] memory res) {
        res = new address[](2);
        res[0] = a;
        res[1] = b;
    }

    function create(address a, address b, address c) internal pure returns (address[] memory res) {
        res = new address[](3);
        res[0] = a;
        res[1] = b;
        res[2] = c;
    }

    function create(address a, address b, address c, address d) internal pure returns (address[] memory res) {
        res = new address[](4);
        res[0] = a;
        res[1] = b;
        res[2] = c;
        res[3] = d;
    }

    function create(address a, address b, address c, address d, address e)
        internal
        pure
        returns (address[] memory res)
    {
        res = new address[](5);
        res[0] = a;
        res[1] = b;
        res[2] = c;
        res[3] = d;
        res[4] = e;
    }

    function create(uint256 a) internal pure returns (uint256[] memory res) {
        res = new uint256[](1);
        res[0] = a;
    }
}

File 10 of 33 : Errors.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library Errors {
    // BulkSeller
    error BulkInsufficientSyForTrade(uint256 currentAmount, uint256 requiredAmount);
    error BulkInsufficientTokenForTrade(uint256 currentAmount, uint256 requiredAmount);
    error BulkInSufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
    error BulkInSufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
    error BulkInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
    error BulkNotMaintainer();
    error BulkNotAdmin();
    error BulkSellerAlreadyExisted(address token, address SY, address bulk);
    error BulkSellerInvalidToken(address token, address SY);
    error BulkBadRateTokenToSy(uint256 actualRate, uint256 currentRate, uint256 eps);
    error BulkBadRateSyToToken(uint256 actualRate, uint256 currentRate, uint256 eps);

    // APPROX
    error ApproxFail();
    error ApproxParamsInvalid(uint256 guessMin, uint256 guessMax, uint256 eps);
    error ApproxBinarySearchInputInvalid(
        uint256 approxGuessMin, uint256 approxGuessMax, uint256 minGuessMin, uint256 maxGuessMax
    );

    // MARKET + MARKET MATH CORE
    error MarketExpired();
    error MarketZeroAmountsInput();
    error MarketZeroAmountsOutput();
    error MarketZeroLnImpliedRate();
    error MarketZeroNetLPFee();
    error MarketInsufficientPtForTrade(int256 currentAmount, int256 requiredAmount);
    error MarketInsufficientPtReceived(uint256 actualBalance, uint256 requiredBalance);
    error MarketInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
    error MarketZeroTotalPtOrTotalAsset(int256 totalPt, int256 totalAsset);
    error MarketExchangeRateBelowOne(int256 exchangeRate);
    error MarketProportionMustNotEqualOne();
    error MarketRateScalarBelowZero(int256 rateScalar);
    error MarketScalarRootBelowZero(int256 scalarRoot);
    error MarketProportionTooHigh(int256 proportion, int256 maxProportion);

    error OracleUninitialized();
    error OracleTargetTooOld(uint32 target, uint32 oldest);
    error OracleZeroCardinality();

    error MarketFactoryExpiredPt();
    error MarketFactoryInvalidPt();
    error MarketFactoryMarketExists();

    error MarketFactoryLnFeeRateRootTooHigh(uint80 lnFeeRateRoot, uint256 maxLnFeeRateRoot);
    error MarketFactoryOverriddenFeeTooHigh(uint80 overriddenFee, uint256 marketLnFeeRateRoot);
    error MarketFactoryReserveFeePercentTooHigh(uint8 reserveFeePercent, uint8 maxReserveFeePercent);
    error MarketFactoryZeroTreasury();
    error MarketFactoryInitialAnchorTooLow(int256 initialAnchor, int256 minInitialAnchor);
    error MFNotPendleMarket(address addr);

    // ROUTER
    error RouterInsufficientLpOut(uint256 actualLpOut, uint256 requiredLpOut);
    error RouterInsufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
    error RouterInsufficientPtOut(uint256 actualPtOut, uint256 requiredPtOut);
    error RouterInsufficientYtOut(uint256 actualYtOut, uint256 requiredYtOut);
    error RouterInsufficientPYOut(uint256 actualPYOut, uint256 requiredPYOut);
    error RouterInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
    error RouterInsufficientSyRepay(uint256 actualSyRepay, uint256 requiredSyRepay);
    error RouterInsufficientPtRepay(uint256 actualPtRepay, uint256 requiredPtRepay);
    error RouterNotAllSyUsed(uint256 netSyDesired, uint256 netSyUsed);

    error RouterTimeRangeZero();
    error RouterCallbackNotPendleMarket(address caller);
    error RouterInvalidAction(bytes4 selector);
    error RouterInvalidFacet(address facet);

    error RouterKyberSwapDataZero();

    error SimulationResults(bool success, bytes res);

    // YIELD CONTRACT
    error YCExpired();
    error YCNotExpired();
    error YieldContractInsufficientSy(uint256 actualSy, uint256 requiredSy);
    error YCNothingToRedeem();
    error YCPostExpiryDataNotSet();
    error YCNoFloatingSy();

    // YieldFactory
    error YCFactoryInvalidExpiry();
    error YCFactoryYieldContractExisted();
    error YCFactoryZeroExpiryDivisor();
    error YCFactoryZeroTreasury();
    error YCFactoryInterestFeeRateTooHigh(uint256 interestFeeRate, uint256 maxInterestFeeRate);
    error YCFactoryRewardFeeRateTooHigh(uint256 newRewardFeeRate, uint256 maxRewardFeeRate);

    // SY
    error SYInvalidTokenIn(address token);
    error SYInvalidTokenOut(address token);
    error SYZeroDeposit();
    error SYZeroRedeem();
    error SYInsufficientSharesOut(uint256 actualSharesOut, uint256 requiredSharesOut);
    error SYInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);

    // SY-specific
    error SYQiTokenMintFailed(uint256 errCode);
    error SYQiTokenRedeemFailed(uint256 errCode);
    error SYQiTokenRedeemRewardsFailed(uint256 rewardAccruedType0, uint256 rewardAccruedType1);
    error SYQiTokenBorrowRateTooHigh(uint256 borrowRate, uint256 borrowRateMax);

    error SYCurveInvalidPid();
    error SYCurve3crvPoolNotFound();

    error SYApeDepositAmountTooSmall(uint256 amountDeposited);
    error SYBalancerInvalidPid();
    error SYInvalidRewardToken(address token);

    error SYStargateRedeemCapExceeded(uint256 amountLpDesired, uint256 amountLpRedeemable);

    error SYBalancerReentrancy();

    error NotFromTrustedRemote(uint16 srcChainId, bytes path);

    error ApxETHNotEnoughBuffer();

    // Liquidity Mining
    error VCInvalidCap(uint256 cap);
    error VCInactivePool(address pool);
    error VCPoolAlreadyActive(address pool);
    error VCZeroVePendle(address user);
    error VCExceededMaxWeight(uint256 totalWeight, uint256 maxWeight);
    error VCEpochNotFinalized(uint256 wTime);
    error VCPoolAlreadyAddAndRemoved(address pool);

    error VEInvalidNewExpiry(uint256 newExpiry);
    error VEExceededMaxLockTime();
    error VEInsufficientLockTime();
    error VENotAllowedReduceExpiry();
    error VEZeroAmountLocked();
    error VEPositionNotExpired();
    error VEZeroPosition();
    error VEZeroSlope(uint128 bias, uint128 slope);
    error VEReceiveOldSupply(uint256 msgTime);

    error GCNotPendleMarket(address caller);
    error GCNotRewardDataUpdater(address caller);

    error InvalidWTime(uint256 wTime);
    error ExpiryInThePast(uint256 expiry);
    error ChainNotSupported(uint256 chainId);

    error FDTotalAmountFundedNotMatch(uint256 actualTotalAmount, uint256 expectedTotalAmount);
    error FDEpochLengthMismatch();
    error FDInvalidPool(address pool);
    error FDPoolAlreadyExists(address pool);
    error FDInvalidNewFinishedEpoch(uint256 oldFinishedEpoch, uint256 newFinishedEpoch);
    error FDInvalidStartEpoch(uint256 startEpoch);
    error FDInvalidWTimeFund(uint256 lastFunded, uint256 wTime);
    error FDFutureFunding(uint256 lastFunded, uint256 currentWTime);

    error BDInvalidEpoch(uint256 epoch, uint256 startTime);

    // Cross-Chain
    error MsgNotFromSendEndpoint(uint16 srcChainId, bytes path);
    error MsgNotFromReceiveEndpoint(address sender);
    error InsufficientFeeToSendMsg(uint256 currentFee, uint256 requiredFee);
    error ApproxDstExecutionGasNotSet();
    error InvalidRetryData();

    // GENERIC MSG
    error ArrayLengthMismatch();
    error ArrayEmpty();
    error ArrayOutOfBounds();
    error ZeroAddress();
    error FailedToSendEther();
    error InvalidMerkleProof();

    error OnlyLayerZeroEndpoint();
    error OnlyYT();
    error OnlyYCFactory();
    error OnlyWhitelisted();

    // Swap Aggregator
    error SAInsufficientTokenIn(address tokenIn, uint256 amountExpected, uint256 amountActual);
    error UnsupportedSelector(uint256 aggregatorType, bytes4 selector);

    // Cross Chain Oracle App
    error FeedNotInitialized();
    error ExchangeRateCallFailed();
    error InvalidDestinationEid();
    error InvalidMsgType();
    error NotEnoughNativeFee(uint256 msgValue, uint256 totalFee);
}

// SPDX-License-Identifier: GPL-3.0-or-later
// 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 SOFTWARE.

pragma solidity ^0.8.0;

/* solhint-disable */

/**
 * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument).
 *
 * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural
 * exponentiation and logarithm (where the base is Euler's number).
 *
 * @author Fernando Martinelli - @fernandomartinelli
 * @author Sergio Yuhjtman - @sergioyuhjtman
 * @author Daniel Fernandez - @dmf7z
 */
library LogExpMath {
    // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying
    // two numbers, and multiply by ONE when dividing them.

    // All arguments and return values are 18 decimal fixed point numbers.
    int256 constant ONE_18 = 1e18;

    // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the
    // case of ln36, 36 decimals.
    int256 constant ONE_20 = 1e20;
    int256 constant ONE_36 = 1e36;

    // The domain of natural exponentiation is bound by the word size and number of decimals used.
    //
    // Because internally the result will be stored using 20 decimals, the largest possible result is
    // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221.
    // The smallest possible result is 10^(-18), which makes largest negative argument
    // ln(10^(-18)) = -41.446531673892822312.
    // We use 130.0 and -41.0 to have some safety margin.
    int256 constant MAX_NATURAL_EXPONENT = 130e18;
    int256 constant MIN_NATURAL_EXPONENT = -41e18;

    // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point
    // 256 bit integer.
    int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17;
    int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17;

    uint256 constant MILD_EXPONENT_BOUND = 2 ** 254 / uint256(ONE_20);

    // 18 decimal constants
    int256 constant x0 = 128_000_000_000_000_000_000; // 2ˆ7
    int256 constant a0 = 38_877_084_059_945_950_922_200_000_000_000_000_000_000_000_000_000_000_000; // eˆ(x0) (no
    // decimals)
    int256 constant x1 = 64_000_000_000_000_000_000; // 2ˆ6
    int256 constant a1 = 6_235_149_080_811_616_882_910_000_000; // eˆ(x1) (no decimals)

    // 20 decimal constants
    int256 constant x2 = 3_200_000_000_000_000_000_000; // 2ˆ5
    int256 constant a2 = 7_896_296_018_268_069_516_100_000_000_000_000; // eˆ(x2)
    int256 constant x3 = 1_600_000_000_000_000_000_000; // 2ˆ4
    int256 constant a3 = 888_611_052_050_787_263_676_000_000; // eˆ(x3)
    int256 constant x4 = 800_000_000_000_000_000_000; // 2ˆ3
    int256 constant a4 = 298_095_798_704_172_827_474_000; // eˆ(x4)
    int256 constant x5 = 400_000_000_000_000_000_000; // 2ˆ2
    int256 constant a5 = 5_459_815_003_314_423_907_810; // eˆ(x5)
    int256 constant x6 = 200_000_000_000_000_000_000; // 2ˆ1
    int256 constant a6 = 738_905_609_893_065_022_723; // eˆ(x6)
    int256 constant x7 = 100_000_000_000_000_000_000; // 2ˆ0
    int256 constant a7 = 271_828_182_845_904_523_536; // eˆ(x7)
    int256 constant x8 = 50_000_000_000_000_000_000; // 2ˆ-1
    int256 constant a8 = 164_872_127_070_012_814_685; // eˆ(x8)
    int256 constant x9 = 25_000_000_000_000_000_000; // 2ˆ-2
    int256 constant a9 = 128_402_541_668_774_148_407; // eˆ(x9)
    int256 constant x10 = 12_500_000_000_000_000_000; // 2ˆ-3
    int256 constant a10 = 113_314_845_306_682_631_683; // eˆ(x10)
    int256 constant x11 = 6_250_000_000_000_000_000; // 2ˆ-4
    int256 constant a11 = 106_449_445_891_785_942_956; // eˆ(x11)

    /**
     * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent.
     *
     * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`.
     */
    function exp(int256 x) internal pure returns (int256) {
        unchecked {
            require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, "Invalid exponent");

            if (x < 0) {
                // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since
                // it fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT).
                // Fixed point division requires multiplying by ONE_18.
                return ((ONE_18 * ONE_18) / exp(-x));
            }

            // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call
            // x_n, where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal
            // 2^7
            // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the
            // decomposition.
            // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of
            // this decomposition, which will be lower than the smallest x_n.
            // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1.
            // We mutate x by subtracting x_n, making it the remainder of the decomposition.

            // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause
            // intermediate overflows. Instead we store them as plain integers, with 0 decimals.
            // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in
            // the decomposition.

            // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so
            // deduct it and compute the accumulated product.

            int256 firstAN;
            if (x >= x0) {
                x -= x0;
                firstAN = a0;
            } else if (x >= x1) {
                x -= x1;
                firstAN = a1;
            } else {
                firstAN = 1; // One with no decimal places
            }

            // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the
            // smaller terms.
            x *= 100;

            // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed
            // point one. Recall that fixed point multiplication requires dividing by ONE_20.
            int256 product = ONE_20;

            if (x >= x2) {
                x -= x2;
                product = (product * a2) / ONE_20;
            }
            if (x >= x3) {
                x -= x3;
                product = (product * a3) / ONE_20;
            }
            if (x >= x4) {
                x -= x4;
                product = (product * a4) / ONE_20;
            }
            if (x >= x5) {
                x -= x5;
                product = (product * a5) / ONE_20;
            }
            if (x >= x6) {
                x -= x6;
                product = (product * a6) / ONE_20;
            }
            if (x >= x7) {
                x -= x7;
                product = (product * a7) / ONE_20;
            }
            if (x >= x8) {
                x -= x8;
                product = (product * a8) / ONE_20;
            }
            if (x >= x9) {
                x -= x9;
                product = (product * a9) / ONE_20;
            }

            // x10 and x11 are unnecessary here since we have high enough precision already.

            // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor
            // series expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!).

            int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places.
            int256 term; // Each term in the sum, where the nth term is (x^n / n!).

            // The first term is simply x.
            term = x;
            seriesSum += term;

            // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number,
            // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not.

            term = ((term * x) / ONE_20) / 2;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 3;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 4;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 5;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 6;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 7;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 8;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 9;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 10;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 11;
            seriesSum += term;

            term = ((term * x) / ONE_20) / 12;
            seriesSum += term;

            // 12 Taylor terms are sufficient for 18 decimal precision.

            // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor
            // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to
            // multiply all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer
            // multiplication),
            // and then drop two digits to return an 18 decimal value.

            return (((product * seriesSum) / ONE_20) * firstAN) / 100;
        }
    }

    /**
     * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
     */
    function ln(int256 a) internal pure returns (int256) {
        unchecked {
            // The real natural logarithm is not defined for negative numbers or zero.
            require(a > 0, "out of bounds");
            if (LN_36_LOWER_BOUND < a && a < LN_36_UPPER_BOUND) {
                return _ln_36(a) / ONE_18;
            } else {
                return _ln(a);
            }
        }
    }

    /**
     * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent.
     *
     * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`.
     */
    function pow(uint256 x, uint256 y) internal pure returns (uint256) {
        unchecked {
            if (y == 0) {
                // We solve the 0^0 indetermination by making it equal one.
                return uint256(ONE_18);
            }

            if (x == 0) {
                return 0;
            }

            // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to
            // arrive at that r`esult. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means
            // x^y = exp(y * ln(x)).

            // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range.
            require(x < 2 ** 255, "x out of bounds");
            int256 x_int256 = int256(x);

            // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36.
            // In both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end.

            // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit
            // range.
            require(y < MILD_EXPONENT_BOUND, "y out of bounds");
            int256 y_int256 = int256(y);

            int256 logx_times_y;
            if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) {
                int256 ln_36_x = _ln_36(x_int256);

                // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't
                // just bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal
                // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the
                // (downscaled) last 18 decimals.
                logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18);
            } else {
                logx_times_y = _ln(x_int256) * y_int256;
            }
            logx_times_y /= ONE_18;

            // Finally, we compute exp(y * ln(x)) to arrive at x^y
            require(
                MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, "product out of bounds"
            );

            return uint256(exp(logx_times_y));
        }
    }

    /**
     * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
     */
    function _ln(int256 a) private pure returns (int256) {
        unchecked {
            if (a < ONE_18) {
                // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less
                // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive
                // call. Fixed point division requires multiplying by ONE_18.
                return (-_ln((ONE_18 * ONE_18) / a));
            }

            // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two,
            // which we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n
            // (that is,
            // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers
            // cannot be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a.
            // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of
            // this decomposition, which will be lower than the smallest a_n.
            // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1.
            // We mutate a by subtracting a_n, making it the remainder of the decomposition.

            // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed
            // point numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply
            // them by
            // ONE_18 to convert them to fixed point.
            // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so
            // divide by it and compute the accumulated sum.

            int256 sum = 0;
            if (a >= a0 * ONE_18) {
                a /= a0; // Integer, not fixed point division
                sum += x0;
            }

            if (a >= a1 * ONE_18) {
                a /= a1; // Integer, not fixed point division
                sum += x1;
            }

            // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this
            // format.
            sum *= 100;
            a *= 100;

            // Because further a_n are  20 digit fixed point numbers, we multiply by ONE_20 when dividing by them.

            if (a >= a2) {
                a = (a * ONE_20) / a2;
                sum += x2;
            }

            if (a >= a3) {
                a = (a * ONE_20) / a3;
                sum += x3;
            }

            if (a >= a4) {
                a = (a * ONE_20) / a4;
                sum += x4;
            }

            if (a >= a5) {
                a = (a * ONE_20) / a5;
                sum += x5;
            }

            if (a >= a6) {
                a = (a * ONE_20) / a6;
                sum += x6;
            }

            if (a >= a7) {
                a = (a * ONE_20) / a7;
                sum += x7;
            }

            if (a >= a8) {
                a = (a * ONE_20) / a8;
                sum += x8;
            }

            if (a >= a9) {
                a = (a * ONE_20) / a9;
                sum += x9;
            }

            if (a >= a10) {
                a = (a * ONE_20) / a10;
                sum += x10;
            }

            if (a >= a11) {
                a = (a * ONE_20) / a11;
                sum += x11;
            }

            // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor
            // series that converges rapidly for values of `a` close to one - the same one used in ln_36.
            // Let z = (a - 1) / (a + 1).
            // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1))

            // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires
            // division by ONE_20.
            int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20);
            int256 z_squared = (z * z) / ONE_20;

            // num is the numerator of the series: the z^(2 * n + 1) term
            int256 num = z;

            // seriesSum holds the accumulated sum of each term in the series, starting with the initial z
            int256 seriesSum = num;

            // In each step, the numerator is multiplied by z^2
            num = (num * z_squared) / ONE_20;
            seriesSum += num / 3;

            num = (num * z_squared) / ONE_20;
            seriesSum += num / 5;

            num = (num * z_squared) / ONE_20;
            seriesSum += num / 7;

            num = (num * z_squared) / ONE_20;
            seriesSum += num / 9;

            num = (num * z_squared) / ONE_20;
            seriesSum += num / 11;

            // 6 Taylor terms are sufficient for 36 decimal precision.

            // Finally, we multiply by 2 (non fixed point) to compute ln(remainder)
            seriesSum *= 2;

            // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder
            // (both with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18
            // decimal
            // value.

            return (sum + seriesSum) / 100;
        }
    }

    /**
     * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point
     * argument,
     * for x close to one.
     *
     * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND.
     */
    function _ln_36(int256 x) private pure returns (int256) {
        unchecked {
            // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits
            // worthwhile.

            // First, we transform x to a 36 digit fixed point value.
            x *= ONE_18;

            // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1).
            // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1))

            // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires
            // division by ONE_36.
            int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36);
            int256 z_squared = (z * z) / ONE_36;

            // num is the numerator of the series: the z^(2 * n + 1) term
            int256 num = z;

            // seriesSum holds the accumulated sum of each term in the series, starting with the initial z
            int256 seriesSum = num;

            // In each step, the numerator is multiplied by z^2
            num = (num * z_squared) / ONE_36;
            seriesSum += num / 3;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 5;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 7;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 9;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 11;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 13;

            num = (num * z_squared) / ONE_36;
            seriesSum += num / 15;

            // 8 Taylor terms are sufficient for 36 decimal precision.

            // All that remains is multiplying by 2 (non fixed point).
            return seriesSum * 2;
        }
    }
}

File 12 of 33 : PMath.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

/* solhint-disable private-vars-leading-underscore, reason-string */

library PMath {
    uint256 internal constant ONE = 1e18; // 18 decimal places
    int256 internal constant IONE = 1e18; // 18 decimal places

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

    function subNoNeg(int256 a, int256 b) internal pure returns (int256) {
        require(a >= b, "negative");
        return a - b; // no unchecked since if b is very negative, a - b might overflow
    }

    function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 product = a * b;
        unchecked {
            return product / ONE;
        }
    }

    function mulDown(int256 a, int256 b) internal pure returns (int256) {
        int256 product = a * b;
        unchecked {
            return product / IONE;
        }
    }

    function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 aInflated = a * ONE;
        unchecked {
            return aInflated / b;
        }
    }

    function divDown(int256 a, int256 b) internal pure returns (int256) {
        int256 aInflated = a * IONE;
        unchecked {
            return aInflated / b;
        }
    }

    function rawDivUp(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a + b - 1) / b;
    }

    function rawDivUp(int256 a, int256 b) internal pure returns (int256) {
        return (a + b - 1) / b;
    }

    function tweakUp(uint256 a, uint256 factor) internal pure returns (uint256) {
        return mulDown(a, ONE + factor);
    }

    function tweakDown(uint256 a, uint256 factor) internal pure returns (uint256) {
        return mulDown(a, ONE - factor);
    }

    /// @return res = min(a + b, bound)
    /// @dev This function should handle arithmetic operation and bound check without overflow/underflow
    function addWithUpperBound(uint256 a, uint256 b, uint256 bound) internal pure returns (uint256 res) {
        unchecked {
            if (type(uint256).max - b < a) res = bound;
            else res = min(bound, a + b);
        }
    }

    /// @return res = max(a - b, bound)
    /// @dev This function should handle arithmetic operation and bound check without overflow/underflow
    function subWithLowerBound(uint256 a, uint256 b, uint256 bound) internal pure returns (uint256 res) {
        unchecked {
            if (b > a) res = bound;
            else res = max(a - b, bound);
        }
    }

    function clamp(uint256 x, uint256 lower, uint256 upper) internal pure returns (uint256 res) {
        res = x;
        if (x < lower) res = lower;
        else if (x > upper) res = upper;
    }

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

    function square(uint256 x) internal pure returns (uint256) {
        return x * x;
    }

    function squareDown(uint256 x) internal pure returns (uint256) {
        return mulDown(x, x);
    }

    function abs(int256 x) internal pure returns (uint256) {
        return uint256(x > 0 ? x : -x);
    }

    function neg(int256 x) internal pure returns (int256) {
        return x * (-1);
    }

    function neg(uint256 x) internal pure returns (int256) {
        return Int(x) * (-1);
    }

    function max(uint256 x, uint256 y) internal pure returns (uint256) {
        return (x > y ? x : y);
    }

    function max(int256 x, int256 y) internal pure returns (int256) {
        return (x > y ? x : y);
    }

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

    function min(int256 x, int256 y) internal pure returns (int256) {
        return (x < y ? x : y);
    }

    /*///////////////////////////////////////////////////////////////
                               SIGNED CASTS
    //////////////////////////////////////////////////////////////*/

    function Int(uint256 x) internal pure returns (int256) {
        require(x <= uint256(type(int256).max));
        return int256(x);
    }

    function Int128(int256 x) internal pure returns (int128) {
        require(type(int128).min <= x && x <= type(int128).max);
        return int128(x);
    }

    function Int128(uint256 x) internal pure returns (int128) {
        return Int128(Int(x));
    }

    /*///////////////////////////////////////////////////////////////
                               UNSIGNED CASTS
    //////////////////////////////////////////////////////////////*/

    function Uint(int256 x) internal pure returns (uint256) {
        require(x >= 0);
        return uint256(x);
    }

    function Uint32(uint256 x) internal pure returns (uint32) {
        require(x <= type(uint32).max);
        return uint32(x);
    }

    function Uint64(uint256 x) internal pure returns (uint64) {
        require(x <= type(uint64).max);
        return uint64(x);
    }

    function Uint112(uint256 x) internal pure returns (uint112) {
        require(x <= type(uint112).max);
        return uint112(x);
    }

    function Uint96(uint256 x) internal pure returns (uint96) {
        require(x <= type(uint96).max);
        return uint96(x);
    }

    function Uint128(uint256 x) internal pure returns (uint128) {
        require(x <= type(uint128).max);
        return uint128(x);
    }

    function Uint192(uint256 x) internal pure returns (uint192) {
        require(x <= type(uint192).max);
        return uint192(x);
    }

    function Uint80(uint256 x) internal pure returns (uint80) {
        require(x <= type(uint80).max);
        return uint80(x);
    }

    function Uint152(uint256 x) internal pure returns (uint152) {
        require(x <= type(uint152).max);
        return uint152(x);
    }

    function isAApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
        return mulDown(b, ONE - eps) <= a && a <= mulDown(b, ONE + eps);
    }

    function isAGreaterApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
        return a >= b && a <= mulDown(b, ONE + eps);
    }

    function isASmallerApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
        return a <= b && a >= mulDown(b, ONE - eps);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library MiniHelpers {
    function isCurrentlyExpired(uint256 expiry) internal view returns (bool) {
        return (expiry <= block.timestamp);
    }

    function isExpired(uint256 expiry, uint256 blockTime) internal pure returns (bool) {
        return (expiry <= blockTime);
    }

    function isTimeInThePast(uint256 timestamp) internal view returns (bool) {
        return (timestamp <= block.timestamp); // same definition as isCurrentlyExpired
    }
}

File 14 of 33 : StringLib.sol
/*
 * @title String & slice utility library for Solidity contracts.
 * @author Nick Johnson <arachnid@notdot.net>
 *
 * @dev Functionality in this library is largely implemented using an
 *      abstraction called a 'slice'. A slice represents a part of a string -
 *      anything from the entire string to a single character, or even no
 *      characters at all (a 0-length slice). Since a slice only has to specify
 *      an offset and a length, copying and manipulating slices is a lot less
 *      expensive than copying and manipulating the strings they reference.
 *
 *      To further reduce gas costs, most functions on slice that need to return
 *      a slice modify the original one instead of allocating a new one; for
 *      instance, `s.split(".")` will return the text up to the first '.',
 *      modifying s to only contain the remainder of the string after the '.'.
 *      In situations where you do not want to modify the original slice, you
 *      can make a copy first with `.copy()`, for example:
 *      `s.copy().split(".")`. Try and avoid using this idiom in loops; since
 *      Solidity has no memory management, it will result in allocating many
 *      short-lived slices that are later discarded.
 *
 *      Functions that return two slices come in two versions: a non-allocating
 *      version that takes the second slice as an argument, modifying it in
 *      place, and an allocating version that allocates and returns the second
 *      slice; see `nextRune` for example.
 *
 *      Functions that have to copy string data will return strings rather than
 *      slices; these can be cast back to slices for further processing if
 *      required.
 *
 *      For convenience, some functions are provided with non-modifying
 *      variants that create a new slice and return both; for instance,
 *      `s.splitNew('.')` leaves s unmodified, and returns two values
 *      corresponding to the left and right parts of the string.
 */

pragma solidity ^0.8.0;

library StringLib {
    struct slice {
        uint256 _len;
        uint256 _ptr;
    }

    function memcpy(uint256 dest, uint256 src, uint256 len) private pure {
        // Copy word-length chunks while possible
        for (; len >= 32; len -= 32) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += 32;
            src += 32;
        }

        // Copy remaining bytes
        uint256 mask = type(uint256).max;
        if (len > 0) {
            mask = 256 ** (32 - len) - 1;
        }
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }

    /*
     * @dev Returns a slice containing the entire string.
     * @param self The string to make a slice from.
     * @return A newly allocated slice containing the entire string.
     */
    function toSlice(string memory self) internal pure returns (slice memory) {
        uint256 ptr;
        assembly {
            ptr := add(self, 0x20)
        }
        return slice(bytes(self).length, ptr);
    }

    /*
     * @dev Returns the length of a null-terminated bytes32 string.
     * @param self The value to find the length of.
     * @return The length of the string, from 0 to 32.
     */
    function len(bytes32 self) internal pure returns (uint256) {
        uint256 ret;
        if (self == 0) return 0;
        if (uint256(self) & type(uint128).max == 0) {
            ret += 16;
            self = bytes32(uint256(self) / 0x100000000000000000000000000000000);
        }
        if (uint256(self) & type(uint64).max == 0) {
            ret += 8;
            self = bytes32(uint256(self) / 0x10000000000000000);
        }
        if (uint256(self) & type(uint32).max == 0) {
            ret += 4;
            self = bytes32(uint256(self) / 0x100000000);
        }
        if (uint256(self) & type(uint16).max == 0) {
            ret += 2;
            self = bytes32(uint256(self) / 0x10000);
        }
        if (uint256(self) & type(uint8).max == 0) {
            ret += 1;
        }
        return 32 - ret;
    }

    /*
     * @dev Returns a slice containing the entire bytes32, interpreted as a
     *      null-terminated utf-8 string.
     * @param self The bytes32 value to convert to a slice.
     * @return A new slice containing the value of the input argument up to the
     *         first null.
     */
    function toSliceB32(bytes32 self) internal pure returns (slice memory ret) {
        // Allocate space for `self` in memory, copy it there, and point ret at it
        assembly {
            let ptr := mload(0x40)
            mstore(0x40, add(ptr, 0x20))
            mstore(ptr, self)
            mstore(add(ret, 0x20), ptr)
        }
        ret._len = len(self);
    }

    /*
     * @dev Returns a new slice containing the same data as the current slice.
     * @param self The slice to copy.
     * @return A new slice containing the same data as `self`.
     */
    function copy(slice memory self) internal pure returns (slice memory) {
        return slice(self._len, self._ptr);
    }

    /*
     * @dev Copies a slice to a new string.
     * @param self The slice to copy.
     * @return A newly allocated string containing the slice's text.
     */
    function toString(slice memory self) internal pure returns (string memory) {
        string memory ret = new string(self._len);
        uint256 retptr;
        assembly {
            retptr := add(ret, 32)
        }

        memcpy(retptr, self._ptr, self._len);
        return ret;
    }

    /*
     * @dev Returns the length in runes of the slice. Note that this operation
     *      takes time proportional to the length of the slice; avoid using it
     *      in loops, and call `slice.empty()` if you only need to know whether
     *      the slice is empty or not.
     * @param self The slice to operate on.
     * @return The length of the slice in runes.
     */
    function len(slice memory self) internal pure returns (uint256 l) {
        // Starting at ptr-31 means the LSB will be the byte we care about
        uint256 ptr = self._ptr - 31;
        uint256 end = ptr + self._len;
        for (l = 0; ptr < end; l++) {
            uint8 b;
            assembly {
                b := and(mload(ptr), 0xFF)
            }
            if (b < 0x80) {
                ptr += 1;
            } else if (b < 0xE0) {
                ptr += 2;
            } else if (b < 0xF0) {
                ptr += 3;
            } else if (b < 0xF8) {
                ptr += 4;
            } else if (b < 0xFC) {
                ptr += 5;
            } else {
                ptr += 6;
            }
        }
    }

    /*
     * @dev Returns true if the slice is empty (has a length of 0).
     * @param self The slice to operate on.
     * @return True if the slice is empty, False otherwise.
     */
    function empty(slice memory self) internal pure returns (bool) {
        return self._len == 0;
    }

    /*
     * @dev Returns a positive number if `other` comes lexicographically after
     *      `self`, a negative number if it comes before, or zero if the
     *      contents of the two slices are equal. Comparison is done per-rune,
     *      on unicode codepoints.
     * @param self The first slice to compare.
     * @param other The second slice to compare.
     * @return The result of the comparison.
     */
    function compare(slice memory self, slice memory other) internal pure returns (int256) {
        uint256 shortest = self._len;
        if (other._len < self._len) shortest = other._len;

        uint256 selfptr = self._ptr;
        uint256 otherptr = other._ptr;
        for (uint256 idx = 0; idx < shortest; idx += 32) {
            uint256 a;
            uint256 b;
            assembly {
                a := mload(selfptr)
                b := mload(otherptr)
            }
            if (a != b) {
                // Mask out irrelevant bytes and check again
                uint256 mask = type(uint256).max; // 0xffff...
                if (shortest < 32) {
                    mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
                }
                unchecked {
                    uint256 diff = (a & mask) - (b & mask);
                    if (diff != 0) return int256(diff);
                }
            }
            selfptr += 32;
            otherptr += 32;
        }
        return int256(self._len) - int256(other._len);
    }

    /*
     * @dev Returns true if the two slices contain the same text.
     * @param self The first slice to compare.
     * @param self The second slice to compare.
     * @return True if the slices are equal, false otherwise.
     */
    function equals(slice memory self, slice memory other) internal pure returns (bool) {
        return compare(self, other) == 0;
    }

    /*
     * @dev Extracts the first rune in the slice into `rune`, advancing the
     *      slice to point to the next rune and returning `self`.
     * @param self The slice to operate on.
     * @param rune The slice that will contain the first rune.
     * @return `rune`.
     */
    function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) {
        rune._ptr = self._ptr;

        if (self._len == 0) {
            rune._len = 0;
            return rune;
        }

        uint256 l;
        uint256 b;
        // Load the first byte of the rune into the LSBs of b
        assembly {
            b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF)
        }
        if (b < 0x80) {
            l = 1;
        } else if (b < 0xE0) {
            l = 2;
        } else if (b < 0xF0) {
            l = 3;
        } else {
            l = 4;
        }

        // Check for truncated codepoints
        if (l > self._len) {
            rune._len = self._len;
            self._ptr += self._len;
            self._len = 0;
            return rune;
        }

        self._ptr += l;
        self._len -= l;
        rune._len = l;
        return rune;
    }

    /*
     * @dev Returns the first rune in the slice, advancing the slice to point
     *      to the next rune.
     * @param self The slice to operate on.
     * @return A slice containing only the first rune from `self`.
     */
    function nextRune(slice memory self) internal pure returns (slice memory ret) {
        nextRune(self, ret);
    }

    /*
     * @dev Returns the number of the first codepoint in the slice.
     * @param self The slice to operate on.
     * @return The number of the first codepoint in the slice.
     */
    function ord(slice memory self) internal pure returns (uint256 ret) {
        if (self._len == 0) {
            return 0;
        }

        uint256 word;
        uint256 length;
        uint256 divisor = 2 ** 248;

        // Load the rune into the MSBs of b
        assembly {
            word := mload(mload(add(self, 32)))
        }
        uint256 b = word / divisor;
        if (b < 0x80) {
            ret = b;
            length = 1;
        } else if (b < 0xE0) {
            ret = b & 0x1F;
            length = 2;
        } else if (b < 0xF0) {
            ret = b & 0x0F;
            length = 3;
        } else {
            ret = b & 0x07;
            length = 4;
        }

        // Check for truncated codepoints
        if (length > self._len) {
            return 0;
        }

        for (uint256 i = 1; i < length; i++) {
            divisor = divisor / 256;
            b = (word / divisor) & 0xFF;
            if (b & 0xC0 != 0x80) {
                // Invalid UTF-8 sequence
                return 0;
            }
            ret = (ret * 64) | (b & 0x3F);
        }

        return ret;
    }

    /*
     * @dev Returns the keccak-256 hash of the slice.
     * @param self The slice to hash.
     * @return The hash of the slice.
     */
    function keccak(slice memory self) internal pure returns (bytes32 ret) {
        assembly {
            ret := keccak256(mload(add(self, 32)), mload(self))
        }
    }

    /*
     * @dev Returns true if `self` starts with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        if (self._ptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let length := mload(needle)
            let selfptr := mload(add(self, 0x20))
            let needleptr := mload(add(needle, 0x20))
            equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
        }
        return equal;
    }

    /*
     * @dev If `self` starts with `needle`, `needle` is removed from the
     *      beginning of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
        if (self._len < needle._len) {
            return self;
        }

        bool equal = true;
        if (self._ptr != needle._ptr) {
            assembly {
                let length := mload(needle)
                let selfptr := mload(add(self, 0x20))
                let needleptr := mload(add(needle, 0x20))
                equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
            }
        }

        if (equal) {
            self._len -= needle._len;
            self._ptr += needle._len;
        }

        return self;
    }

    /*
     * @dev Returns true if the slice ends with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function endsWith(slice memory self, slice memory needle) internal pure returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        uint256 selfptr = self._ptr + self._len - needle._len;

        if (selfptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let length := mload(needle)
            let needleptr := mload(add(needle, 0x20))
            equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
        }

        return equal;
    }

    /*
     * @dev If `self` ends with `needle`, `needle` is removed from the
     *      end of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
        if (self._len < needle._len) {
            return self;
        }

        uint256 selfptr = self._ptr + self._len - needle._len;
        bool equal = true;
        if (selfptr != needle._ptr) {
            assembly {
                let length := mload(needle)
                let needleptr := mload(add(needle, 0x20))
                equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
            }
        }

        if (equal) {
            self._len -= needle._len;
        }

        return self;
    }

    // Returns the memory address of the first byte of the first occurrence of
    // `needle` in `self`, or the first byte after `self` if not found.
    function findPtr(uint256 selflen, uint256 selfptr, uint256 needlelen, uint256 needleptr)
        private
        pure
        returns (uint256)
    {
        uint256 ptr = selfptr;
        uint256 idx;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                bytes32 mask;
                if (needlelen > 0) {
                    mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
                }

                bytes32 needledata;
                assembly {
                    needledata := and(mload(needleptr), mask)
                }

                uint256 end = selfptr + selflen - needlelen;
                bytes32 ptrdata;
                assembly {
                    ptrdata := and(mload(ptr), mask)
                }

                while (ptrdata != needledata) {
                    if (ptr >= end) return selfptr + selflen;
                    ptr++;
                    assembly {
                        ptrdata := and(mload(ptr), mask)
                    }
                }
                return ptr;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly {
                    hash := keccak256(needleptr, needlelen)
                }

                for (idx = 0; idx <= selflen - needlelen; idx++) {
                    bytes32 testHash;
                    assembly {
                        testHash := keccak256(ptr, needlelen)
                    }
                    if (hash == testHash) return ptr;
                    ptr += 1;
                }
            }
        }
        return selfptr + selflen;
    }

    // Returns the memory address of the first byte after the last occurrence of
    // `needle` in `self`, or the address of `self` if not found.
    function rfindPtr(uint256 selflen, uint256 selfptr, uint256 needlelen, uint256 needleptr)
        private
        pure
        returns (uint256)
    {
        uint256 ptr;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                bytes32 mask;
                if (needlelen > 0) {
                    mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
                }

                bytes32 needledata;
                assembly {
                    needledata := and(mload(needleptr), mask)
                }

                ptr = selfptr + selflen - needlelen;
                bytes32 ptrdata;
                assembly {
                    ptrdata := and(mload(ptr), mask)
                }

                while (ptrdata != needledata) {
                    if (ptr <= selfptr) return selfptr;
                    ptr--;
                    assembly {
                        ptrdata := and(mload(ptr), mask)
                    }
                }
                return ptr + needlelen;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly {
                    hash := keccak256(needleptr, needlelen)
                }
                ptr = selfptr + (selflen - needlelen);
                while (ptr >= selfptr) {
                    bytes32 testHash;
                    assembly {
                        testHash := keccak256(ptr, needlelen)
                    }
                    if (hash == testHash) return ptr + needlelen;
                    ptr -= 1;
                }
            }
        }
        return selfptr;
    }

    /*
     * @dev Modifies `self` to contain everything from the first occurrence of
     *      `needle` to the end of the slice. `self` is set to the empty slice
     *      if `needle` is not found.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function find(slice memory self, slice memory needle) internal pure returns (slice memory) {
        uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len -= ptr - self._ptr;
        self._ptr = ptr;
        return self;
    }

    /*
     * @dev Modifies `self` to contain the part of the string from the start of
     *      `self` to the end of the first occurrence of `needle`. If `needle`
     *      is not found, `self` is set to the empty slice.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) {
        uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len = ptr - self._ptr;
        return self;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and `token` to everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
        uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = self._ptr;
        token._len = ptr - self._ptr;
        if (ptr == self._ptr + self._len) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
            self._ptr = ptr + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and returning everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` up to the first occurrence of `delim`.
     */
    function split(slice memory self, slice memory needle) internal pure returns (slice memory token) {
        split(self, needle, token);
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and `token` to everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
        uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = ptr;
        token._len = self._len - (ptr - self._ptr);
        if (ptr == self._ptr) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and returning everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` after the last occurrence of `delim`.
     */
    function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) {
        rsplit(self, needle, token);
    }

    /*
     * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return The number of occurrences of `needle` found in `self`.
     */
    function count(slice memory self, slice memory needle) internal pure returns (uint256 cnt) {
        uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
        while (ptr <= self._ptr + self._len) {
            cnt++;
            ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len;
        }
    }

    /*
     * @dev Returns True if `self` contains `needle`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return True if `needle` is found in `self`, false otherwise.
     */
    function contains(slice memory self, slice memory needle) internal pure returns (bool) {
        return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
    }

    /*
     * @dev Returns a newly allocated string containing the concatenation of
     *      `self` and `other`.
     * @param self The first slice to concatenate.
     * @param other The second slice to concatenate.
     * @return The concatenation of the two strings.
     */
    function concat(slice memory self, slice memory other) internal pure returns (string memory) {
        string memory ret = new string(self._len + other._len);
        uint256 retptr;
        assembly {
            retptr := add(ret, 32)
        }
        memcpy(retptr, self._ptr, self._len);
        memcpy(retptr + self._len, other._ptr, other._len);
        return ret;
    }

    /*
     * @dev Joins an array of slices, using `self` as a delimiter, returning a
     *      newly allocated string.
     * @param self The delimiter to use.
     * @param parts A list of slices to join.
     * @return A newly allocated string containing all the slices in `parts`,
     *         joined with `self`.
     */
    function join(slice memory self, slice[] memory parts) internal pure returns (string memory) {
        if (parts.length == 0) return "";

        uint256 length = self._len * (parts.length - 1);
        for (uint256 i = 0; i < parts.length; i++) {
            length += parts[i]._len;
        }

        string memory ret = new string(length);
        uint256 retptr;
        assembly {
            retptr := add(ret, 32)
        }

        for (uint256 i = 0; i < parts.length; i++) {
            memcpy(retptr, parts[i]._ptr, parts[i]._len);
            retptr += parts[i]._len;
            if (i < parts.length - 1) {
                memcpy(retptr, self._ptr, self._len);
                retptr += self._len;
            }
        }

        return ret;
    }

    function stripPrefix(string memory _str, string memory _prefix) internal pure returns (string memory) {
        slice memory s = toSlice(_str);
        slice memory d = toSlice(_prefix);
        return toString(beyond(s, d));
    }

    function stripPrefixSlice(string memory _str, string memory _delim) internal pure returns (slice memory) {
        slice memory s = toSlice(_str);
        slice memory d = toSlice(_delim);
        return beyond(s, d);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../../interfaces/IWETH.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

abstract contract TokenHelper {
    using SafeERC20 for IERC20;

    address internal constant NATIVE = address(0);
    uint256 internal constant LOWER_BOUND_APPROVAL = type(uint96).max / 2; // some tokens use 96 bits for approval

    function _transferIn(address token, address from, uint256 amount) internal {
        if (token == NATIVE) require(msg.value == amount, "eth mismatch");
        else if (amount != 0) IERC20(token).safeTransferFrom(from, address(this), amount);
    }

    function _transferFrom(IERC20 token, address from, address to, uint256 amount) internal {
        if (amount != 0) token.safeTransferFrom(from, to, amount);
    }

    function _transferOut(address token, address to, uint256 amount) internal {
        if (amount == 0) return;
        if (token == NATIVE) {
            (bool success,) = to.call{value: amount}("");
            require(success, "eth send failed");
        } else {
            IERC20(token).safeTransfer(to, amount);
        }
    }

    function _transferOut(address[] memory tokens, address to, uint256[] memory amounts) internal {
        uint256 numTokens = tokens.length;
        require(numTokens == amounts.length, "length mismatch");
        for (uint256 i = 0; i < numTokens;) {
            _transferOut(tokens[i], to, amounts[i]);
            unchecked {
                i++;
            }
        }
    }

    function _selfBalance(address token) internal view returns (uint256) {
        return (token == NATIVE) ? address(this).balance : IERC20(token).balanceOf(address(this));
    }

    function _selfBalance(IERC20 token) internal view returns (uint256) {
        return token.balanceOf(address(this));
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev PLS PAY ATTENTION to tokens that requires the approval to be set to 0 before changing it
    function _safeApprove(address token, address to, uint256 value) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), "Safe Approve");
    }

    function _safeApproveInf(address token, address to) internal {
        if (token == NATIVE) return;
        if (IERC20(token).allowance(address(this), to) < LOWER_BOUND_APPROVAL) {
            _safeApprove(token, to, 0);
            _safeApprove(token, to, type(uint256).max);
        }
    }

    function _wrap_unwrap_ETH(address tokenIn, address tokenOut, uint256 netTokenIn) internal {
        if (tokenIn == NATIVE) IWETH(tokenOut).deposit{value: netTokenIn}();
        else IWETH(tokenIn).withdraw(netTokenIn);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../libraries/math/LogExpMath.sol";
import "../libraries/math/PMath.sol";

import "../StandardizedYield/PYIndex.sol";
import "../libraries/Errors.sol";
import "../libraries/MiniHelpers.sol";

struct MarketState {
    int256 totalPt;
    int256 totalSy;
    int256 totalLp;
    address treasury;
    /// immutable variables ///
    int256 scalarRoot;
    uint256 expiry;
    /// fee data ///
    uint256 lnFeeRateRoot;
    uint256 reserveFeePercent; // base 100
    /// last trade data ///
    uint256 lastLnImpliedRate;
}

// params that are expensive to compute, therefore we pre-compute them
struct MarketPreCompute {
    int256 rateScalar;
    int256 totalAsset;
    int256 rateAnchor;
    int256 feeRate;
}

// solhint-disable ordering
library MarketMathCore {
    using PMath for uint256;
    using PMath for int256;
    using LogExpMath for int256;
    using PYIndexLib for PYIndex;

    int256 internal constant MINIMUM_LIQUIDITY = 10 ** 3;
    int256 internal constant PERCENTAGE_DECIMALS = 100;
    uint256 internal constant DAY = 86_400;
    uint256 internal constant IMPLIED_RATE_TIME = 365 * DAY;

    int256 internal constant MAX_MARKET_PROPORTION = (1e18 * 96) / 100;

    using PMath for uint256;
    using PMath for int256;

    /*///////////////////////////////////////////////////////////////
                UINT FUNCTIONS TO PROXY TO CORE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function addLiquidity(MarketState memory market, uint256 syDesired, uint256 ptDesired, uint256 blockTime)
        internal
        pure
        returns (uint256 lpToReserve, uint256 lpToAccount, uint256 syUsed, uint256 ptUsed)
    {
        (int256 _lpToReserve, int256 _lpToAccount, int256 _syUsed, int256 _ptUsed) =
            addLiquidityCore(market, syDesired.Int(), ptDesired.Int(), blockTime);

        lpToReserve = _lpToReserve.Uint();
        lpToAccount = _lpToAccount.Uint();
        syUsed = _syUsed.Uint();
        ptUsed = _ptUsed.Uint();
    }

    function removeLiquidity(MarketState memory market, uint256 lpToRemove)
        internal
        pure
        returns (uint256 netSyToAccount, uint256 netPtToAccount)
    {
        (int256 _syToAccount, int256 _ptToAccount) = removeLiquidityCore(market, lpToRemove.Int());

        netSyToAccount = _syToAccount.Uint();
        netPtToAccount = _ptToAccount.Uint();
    }

    function swapExactPtForSy(MarketState memory market, PYIndex index, uint256 exactPtToMarket, uint256 blockTime)
        internal
        pure
        returns (uint256 netSyToAccount, uint256 netSyFee, uint256 netSyToReserve)
    {
        (int256 _netSyToAccount, int256 _netSyFee, int256 _netSyToReserve) =
            executeTradeCore(market, index, exactPtToMarket.neg(), blockTime);

        netSyToAccount = _netSyToAccount.Uint();
        netSyFee = _netSyFee.Uint();
        netSyToReserve = _netSyToReserve.Uint();
    }

    function swapSyForExactPt(MarketState memory market, PYIndex index, uint256 exactPtToAccount, uint256 blockTime)
        internal
        pure
        returns (uint256 netSyToMarket, uint256 netSyFee, uint256 netSyToReserve)
    {
        (int256 _netSyToAccount, int256 _netSyFee, int256 _netSyToReserve) =
            executeTradeCore(market, index, exactPtToAccount.Int(), blockTime);

        netSyToMarket = _netSyToAccount.neg().Uint();
        netSyFee = _netSyFee.Uint();
        netSyToReserve = _netSyToReserve.Uint();
    }

    /*///////////////////////////////////////////////////////////////
                    CORE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    function addLiquidityCore(MarketState memory market, int256 syDesired, int256 ptDesired, uint256 blockTime)
        internal
        pure
        returns (int256 lpToReserve, int256 lpToAccount, int256 syUsed, int256 ptUsed)
    {
        /// ------------------------------------------------------------
        /// CHECKS
        /// ------------------------------------------------------------
        if (syDesired == 0 || ptDesired == 0) revert Errors.MarketZeroAmountsInput();
        if (MiniHelpers.isExpired(market.expiry, blockTime)) revert Errors.MarketExpired();

        /// ------------------------------------------------------------
        /// MATH
        /// ------------------------------------------------------------
        if (market.totalLp == 0) {
            lpToAccount = PMath.sqrt((syDesired * ptDesired).Uint()).Int() - MINIMUM_LIQUIDITY;
            lpToReserve = MINIMUM_LIQUIDITY;
            syUsed = syDesired;
            ptUsed = ptDesired;
        } else {
            int256 netLpByPt = (ptDesired * market.totalLp) / market.totalPt;
            int256 netLpBySy = (syDesired * market.totalLp) / market.totalSy;
            if (netLpByPt < netLpBySy) {
                lpToAccount = netLpByPt;
                ptUsed = ptDesired;
                syUsed = (market.totalSy * lpToAccount).rawDivUp(market.totalLp);
            } else {
                lpToAccount = netLpBySy;
                syUsed = syDesired;
                ptUsed = (market.totalPt * lpToAccount).rawDivUp(market.totalLp);
            }
        }

        if (lpToAccount <= 0 || syUsed <= 0 || ptUsed <= 0) revert Errors.MarketZeroAmountsOutput();

        /// ------------------------------------------------------------
        /// WRITE
        /// ------------------------------------------------------------
        market.totalSy += syUsed;
        market.totalPt += ptUsed;
        market.totalLp += lpToAccount + lpToReserve;
    }

    function removeLiquidityCore(MarketState memory market, int256 lpToRemove)
        internal
        pure
        returns (int256 netSyToAccount, int256 netPtToAccount)
    {
        /// ------------------------------------------------------------
        /// CHECKS
        /// ------------------------------------------------------------
        if (lpToRemove == 0) revert Errors.MarketZeroAmountsInput();

        /// ------------------------------------------------------------
        /// MATH
        /// ------------------------------------------------------------
        netSyToAccount = (lpToRemove * market.totalSy) / market.totalLp;
        netPtToAccount = (lpToRemove * market.totalPt) / market.totalLp;

        if (netSyToAccount == 0 && netPtToAccount == 0) revert Errors.MarketZeroAmountsOutput();

        /// ------------------------------------------------------------
        /// WRITE
        /// ------------------------------------------------------------
        market.totalLp = market.totalLp.subNoNeg(lpToRemove);
        market.totalPt = market.totalPt.subNoNeg(netPtToAccount);
        market.totalSy = market.totalSy.subNoNeg(netSyToAccount);
    }

    function executeTradeCore(MarketState memory market, PYIndex index, int256 netPtToAccount, uint256 blockTime)
        internal
        pure
        returns (int256 netSyToAccount, int256 netSyFee, int256 netSyToReserve)
    {
        /// ------------------------------------------------------------
        /// CHECKS
        /// ------------------------------------------------------------
        if (MiniHelpers.isExpired(market.expiry, blockTime)) revert Errors.MarketExpired();
        if (market.totalPt <= netPtToAccount) {
            revert Errors.MarketInsufficientPtForTrade(market.totalPt, netPtToAccount);
        }

        /// ------------------------------------------------------------
        /// MATH
        /// ------------------------------------------------------------
        MarketPreCompute memory comp = getMarketPreCompute(market, index, blockTime);

        (netSyToAccount, netSyFee, netSyToReserve) = calcTrade(market, comp, index, netPtToAccount);

        /// ------------------------------------------------------------
        /// WRITE
        /// ------------------------------------------------------------
        _setNewMarketStateTrade(market, comp, index, netPtToAccount, netSyToAccount, netSyToReserve, blockTime);
    }

    function getMarketPreCompute(MarketState memory market, PYIndex index, uint256 blockTime)
        internal
        pure
        returns (MarketPreCompute memory res)
    {
        if (MiniHelpers.isExpired(market.expiry, blockTime)) revert Errors.MarketExpired();

        uint256 timeToExpiry = market.expiry - blockTime;

        res.rateScalar = _getRateScalar(market, timeToExpiry);
        res.totalAsset = index.syToAsset(market.totalSy);

        if (market.totalPt == 0 || res.totalAsset == 0) {
            revert Errors.MarketZeroTotalPtOrTotalAsset(market.totalPt, res.totalAsset);
        }

        res.rateAnchor =
            _getRateAnchor(market.totalPt, market.lastLnImpliedRate, res.totalAsset, res.rateScalar, timeToExpiry);
        res.feeRate = _getExchangeRateFromImpliedRate(market.lnFeeRateRoot, timeToExpiry);
    }

    function calcTrade(MarketState memory market, MarketPreCompute memory comp, PYIndex index, int256 netPtToAccount)
        internal
        pure
        returns (int256 netSyToAccount, int256 netSyFee, int256 netSyToReserve)
    {
        int256 preFeeExchangeRate =
            _getExchangeRate(market.totalPt, comp.totalAsset, comp.rateScalar, comp.rateAnchor, netPtToAccount);

        int256 preFeeAssetToAccount = netPtToAccount.divDown(preFeeExchangeRate).neg();
        int256 fee = comp.feeRate;

        if (netPtToAccount > 0) {
            int256 postFeeExchangeRate = preFeeExchangeRate.divDown(fee);
            if (postFeeExchangeRate < PMath.IONE) revert Errors.MarketExchangeRateBelowOne(postFeeExchangeRate);

            fee = preFeeAssetToAccount.mulDown(PMath.IONE - fee);
        } else {
            fee = ((preFeeAssetToAccount * (PMath.IONE - fee)) / fee).neg();
        }

        int256 netAssetToReserve = (fee * market.reserveFeePercent.Int()) / PERCENTAGE_DECIMALS;
        int256 netAssetToAccount = preFeeAssetToAccount - fee;

        netSyToAccount =
            netAssetToAccount < 0 ? index.assetToSyUp(netAssetToAccount) : index.assetToSy(netAssetToAccount);
        netSyFee = index.assetToSy(fee);
        netSyToReserve = index.assetToSy(netAssetToReserve);
    }

    function _setNewMarketStateTrade(
        MarketState memory market,
        MarketPreCompute memory comp,
        PYIndex index,
        int256 netPtToAccount,
        int256 netSyToAccount,
        int256 netSyToReserve,
        uint256 blockTime
    ) internal pure {
        uint256 timeToExpiry = market.expiry - blockTime;

        market.totalPt = market.totalPt.subNoNeg(netPtToAccount);
        market.totalSy = market.totalSy.subNoNeg(netSyToAccount + netSyToReserve);

        market.lastLnImpliedRate = _getLnImpliedRate(
            market.totalPt, index.syToAsset(market.totalSy), comp.rateScalar, comp.rateAnchor, timeToExpiry
        );

        if (market.lastLnImpliedRate == 0) revert Errors.MarketZeroLnImpliedRate();
    }

    function _getRateAnchor(
        int256 totalPt,
        uint256 lastLnImpliedRate,
        int256 totalAsset,
        int256 rateScalar,
        uint256 timeToExpiry
    ) internal pure returns (int256 rateAnchor) {
        int256 newExchangeRate = _getExchangeRateFromImpliedRate(lastLnImpliedRate, timeToExpiry);

        if (newExchangeRate < PMath.IONE) revert Errors.MarketExchangeRateBelowOne(newExchangeRate);

        {
            int256 proportion = totalPt.divDown(totalPt + totalAsset);

            int256 lnProportion = _logProportion(proportion);

            rateAnchor = newExchangeRate - lnProportion.divDown(rateScalar);
        }
    }

    /// @notice Calculates the current market implied rate.
    /// @return lnImpliedRate the implied rate
    function _getLnImpliedRate(
        int256 totalPt,
        int256 totalAsset,
        int256 rateScalar,
        int256 rateAnchor,
        uint256 timeToExpiry
    ) internal pure returns (uint256 lnImpliedRate) {
        // This will check for exchange rates < PMath.IONE
        int256 exchangeRate = _getExchangeRate(totalPt, totalAsset, rateScalar, rateAnchor, 0);

        // exchangeRate >= 1 so its ln >= 0
        uint256 lnRate = exchangeRate.ln().Uint();

        lnImpliedRate = (lnRate * IMPLIED_RATE_TIME) / timeToExpiry;
    }

    /// @notice Converts an implied rate to an exchange rate given a time to expiry. The
    /// formula is E = e^rt
    function _getExchangeRateFromImpliedRate(uint256 lnImpliedRate, uint256 timeToExpiry)
        internal
        pure
        returns (int256 exchangeRate)
    {
        uint256 rt = (lnImpliedRate * timeToExpiry) / IMPLIED_RATE_TIME;

        exchangeRate = LogExpMath.exp(rt.Int());
    }

    function _getExchangeRate(
        int256 totalPt,
        int256 totalAsset,
        int256 rateScalar,
        int256 rateAnchor,
        int256 netPtToAccount
    ) internal pure returns (int256 exchangeRate) {
        int256 numerator = totalPt.subNoNeg(netPtToAccount);

        int256 proportion = (numerator.divDown(totalPt + totalAsset));

        if (proportion > MAX_MARKET_PROPORTION) {
            revert Errors.MarketProportionTooHigh(proportion, MAX_MARKET_PROPORTION);
        }

        int256 lnProportion = _logProportion(proportion);

        exchangeRate = lnProportion.divDown(rateScalar) + rateAnchor;

        if (exchangeRate < PMath.IONE) revert Errors.MarketExchangeRateBelowOne(exchangeRate);
    }

    function _logProportion(int256 proportion) internal pure returns (int256 res) {
        if (proportion == PMath.IONE) revert Errors.MarketProportionMustNotEqualOne();

        int256 logitP = proportion.divDown(PMath.IONE - proportion);

        res = logitP.ln();
    }

    function _getRateScalar(MarketState memory market, uint256 timeToExpiry) internal pure returns (int256 rateScalar) {
        rateScalar = (market.scalarRoot * IMPLIED_RATE_TIME.Int()) / timeToExpiry.Int();
        if (rateScalar <= 0) revert Errors.MarketRateScalarBelowZero(rateScalar);
    }

    function setInitialLnImpliedRate(MarketState memory market, PYIndex index, int256 initialAnchor, uint256 blockTime)
        internal
        pure
    {
        /// ------------------------------------------------------------
        /// CHECKS
        /// ------------------------------------------------------------
        if (MiniHelpers.isExpired(market.expiry, blockTime)) revert Errors.MarketExpired();

        /// ------------------------------------------------------------
        /// MATH
        /// ------------------------------------------------------------
        int256 totalAsset = index.syToAsset(market.totalSy);
        uint256 timeToExpiry = market.expiry - blockTime;
        int256 rateScalar = _getRateScalar(market, timeToExpiry);

        /// ------------------------------------------------------------
        /// WRITE
        /// ------------------------------------------------------------
        market.lastLnImpliedRate =
            _getLnImpliedRate(market.totalPt, totalAsset, rateScalar, initialAnchor, timeToExpiry);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../libraries/Errors.sol";

/// Adapted from UniswapV3's Oracle

library OracleLib {
    struct Observation {
        uint32 blockTimestamp;
        uint216 lnImpliedRateCumulative;
        bool initialized;
        // 1 SLOT = 256 bits
    }

    function transform(Observation memory last, uint32 blockTimestamp, uint96 lnImpliedRate)
        public
        pure
        returns (Observation memory)
    {
        return Observation({
            blockTimestamp: blockTimestamp,
            lnImpliedRateCumulative: last.lnImpliedRateCumulative + uint216(lnImpliedRate)
                * (blockTimestamp - last.blockTimestamp),
            initialized: true
        });
    }

    function initialize(Observation[65_535] storage self, uint32 time)
        public
        returns (uint16 cardinality, uint16 cardinalityNext)
    {
        self[0] = Observation({blockTimestamp: time, lnImpliedRateCumulative: 0, initialized: true});
        return (1, 1);
    }

    function write(
        Observation[65_535] storage self,
        uint16 index,
        uint32 blockTimestamp,
        uint96 lnImpliedRate,
        uint16 cardinality,
        uint16 cardinalityNext
    ) public returns (uint16 indexUpdated, uint16 cardinalityUpdated) {
        Observation memory last = self[index];

        // early return if we've already written an observation this block
        if (last.blockTimestamp == blockTimestamp) return (index, cardinality);

        // if the conditions are right, we can bump the cardinality
        if (cardinalityNext > cardinality && index == (cardinality - 1)) {
            cardinalityUpdated = cardinalityNext;
        } else {
            cardinalityUpdated = cardinality;
        }

        indexUpdated = (index + 1) % cardinalityUpdated;
        self[indexUpdated] = transform(last, blockTimestamp, lnImpliedRate);
    }

    function grow(Observation[65_535] storage self, uint16 current, uint16 next) public returns (uint16) {
        if (current == 0) revert Errors.OracleUninitialized();
        // no-op if the passed next value isn't greater than the current next value
        if (next <= current) return current;
        // store in each slot to prevent fresh SSTOREs in swaps
        // this data will not be used because the initialized boolean is still false
        for (uint16 i = current; i != next;) {
            self[i].blockTimestamp = 1;
            unchecked {
                ++i;
            }
        }
        return next;
    }

    function binarySearch(Observation[65_535] storage self, uint32 target, uint16 index, uint16 cardinality)
        public
        view
        returns (Observation memory beforeOrAt, Observation memory atOrAfter)
    {
        uint256 l = (index + 1) % cardinality; // oldest observation
        uint256 r = l + cardinality - 1; // newest observation
        uint256 i;
        while (true) {
            i = (l + r) / 2;

            beforeOrAt = self[i % cardinality];

            // we've landed on an uninitialized observation, keep searching higher (more recently)
            if (!beforeOrAt.initialized) {
                l = i + 1;
                continue;
            }

            atOrAfter = self[(i + 1) % cardinality];

            bool targetAtOrAfter = beforeOrAt.blockTimestamp <= target;

            // check if we've found the answer!
            if (targetAtOrAfter && target <= atOrAfter.blockTimestamp) break;

            if (!targetAtOrAfter) r = i - 1;
            else l = i + 1;
        }
    }

    function getSurroundingObservations(
        Observation[65_535] storage self,
        uint32 target,
        uint96 lnImpliedRate,
        uint16 index,
        uint16 cardinality
    ) public view returns (Observation memory beforeOrAt, Observation memory atOrAfter) {
        // optimistically set before to the newest observation
        beforeOrAt = self[index];

        // if the target is chronologically at or after the newest observation, we can early return
        if (beforeOrAt.blockTimestamp <= target) {
            if (beforeOrAt.blockTimestamp == target) {
                // if newest observation equals target, we're in the same block, so we can ignore atOrAfter
                return (beforeOrAt, atOrAfter);
            } else {
                // otherwise, we need to transform
                return (beforeOrAt, transform(beforeOrAt, target, lnImpliedRate));
            }
        }

        // now, set beforeOrAt to the oldest observation
        beforeOrAt = self[(index + 1) % cardinality];
        if (!beforeOrAt.initialized) beforeOrAt = self[0];

        // ensure that the target is chronologically at or after the oldest observation
        if (target < beforeOrAt.blockTimestamp) revert Errors.OracleTargetTooOld(target, beforeOrAt.blockTimestamp);

        // if we've reached this point, we have to binary search
        return binarySearch(self, target, index, cardinality);
    }

    function observeSingle(
        Observation[65_535] storage self,
        uint32 time,
        uint32 secondsAgo,
        uint96 lnImpliedRate,
        uint16 index,
        uint16 cardinality
    ) public view returns (uint216 lnImpliedRateCumulative) {
        if (secondsAgo == 0) {
            Observation memory last = self[index];
            if (last.blockTimestamp != time) {
                return transform(last, time, lnImpliedRate).lnImpliedRateCumulative;
            }
            return last.lnImpliedRateCumulative;
        }

        uint32 target = time - secondsAgo;

        (Observation memory beforeOrAt, Observation memory atOrAfter) =
            getSurroundingObservations(self, target, lnImpliedRate, index, cardinality);

        if (target == beforeOrAt.blockTimestamp) {
            // we're at the left boundary
            return beforeOrAt.lnImpliedRateCumulative;
        } else if (target == atOrAfter.blockTimestamp) {
            // we're at the right boundary
            return atOrAfter.lnImpliedRateCumulative;
        } else {
            // we're in the middle
            return (beforeOrAt.lnImpliedRateCumulative
                    + uint216(
                        (uint256(atOrAfter.lnImpliedRateCumulative - beforeOrAt.lnImpliedRateCumulative)
                                * (target - beforeOrAt.blockTimestamp))
                            / (atOrAfter.blockTimestamp - beforeOrAt.blockTimestamp)
                    ));
        }
    }

    function observe(
        Observation[65_535] storage self,
        uint32 time,
        uint32[] memory secondsAgos,
        uint96 lnImpliedRate,
        uint16 index,
        uint16 cardinality
    ) public view returns (uint216[] memory lnImpliedRateCumulative) {
        if (cardinality == 0) revert Errors.OracleZeroCardinality();

        lnImpliedRateCumulative = new uint216[](secondsAgos.length);
        for (uint256 i = 0; i < lnImpliedRateCumulative.length; ++i) {
            lnImpliedRateCumulative[i] = observeSingle(self, time, secondsAgos[i], lnImpliedRate, index, cardinality);
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../../interfaces/IPGauge.sol";
import "../../interfaces/IPGaugeController.sol";
import "../../interfaces/IStandardizedYield.sol";

import "../RewardManager/RewardManager.sol";

abstract contract PendleGauge is RewardManager, IPGauge {
    using ArrayLib for address[];

    address private immutable SY;
    address internal immutable PENDLE;
    address internal immutable gaugeController;

    constructor(address _SY, address _gaugeController) {
        SY = _SY;
        gaugeController = _gaugeController;
        PENDLE = IPGaugeController(gaugeController).pendle();
    }

    function _redeemRewards(address user) internal virtual returns (uint256[] memory rewardsOut) {
        _updateAndDistributeRewards(user);
        rewardsOut = _doTransferOutRewards(user, user);
        emit RedeemRewards(user, rewardsOut);
    }

    function _redeemExternalReward() internal virtual override {
        IStandardizedYield(SY).claimRewards(address(this));
        IPGaugeController(gaugeController).redeemMarketReward();
    }

    function _getRewardTokens() internal view virtual override returns (address[] memory) {
        address[] memory SYRewards = IStandardizedYield(SY).getRewardTokens();
        if (SYRewards.contains(PENDLE)) return SYRewards;
        return SYRewards.append(PENDLE);
    }

    function _beforeTokenTransfer(address from, address to, uint256) internal virtual {
        _updateAndDistributeRewardsForTwo(from, to);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "./RewardManagerAbstract.sol";

/// NOTE: This RewardManager is used with SY & YTv2 & PendleMarket. For YTv1, it will use RewardManagerAbstract
/// NOTE: RewardManager must not have duplicated rewardTokens
abstract contract RewardManager is RewardManagerAbstract {
    using PMath for uint256;
    using ArrayLib for uint256[];

    uint256 public lastRewardBlock;

    mapping(address => RewardState) public rewardState;

    function _updateRewardIndex()
        internal
        virtual
        override
        returns (address[] memory tokens, uint256[] memory indexes)
    {
        tokens = _getRewardTokens();
        indexes = new uint256[](tokens.length);

        if (tokens.length == 0) return (tokens, indexes);

        if (lastRewardBlock != block.number) {
            // if we have not yet update the index for this block
            lastRewardBlock = block.number;

            uint256 totalShares = _rewardSharesTotal();

            _redeemExternalReward();

            for (uint256 i = 0; i < tokens.length; ++i) {
                address token = tokens[i];

                // the entire token balance of the contract must be the rewards of the contract

                RewardState memory _state = rewardState[token];
                (uint256 lastBalance, uint256 index) = (_state.lastBalance, _state.index);

                uint256 accrued = _selfBalance(tokens[i]) - lastBalance;

                if (index == 0) index = INITIAL_REWARD_INDEX;
                if (totalShares != 0) index += accrued.divDown(totalShares);

                rewardState[token] =
                    RewardState({index: index.Uint128(), lastBalance: (lastBalance + accrued).Uint128()});
                indexes[i] = index;
            }
        } else {
            for (uint256 i = 0; i < tokens.length; i++) {
                indexes[i] = rewardState[tokens[i]].index;
            }
        }
    }

    /// @dev this function doesn't need redeemExternal since redeemExternal is bundled in updateRewardIndex
    /// @dev this function also has to update rewardState.lastBalance
    function _doTransferOutRewards(address user, address receiver)
        internal
        virtual
        override
        returns (uint256[] memory rewardAmounts)
    {
        address[] memory tokens = _getRewardTokens();
        rewardAmounts = new uint256[](tokens.length);
        for (uint256 i = 0; i < tokens.length; i++) {
            rewardAmounts[i] = userReward[tokens[i]][user].accrued;
            if (rewardAmounts[i] != 0) {
                userReward[tokens[i]][user].accrued = 0;
                rewardState[tokens[i]].lastBalance -= rewardAmounts[i].Uint128();
                _transferOut(tokens[i], receiver, rewardAmounts[i]);
            }
        }
    }

    function _getRewardTokens() internal view virtual returns (address[] memory);

    function _rewardSharesTotal() internal view virtual returns (uint256);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../../interfaces/IRewardManager.sol";

import "../libraries/ArrayLib.sol";
import "../libraries/TokenHelper.sol";
import "../libraries/math/PMath.sol";

import "./RewardManagerAbstract.sol";

/// NOTE: RewardManager must not have duplicated rewardTokens
abstract contract RewardManagerAbstract is IRewardManager, TokenHelper {
    using PMath for uint256;

    uint256 internal constant INITIAL_REWARD_INDEX = 1;

    struct RewardState {
        uint128 index;
        uint128 lastBalance;
    }

    struct UserReward {
        uint128 index;
        uint128 accrued;
    }

    // [token] => [user] => (index,accrued)
    mapping(address => mapping(address => UserReward)) public userReward;

    function _updateAndDistributeRewards(address user) internal virtual {
        _updateAndDistributeRewardsForTwo(user, address(0));
    }

    function _updateAndDistributeRewardsForTwo(address user1, address user2) internal virtual {
        (address[] memory tokens, uint256[] memory indexes) = _updateRewardIndex();
        if (tokens.length == 0) return;

        if (user1 != address(0) && user1 != address(this)) _distributeRewardsPrivate(user1, tokens, indexes);
        if (user2 != address(0) && user2 != address(this)) _distributeRewardsPrivate(user2, tokens, indexes);
    }

    // should only be callable from `_updateAndDistributeRewardsForTwo` to guarantee user != address(0) && user !=
    // address(this)
    function _distributeRewardsPrivate(address user, address[] memory tokens, uint256[] memory indexes) private {
        assert(user != address(0) && user != address(this));

        uint256 userShares = _rewardSharesUser(user);

        for (uint256 i = 0; i < tokens.length; ++i) {
            address token = tokens[i];
            uint256 index = indexes[i];
            uint256 userIndex = userReward[token][user].index;

            if (userIndex == 0) {
                userIndex = INITIAL_REWARD_INDEX.Uint128();
            }

            if (userIndex == index || index == 0) continue;

            uint256 deltaIndex = index - userIndex;
            uint256 rewardDelta = userShares.mulDown(deltaIndex);
            uint256 rewardAccrued = userReward[token][user].accrued + rewardDelta;

            userReward[token][user] = UserReward({index: index.Uint128(), accrued: rewardAccrued.Uint128()});
        }
    }

    function _updateRewardIndex() internal virtual returns (address[] memory tokens, uint256[] memory indexes);

    function _redeemExternalReward() internal virtual;

    function _doTransferOutRewards(address user, address receiver)
        internal
        virtual
        returns (uint256[] memory rewardAmounts);

    function _rewardSharesUser(address user) internal view virtual returns (uint256);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "../../interfaces/IPPrincipalToken.sol";
import "../../interfaces/IPYieldToken.sol";

import "../libraries/math/PMath.sol";
import "./SYUtils.sol";

type PYIndex is uint256;

library PYIndexLib {
    using PMath for uint256;
    using PMath for int256;

    function newIndex(IPYieldToken YT) internal returns (PYIndex) {
        return PYIndex.wrap(YT.pyIndexCurrent());
    }

    function syToAsset(PYIndex index, uint256 syAmount) internal pure returns (uint256) {
        return SYUtils.syToAsset(PYIndex.unwrap(index), syAmount);
    }

    function assetToSy(PYIndex index, uint256 assetAmount) internal pure returns (uint256) {
        return SYUtils.assetToSy(PYIndex.unwrap(index), assetAmount);
    }

    function assetToSyUp(PYIndex index, uint256 assetAmount) internal pure returns (uint256) {
        return SYUtils.assetToSyUp(PYIndex.unwrap(index), assetAmount);
    }

    function syToAssetUp(PYIndex index, uint256 syAmount) internal pure returns (uint256) {
        uint256 _index = PYIndex.unwrap(index);
        return SYUtils.syToAssetUp(_index, syAmount);
    }

    function syToAsset(PYIndex index, int256 syAmount) internal pure returns (int256) {
        int256 sign = syAmount < 0 ? int256(-1) : int256(1);
        return sign * (SYUtils.syToAsset(PYIndex.unwrap(index), syAmount.abs())).Int();
    }

    function assetToSy(PYIndex index, int256 assetAmount) internal pure returns (int256) {
        int256 sign = assetAmount < 0 ? int256(-1) : int256(1);
        return sign * (SYUtils.assetToSy(PYIndex.unwrap(index), assetAmount.abs())).Int();
    }

    function assetToSyUp(PYIndex index, int256 assetAmount) internal pure returns (int256) {
        int256 sign = assetAmount < 0 ? int256(-1) : int256(1);
        return sign * (SYUtils.assetToSyUp(PYIndex.unwrap(index), assetAmount.abs())).Int();
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library SYUtils {
    uint256 internal constant ONE = 1e18;

    function syToAsset(uint256 exchangeRate, uint256 syAmount) internal pure returns (uint256) {
        return (syAmount * exchangeRate) / ONE;
    }

    function syToAssetUp(uint256 exchangeRate, uint256 syAmount) internal pure returns (uint256) {
        return (syAmount * exchangeRate + ONE - 1) / ONE;
    }

    function assetToSy(uint256 exchangeRate, uint256 assetAmount) internal pure returns (uint256) {
        return (assetAmount * ONE) / exchangeRate;
    }

    function assetToSyUp(uint256 exchangeRate, uint256 assetAmount) internal pure returns (uint256) {
        return (assetAmount * ONE + exchangeRate - 1) / exchangeRate;
    }
}

File 23 of 33 : IPGauge.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IPGauge {
    event RedeemRewards(address indexed user, uint256[] rewardsOut);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IPGaugeController {
    event MarketClaimReward(address indexed market, uint256 amount);

    // deprecated from MarketV7 onwards
    event ReceiveVotingResults(uint128 indexed wTime, address[] markets, uint256[] pendleAmounts);

    // deprecated from MarketV7 onwards
    event UpdateMarketReward(address indexed market, uint256 pendlePerSec, uint256 incentiveEndsAt);

    event UpdateMarketRewardV2(address indexed market, uint128 pendlePerSec, uint128 incentiveEndsAt);

    event WhitelistMarketSet(address indexed market, bool isWhitelisted);

    function setRewardDatas(
        address[] calldata markets,
        uint128[] calldata pendlePerSecs,
        uint128[] calldata incentiveEndsAts
    ) external;

    function withdrawPendle(uint256 amount) external;

    function pendle() external view returns (address);

    function redeemMarketReward() external;

    function rewardData(address market)
        external
        view
        returns (uint128 pendlePerSec, uint128 accumulatedPendle, uint128 lastUpdated, uint128 incentiveEndsAt);

    function isWhitelisted(address market) external view returns (bool);

    function whitelistMarkets(address[] memory markets, bool _isWhitelisted) external;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IPInterestManagerYT {
    event CollectInterestFee(uint256 amountInterestFee);

    function userInterest(address user) external view returns (uint128 lastPYIndex, uint128 accruedInterest);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "../core/Market/MarketMathCore.sol";
import "./IPGauge.sol";
import "./IPPrincipalToken.sol";
import "./IPYieldToken.sol";
import "./IStandardizedYield.sol";

interface IPMarket is IPGauge, IERC20Metadata {
    event Mint(address indexed receiver, uint256 netLpMinted, uint256 netSyUsed, uint256 netPtUsed);

    event Burn(
        address indexed receiverSy, address indexed receiverPt, uint256 netLpBurned, uint256 netSyOut, uint256 netPtOut
    );

    event Swap(
        address indexed caller,
        address indexed receiver,
        int256 netPtOut,
        int256 netSyOut,
        uint256 netSyFee,
        uint256 netSyToReserve
    );

    event UpdateImpliedRate(uint256 indexed timestamp, uint256 lnLastImpliedRate);

    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew
    );

    function mint(address receiver, uint256 netSyDesired, uint256 netPtDesired)
        external
        returns (uint256 netLpOut, uint256 netSyUsed, uint256 netPtUsed);

    function burn(address receiverSy, address receiverPt, uint256 netLpToBurn)
        external
        returns (uint256 netSyOut, uint256 netPtOut);

    function swapExactPtForSy(address receiver, uint256 exactPtIn, bytes calldata data)
        external
        returns (uint256 netSyOut, uint256 netSyFee);

    function swapSyForExactPt(address receiver, uint256 exactPtOut, bytes calldata data)
        external
        returns (uint256 netSyIn, uint256 netSyFee);

    function redeemRewards(address user) external returns (uint256[] memory);

    function readState(address router) external view returns (MarketState memory market);

    function observe(uint32[] memory secondsAgos) external view returns (uint216[] memory lnImpliedRateCumulative);

    function increaseObservationsCardinalityNext(uint16 cardinalityNext) external;

    function readTokens() external view returns (IStandardizedYield _SY, IPPrincipalToken _PT, IPYieldToken _YT);

    function getRewardTokens() external view returns (address[] memory);

    function isExpired() external view returns (bool);

    function factory() external view returns (address);

    function expiry() external view returns (uint256);

    function observations(uint256 index)
        external
        view
        returns (uint32 blockTimestamp, uint216 lnImpliedRateCumulative, bool initialized);

    function _storage()
        external
        view
        returns (
            int128 totalPt,
            int128 totalSy,
            uint96 lastLnImpliedRate,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext
        );

    function getNonOverrideLnFeeRateRoot() external view returns (uint80);

    function VERSION() external pure returns (uint256);

    function reentrancyGuardEntered() external view returns (bool);

    /*///////////////////////////////////////////////////////////////
                            LEGACY FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /// @dev Kept for backward compatibility
    /// @dev From version 7, this function returns `totalSupply()`.
    function totalActiveSupply() external view returns (uint256);

    /// @dev Kept for backward compatibility
    /// @dev From version 7, this function returns `balanceOf(user)`.
    function activeBalance(address user) external view returns (uint256);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IPMarketFactory {
    event SetOverriddenFee(address indexed router, address indexed market, uint80 lnFeeRateRoot);

    event CreateNewMarket(
        address indexed market, address indexed PT, int256 scalarRoot, int256 initialAnchor, uint256 lnFeeRateRoot
    );

    event NewTreasuryAndFeeReserve(address indexed treasury, uint8 reserveFeePercent);

    function VERSION() external pure returns (uint256);

    function isValidMarket(address market) external view returns (bool);

    // If this is changed, change the readState function in market as well
    function getMarketConfig(address market, address router)
        external
        view
        returns (address treasury, uint80 overriddenFee, uint8 reserveFeePercent);

    function createNewMarket(address PT, int256 scalarRoot, int256 initialAnchor, uint80 lnFeeRateRoot)
        external
        returns (address market);

    function setOverriddenFee(address router, address market, uint80 newFee) external;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IPMarketSwapCallback {
    function swapCallback(int256 ptToAccount, int256 syToAccount, bytes calldata data) external;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IPPrincipalToken is IERC20Metadata {
    function burnByYT(address user, uint256 amount) external;

    function mintByYT(address user, uint256 amount) external;

    function initialize(address _YT) external;

    function SY() external view returns (address);

    function YT() external view returns (address);

    function factory() external view returns (address);

    function expiry() external view returns (uint256);

    function isExpired() external view returns (bool);

    function VERSION() external pure returns (uint256);

    function reentrancyGuardEntered() external view returns (bool);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "./IPInterestManagerYT.sol";
import "./IRewardManager.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IPYieldToken is IERC20Metadata, IRewardManager, IPInterestManagerYT {
    event NewInterestIndex(uint256 indexed newIndex);

    event Mint(
        address indexed caller,
        address indexed receiverPT,
        address indexed receiverYT,
        uint256 amountSyToMint,
        uint256 amountPYOut
    );

    event Burn(address indexed caller, address indexed receiver, uint256 amountPYToRedeem, uint256 amountSyOut);

    event RedeemRewards(address indexed user, uint256[] amountRewardsOut);

    event RedeemInterest(address indexed user, uint256 interestOut);

    event CollectRewardFee(address indexed rewardToken, uint256 amountRewardFee);

    function mintPY(address receiverPT, address receiverYT) external returns (uint256 amountPYOut);

    function redeemPY(address receiver) external returns (uint256 amountSyOut);

    function redeemPYMulti(address[] calldata receivers, uint256[] calldata amountPYToRedeems)
        external
        returns (uint256[] memory amountSyOuts);

    function redeemDueInterestAndRewards(address user, bool redeemInterest, bool redeemRewards)
        external
        returns (uint256 interestOut, uint256[] memory rewardsOut);

    function rewardIndexesCurrent() external returns (uint256[] memory);

    function pyIndexCurrent() external returns (uint256);

    function pyIndexStored() external view returns (uint256);

    function getRewardTokens() external view returns (address[] memory);

    function SY() external view returns (address);

    function PT() external view returns (address);

    function factory() external view returns (address);

    function expiry() external view returns (uint256);

    function isExpired() external view returns (bool);

    function doCacheIndexSameBlock() external view returns (bool);

    function pyIndexLastUpdatedBlock() external view returns (uint128);

    function reentrancyGuardEntered() external view returns (bool);

    function VERSION() external pure returns (uint256);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IRewardManager {
    function userReward(address token, address user) external view returns (uint128 index, uint128 accrued);
}

// SPDX-License-Identifier: GPL-3.0-or-later
/*
 * 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.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IStandardizedYield is IERC20Metadata {
    /// @dev Emitted when any base tokens is deposited to mint shares
    event Deposit(
        address indexed caller,
        address indexed receiver,
        address indexed tokenIn,
        uint256 amountDeposited,
        uint256 amountSyOut
    );

    /// @dev Emitted when any shares are redeemed for base tokens
    event Redeem(
        address indexed caller,
        address indexed receiver,
        address indexed tokenOut,
        uint256 amountSyToRedeem,
        uint256 amountTokenOut
    );

    /// @dev check `assetInfo()` for more information
    enum AssetType {
        TOKEN,
        LIQUIDITY
    }

    /// @dev Emitted when (`user`) claims their rewards
    event ClaimRewards(address indexed user, address[] rewardTokens, uint256[] rewardAmounts);

    /**
     * @notice mints an amount of shares by depositing a base token.
     * @param receiver shares recipient address
     * @param tokenIn address of the base tokens to mint shares
     * @param amountTokenToDeposit amount of base tokens to be transferred from (`msg.sender`)
     * @param minSharesOut reverts if amount of shares minted is lower than this
     * @return amountSharesOut amount of shares minted
     * @dev Emits a {Deposit} event
     *
     * Requirements:
     * - (`tokenIn`) must be a valid base token.
     */
    function deposit(address receiver, address tokenIn, uint256 amountTokenToDeposit, uint256 minSharesOut)
        external
        payable
        returns (uint256 amountSharesOut);

    /**
     * @notice redeems an amount of base tokens by burning some shares
     * @param receiver recipient address
     * @param amountSharesToRedeem amount of shares to be burned
     * @param tokenOut address of the base token to be redeemed
     * @param minTokenOut reverts if amount of base token redeemed is lower than this
     * @param burnFromInternalBalance if true, burns from balance of `address(this)`, otherwise burns from `msg.sender`
     * @return amountTokenOut amount of base tokens redeemed
     * @dev Emits a {Redeem} event
     *
     * Requirements:
     * - (`tokenOut`) must be a valid base token.
     */
    function redeem(
        address receiver,
        uint256 amountSharesToRedeem,
        address tokenOut,
        uint256 minTokenOut,
        bool burnFromInternalBalance
    ) external returns (uint256 amountTokenOut);

    /**
     * @notice exchangeRate * syBalance / 1e18 must return the asset balance of the account
     * @notice vice-versa, if a user uses some amount of tokens equivalent to X asset, the amount of sy
     * exchangeRate / 1e18
     * @dev SYUtils's assetToSy & syToAsset should be used instead of raw multiplication
     *  & division
     */
    function exchangeRate() external view returns (uint256 res);

    /**
     * @notice claims reward for (`user`)
     * @param user the user receiving their rewards
     * @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens`
     * @dev
     * Emits a `ClaimRewards` event
     * See {getRewardTokens} for list of reward tokens
     */
    function claimRewards(address user) external returns (uint256[] memory rewardAmounts);

    /**
     * @notice get the amount of unclaimed rewards for (`user`)
     * @param user the user to check for
     * @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens`
     */
    function accruedRewards(address user) external view returns (uint256[] memory rewardAmounts);

    function rewardIndexesCurrent() external returns (uint256[] memory indexes);

    function rewardIndexesStored() external view returns (uint256[] memory indexes);

    /**
     * @notice returns the list of reward token addresses
     */
    function getRewardTokens() external view returns (address[] memory);

    /**
     * @notice returns the address of the underlying yield token
     */
    function yieldToken() external view returns (address);

    /**
     * @notice returns all tokens that can mint this SY
     */
    function getTokensIn() external view returns (address[] memory res);

    /**
     * @notice returns all tokens that can be redeemed by this SY
     */
    function getTokensOut() external view returns (address[] memory res);

    function isValidTokenIn(address token) external view returns (bool);

    function isValidTokenOut(address token) external view returns (bool);

    function previewDeposit(address tokenIn, uint256 amountTokenToDeposit)
        external
        view
        returns (uint256 amountSharesOut);

    function previewRedeem(address tokenOut, uint256 amountSharesToRedeem)
        external
        view
        returns (uint256 amountTokenOut);

    /**
     * @notice This function contains information to interpret what the asset is
     * @return assetType the type of the asset (0 for ERC20 tokens, 1 for AMM liquidity tokens,
     *     2 for bridged yield bearing tokens like wstETH, rETH on Arbi whose the underlying asset doesn't exist on the
     * chain)
     * @return assetAddress the address of the asset
     * @return assetDecimals the decimals of the asset
     */
    function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals);
}

// SPDX-License-Identifier: GPL-3.0-or-later
/*
 * 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.8.0;

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

interface IWETH is IERC20 {
    event Deposit(address indexed dst, uint256 wad);
    event Withdrawal(address indexed src, uint256 wad);

    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

Settings
{
  "viaIR": true,
  "optimizer": {
    "runs": 50000,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/pendle/contracts/core/Market/PendleMarketV7.sol": {
      "OracleLib": "0xa906e5ada287a37e551845bd8b2de2b6ed7769f7"
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_PT","type":"address"},{"internalType":"int256","name":"_scalarRoot","type":"int256"},{"internalType":"int256","name":"_initialAnchor","type":"int256"},{"internalType":"uint80","name":"_lnFeeRateRoot","type":"uint80"},{"internalType":"address","name":"_gaugeController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"int256","name":"exchangeRate","type":"int256"}],"name":"MarketExchangeRateBelowOne","type":"error"},{"inputs":[],"name":"MarketExpired","type":"error"},{"inputs":[{"internalType":"int256","name":"currentAmount","type":"int256"},{"internalType":"int256","name":"requiredAmount","type":"int256"}],"name":"MarketInsufficientPtForTrade","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualBalance","type":"uint256"},{"internalType":"uint256","name":"requiredBalance","type":"uint256"}],"name":"MarketInsufficientPtReceived","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualBalance","type":"uint256"},{"internalType":"uint256","name":"requiredBalance","type":"uint256"}],"name":"MarketInsufficientSyReceived","type":"error"},{"inputs":[],"name":"MarketProportionMustNotEqualOne","type":"error"},{"inputs":[{"internalType":"int256","name":"proportion","type":"int256"},{"internalType":"int256","name":"maxProportion","type":"int256"}],"name":"MarketProportionTooHigh","type":"error"},{"inputs":[{"internalType":"int256","name":"rateScalar","type":"int256"}],"name":"MarketRateScalarBelowZero","type":"error"},{"inputs":[{"internalType":"int256","name":"scalarRoot","type":"int256"}],"name":"MarketScalarRootBelowZero","type":"error"},{"inputs":[],"name":"MarketZeroAmountsInput","type":"error"},{"inputs":[],"name":"MarketZeroAmountsOutput","type":"error"},{"inputs":[],"name":"MarketZeroLnImpliedRate","type":"error"},{"inputs":[],"name":"MarketZeroNetLPFee","type":"error"},{"inputs":[{"internalType":"int256","name":"totalPt","type":"int256"},{"internalType":"int256","name":"totalAsset","type":"int256"}],"name":"MarketZeroTotalPtOrTotalAsset","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiverSy","type":"address"},{"indexed":true,"internalType":"address","name":"receiverPt","type":"address"},{"indexed":false,"internalType":"uint256","name":"netLpBurned","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netSyOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netPtOut","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"observationCardinalityNextOld","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"observationCardinalityNextNew","type":"uint16"}],"name":"IncreaseObservationCardinalityNext","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"netLpMinted","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netSyUsed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netPtUsed","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"rewardsOut","type":"uint256[]"}],"name":"RedeemRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"int256","name":"netPtOut","type":"int256"},{"indexed":false,"internalType":"int256","name":"netSyOut","type":"int256"},{"indexed":false,"internalType":"uint256","name":"netSyFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netSyToReserve","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lnLastImpliedRate","type":"uint256"}],"name":"UpdateImpliedRate","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_storage","outputs":[{"internalType":"int128","name":"totalPt","type":"int128"},{"internalType":"int128","name":"totalSy","type":"int128"},{"internalType":"uint96","name":"lastLnImpliedRate","type":"uint96"},{"internalType":"uint16","name":"observationIndex","type":"uint16"},{"internalType":"uint16","name":"observationCardinality","type":"uint16"},{"internalType":"uint16","name":"observationCardinalityNext","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"activeBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiverSy","type":"address"},{"internalType":"address","name":"receiverPt","type":"address"},{"internalType":"uint256","name":"netLpToBurn","type":"uint256"}],"name":"burn","outputs":[{"internalType":"uint256","name":"netSyOut","type":"uint256"},{"internalType":"uint256","name":"netPtOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expiry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNonOverrideLnFeeRateRoot","outputs":[{"internalType":"uint80","name":"","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"cardinalityNext","type":"uint16"}],"name":"increaseObservationsCardinalityNext","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRewardBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"netSyDesired","type":"uint256"},{"internalType":"uint256","name":"netPtDesired","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"netLpOut","type":"uint256"},{"internalType":"uint256","name":"netSyUsed","type":"uint256"},{"internalType":"uint256","name":"netPtUsed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"observations","outputs":[{"internalType":"uint32","name":"blockTimestamp","type":"uint32"},{"internalType":"uint216","name":"lnImpliedRateCumulative","type":"uint216"},{"internalType":"bool","name":"initialized","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"secondsAgos","type":"uint32[]"}],"name":"observe","outputs":[{"internalType":"uint216[]","name":"lnImpliedRateCumulative","type":"uint216[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"router","type":"address"}],"name":"readState","outputs":[{"components":[{"internalType":"int256","name":"totalPt","type":"int256"},{"internalType":"int256","name":"totalSy","type":"int256"},{"internalType":"int256","name":"totalLp","type":"int256"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"int256","name":"scalarRoot","type":"int256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"lnFeeRateRoot","type":"uint256"},{"internalType":"uint256","name":"reserveFeePercent","type":"uint256"},{"internalType":"uint256","name":"lastLnImpliedRate","type":"uint256"}],"internalType":"struct MarketState","name":"market","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"readTokens","outputs":[{"internalType":"contract IStandardizedYield","name":"_SY","type":"address"},{"internalType":"contract IPPrincipalToken","name":"_PT","type":"address"},{"internalType":"contract IPYieldToken","name":"_YT","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemRewards","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reentrancyGuardEntered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardState","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"lastBalance","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"skim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"exactPtIn","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swapExactPtForSy","outputs":[{"internalType":"uint256","name":"netSyOut","type":"uint256"},{"internalType":"uint256","name":"netSyFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"exactPtOut","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swapSyForExactPt","outputs":[{"internalType":"uint256","name":"netSyIn","type":"uint256"},{"internalType":"uint256","name":"netSyFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalActiveSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userReward","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"accrued","type":"uint128"}],"stateMutability":"view","type":"function"}]

6102006040523461013b5761001e6100156101aa565b9392909261026f565b604051615dbf9081610c428239608051816119bc015260a051818181613c440152615132015260c05181613c77015260e051816151770152610100518181816104bf0152818161174a01528181611a8401528181611cb20152818161217201526126cc015261012051818181610506015281816114a301528181611a4b01528181611c6501528181611ed9015281816121c5015261267b0152610140518181816113ea01528181611ac001528181611b9201526123ab0152610160518181816108f001526131440152610180518181816107ad015281816113b6015281816119f901528181611b5e0152818161237701526131fd01526101a051816131da01526101c051816128f201526101e05181818161077101526131b50152f35b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b604081019081106001600160401b0382111761016e57604052565b61013f565b601f909101601f19168101906001600160401b0382119082101761016e57604052565b51906001600160a01b038216820361013b57565b616a019060a082380392836040519485926101c58285610173565b83398101031261013b576101d882610196565b9160208101519260408201519260608301519260018060501b038416840361013b5760806102069101610196565b919493929190565b9081602091031261013b5761022290610196565b90565b6040513d5f823e3d90fd5b519061ffff8216820361013b57565b919082604091031261013b57610222602061025984610230565b9301610230565b9081602091031261013b575190565b60405163afd27bf560e01b81526001600160a01b0382169590916020836004818a5afa918215610461576102bd935f936104fb575b506102b76102b18361090b565b926109cf565b9261051c565b610100849052600460206102e16001600160a01b0387165b6001600160a01b031690565b60405163afd27bf560e01b815292839182905afa908115610461575f916104dc575b506001600160a01b03908116610120526101005160049160209161032791166102d5565b60405163781c18db60e01b815292839182905afa908115610461575f916104ad575b506001600160a01b0316610140526040805163329f6acb60e21b8152600a600482015263ffffffff42166024820152908160448173a906e5ada287a37e551845bd8b2de2b6ed7769f75af4908115610461576103ea915f915f91610478575b506009805461ffff60801b191660809290921b61ffff60801b169190911790555b6009805461ffff60701b191660709290921b61ffff60701b16919091179055565b5f811315610466576101a0526101c0526101e0526040516370c264df60e11b815290602090829060049082905afa908115610461575f91610432575b50610180523361016052565b610454915060203d60201161045a575b61044c8183610173565b810190610260565b5f610426565b503d610442565b610225565b63483512b160e11b5f5260045260245ffd5b6103c9925061049f915060403d6040116104a6575b6104978183610173565b81019061023f565b90916103a8565b503d61048d565b6104cf915060203d6020116104d5575b6104c78183610173565b81019061020e565b5f610349565b503d6104bd565b6104f5915060203d6020116104d5576104c78183610173565b5f610303565b61051591935060203d6020116104d5576104c78183610173565b915f6102a4565b8251919390929091906001600160401b03821161016e57610547826105426006546106a8565b6106e0565b602090601f831160011461061257946020946105926105c09561058a866102d5976102d59760049c5f92610607575b50508160011b915f199060031b1c19161790565b60065561079d565b6012608052600580546001600160f81b0316600160f81b17905560a05260e08190526001600160a01b031690565b604051635162986d60e11b815292839182905afa908115610461575f916105e8575b5060c052565b610601915060203d6020116104d5576104c78183610173565b5f6105e2565b015190505f80610576565b60065f52601f19831691907ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f925f5b81811061069057506105c0956001866102d59660049b9660209b966102d59a6105929710610678575b505050811b0160065561079d565b01515f1960f88460031b161c191690555f808061066a565b92936020600181928786015181550195019301610641565b90600182811c921680156106d6575b60208310146106c257565b634e487b7160e01b5f52602260045260245ffd5b91607f16916106b7565b90601f82116106ed575050565b8082116106f8575050565b60065f5260205f206020601f830160051c9210610737575b81601f9101920160051c03905f5b82811061072a57505050565b5f8282015560010161071e565b5f9150610710565b919091601f8311610750575b505050565b81831161075c57505050565b5f5260205f206020601f830160051c9210610795575b81601f9101920160051c03905f5b8281101561074b575f82820155600101610780565b5f9150610772565b80519091906001600160401b03811161016e576107c6816107bf6007546106a8565b600761073f565b602092601f82116001146107fa576107f5929382915f926106075750508160011b915f199060031b1c19161790565b600755565b60075f52601f198216937fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688915f5b86811061085e5750836001959610610846575b505050811b01600755565b01515f1960f88460031b161c191690555f808061083b565b91926020600181928685015181550194019201610828565b6001600160401b03811161016e57601f01601f191660200190565b60208183031261013b578051906001600160401b03821161013b570181601f8201121561013b578051906108c482610876565b926108d26040519485610173565b8284526020838301011161013b575f5b8281106108f657505060205f918301015290565b806020809284010151828287010152016108e2565b60409060045f61093584516109208682610173565b838152630282628160e51b6020820152610a8b565b84516306fdde0360e01b815290939092839182906001600160a01b03165afa928315610461576109a161099b610222956109a7945f916109ad575b5061097d84519485610173565b60038452620282a160ed1b6020850152610995610a73565b50610a8b565b91610a8b565b90610b43565b90610ac5565b6109c991503d805f833e6109c18183610173565b810190610891565b5f610970565b60409060045f6109f984516109e48682610173565b83815263504c502d60e01b6020820152610a8b565b84516395d89b4160e01b815290939092839182906001600160a01b03165afa928315610461576109a161099b610222956109a7945f91610a59575b50610a4184519485610173565b600384526250542d60e81b6020850152610995610a73565b610a6d91503d805f833e6109c18183610173565b5f610a34565b60405190610a8082610153565b5f6020838281520152565b610a93610a73565b50602081519160405192610aa684610153565b835201602082015290565b634e487b7160e01b5f52601160045260245ffd5b9081519181518301809311610b30576020610af8610ae285610876565b94610af06040519687610173565b808652610876565b8482019290601f1901368437610b148282015182519085610bc9565b51840101809111610b3057816020610222930151905191610bc9565b610ab1565b5f19810191908211610b3057565b90610b4c610a73565b50815190805191828110610bb45760019260208501938451826020860151808303610ba4575b505050610b81575b5050505090565b8103908111610b3057835251908051918201809211610b3057525f808080610b7a565b81929350209120145f8281610b72565b50505090565b601f8111610b30576101000a90565b91905b6020821015610c12575f199180610bec575b505182518216911916179052565b90915060200360208111610b3057610c06610c0b91610bba565b610b35565b905f610bde565b918251815260208101809111610b30579160208101809111610b305790601f198101908111610b305790610bcc56fe6080806040526004361015610012575f80fd5b5f905f3560e01c90816306fdde0314612bbe575080630892cd8b14612ba0578063095ea7b314612b6f578063156e29f6146122f457806318160ddd146122b65780631dd19cb4146120e957806323b872dd14611f91578063252c09d714611f2d57806329910b1114611ae75780632c8ce6bc14611a1e5780632f13b60c146119e0578063313ce567146119a257806337d45e3a1461179e5780635b709f17146113415780635cbadbe4146112aa57806370a082311461125e578063720692641461121f578063794052f314611189578063883bdbfd14610ed55780639262187b14610ba857806395d89b4114610a6c578063a9059cbb14610998578063a9f8d1811461097a578063c3fb90d614610914578063c45a0155146108c3578063c4f59f9b1461084f578063d2c725e01461082b578063dd62ed3e146107d0578063e184c9be14610795578063e4f8b2e91461074e578063ea64a820146106c7578063f6b911bc146101a75763ffa1ad7414610189575f80fd5b346101a457806003193601126101a457602060405160078152f35b80fd5b50346101a4576101b636612d92565b92907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461020c60028260f81c1415612f37565b161760055561021a3361302a565b9230156106435761022a30614925565b308352600360205260408320548581106105bf57859030855260036020520360408420557effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8681168282160390811161058e577effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fff000000000000000000000000000000000000000000000000000000000000009116911617600555826040518681527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203092a37f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff851161058a578415610562576020840193610358855187613bc4565b936103696040830195865190613dff565b9561038061037884518a613bc4565b875190613dff565b9587158061055a575b61053257610398898251614b06565b90526103a5868451614b06565b83526103b2878251614b06565b90528086126101a4578085126101a45750846040966104377f4cf25bc1d991c17529c25213d3cc0cda295eeaad5f13f361969b12ea48015f909373ffffffffffffffffffffffffffffffffffffffff861695843088036104eb575b505073ffffffffffffffffffffffffffffffffffffffff871696883089036104a4575b50506134c7565b8751908152602081019190915260408101859052606090a37f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055582519182526020820152f35b6104e49173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661375c565b5f88610430565b61052b9173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661375c565b5f8461040d565b6004837fccbf5468000000000000000000000000000000000000000000000000000000008152fd5b508615610389565b6004837f25daaec3000000000000000000000000000000000000000000000000000000008152fd5b8280fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b5f80fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b50346101a45760206003193601126101a457604061074a9173ffffffffffffffffffffffffffffffffffffffff6106fc612d4c565b1681526002602052205460405191816fffffffffffffffffffffffffffffffff849360801c9116839092916fffffffffffffffffffffffffffffffff60209181604085019616845216910152565b0390f35b50346101a457806003193601126101a457602060405169ffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346101a457806003193601126101a45760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346101a45760406003193601126101a45773ffffffffffffffffffffffffffffffffffffffff6040610801612d4c565b928261080b612d6f565b9416815260046020522091165f52602052602060405f2054604051908152f35b50346101a457806003193601126101a4576020600260055460f81c14604051908152f35b50346101a457806003193601126101a457610868613c02565b90604051918291602083016020845282518091526020604085019301915b818110610894575050500390f35b825173ffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101610886565b50346101a457806003193601126101a457602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346101a457806003193601126101a45760c060085461ffff6009546040519280600f0b845260801d600f0b60208401526bffffffffffffffffffffffff81166040840152818160601c166060840152818160701c16608084015260801c1660a0820152f35b50346101a457806003193601126101a4576020600154604051908152f35b50346101a45760406003193601126101a457610a186109b5612d4c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554610a0960028260f81c1415612f37565b161760055560243590336138cc565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555602060405160018152f35b50346101a457806003193601126101a4576040519080600754908160011c91600181168015610b9e575b602084108114610b7157838652908115610b2c5750600114610acf575b61074a84610ac381860382612ea5565b60405191829182612ce6565b600781527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688939250905b808210610b1257509091508101602001610ac382610ab3565b919260018160209254838588010152019101909291610af9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208087019190915292151560051b85019092019250610ac39150839050610ab3565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526022600452fd5b92607f1692610a96565b50346101a45760206003193601126101a457610bc2612d4c565b907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554610c1760028260f81c1415612f37565b1617600555610c2582614925565b610c2d613c02565b91610c3883516145b9565b928273ffffffffffffffffffffffffffffffffffffffff8316935b8251811015610e495773ffffffffffffffffffffffffffffffffffffffff610c7b8285614608565b511682528160205260408220855f5260205260405f205460801c610c9f8288614608565b52610caa8187614608565b51610cb8575b600101610c53565b73ffffffffffffffffffffffffffffffffffffffff610cd78285614608565b511682528160205260408220855f5260205260405f206fffffffffffffffffffffffffffffffff8154169055610d0d8187614608565b516fffffffffffffffffffffffffffffffff81116105bb576fffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff610d568386614608565b51168352600260205260408320906fffffffffffffffffffffffffffffffff825460801c91169003906fffffffffffffffffffffffffffffffff8211610e1c5760019291610ddf91906fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b610e1573ffffffffffffffffffffffffffffffffffffffff610e018387614608565b511686610e0e848b614608565b5191614a60565b9050610cb0565b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b61074a86867f78d61a0c27b13f43911095f9f356f14daa3cd8b125eea1aa22421245e90e813d60405180610e7d8582612efe565b0390a27f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055560405191829182612efe565b50346101a45760206003193601126101a45760043567ffffffffffffffff81116111855736602382011215611185578060040135610f1281612ee6565b91610f206040519384612ea5565b81835260208301906024829360051b8201019036821161111e57906024869495939201915b8183106111575750506009546040517f1dd421ce000000000000000000000000000000000000000000000000000000008152600a60048201524263ffffffff16602482015260c06044820152925160c484018190529294859360e485019350855b818110611135575050509061ffff826bffffffffffffffffffffffff8594166064850152818160601c16608485015260701c1660a4830152038173a906e5ada287a37e551845bd8b2de2b6ed7769f75af490811561112a578291611068575b5090604051918291602083016020845282518091526020604085019301915b818110611032575050500390f35b82517affffffffffffffffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101611024565b90503d8083833e6110798183612ea5565b81019060208183031261058a5780519067ffffffffffffffff821161112657019080601f8301121561058a578151906110b182612ee6565b926110bf6040519485612ea5565b82845260208085019360051b82010191821161112257602001915b8183106110ea575050505f611005565b82517affffffffffffffffffffffffffffffffffffffffffffffffffffff8116810361111e578152602092830192016110da565b8580fd5b8480fd5b8380fd5b6040513d84823e3d90fd5b825163ffffffff16855288965087955060209485019490920191600101610fa6565b909180939594503563ffffffff811681036111815781602092918392520192019085939492610f45565b8680fd5b5080fd5b50346101a45760206003193601126101a4576101206111ae6111a9612d4c565b61302a565b6101006040519180518352602081015160208401526040810151604084015273ffffffffffffffffffffffffffffffffffffffff60608201511660608401526080810151608084015260a081015160a084015260c081015160c084015260e081015160e08401520151610100820152f35b50346101a457806003193601126101a45760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b50346101a45760206003193601126101a45760206112a261127d612d4c565b73ffffffffffffffffffffffffffffffffffffffff165f52600360205260405f205490565b604051908152f35b50346101a45760406003193601126101a45773ffffffffffffffffffffffffffffffffffffffff60406112db612d4c565b92826112e5612d6f565b94168152806020522091165f5260205261074a60405f205460405191816fffffffffffffffffffffffffffffffff849360801c9116839092916fffffffffffffffffffffffffffffffff60209181604085019616845216910152565b50346101a45761135036612de6565b929091611365600260055460f81c1415612f37565b6113b37f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f00000000000000000000000000000000000000000000000000000000000000001115611776576113e43361302a565b9461140e7f0000000000000000000000000000000000000000000000000000000000000000613431565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311908161058a576114539596976114494286848461407c565b9a91989098613b6c565b98858a1261111e5785891261111e57858b1261111e5773ffffffffffffffffffffffffffffffffffffffff88169787308a0361172f575b505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016916114e98c73ffffffffffffffffffffffffffffffffffffffff6060870151168561375c565b6114f2846134c7565b80611681575b50506020611505826136fe565b9201918251908682126111815710611640575050611535670de0b6b3a7640000916115308a89612f9c565b613f95565b0415611618576101a4577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116101a457507f829000a5bc6a12d46e30cdcecd7c56b1efd88f6d7d059da6734a04f3764557c4836040966115bb61159888613b6c565b895195865260208601526040850192909252606084015233929081906080820190565b0390a361160c7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b82519182526020820152f35b6004827f880ccd2c000000000000000000000000000000000000000000000000000000008152fd5b61164a85916136fe565b9151818112611185576044927ff62951c7000000000000000000000000000000000000000000000000000000008352600452602452fd5b869550907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b11611181576116b58b613b6c565b333b1561172b579087916116f760405194859384937ffa483e720000000000000000000000000000000000000000000000000000000085528d60048601612fa9565b038183335af1801561172057908691156114f8578161171591612ea5565b61112257845f6114f8565b6040513d88823e3d90fd5b8780fd5b61176f9173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661375c565b5f8761148a565b6004857fb2094b59000000000000000000000000000000000000000000000000000000008152fd5b50346101a45760206003193601126101a45760043561ffff8116809103611185577f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461181360028260f81c1415612f37565b161760055561ffff60095460801c1690604051907f587cdc06000000000000000000000000000000000000000000000000000000008252600a6004830152826024830152604482015260208160648173a906e5ada287a37e551845bd8b2de2b6ed7769f75af490811561199757839161195d575b5061ffff8116918281036118e3575b837f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055580f35b7fac49e518f90a358f652e4400164f05a5d8f7e35e7747279bc3a93dbf584e125a926040927fffffffffffffffffffffffffffff0000ffffffffffffffffffffffffffffffff71ffff000000000000000000000000000000006009549260801b1691161760095582519182526020820152a15f8080611896565b90506020813d60201161198f575b8161197860209383612ea5565b8101031261058a5761198990612ffa565b5f611887565b3d915061196b565b6040513d85823e3d90fd5b50346101a457806003193601126101a457602060405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346101a457806003193601126101a4576020604051427f000000000000000000000000000000000000000000000000000000000000000011158152f35b50346101a457806003193601126101a457606060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016602082015273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166040820152f35b50346105bb57611af636612de6565b9193611b0d600260059593955460f81c1415612f37565b611b5b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f00000000000000000000000000000000000000000000000000000000000000001115611f0557611b8c3361302a565b94611bb67f0000000000000000000000000000000000000000000000000000000000000000613431565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb57611bf2611be983613b6c565b4290838a61407c565b98919790965f89126105bb575f88126105bb575f8a126105bb5773ffffffffffffffffffffffffffffffffffffffff87169689308903611ebe575b5050611c8a8a73ffffffffffffffffffffffffffffffffffffffff60608601511673ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661375c565b611c93836134c7565b80611ded575b505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016611cdb816136fe565b8251908682126111815710611dac575050611d03670de0b6b3a7640000916115308988612f9c565b0415611618577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811161118557611d3990613b6c565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116101a457506040805191825260208201859052818101849052606082019590955233907f829000a5bc6a12d46e30cdcecd7c56b1efd88f6d7d059da6734a04f3764557c49080608081016115bb565b611db685916136fe565b9151818112611185576044927f2c49ea0f000000000000000000000000000000000000000000000000000000008352600452602452fd5b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb57611e1d85613b6c565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a116105bb57333b156105bb575f91611e878b9260405195869485947ffa483e7200000000000000000000000000000000000000000000000000000000865260048601612fa9565b038183335af18015611eb357611e9e575b80611c99565b611eab9194505f90612ea5565b5f925f611e98565b6040513d5f823e3d90fd5b611efe9173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661375c565b5f89611c2d565b7fb2094b59000000000000000000000000000000000000000000000000000000005f5260045ffd5b346105bb5760206003193601126105bb5760043561ffff8110156105bb57606090600a01546040519063ffffffff811682527affffffffffffffffffffffffffffffffffffffffffffffffffffff8160201c16602083015260f81c15156040820152f35b346105bb57611f9f36612d92565b907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554611ff460028260f81c1415612f37565b161760055573ffffffffffffffffffffffffffffffffffffffff83165f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260405f2054927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff840361206f575b610a1893506138cc565b82841061208b5761208683610a18950333836132ad565b612065565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b346105bb575f6003193601126105bb577f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461214d60028260f81c1415612f37565b161760055561215b3361302a565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001661219b816136fe565b82515f81126105bb576121ad91612f9c565b9073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906121ef826136fe565b60208501515f81126105bb5761220491612f9c565b928061228a575b50508161225e575b600580547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f0100000000000000000000000000000000000000000000000000000000000000179055005b73ffffffffffffffffffffffffffffffffffffffff6060612282940151169061375c565b808080612213565b6122af9173ffffffffffffffffffffffffffffffffffffffff6060870151169061375c565b838061220b565b346105bb575f6003193601126105bb5760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b346105bb5760606003193601126105bb5761230d612d4c565b60243560443591612326600260055460f81c1415612f37565b6123747f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f00000000000000000000000000000000000000000000000000000000000000001115611f05576123a53361302a565b906123cf7f0000000000000000000000000000000000000000000000000000000000000000613431565b917f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84116105bb577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb575f84158015612b67575b612b3f5760a08201944286511115611f05576040830191825180155f14612ab35750506124558782613bc4565b5f81126105bb575f6003821115612aa55750808060011c6001810180911161283d57905b828210612a865750505b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18810190811360011661283d57956103e89197955b5f8813801590612a7c575b8015612a72575b612a4a5760208501936125058a8651613efb565b8552612512888751613efb565b8652612528612521858b613efb565b8251613efb565b90525f83126105bb575f88126105bb575f89126105bb575f87126105bb57826128c8575b50505073ffffffffffffffffffffffffffffffffffffffff831692831561286a5761257690614925565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8181168782160190811161283d577effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fff000000000000000000000000000000000000000000000000000000000000009116911617600555825f52600360205260405f2061262d8682546134ba565b9055825f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020604051898152a3612664826134c7565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166126a4816136fe565b8251905f82126105bb57106127fc57505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166126f5816136fe565b8251905f82126105bb57106127bb5750509061074a917fb4c03061fb5b7fed76389d5af8f2e0ddb09f8c70d1333abbb62582835e10accb6040518061274d858989846040919493926060820195825260208201520152565b0390a261279e7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b604051938493846040919493926060820195825260208201520152565b6127c4906136fe565b9051905f82126105bb577f2c49ea0f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b612805906136fe565b9051905f82126105bb577ff62951c7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b4282511115611f05576129246128ef6128e661292993875190613f16565b93429051612f9c565b927f00000000000000000000000000000000000000000000000000000000000000009061291c8589613fa8565b9088516146e3565b6147b9565b905f82126105bb5761294991612944906301e1338090613f95565b614023565b6101008401526129596001614925565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81811683821601929190831161283d5760205f927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef927fff000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600197169116176005558484526003825260408420612a398282546134ba565b9055604051908152a386808061254c565b7fccbf5468000000000000000000000000000000000000000000000000000000005f5260045ffd5b505f8713156124f1565b505f8913156124ea565b909150612a9c82612a978184614023565b6134ba565b60011c90612479565b901561248357506001612483565b612ac5612acd918a999394989a613bc4565b855190613dff565b612ad8845188613bc4565b96612ae96020870198895190613dff565b9081831215612b23575050612b0481612b1d92999851613bc4565b612b18612b1386518093613efb565b613e81565b613dff565b976124df565b985098965050612b39612b048998998651613bc4565b956124df565b7f25daaec3000000000000000000000000000000000000000000000000000000005f5260045ffd5b508515612428565b346105bb5760406003193601126105bb57612b95612b8b612d4c565b60243590336132ad565b602060405160018152f35b346105bb5760206003193601126105bb5760206112a261127d612d4c565b346105bb575f6003193601126105bb575f6006548060011c90600181168015612cdc575b602083108114612caf57828552908115612c6d5750600114612c0f575b61074a83610ac381850382612ea5565b91905060065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f915f905b808210612c5357509091508101602001610ac3612bff565b919260018160209254838588010152019101909291612c3b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208086019190915291151560051b84019091019150610ac39050612bff565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691612be2565b919091602081528251928360208301525f5b848110612d365750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6040809697860101520116010190565b8060208092840101516040828601015201612cf8565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b60031960609101126105bb5760043573ffffffffffffffffffffffffffffffffffffffff811681036105bb579060243573ffffffffffffffffffffffffffffffffffffffff811681036105bb579060443590565b9060606003198301126105bb5760043573ffffffffffffffffffffffffffffffffffffffff811681036105bb57916024359160443567ffffffffffffffff81116105bb57826023820112156105bb5780600401359267ffffffffffffffff84116105bb57602484830101116105bb576024019190565b6040810190811067ffffffffffffffff821117612e7857604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117612e7857604052565b67ffffffffffffffff8111612e785760051b60200190565b60206040818301928281528451809452019201905f5b818110612f215750505090565b8251845260209384019390920191600101612f14565b15612f3e57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b9190820391821161283d57565b9293806080957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe094601f948752602087015260606040870152816060870152868601375f8582860101520116010190565b519061ffff821682036105bb57565b519073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b9060405191610120830183811067ffffffffffffffff821117612e785760405260608301905f8252608084015f815260a08501915f835260c08601905f825260e08701945f86526101008801955f87528860085480600f0b825260801d600f0b60208201527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb576040015273ffffffffffffffffffffffffffffffffffffffff604051937f5c098c1100000000000000000000000000000000000000000000000000000000855230600486015216602484015260608360448173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa908115611eb3575f915f945f91613244575b5060ff16905273ffffffffffffffffffffffffffffffffffffffff16905269ffffffffffffffffffff8116613233575069ffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000005b1690527f000000000000000000000000000000000000000000000000000000000000000090527f000000000000000000000000000000000000000000000000000000000000000090526bffffffffffffffffffffffff600954169052565b69ffffffffffffffffffff906131d5565b92505092506060813d6060116132a5575b8161326260609383612ea5565b810103126105bb5761327381613009565b9060208101519069ffffffffffffffffffff821682036105bb57604001519360ff851685036105bb57909360ff613178565b3d9150613255565b73ffffffffffffffffffffffffffffffffffffffff169081156133ae5773ffffffffffffffffffffffffffffffffffffffff1691821561332a5760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526004825260405f20855f5282528060405f2055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b602073ffffffffffffffffffffffffffffffffffffffff60045f9360405194859384927f1d52edc4000000000000000000000000000000000000000000000000000000008452165af1908115611eb3575f9161348b575090565b90506020813d6020116134b2575b816134a660209383612ea5565b810103126105bb575190565b3d9150613499565b9190820180921161283d57565b6101008101908151906bffffffffffffffffffffffff82116105bb576134fa60206134f2835161402d565b92015161402d565b906009549061ffff604051927f4af74b68000000000000000000000000000000000000000000000000000000008452600a6004850152818160601c16602485015263ffffffff421660448501526bffffffffffffffffffffffff81166064850152818160701c16608485015260801c1660a483015260408260c48173a906e5ada287a37e551845bd8b2de2b6ed7769f75af4908115611eb3575f925f9261366f575b506fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff000000000000000000000000000000006dffff000000000000000000000000949560801b169116176008557fffffffffffffffffffffffffffffffff000000000000000000000000000000006bffffffffffffffffffffffff6fffff00000000000000000000000000006009549360701b1695169116179160601b161717600955516040519081527f5c0e21d57bb4cf91d8fe238d6f92e2685a695371b19209afcce6217b478f83e160204292a2565b93915091506040833d6040116136f6575b8161368d60409383612ea5565b810103126105bb576dffff000000000000000000000000916fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff000000000000000000000000000000006136ec60206136e588612ffa565b9701612ffa565b939594505061359c565b3d9150613680565b602073ffffffffffffffffffffffffffffffffffffffff916024604051809481937f70a08231000000000000000000000000000000000000000000000000000000008352306004840152165afa908115611eb3575f9161348b575090565b905f8073ffffffffffffffffffffffffffffffffffffffff61380f9594604051958260208801967fa9059cbb0000000000000000000000000000000000000000000000000000000088521660248801526044870152604486526137c0606487612ea5565b1692604051946137d1604087612ea5565b602086527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65646020870152519082855af1613809614a03565b91615797565b80519081159182156138a9575b50501561382557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b81925090602091810103126105bb576020015180151581036105bb575f8061381c565b909173ffffffffffffffffffffffffffffffffffffffff8216918215613ae85773ffffffffffffffffffffffffffffffffffffffff8416938415613a6457848414613a065761391a9161497b565b815f52600360205260405f205481811061398257817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f52600384520360405f2055845f526003825260405f206139778282546134ba565b9055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f45524332303a207472616e7366657220746f2073656c660000000000000000006044820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b90815f03918083057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff149015171561283d57565b90670de0b6b3a7640000820291808305670de0b6b3a7640000149015171561283d57565b81810292915f82127f800000000000000000000000000000000000000000000000000000000000000082141661283d57818405149015171561283d57565b6040517fc4f59f9b0000000000000000000000000000000000000000000000000000000081525f8160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa908115611eb3575f91613d66575b507f0000000000000000000000000000000000000000000000000000000000000000613ca08183614649565b613d62578151600181019283821161283d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0613cf5613cdf86612ee6565b95613ced6040519788612ea5565b808752612ee6565b013660208601375f5b828110613d2d575050613d2673ffffffffffffffffffffffffffffffffffffffff9184614608565b9116905290565b8073ffffffffffffffffffffffffffffffffffffffff613d4f60019385614608565b5116613d5b8288614608565b5201613cfe565b5090565b90503d805f833e613d778183612ea5565b8101906020818303126105bb5780519067ffffffffffffffff82116105bb57019080601f830112156105bb578151613dae81612ee6565b92613dbc6040519485612ea5565b81845260208085019260051b8201019283116105bb57602001905b828210613de7575050505f613c74565b60208091613df484613009565b815201910190613dd7565b8115613e54577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82147f800000000000000000000000000000000000000000000000000000000000000082141661283d570590565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820191821360011661283d57565b905f82670de0b6b3a7640000039212670de0b6b3a76400008312811690670de0b6b3a764000084139015161761283d57565b81810392915f13801582851316918412161761283d57565b9190915f838201938412911290801582169115161761283d57565b613f56670de0b6b3a7640000915f84125f14613f8a576115307fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff946146ac565b047f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613f8791613bc4565b90565b6115306001946146ac565b8181029291811591840414171561283d57565b6080613fbb9101516301e1338090613bc4565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613fec91613dff565b905f821315613ff757565b507f1ca41876000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b8115613e54570490565b807fffffffffffffffffffffffffffffffff80000000000000000000000000000000131580614062575b156105bb57600f0b90565b506f7fffffffffffffffffffffffffffffff811315614057565b939060a08501948486511115611f05578051848113156145895750604051936080850185811067ffffffffffffffff821117612e78576040525f855260208501915f835260408601955f875260608101965f8852888a511115611f05576140e4898b51612f9c565b956140ef8785613fa8565b83526020840193614101855183613f16565b808852815180158015614581575b614553575050805196610100820198895182519061412f83895192613f95565b9a61413f6301e13380809d614023565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb5761416f906158c4565b92670de0b6b3a76400008412614527578c936141bb612944946141ac6141b66141b1876141ac6141a66141c1996141cd9e9b613efb565b91613ba0565b6147af565b614b75565b613ba0565b90613ee3565b885260c0860151613f95565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb576141fd906158c4565b8b5281519051906142238651916141ac6141a688519561421d8d85614b06565b93613efb565b670d529ae9e860000081136144f05761424b92916141ac6141b661424693614b75565b613efb565b670de0b6b3a764000081126144a45761426f61426a826141ac8a613ba0565b613b6c565b9a51905f8813156144cf57816141ac61428792613ba0565b670de0b6b3a764000081126144a457506142b26142ac670de0b6b3a764000092613eb1565b8c613bc4565b05995b60e08201517f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb578b60646142f3836142fa945083613bc4565b0592613ee3565b5f811280156144905715614485576143327fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff916146ac565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561283d578461435d916134ba565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811161283d578461439191614023565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb576143ce916143c691613bc4565b9b5b84615003565b906143d99084615003565b9a8b919c819e51906143ea91612f9c565b978351906143f791614b06565b835286519161440591613efb565b61440e91614b06565b809552519361441c91613f16565b915190519161442a936146e3565b614433906147b9565b5f81126105bb5782810292818404149015171561283d5761445391614023565b8091521561445d57565b7faa69ae1e000000000000000000000000000000000000000000000000000000005f5260045ffd5b6143326001916146ac565b5061449e6143ce9185615003565b9b6143c8565b7fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5061426a81612b188d6144e46144ea95613eb1565b90613bc4565b996142b5565b7ffc68d09e000000000000000000000000000000000000000000000000000000005f52600452670d529ae9e860000060245260445ffd5b837fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7fb1c4aefb000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b50811561410f565b84907f8615426c000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b906145c382612ee6565b6145d06040519182612ea5565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06145fe8294612ee6565b0190602036910137565b805182101561461c5760209160051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b908151915f5b83811061465e57505050505f90565b73ffffffffffffffffffffffffffffffffffffffff61467d8284614608565b511673ffffffffffffffffffffffffffffffffffffffff8416146146a35760010161464f565b50505050600190565b5f8113156146b75790565b7f8000000000000000000000000000000000000000000000000000000000000000811461283d575f0390565b6141ac6141a66146fb939695949661421d5f85614b06565b92670d529ae9e8600000841361475d57614246906141ac6141b661471f9596614b75565b90670de0b6b3a7640000821261473157565b507fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b837ffc68d09e000000000000000000000000000000000000000000000000000000005f52600452670d529ae9e860000060245260445ffd5b8015613e54576ec097ce7bc90715b34b9f10000000000590565b8115613e54570590565b5f8113156148c75780670c7d713b49da000012806148b6575b156148ad57670de0b6b3a7640000026ec097ce7bc90715b34b9f10000000008101907fffffffffffffffffffffffffffffffffff3f68318436f8ea4cb460f000000000016ec097ce7bc90715b34b9f10000000000290614831916147af565b670de0b6b3a764000060036ec097ce7bc90715b34b9f1000000000838002819005808502829005928305909401600592850282900592830501600792850282900592830501600992850282900592830501600b92850282900592830501600d92850282900592830501600f9290940205059190910160011b0590565b613f8790614bbf565b50670f43fc2c04ee000081126147d2565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f6f7574206f6620626f756e6473000000000000000000000000000000000000006044820152fd5b61492d61509b565b908051156149765773ffffffffffffffffffffffffffffffffffffffff8316801515908161496b575b5061496057505050565b6149699261557e565b565b90503014155f614956565b505050565b61498361509b565b918151156149fd57828273ffffffffffffffffffffffffffffffffffffffff831680151590816149f2575b506149e1575b50505073ffffffffffffffffffffffffffffffffffffffff8316801515908161496b575061496057505050565b6149ea9261557e565b5f82826149b4565b90503014155f6149ae565b50505050565b3d15614a5b573d9067ffffffffffffffff8211612e785760405191614a50601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200184612ea5565b82523d5f602084013e565b606090565b91909181156149765773ffffffffffffffffffffffffffffffffffffffff169182614afd575f809350809281925af1614a97614a03565b5015614a9f57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6574682073656e64206661696c656400000000000000000000000000000000006044820152fd5b6149699261375c565b90808212614b1757613f8791613ee3565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f6e656761746976650000000000000000000000000000000000000000000000006044820152fd5b670de0b6b3a76400008114614b9757612924816141ac6141a6613f8794613eb1565b7fa9c8b14d000000000000000000000000000000000000000000000000000000005f5260045ffd5b670de0b6b3a76400008112614fed57613f87905f7e1600ef3172e58d2e933ec884fde10064c63b5372d805e203c0000000000000821215614fc2575b73011798004d755d3c8bc8e03204cf44619e000000821215614f95575b614d1b906064808492029302906e01855144814a7ff805980ff0084000821215614f5b575b506b02df0ab5a80a22c61ab5a700811215614f28575b693f1fce3da636ea5cf850811215614ef7575b690127fa27722cc06cc5e2811215614ec6575b68280e60114edb805d03811215614e96575b680ebc5fb41746121110811215614e76575b6808f00f760a4b2db55d811215614e46575b6806f5f1775788937937811215614e16575b6806248f33704b286603811215614de7575b6805c548670b9510e7ac811215614db8575b68056bc75e2d631000007ffffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf000008183019201026147af565b614dac614da568056bc75e2d6310000083800205614d8e81614d7781614d608168056bc75e2d631000008a8202059960038b0501990268056bc75e2d63100000900590565b976005890501970268056bc75e2d63100000900590565b956007870501950268056bc75e2d63100000900590565b936009850501930268056bc75e2d63100000900590565b600b900590565b0160011b016064900590565b614ddf68056bc75e2d631000006756bc75e2d631000092026805c548670b9510e7ac900590565b920191614ce5565b614e0e68056bc75e2d6310000067ad78ebc5ac62000092026806248f33704b286603900590565b920191614cd3565b614e3e68056bc75e2d6310000068015af1d78b58c4000092026806f5f1775788937937900590565b920191614cc1565b614e6e68056bc75e2d631000006802b5e3af16b188000092026808f00f760a4b2db55d900590565b920191614caf565b68056bc75e2d6310000092830192680ebc5fb41746121110910205614c9d565b614ebe68056bc75e2d63100000680ad78ebc5ac6200000920268280e60114edb805d03900590565b920191614c8b565b614eef68056bc75e2d631000006815af1d78b58c4000009202690127fa27722cc06cc5e2900590565b920191614c79565b614f2068056bc75e2d63100000682b5e3af16b188000009202693f1fce3da636ea5cf850900590565b920191614c66565b614f5368056bc75e2d631000006856bc75e2d63100000092026b02df0ab5a80a22c61ab5a700900590565b920191614c53565b68ad78ebc5ac62000000915069021e19e0c9bab2400000614f8c91026e01855144814a7ff805980ff0084000900590565b9201915f614c3d565b906803782dace9d9000000614fb9614d1b926b1425982cf597cd205cef7380900590565b92019050614c18565b50770195e54c5dd42177f53a27172fa9ec63026282700000000090056806f05b59d3b2000000614bfb565b614ff9614ffe91614795565b614bbf565b5f0390565b5f821215615090576150357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff926146ac565b90670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561283d5761506091614023565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613f8791613bc4565b6150356001926146ac565b6150a3613c02565b6150ad81516145b9565b9080515f901561557a57600154431461551957436001557effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416906040517fef5cfb8c0000000000000000000000000000000000000000000000000000000081523060048201525f816024818373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af18015611eb35761548b575b5073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803b156105bb575f80916004604051809481937f58f3d1630000000000000000000000000000000000000000000000000000000083525af18015611eb357615478575b5081151593815b84518110156154705773ffffffffffffffffffffffffffffffffffffffff6152098287614608565b51169081845260026020526040842060206040519161522783612e5c565b54916fffffffffffffffffffffffffffffffff83169283825260801c91829101528173ffffffffffffffffffffffffffffffffffffffff615268858b614608565b5116806153dc57508961527b8347612f9c565b91156153d3575b61536b575b6fffffffffffffffffffffffffffffffff83116105bb576152bb906fffffffffffffffffffffffffffffffff8416926134ba565b906fffffffffffffffffffffffffffffffff82116105bb576001946fffffffffffffffffffffffffffffffff8061535a941681604051946152fb86612e5c565b168452166020830152875260026020526040872081516020929092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b6153648285614608565b52016151e1565b91670de0b6b3a76400008302838104670de0b6b3a764000014841517156153a6579061539a896153a093614023565b906134ba565b91615287565b6024887f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b60019350615282565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa801561546557838c918a9061542e575b61527b929350612f9c565b5050506020813d821161545d575b8161544960209383612ea5565b810103126105bb57518a9081908490615423565b3d915061543c565b6040513d8a823e3d90fd5b509350505091565b61548491505f90612ea5565b5f5f6151da565b3d805f833e61549a8183612ea5565b8101906020818303126105bb5780519067ffffffffffffffff82116105bb57019080601f830112156105bb5781516154d181612ee6565b926154df6040519485612ea5565b81845260208085019260051b8201019283116105bb57602001905b8282106155095750505061515f565b81518152602091820191016154fa565b5091905f5b8351811015613d62578073ffffffffffffffffffffffffffffffffffffffff61554960019387614608565b51165f5260026020526fffffffffffffffffffffffffffffffff60405f2054166155738285614608565b520161551e565b5091565b91929173ffffffffffffffffffffffffffffffffffffffff168015158061578d575b1561576057805f52600360205260405f2054915f5b81518110156157585773ffffffffffffffffffffffffffffffffffffffff6155dd8284614608565b5116906155ea8188614608565b51825f525f60205260405f20855f526020526fffffffffffffffffffffffffffffffff60405f2054168015615750575b8181148015615748575b61573d57670de0b6b3a76400006156476156416156669385612f9c565b89613f95565b04845f525f60205260405f20875f5260205260405f205460801c6134ba565b906fffffffffffffffffffffffffffffffff81116105bb576fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff82116105bb576001936fffffffffffffffffffffffffffffffff80615737941681604051946156cf86612e5c565b1684521660208301525f525f60205260405f20865f5260205260405f2081516020929092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b016155b5565b505060019150615737565b508115615624565b50600161561a565b505050509050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b50308114156155a0565b9192901561581257508151156157ab575090565b3b156157b45790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b8251909150156158255750805190602001fd5b61585b906040519182917f08c379a000000000000000000000000000000000000000000000000000000000835260048301612ce6565b0390fd5b1561586657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f496e76616c6964206578706f6e656e74000000000000000000000000000000006044820152fd5b7ffffffffffffffffffffffffffffffffffffffffffffffffdc702bd3a30fc000081121580615d76575b6158f79061585f565b5f8112615d6257613f87906806f05b59d3b20000008112615d0b577ffffffffffffffffffffffffffffffffffffffffffffffff90fa4a62c4e00000001615ad46064770195e54c5dd42177f53a27172fa9ec630262827000000000925b0268056bc75e2d631000009068ad78ebc5ac62000000811215615cd2575b6856bc75e2d631000000811215615c88575b682b5e3af16b18800000811215615c40575b6815af1d78b58c400000811215615bf8575b680ad78ebc5ac6200000811215615bb1575b68056bc75e2d63100000811215615b6a575b6802b5e3af16b1880000811215615b23575b68015af1d78b58c40000811215615adc575b600268056bc75e2d631000008280020505600368056bc75e2d631000008383020505600468056bc75e2d631000008483020505600568056bc75e2d631000008583020505600668056bc75e2d631000008683020505600768056bc75e2d63100000878302050590600868056bc75e2d63100000888402050592600968056bc75e2d6310000089860205059468056bc75e2d63100000600a8a88028290050597615aa568056bc75e2d631000008c8b0205614da5565b99600c68056bc75e2d631000008d8d0205059b0101010101010101010101010268056bc75e2d63100000900590565b026064900590565b6806f5f17757889379377ffffffffffffffffffffffffffffffffffffffffffffffffea50e2874a73c0000615b1d9201920268056bc75e2d63100000900590565b906159f0565b6808f00f760a4b2db55d7ffffffffffffffffffffffffffffffffffffffffffffffffd4a1c50e94e780000615b649201920268056bc75e2d63100000900590565b906159de565b680ebc5fb417461211107ffffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf00000615bab9201920268056bc75e2d63100000900590565b906159cc565b68280e60114edb805d037ffffffffffffffffffffffffffffffffffffffffffffffff5287143a539e00000615bf29201920268056bc75e2d63100000900590565b906159ba565b690127fa27722cc06cc5e27fffffffffffffffffffffffffffffffffffffffffffffffea50e2874a73c00000615c3a9201920268056bc75e2d63100000900590565b906159a8565b693f1fce3da636ea5cf8507fffffffffffffffffffffffffffffffffffffffffffffffd4a1c50e94e7800000615c829201920268056bc75e2d63100000900590565b90615996565b6b02df0ab5a80a22c61ab5a7007fffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf000000615ccc9201920268056bc75e2d63100000900590565b90615984565b6e01855144814a7ff805980ff008400091507fffffffffffffffffffffffffffffffffffffffffffffff5287143a539e00000001615972565b6803782dace9d90000008112615d55577ffffffffffffffffffffffffffffffffffffffffffffffffc87d253162700000001615ad460646b1425982cf597cd205cef738092615954565b615ad46064600192615954565b615d6d905f036158c4565b613f8790614795565b5068070c1cc73b00c800008113156158ee56fea26469706673582212205f186ec9b676c4871ce4a39409b9df185eb1d09ce364196ac37ba84a5a3768f264736f6c6343000821003300000000000000000000000082b853db31f025858792d8fa969f2a1dc245c1790000000000000000000000000000000000000000000000013ef5e214c54134030000000000000000000000000000000000000000000000000e6e2fab5ab551a1000000000000000000000000000000000000000000000000002359c5efe693d200000000000000000000000047d74516b33ed5d70dde7119a40839f6fcc24e57

Deployed Bytecode

0x6080806040526004361015610012575f80fd5b5f905f3560e01c90816306fdde0314612bbe575080630892cd8b14612ba0578063095ea7b314612b6f578063156e29f6146122f457806318160ddd146122b65780631dd19cb4146120e957806323b872dd14611f91578063252c09d714611f2d57806329910b1114611ae75780632c8ce6bc14611a1e5780632f13b60c146119e0578063313ce567146119a257806337d45e3a1461179e5780635b709f17146113415780635cbadbe4146112aa57806370a082311461125e578063720692641461121f578063794052f314611189578063883bdbfd14610ed55780639262187b14610ba857806395d89b4114610a6c578063a9059cbb14610998578063a9f8d1811461097a578063c3fb90d614610914578063c45a0155146108c3578063c4f59f9b1461084f578063d2c725e01461082b578063dd62ed3e146107d0578063e184c9be14610795578063e4f8b2e91461074e578063ea64a820146106c7578063f6b911bc146101a75763ffa1ad7414610189575f80fd5b346101a457806003193601126101a457602060405160078152f35b80fd5b50346101a4576101b636612d92565b92907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461020c60028260f81c1415612f37565b161760055561021a3361302a565b9230156106435761022a30614925565b308352600360205260408320548581106105bf57859030855260036020520360408420557effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8681168282160390811161058e577effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fff000000000000000000000000000000000000000000000000000000000000009116911617600555826040518681527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203092a37f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff851161058a578415610562576020840193610358855187613bc4565b936103696040830195865190613dff565b9561038061037884518a613bc4565b875190613dff565b9587158061055a575b61053257610398898251614b06565b90526103a5868451614b06565b83526103b2878251614b06565b90528086126101a4578085126101a45750846040966104377f4cf25bc1d991c17529c25213d3cc0cda295eeaad5f13f361969b12ea48015f909373ffffffffffffffffffffffffffffffffffffffff861695843088036104eb575b505073ffffffffffffffffffffffffffffffffffffffff871696883089036104a4575b50506134c7565b8751908152602081019190915260408101859052606090a37f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055582519182526020820152f35b6104e49173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c1791661375c565b5f88610430565b61052b9173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f1661375c565b5f8461040d565b6004837fccbf5468000000000000000000000000000000000000000000000000000000008152fd5b508615610389565b6004837f25daaec3000000000000000000000000000000000000000000000000000000008152fd5b8280fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b5f80fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b50346101a45760206003193601126101a457604061074a9173ffffffffffffffffffffffffffffffffffffffff6106fc612d4c565b1681526002602052205460405191816fffffffffffffffffffffffffffffffff849360801c9116839092916fffffffffffffffffffffffffffffffff60209181604085019616845216910152565b0390f35b50346101a457806003193601126101a457602060405169ffffffffffffffffffff7f000000000000000000000000000000000000000000000000002359c5efe693d2168152f35b50346101a457806003193601126101a45760206040517f000000000000000000000000000000000000000000000000000000006a1785808152f35b50346101a45760406003193601126101a45773ffffffffffffffffffffffffffffffffffffffff6040610801612d4c565b928261080b612d6f565b9416815260046020522091165f52602052602060405f2054604051908152f35b50346101a457806003193601126101a4576020600260055460f81c14604051908152f35b50346101a457806003193601126101a457610868613c02565b90604051918291602083016020845282518091526020604085019301915b818110610894575050500390f35b825173ffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101610886565b50346101a457806003193601126101a457602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006d247b1c044fa1e22e6b04fa9f71baf99eb29a9f168152f35b50346101a457806003193601126101a45760c060085461ffff6009546040519280600f0b845260801d600f0b60208401526bffffffffffffffffffffffff81166040840152818160601c166060840152818160701c16608084015260801c1660a0820152f35b50346101a457806003193601126101a4576020600154604051908152f35b50346101a45760406003193601126101a457610a186109b5612d4c565b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554610a0960028260f81c1415612f37565b161760055560243590336138cc565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555602060405160018152f35b50346101a457806003193601126101a4576040519080600754908160011c91600181168015610b9e575b602084108114610b7157838652908115610b2c5750600114610acf575b61074a84610ac381860382612ea5565b60405191829182612ce6565b600781527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688939250905b808210610b1257509091508101602001610ac382610ab3565b919260018160209254838588010152019101909291610af9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208087019190915292151560051b85019092019250610ac39150839050610ab3565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526022600452fd5b92607f1692610a96565b50346101a45760206003193601126101a457610bc2612d4c565b907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554610c1760028260f81c1415612f37565b1617600555610c2582614925565b610c2d613c02565b91610c3883516145b9565b928273ffffffffffffffffffffffffffffffffffffffff8316935b8251811015610e495773ffffffffffffffffffffffffffffffffffffffff610c7b8285614608565b511682528160205260408220855f5260205260405f205460801c610c9f8288614608565b52610caa8187614608565b51610cb8575b600101610c53565b73ffffffffffffffffffffffffffffffffffffffff610cd78285614608565b511682528160205260408220855f5260205260405f206fffffffffffffffffffffffffffffffff8154169055610d0d8187614608565b516fffffffffffffffffffffffffffffffff81116105bb576fffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff610d568386614608565b51168352600260205260408320906fffffffffffffffffffffffffffffffff825460801c91169003906fffffffffffffffffffffffffffffffff8211610e1c5760019291610ddf91906fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b610e1573ffffffffffffffffffffffffffffffffffffffff610e018387614608565b511686610e0e848b614608565b5191614a60565b9050610cb0565b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b61074a86867f78d61a0c27b13f43911095f9f356f14daa3cd8b125eea1aa22421245e90e813d60405180610e7d8582612efe565b0390a27f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055560405191829182612efe565b50346101a45760206003193601126101a45760043567ffffffffffffffff81116111855736602382011215611185578060040135610f1281612ee6565b91610f206040519384612ea5565b81835260208301906024829360051b8201019036821161111e57906024869495939201915b8183106111575750506009546040517f1dd421ce000000000000000000000000000000000000000000000000000000008152600a60048201524263ffffffff16602482015260c06044820152925160c484018190529294859360e485019350855b818110611135575050509061ffff826bffffffffffffffffffffffff8594166064850152818160601c16608485015260701c1660a4830152038173a906e5ada287a37e551845bd8b2de2b6ed7769f75af490811561112a578291611068575b5090604051918291602083016020845282518091526020604085019301915b818110611032575050500390f35b82517affffffffffffffffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101611024565b90503d8083833e6110798183612ea5565b81019060208183031261058a5780519067ffffffffffffffff821161112657019080601f8301121561058a578151906110b182612ee6565b926110bf6040519485612ea5565b82845260208085019360051b82010191821161112257602001915b8183106110ea575050505f611005565b82517affffffffffffffffffffffffffffffffffffffffffffffffffffff8116810361111e578152602092830192016110da565b8580fd5b8480fd5b8380fd5b6040513d84823e3d90fd5b825163ffffffff16855288965087955060209485019490920191600101610fa6565b909180939594503563ffffffff811681036111815781602092918392520192019085939492610f45565b8680fd5b5080fd5b50346101a45760206003193601126101a4576101206111ae6111a9612d4c565b61302a565b6101006040519180518352602081015160208401526040810151604084015273ffffffffffffffffffffffffffffffffffffffff60608201511660608401526080810151608084015260a081015160a084015260c081015160c084015260e081015160e08401520151610100820152f35b50346101a457806003193601126101a45760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b50346101a45760206003193601126101a45760206112a261127d612d4c565b73ffffffffffffffffffffffffffffffffffffffff165f52600360205260405f205490565b604051908152f35b50346101a45760406003193601126101a45773ffffffffffffffffffffffffffffffffffffffff60406112db612d4c565b92826112e5612d6f565b94168152806020522091165f5260205261074a60405f205460405191816fffffffffffffffffffffffffffffffff849360801c9116839092916fffffffffffffffffffffffffffffffff60209181604085019616845216910152565b50346101a45761135036612de6565b929091611365600260055460f81c1415612f37565b6113b37f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f000000000000000000000000000000000000000000000000000000006a1785801115611776576113e43361302a565b9461140e7f000000000000000000000000cc1c9ff3cd2f63053512d491c37855056cd587d2613431565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311908161058a576114539596976114494286848461407c565b9a91989098613b6c565b98858a1261111e5785891261111e57858b1261111e5773ffffffffffffffffffffffffffffffffffffffff88169787308a0361172f575b505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f16916114e98c73ffffffffffffffffffffffffffffffffffffffff6060870151168561375c565b6114f2846134c7565b80611681575b50506020611505826136fe565b9201918251908682126111815710611640575050611535670de0b6b3a7640000916115308a89612f9c565b613f95565b0415611618576101a4577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116101a457507f829000a5bc6a12d46e30cdcecd7c56b1efd88f6d7d059da6734a04f3764557c4836040966115bb61159888613b6c565b895195865260208601526040850192909252606084015233929081906080820190565b0390a361160c7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b82519182526020820152f35b6004827f880ccd2c000000000000000000000000000000000000000000000000000000008152fd5b61164a85916136fe565b9151818112611185576044927ff62951c7000000000000000000000000000000000000000000000000000000008352600452602452fd5b869550907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b11611181576116b58b613b6c565b333b1561172b579087916116f760405194859384937ffa483e720000000000000000000000000000000000000000000000000000000085528d60048601612fa9565b038183335af1801561172057908691156114f8578161171591612ea5565b61112257845f6114f8565b6040513d88823e3d90fd5b8780fd5b61176f9173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c1791661375c565b5f8761148a565b6004857fb2094b59000000000000000000000000000000000000000000000000000000008152fd5b50346101a45760206003193601126101a45760043561ffff8116809103611185577f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461181360028260f81c1415612f37565b161760055561ffff60095460801c1690604051907f587cdc06000000000000000000000000000000000000000000000000000000008252600a6004830152826024830152604482015260208160648173a906e5ada287a37e551845bd8b2de2b6ed7769f75af490811561199757839161195d575b5061ffff8116918281036118e3575b837f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554161760055580f35b7fac49e518f90a358f652e4400164f05a5d8f7e35e7747279bc3a93dbf584e125a926040927fffffffffffffffffffffffffffff0000ffffffffffffffffffffffffffffffff71ffff000000000000000000000000000000006009549260801b1691161760095582519182526020820152a15f8080611896565b90506020813d60201161198f575b8161197860209383612ea5565b8101031261058a5761198990612ffa565b5f611887565b3d915061196b565b6040513d85823e3d90fd5b50346101a457806003193601126101a457602060405160ff7f0000000000000000000000000000000000000000000000000000000000000012168152f35b50346101a457806003193601126101a4576020604051427f000000000000000000000000000000000000000000000000000000006a17858011158152f35b50346101a457806003193601126101a457606060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f16815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c17916602082015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000cc1c9ff3cd2f63053512d491c37855056cd587d2166040820152f35b50346105bb57611af636612de6565b9193611b0d600260059593955460f81c1415612f37565b611b5b7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f000000000000000000000000000000000000000000000000000000006a1785801115611f0557611b8c3361302a565b94611bb67f000000000000000000000000cc1c9ff3cd2f63053512d491c37855056cd587d2613431565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb57611bf2611be983613b6c565b4290838a61407c565b98919790965f89126105bb575f88126105bb575f8a126105bb5773ffffffffffffffffffffffffffffffffffffffff87169689308903611ebe575b5050611c8a8a73ffffffffffffffffffffffffffffffffffffffff60608601511673ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f1661375c565b611c93836134c7565b80611ded575b505073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c17916611cdb816136fe565b8251908682126111815710611dac575050611d03670de0b6b3a7640000916115308988612f9c565b0415611618577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811161118557611d3990613b6c565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116101a457506040805191825260208201859052818101849052606082019590955233907f829000a5bc6a12d46e30cdcecd7c56b1efd88f6d7d059da6734a04f3764557c49080608081016115bb565b611db685916136fe565b9151818112611185576044927f2c49ea0f000000000000000000000000000000000000000000000000000000008352600452602452fd5b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb57611e1d85613b6c565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a116105bb57333b156105bb575f91611e878b9260405195869485947ffa483e7200000000000000000000000000000000000000000000000000000000865260048601612fa9565b038183335af18015611eb357611e9e575b80611c99565b611eab9194505f90612ea5565b5f925f611e98565b6040513d5f823e3d90fd5b611efe9173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f1661375c565b5f89611c2d565b7fb2094b59000000000000000000000000000000000000000000000000000000005f5260045ffd5b346105bb5760206003193601126105bb5760043561ffff8110156105bb57606090600a01546040519063ffffffff811682527affffffffffffffffffffffffffffffffffffffffffffffffffffff8160201c16602083015260f81c15156040820152f35b346105bb57611f9f36612d92565b907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600554611ff460028260f81c1415612f37565b161760055573ffffffffffffffffffffffffffffffffffffffff83165f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260405f2054927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff840361206f575b610a1893506138cc565b82841061208b5761208683610a18950333836132ad565b612065565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b346105bb575f6003193601126105bb577f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055461214d60028260f81c1415612f37565b161760055561215b3361302a565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c1791661219b816136fe565b82515f81126105bb576121ad91612f9c565b9073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f16906121ef826136fe565b60208501515f81126105bb5761220491612f9c565b928061228a575b50508161225e575b600580547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f0100000000000000000000000000000000000000000000000000000000000000179055005b73ffffffffffffffffffffffffffffffffffffffff6060612282940151169061375c565b808080612213565b6122af9173ffffffffffffffffffffffffffffffffffffffff6060870151169061375c565b838061220b565b346105bb575f6003193601126105bb5760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416604051908152f35b346105bb5760606003193601126105bb5761230d612d4c565b60243560443591612326600260055460f81c1415612f37565b6123747f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b427f000000000000000000000000000000000000000000000000000000006a1785801115611f05576123a53361302a565b906123cf7f000000000000000000000000cc1c9ff3cd2f63053512d491c37855056cd587d2613431565b917f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84116105bb577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb575f84158015612b67575b612b3f5760a08201944286511115611f05576040830191825180155f14612ab35750506124558782613bc4565b5f81126105bb575f6003821115612aa55750808060011c6001810180911161283d57905b828210612a865750505b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18810190811360011661283d57956103e89197955b5f8813801590612a7c575b8015612a72575b612a4a5760208501936125058a8651613efb565b8552612512888751613efb565b8652612528612521858b613efb565b8251613efb565b90525f83126105bb575f88126105bb575f89126105bb575f87126105bb57826128c8575b50505073ffffffffffffffffffffffffffffffffffffffff831692831561286a5761257690614925565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8181168782160190811161283d577effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fff000000000000000000000000000000000000000000000000000000000000009116911617600555825f52600360205260405f2061262d8682546134ba565b9055825f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020604051898152a3612664826134c7565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f166126a4816136fe565b8251905f82126105bb57106127fc57505073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c179166126f5816136fe565b8251905f82126105bb57106127bb5750509061074a917fb4c03061fb5b7fed76389d5af8f2e0ddb09f8c70d1333abbb62582835e10accb6040518061274d858989846040919493926060820195825260208201520152565b0390a261279e7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6005541617600555565b604051938493846040919493926060820195825260208201520152565b6127c4906136fe565b9051905f82126105bb577f2c49ea0f000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b612805906136fe565b9051905f82126105bb577ff62951c7000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b4282511115611f05576129246128ef6128e661292993875190613f16565b93429051612f9c565b927f0000000000000000000000000000000000000000000000000e6e2fab5ab551a19061291c8589613fa8565b9088516146e3565b6147b9565b905f82126105bb5761294991612944906301e1338090613f95565b614023565b6101008401526129596001614925565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb576005547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81811683821601929190831161283d5760205f927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef927fff000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600197169116176005558484526003825260408420612a398282546134ba565b9055604051908152a386808061254c565b7fccbf5468000000000000000000000000000000000000000000000000000000005f5260045ffd5b505f8713156124f1565b505f8913156124ea565b909150612a9c82612a978184614023565b6134ba565b60011c90612479565b901561248357506001612483565b612ac5612acd918a999394989a613bc4565b855190613dff565b612ad8845188613bc4565b96612ae96020870198895190613dff565b9081831215612b23575050612b0481612b1d92999851613bc4565b612b18612b1386518093613efb565b613e81565b613dff565b976124df565b985098965050612b39612b048998998651613bc4565b956124df565b7f25daaec3000000000000000000000000000000000000000000000000000000005f5260045ffd5b508515612428565b346105bb5760406003193601126105bb57612b95612b8b612d4c565b60243590336132ad565b602060405160018152f35b346105bb5760206003193601126105bb5760206112a261127d612d4c565b346105bb575f6003193601126105bb575f6006548060011c90600181168015612cdc575b602083108114612caf57828552908115612c6d5750600114612c0f575b61074a83610ac381850382612ea5565b91905060065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f915f905b808210612c5357509091508101602001610ac3612bff565b919260018160209254838588010152019101909291612c3b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208086019190915291151560051b84019091019150610ac39050612bff565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691612be2565b919091602081528251928360208301525f5b848110612d365750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6040809697860101520116010190565b8060208092840101516040828601015201612cf8565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b60031960609101126105bb5760043573ffffffffffffffffffffffffffffffffffffffff811681036105bb579060243573ffffffffffffffffffffffffffffffffffffffff811681036105bb579060443590565b9060606003198301126105bb5760043573ffffffffffffffffffffffffffffffffffffffff811681036105bb57916024359160443567ffffffffffffffff81116105bb57826023820112156105bb5780600401359267ffffffffffffffff84116105bb57602484830101116105bb576024019190565b6040810190811067ffffffffffffffff821117612e7857604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117612e7857604052565b67ffffffffffffffff8111612e785760051b60200190565b60206040818301928281528451809452019201905f5b818110612f215750505090565b8251845260209384019390920191600101612f14565b15612f3e57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b9190820391821161283d57565b9293806080957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe094601f948752602087015260606040870152816060870152868601375f8582860101520116010190565b519061ffff821682036105bb57565b519073ffffffffffffffffffffffffffffffffffffffff821682036105bb57565b9060405191610120830183811067ffffffffffffffff821117612e785760405260608301905f8252608084015f815260a08501915f835260c08601905f825260e08701945f86526101008801955f87528860085480600f0b825260801d600f0b60208201527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb576040015273ffffffffffffffffffffffffffffffffffffffff604051937f5c098c1100000000000000000000000000000000000000000000000000000000855230600486015216602484015260608360448173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006d247b1c044fa1e22e6b04fa9f71baf99eb29a9f165afa908115611eb3575f915f945f91613244575b5060ff16905273ffffffffffffffffffffffffffffffffffffffff16905269ffffffffffffffffffff8116613233575069ffffffffffffffffffff7f000000000000000000000000000000000000000000000000002359c5efe693d25b1690527f0000000000000000000000000000000000000000000000013ef5e214c541340390527f000000000000000000000000000000000000000000000000000000006a17858090526bffffffffffffffffffffffff600954169052565b69ffffffffffffffffffff906131d5565b92505092506060813d6060116132a5575b8161326260609383612ea5565b810103126105bb5761327381613009565b9060208101519069ffffffffffffffffffff821682036105bb57604001519360ff851685036105bb57909360ff613178565b3d9150613255565b73ffffffffffffffffffffffffffffffffffffffff169081156133ae5773ffffffffffffffffffffffffffffffffffffffff1691821561332a5760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526004825260405f20855f5282528060405f2055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b602073ffffffffffffffffffffffffffffffffffffffff60045f9360405194859384927f1d52edc4000000000000000000000000000000000000000000000000000000008452165af1908115611eb3575f9161348b575090565b90506020813d6020116134b2575b816134a660209383612ea5565b810103126105bb575190565b3d9150613499565b9190820180921161283d57565b6101008101908151906bffffffffffffffffffffffff82116105bb576134fa60206134f2835161402d565b92015161402d565b906009549061ffff604051927f4af74b68000000000000000000000000000000000000000000000000000000008452600a6004850152818160601c16602485015263ffffffff421660448501526bffffffffffffffffffffffff81166064850152818160701c16608485015260801c1660a483015260408260c48173a906e5ada287a37e551845bd8b2de2b6ed7769f75af4908115611eb3575f925f9261366f575b506fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff000000000000000000000000000000006dffff000000000000000000000000949560801b169116176008557fffffffffffffffffffffffffffffffff000000000000000000000000000000006bffffffffffffffffffffffff6fffff00000000000000000000000000006009549360701b1695169116179160601b161717600955516040519081527f5c0e21d57bb4cf91d8fe238d6f92e2685a695371b19209afcce6217b478f83e160204292a2565b93915091506040833d6040116136f6575b8161368d60409383612ea5565b810103126105bb576dffff000000000000000000000000916fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff000000000000000000000000000000006136ec60206136e588612ffa565b9701612ffa565b939594505061359c565b3d9150613680565b602073ffffffffffffffffffffffffffffffffffffffff916024604051809481937f70a08231000000000000000000000000000000000000000000000000000000008352306004840152165afa908115611eb3575f9161348b575090565b905f8073ffffffffffffffffffffffffffffffffffffffff61380f9594604051958260208801967fa9059cbb0000000000000000000000000000000000000000000000000000000088521660248801526044870152604486526137c0606487612ea5565b1692604051946137d1604087612ea5565b602086527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65646020870152519082855af1613809614a03565b91615797565b80519081159182156138a9575b50501561382557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b81925090602091810103126105bb576020015180151581036105bb575f8061381c565b909173ffffffffffffffffffffffffffffffffffffffff8216918215613ae85773ffffffffffffffffffffffffffffffffffffffff8416938415613a6457848414613a065761391a9161497b565b815f52600360205260405f205481811061398257817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f52600384520360405f2055845f526003825260405f206139778282546134ba565b9055604051908152a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f45524332303a207472616e7366657220746f2073656c660000000000000000006044820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b90815f03918083057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff149015171561283d57565b90670de0b6b3a7640000820291808305670de0b6b3a7640000149015171561283d57565b81810292915f82127f800000000000000000000000000000000000000000000000000000000000000082141661283d57818405149015171561283d57565b6040517fc4f59f9b0000000000000000000000000000000000000000000000000000000081525f8160048173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f165afa908115611eb3575f91613d66575b507f000000000000000000000000808507121b80c02388fad14726482e061b8da827613ca08183614649565b613d62578151600181019283821161283d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0613cf5613cdf86612ee6565b95613ced6040519788612ea5565b808752612ee6565b013660208601375f5b828110613d2d575050613d2673ffffffffffffffffffffffffffffffffffffffff9184614608565b9116905290565b8073ffffffffffffffffffffffffffffffffffffffff613d4f60019385614608565b5116613d5b8288614608565b5201613cfe565b5090565b90503d805f833e613d778183612ea5565b8101906020818303126105bb5780519067ffffffffffffffff82116105bb57019080601f830112156105bb578151613dae81612ee6565b92613dbc6040519485612ea5565b81845260208085019260051b8201019283116105bb57602001905b828210613de7575050505f613c74565b60208091613df484613009565b815201910190613dd7565b8115613e54577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82147f800000000000000000000000000000000000000000000000000000000000000082141661283d570590565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820191821360011661283d57565b905f82670de0b6b3a7640000039212670de0b6b3a76400008312811690670de0b6b3a764000084139015161761283d57565b81810392915f13801582851316918412161761283d57565b9190915f838201938412911290801582169115161761283d57565b613f56670de0b6b3a7640000915f84125f14613f8a576115307fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff946146ac565b047f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613f8791613bc4565b90565b6115306001946146ac565b8181029291811591840414171561283d57565b6080613fbb9101516301e1338090613bc4565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613fec91613dff565b905f821315613ff757565b507f1ca41876000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b8115613e54570490565b807fffffffffffffffffffffffffffffffff80000000000000000000000000000000131580614062575b156105bb57600f0b90565b506f7fffffffffffffffffffffffffffffff811315614057565b939060a08501948486511115611f05578051848113156145895750604051936080850185811067ffffffffffffffff821117612e78576040525f855260208501915f835260408601955f875260608101965f8852888a511115611f05576140e4898b51612f9c565b956140ef8785613fa8565b83526020840193614101855183613f16565b808852815180158015614581575b614553575050805196610100820198895182519061412f83895192613f95565b9a61413f6301e13380809d614023565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb5761416f906158c4565b92670de0b6b3a76400008412614527578c936141bb612944946141ac6141b66141b1876141ac6141a66141c1996141cd9e9b613efb565b91613ba0565b6147af565b614b75565b613ba0565b90613ee3565b885260c0860151613f95565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb576141fd906158c4565b8b5281519051906142238651916141ac6141a688519561421d8d85614b06565b93613efb565b670d529ae9e860000081136144f05761424b92916141ac6141b661424693614b75565b613efb565b670de0b6b3a764000081126144a45761426f61426a826141ac8a613ba0565b613b6c565b9a51905f8813156144cf57816141ac61428792613ba0565b670de0b6b3a764000081126144a457506142b26142ac670de0b6b3a764000092613eb1565b8c613bc4565b05995b60e08201517f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb578b60646142f3836142fa945083613bc4565b0592613ee3565b5f811280156144905715614485576143327fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff916146ac565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561283d578461435d916134ba565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811161283d578461439191614023565b907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116105bb576143ce916143c691613bc4565b9b5b84615003565b906143d99084615003565b9a8b919c819e51906143ea91612f9c565b978351906143f791614b06565b835286519161440591613efb565b61440e91614b06565b809552519361441c91613f16565b915190519161442a936146e3565b614433906147b9565b5f81126105bb5782810292818404149015171561283d5761445391614023565b8091521561445d57565b7faa69ae1e000000000000000000000000000000000000000000000000000000005f5260045ffd5b6143326001916146ac565b5061449e6143ce9185615003565b9b6143c8565b7fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5061426a81612b188d6144e46144ea95613eb1565b90613bc4565b996142b5565b7ffc68d09e000000000000000000000000000000000000000000000000000000005f52600452670d529ae9e860000060245260445ffd5b837fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7fb1c4aefb000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b50811561410f565b84907f8615426c000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b906145c382612ee6565b6145d06040519182612ea5565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06145fe8294612ee6565b0190602036910137565b805182101561461c5760209160051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b908151915f5b83811061465e57505050505f90565b73ffffffffffffffffffffffffffffffffffffffff61467d8284614608565b511673ffffffffffffffffffffffffffffffffffffffff8416146146a35760010161464f565b50505050600190565b5f8113156146b75790565b7f8000000000000000000000000000000000000000000000000000000000000000811461283d575f0390565b6141ac6141a66146fb939695949661421d5f85614b06565b92670d529ae9e8600000841361475d57614246906141ac6141b661471f9596614b75565b90670de0b6b3a7640000821261473157565b507fca78c8a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b837ffc68d09e000000000000000000000000000000000000000000000000000000005f52600452670d529ae9e860000060245260445ffd5b8015613e54576ec097ce7bc90715b34b9f10000000000590565b8115613e54570590565b5f8113156148c75780670c7d713b49da000012806148b6575b156148ad57670de0b6b3a7640000026ec097ce7bc90715b34b9f10000000008101907fffffffffffffffffffffffffffffffffff3f68318436f8ea4cb460f000000000016ec097ce7bc90715b34b9f10000000000290614831916147af565b670de0b6b3a764000060036ec097ce7bc90715b34b9f1000000000838002819005808502829005928305909401600592850282900592830501600792850282900592830501600992850282900592830501600b92850282900592830501600d92850282900592830501600f9290940205059190910160011b0590565b613f8790614bbf565b50670f43fc2c04ee000081126147d2565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f6f7574206f6620626f756e6473000000000000000000000000000000000000006044820152fd5b61492d61509b565b908051156149765773ffffffffffffffffffffffffffffffffffffffff8316801515908161496b575b5061496057505050565b6149699261557e565b565b90503014155f614956565b505050565b61498361509b565b918151156149fd57828273ffffffffffffffffffffffffffffffffffffffff831680151590816149f2575b506149e1575b50505073ffffffffffffffffffffffffffffffffffffffff8316801515908161496b575061496057505050565b6149ea9261557e565b5f82826149b4565b90503014155f6149ae565b50505050565b3d15614a5b573d9067ffffffffffffffff8211612e785760405191614a50601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200184612ea5565b82523d5f602084013e565b606090565b91909181156149765773ffffffffffffffffffffffffffffffffffffffff169182614afd575f809350809281925af1614a97614a03565b5015614a9f57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6574682073656e64206661696c656400000000000000000000000000000000006044820152fd5b6149699261375c565b90808212614b1757613f8791613ee3565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f6e656761746976650000000000000000000000000000000000000000000000006044820152fd5b670de0b6b3a76400008114614b9757612924816141ac6141a6613f8794613eb1565b7fa9c8b14d000000000000000000000000000000000000000000000000000000005f5260045ffd5b670de0b6b3a76400008112614fed57613f87905f7e1600ef3172e58d2e933ec884fde10064c63b5372d805e203c0000000000000821215614fc2575b73011798004d755d3c8bc8e03204cf44619e000000821215614f95575b614d1b906064808492029302906e01855144814a7ff805980ff0084000821215614f5b575b506b02df0ab5a80a22c61ab5a700811215614f28575b693f1fce3da636ea5cf850811215614ef7575b690127fa27722cc06cc5e2811215614ec6575b68280e60114edb805d03811215614e96575b680ebc5fb41746121110811215614e76575b6808f00f760a4b2db55d811215614e46575b6806f5f1775788937937811215614e16575b6806248f33704b286603811215614de7575b6805c548670b9510e7ac811215614db8575b68056bc75e2d631000007ffffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf000008183019201026147af565b614dac614da568056bc75e2d6310000083800205614d8e81614d7781614d608168056bc75e2d631000008a8202059960038b0501990268056bc75e2d63100000900590565b976005890501970268056bc75e2d63100000900590565b956007870501950268056bc75e2d63100000900590565b936009850501930268056bc75e2d63100000900590565b600b900590565b0160011b016064900590565b614ddf68056bc75e2d631000006756bc75e2d631000092026805c548670b9510e7ac900590565b920191614ce5565b614e0e68056bc75e2d6310000067ad78ebc5ac62000092026806248f33704b286603900590565b920191614cd3565b614e3e68056bc75e2d6310000068015af1d78b58c4000092026806f5f1775788937937900590565b920191614cc1565b614e6e68056bc75e2d631000006802b5e3af16b188000092026808f00f760a4b2db55d900590565b920191614caf565b68056bc75e2d6310000092830192680ebc5fb41746121110910205614c9d565b614ebe68056bc75e2d63100000680ad78ebc5ac6200000920268280e60114edb805d03900590565b920191614c8b565b614eef68056bc75e2d631000006815af1d78b58c4000009202690127fa27722cc06cc5e2900590565b920191614c79565b614f2068056bc75e2d63100000682b5e3af16b188000009202693f1fce3da636ea5cf850900590565b920191614c66565b614f5368056bc75e2d631000006856bc75e2d63100000092026b02df0ab5a80a22c61ab5a700900590565b920191614c53565b68ad78ebc5ac62000000915069021e19e0c9bab2400000614f8c91026e01855144814a7ff805980ff0084000900590565b9201915f614c3d565b906803782dace9d9000000614fb9614d1b926b1425982cf597cd205cef7380900590565b92019050614c18565b50770195e54c5dd42177f53a27172fa9ec63026282700000000090056806f05b59d3b2000000614bfb565b614ff9614ffe91614795565b614bbf565b5f0390565b5f821215615090576150357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff926146ac565b90670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561283d5761506091614023565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116105bb57613f8791613bc4565b6150356001926146ac565b6150a3613c02565b6150ad81516145b9565b9080515f901561557a57600154431461551957436001557effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60055416906040517fef5cfb8c0000000000000000000000000000000000000000000000000000000081523060048201525f816024818373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000db8f1d15880b97dc38edfa46d8a5a7e5b506c45f165af18015611eb35761548b575b5073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000047d74516b33ed5d70dde7119a40839f6fcc24e5716803b156105bb575f80916004604051809481937f58f3d1630000000000000000000000000000000000000000000000000000000083525af18015611eb357615478575b5081151593815b84518110156154705773ffffffffffffffffffffffffffffffffffffffff6152098287614608565b51169081845260026020526040842060206040519161522783612e5c565b54916fffffffffffffffffffffffffffffffff83169283825260801c91829101528173ffffffffffffffffffffffffffffffffffffffff615268858b614608565b5116806153dc57508961527b8347612f9c565b91156153d3575b61536b575b6fffffffffffffffffffffffffffffffff83116105bb576152bb906fffffffffffffffffffffffffffffffff8416926134ba565b906fffffffffffffffffffffffffffffffff82116105bb576001946fffffffffffffffffffffffffffffffff8061535a941681604051946152fb86612e5c565b168452166020830152875260026020526040872081516020929092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b6153648285614608565b52016151e1565b91670de0b6b3a76400008302838104670de0b6b3a764000014841517156153a6579061539a896153a093614023565b906134ba565b91615287565b6024887f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b60019350615282565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa801561546557838c918a9061542e575b61527b929350612f9c565b5050506020813d821161545d575b8161544960209383612ea5565b810103126105bb57518a9081908490615423565b3d915061543c565b6040513d8a823e3d90fd5b509350505091565b61548491505f90612ea5565b5f5f6151da565b3d805f833e61549a8183612ea5565b8101906020818303126105bb5780519067ffffffffffffffff82116105bb57019080601f830112156105bb5781516154d181612ee6565b926154df6040519485612ea5565b81845260208085019260051b8201019283116105bb57602001905b8282106155095750505061515f565b81518152602091820191016154fa565b5091905f5b8351811015613d62578073ffffffffffffffffffffffffffffffffffffffff61554960019387614608565b51165f5260026020526fffffffffffffffffffffffffffffffff60405f2054166155738285614608565b520161551e565b5091565b91929173ffffffffffffffffffffffffffffffffffffffff168015158061578d575b1561576057805f52600360205260405f2054915f5b81518110156157585773ffffffffffffffffffffffffffffffffffffffff6155dd8284614608565b5116906155ea8188614608565b51825f525f60205260405f20855f526020526fffffffffffffffffffffffffffffffff60405f2054168015615750575b8181148015615748575b61573d57670de0b6b3a76400006156476156416156669385612f9c565b89613f95565b04845f525f60205260405f20875f5260205260405f205460801c6134ba565b906fffffffffffffffffffffffffffffffff81116105bb576fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff82116105bb576001936fffffffffffffffffffffffffffffffff80615737941681604051946156cf86612e5c565b1684521660208301525f525f60205260405f20865f5260205260405f2081516020929092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b016155b5565b505060019150615737565b508115615624565b50600161561a565b505050509050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b50308114156155a0565b9192901561581257508151156157ab575090565b3b156157b45790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b8251909150156158255750805190602001fd5b61585b906040519182917f08c379a000000000000000000000000000000000000000000000000000000000835260048301612ce6565b0390fd5b1561586657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f496e76616c6964206578706f6e656e74000000000000000000000000000000006044820152fd5b7ffffffffffffffffffffffffffffffffffffffffffffffffdc702bd3a30fc000081121580615d76575b6158f79061585f565b5f8112615d6257613f87906806f05b59d3b20000008112615d0b577ffffffffffffffffffffffffffffffffffffffffffffffff90fa4a62c4e00000001615ad46064770195e54c5dd42177f53a27172fa9ec630262827000000000925b0268056bc75e2d631000009068ad78ebc5ac62000000811215615cd2575b6856bc75e2d631000000811215615c88575b682b5e3af16b18800000811215615c40575b6815af1d78b58c400000811215615bf8575b680ad78ebc5ac6200000811215615bb1575b68056bc75e2d63100000811215615b6a575b6802b5e3af16b1880000811215615b23575b68015af1d78b58c40000811215615adc575b600268056bc75e2d631000008280020505600368056bc75e2d631000008383020505600468056bc75e2d631000008483020505600568056bc75e2d631000008583020505600668056bc75e2d631000008683020505600768056bc75e2d63100000878302050590600868056bc75e2d63100000888402050592600968056bc75e2d6310000089860205059468056bc75e2d63100000600a8a88028290050597615aa568056bc75e2d631000008c8b0205614da5565b99600c68056bc75e2d631000008d8d0205059b0101010101010101010101010268056bc75e2d63100000900590565b026064900590565b6806f5f17757889379377ffffffffffffffffffffffffffffffffffffffffffffffffea50e2874a73c0000615b1d9201920268056bc75e2d63100000900590565b906159f0565b6808f00f760a4b2db55d7ffffffffffffffffffffffffffffffffffffffffffffffffd4a1c50e94e780000615b649201920268056bc75e2d63100000900590565b906159de565b680ebc5fb417461211107ffffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf00000615bab9201920268056bc75e2d63100000900590565b906159cc565b68280e60114edb805d037ffffffffffffffffffffffffffffffffffffffffffffffff5287143a539e00000615bf29201920268056bc75e2d63100000900590565b906159ba565b690127fa27722cc06cc5e27fffffffffffffffffffffffffffffffffffffffffffffffea50e2874a73c00000615c3a9201920268056bc75e2d63100000900590565b906159a8565b693f1fce3da636ea5cf8507fffffffffffffffffffffffffffffffffffffffffffffffd4a1c50e94e7800000615c829201920268056bc75e2d63100000900590565b90615996565b6b02df0ab5a80a22c61ab5a7007fffffffffffffffffffffffffffffffffffffffffffffffa9438a1d29cf000000615ccc9201920268056bc75e2d63100000900590565b90615984565b6e01855144814a7ff805980ff008400091507fffffffffffffffffffffffffffffffffffffffffffffff5287143a539e00000001615972565b6803782dace9d90000008112615d55577ffffffffffffffffffffffffffffffffffffffffffffffffc87d253162700000001615ad460646b1425982cf597cd205cef738092615954565b615ad46064600192615954565b615d6d905f036158c4565b613f8790614795565b5068070c1cc73b00c800008113156158ee56fea26469706673582212205f186ec9b676c4871ce4a39409b9df185eb1d09ce364196ac37ba84a5a3768f264736f6c63430008210033

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

00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c1790000000000000000000000000000000000000000000000013ef5e214c54134030000000000000000000000000000000000000000000000000e6e2fab5ab551a1000000000000000000000000000000000000000000000000002359c5efe693d200000000000000000000000047d74516b33ed5d70dde7119a40839f6fcc24e57

-----Decoded View---------------
Arg [0] : _PT (address): 0x82b853DB31F025858792d8fA969f2a1Dc245C179
Arg [1] : _scalarRoot (int256): 22983524852191802371
Arg [2] : _initialAnchor (int256): 1039820976976908705
Arg [3] : _lnFeeRateRoot (uint80): 9950330853168082
Arg [4] : _gaugeController (address): 0x47D74516B33eD5D70ddE7119A40839f6Fcc24e57

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000082b853db31f025858792d8fa969f2a1dc245c179
Arg [1] : 0000000000000000000000000000000000000000000000013ef5e214c5413403
Arg [2] : 0000000000000000000000000000000000000000000000000e6e2fab5ab551a1
Arg [3] : 000000000000000000000000000000000000000000000000002359c5efe693d2
Arg [4] : 00000000000000000000000047d74516b33ed5d70dde7119a40839f6fcc24e57


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.