Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 31 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Approve | 19247365 | 194 days ago | IN | 0 ETH | 0.00071884 | ||||
Approve | 16290911 | 609 days ago | IN | 0 ETH | 0.00071384 | ||||
Approve | 15979956 | 652 days ago | IN | 0 ETH | 0.00076751 | ||||
Approve | 14201254 | 928 days ago | IN | 0 ETH | 0.00132027 | ||||
Approve | 14113138 | 941 days ago | IN | 0 ETH | 0.00279106 | ||||
Approve | 14036642 | 953 days ago | IN | 0 ETH | 0.00396865 | ||||
Approve | 14013686 | 956 days ago | IN | 0 ETH | 0.00682887 | ||||
Approve | 13912538 | 972 days ago | IN | 0 ETH | 0.00352364 | ||||
Approve | 13847762 | 982 days ago | IN | 0 ETH | 0.00146327 | ||||
Approve | 13468465 | 1042 days ago | IN | 0 ETH | 0.00457974 | ||||
Approve | 13165359 | 1089 days ago | IN | 0 ETH | 0.00303563 | ||||
Approve | 13101825 | 1099 days ago | IN | 0 ETH | 0.00699621 | ||||
Approve | 13056416 | 1106 days ago | IN | 0 ETH | 0.00270871 | ||||
Approve | 13009196 | 1113 days ago | IN | 0 ETH | 0.00205488 | ||||
Approve | 13007350 | 1114 days ago | IN | 0 ETH | 0.00280212 | ||||
Approve | 13007338 | 1114 days ago | IN | 0 ETH | 0.0024285 | ||||
Approve | 12912341 | 1128 days ago | IN | 0 ETH | 0.00126095 | ||||
Approve | 12908496 | 1129 days ago | IN | 0 ETH | 0.00312903 | ||||
Approve | 12899997 | 1130 days ago | IN | 0 ETH | 0.00107414 | ||||
Approve | 12899639 | 1130 days ago | IN | 0 ETH | 0.00084063 | ||||
Approve | 12898558 | 1131 days ago | IN | 0 ETH | 0.00093404 | ||||
Approve | 12897647 | 1131 days ago | IN | 0 ETH | 0.00074723 | ||||
Approve | 12885263 | 1133 days ago | IN | 0 ETH | 0.01139528 | ||||
Approve | 12876840 | 1134 days ago | IN | 0 ETH | 0.00084063 | ||||
Approve | 12874317 | 1134 days ago | IN | 0 ETH | 0.00079393 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
12774364 | 1150 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
PendleCompoundMarket
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "../../interfaces/IPendleCompoundForge.sol"; import "./../abstract/PendleMarketBase.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract PendleCompoundMarket is PendleMarketBase { using Math for uint256; using SafeMath for uint256; using SafeERC20 for IERC20; uint256 private globalLastExchangeRate; constructor( address _governanceManager, address _xyt, address _token ) PendleMarketBase(_governanceManager, _xyt, _token) {} function _getExchangeRate() internal returns (uint256) { return IPendleCompoundForge(forge).getExchangeRate(underlyingAsset); } function _afterBootstrap() internal override { paramL = 1; globalLastExchangeRate = _getExchangeRate(); } /// @inheritdoc PendleMarketBase /* * Please refer to AaveMarket's _updateDueInterests to better understand this function * The key difference between Aave & Compound is in Compound there is no compound effect for locked in asset I.e: Only when the user use the cToken to redeem the underlyingAsset that he will enjoy the compound effect */ function _updateDueInterests(address user) internal override { // before calc the interest for users, updateParamL _updateParamL(); uint256 _paramL = paramL; uint256 userLastParamL = lastParamL[user]; if (userLastParamL == 0) { lastParamL[user] = _paramL; return; } uint256 principal = balanceOf(user); uint256 interestValuePerLP = _paramL.sub(userLastParamL); uint256 interestFromLp = principal.mul(interestValuePerLP).div(MULTIPLIER); dueInterests[user] = dueInterests[user].add(interestFromLp); lastParamL[user] = _paramL; } /// @inheritdoc PendleMarketBase // Please refer to AaveMarket's _getFirstTermAndParamR to better understand this function function _getFirstTermAndParamR(uint256 currentNYield) internal override returns (uint256 firstTerm, uint256 paramR) { firstTerm = paramL; paramR = currentNYield.sub(lastNYield); globalLastExchangeRate = _getExchangeRate(); } /// @inheritdoc PendleMarketBase function _getIncomeIndexIncreaseRate() internal override returns (uint256 increaseRate) { return _getExchangeRate().rdiv(globalLastExchangeRate).sub(Math.RONE); } }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "./IPendleForge.sol"; interface IPendleCompoundForge is IPendleForge { /** @dev directly get the exchangeRate from Compound */ function getExchangeRate(address _underlyingAsset) external returns (uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "../../interfaces/IPendleData.sol"; import "../../interfaces/IPendleMarket.sol"; import "../../interfaces/IPendleForge.sol"; import "../../interfaces/IPendleMarketFactory.sol"; import "../../interfaces/IPendleYieldToken.sol"; import "../../interfaces/IPendlePausingManager.sol"; import "../../periphery/WithdrawableV2.sol"; import "../../tokens/PendleBaseToken.sol"; import "../../libraries/MarketMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; /** @dev HIGH LEVEL PRINCIPAL: * So most of the functions in market is only callable by Router, except view/pure functions. If a function is non view/pure and is callable by anyone, it must be explicitly stated so * Market will not do any yieldToken/baseToken transfer but instead will fill in the transfer array and router will do them instead. (This is to reduce the number of approval users need to do) * mint, burn will be done directly with users */ abstract contract PendleMarketBase is IPendleMarket, PendleBaseToken, WithdrawableV2 { using Math for uint256; using SafeMath for uint256; using SafeERC20 for IERC20; bytes32 public immutable override factoryId; address internal immutable forge; address public immutable override token; address public immutable override xyt; bool public bootstrapped; string private constant NAME = "Pendle Market"; string private constant SYMBOL = "PENDLE-LPT"; uint256 private constant MINIMUM_LIQUIDITY = 10**3; uint8 private constant DECIMALS = 18; uint256 private constant LN_PI_PLUSONE = 1562071538258; // this is equal to Math.ln(Math.PI_PLUSONE,Math.RONE) uint256 internal constant MULTIPLIER = 10**20; // variables for LP interests calc uint256 public paramL; uint256 public lastNYield; mapping(address => uint256) internal lastParamL; mapping(address => uint256) internal dueInterests; // paramK used for mintProtocolFee. ParamK = xytBal ^ xytWeight * tokenBal ^ tokenW uint256 public lastParamK; // the last block that we do curveShift uint256 public lastCurveShiftBlock; /* * The reserveData will consist of 3 variables: xytBalance, tokenBalance & xytWeight To save gas, we will pack these 3 variables into a single uint256 variable as follows: Bit 148 -> 255: xytBalance Bit 40 -> 147: tokenBalance Bit 0 -> 39: xytWeight tokenWeight = Math.RONE - xytWeight Refer to writeReserveData and readReserveData for more details */ uint256 private reserveData; uint256 private lastRelativePrice = Math.RONE; uint256 private constant MASK_148_TO_255 = type(uint256).max ^ ((1 << 148) - 1); uint256 private constant MASK_40_TO_147 = ((1 << 148) - 1) ^ ((1 << 40) - 1); uint256 private constant MASK_0_TO_39 = ((1 << 40) - 1); uint256 private constant MAX_TOKEN_RESERVE_BALANCE = (1 << 108) - 1; /* * the lockStartTime is set at the bootstrap time of the market, and will not be changed for the entire market duration Once the market has been locked, only removeMarketLiquidityDual is allowed * Why lock the market? Because when the time is very close to the end of the market, the ratio of weights are either extremely big or small, which leads to high precision error */ uint256 public lockStartTime; /* these variables are used often, so we get them once in the constructor and save gas for retrieving them afterwards */ bytes32 private immutable forgeId; address internal immutable underlyingAsset; IERC20 private immutable underlyingYieldToken; IPendleData private immutable data; IPendlePausingManager private immutable pausingManager; uint256 private immutable xytStartTime; constructor( address _governanceManager, address _xyt, address _token ) PendleBaseToken( address(IPendleYieldToken(_xyt).forge().router()), NAME, SYMBOL, DECIMALS, block.timestamp, IPendleYieldToken(_xyt).expiry() ) PermissionsV2(_governanceManager) { require(_xyt != address(0), "ZERO_ADDRESS"); require(_token != address(0), "ZERO_ADDRESS"); require(_token != IPendleYieldToken(_xyt).underlyingYieldToken(), "INVALID_TOKEN_PAIR"); IPendleForge _forge = IPendleYieldToken(_xyt).forge(); forge = address(_forge); xyt = _xyt; token = _token; forgeId = _forge.forgeId(); underlyingAsset = IPendleYieldToken(_xyt).underlyingAsset(); underlyingYieldToken = IERC20(IPendleYieldToken(_xyt).underlyingYieldToken()); data = _forge.data(); pausingManager = _forge.data().pausingManager(); xytStartTime = IPendleYieldToken(_xyt).start(); factoryId = IPendleMarketFactory(msg.sender).marketFactoryId(); address _router = address(_forge.router()); IERC20(_xyt).safeApprove(_router, type(uint256).max); IERC20(_token).safeApprove(_router, type(uint256).max); } // INVARIANT: All write functions, except for ERC20's approve(), increaseAllowance(), decreaseAllowance() // must go through this check. This means that minting/burning/transferring of LP tokens is paused too. function checkNotPaused() internal { (bool paused, ) = pausingManager.checkMarketStatus(factoryId, address(this)); require(!paused, "MARKET_PAUSED"); } /// Refer to the docs for reserveData function readReserveData() internal view returns ( uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, uint256 tokenWeight ) { xytBalance = (reserveData & MASK_148_TO_255) >> 148; tokenBalance = (reserveData & MASK_40_TO_147) >> 40; xytWeight = reserveData & MASK_0_TO_39; tokenWeight = Math.RONE - xytWeight; } /// parse an asset address to tokenReserve /// _asset will only be either xyt or baseToken function parseTokenReserveData(address _asset) internal view returns (TokenReserve memory tokenReserve) { (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, uint256 tokenWeight) = readReserveData(); if (_asset == xyt) { tokenReserve = TokenReserve(xytWeight, xytBalance); } else { tokenReserve = TokenReserve(tokenWeight, tokenBalance); } } /// pass in a tokenReserve & the type of token (through _asset), update the reserveData function updateReserveData(TokenReserve memory tokenReserve, address _asset) internal { (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, uint256 tokenWeight) = readReserveData(); // Basically just update the weight & bal of the corresponding token & write the reserveData again if (_asset == xyt) { (xytWeight, xytBalance) = (tokenReserve.weight, tokenReserve.balance); } else { (tokenWeight, tokenBalance) = (tokenReserve.weight, tokenReserve.balance); xytWeight = Math.RONE.sub(tokenWeight); } writeReserveData(xytBalance, tokenBalance, xytWeight); } /// Refer to the docs for reserveData function writeReserveData( uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight ) internal { require(0 < xytBalance && xytBalance <= MAX_TOKEN_RESERVE_BALANCE, "YT_BALANCE_ERROR"); require( 0 < tokenBalance && tokenBalance <= MAX_TOKEN_RESERVE_BALANCE, "TOKEN_BALANCE_ERROR" ); reserveData = (xytBalance << 148) | (tokenBalance << 40) | xytWeight; } // Only the marketEmergencyHandler can call this function, when its in emergencyMode // this will allow a spender to spend the whole balance of the specified tokens // the spender should ideally be a contract with logic for users to withdraw out their funds. function setUpEmergencyMode(address spender) external override { (, bool emergencyMode) = pausingManager.checkMarketStatus(factoryId, address(this)); require(emergencyMode, "NOT_EMERGENCY"); (address marketEmergencyHandler, , ) = pausingManager.marketEmergencyHandler(); require(msg.sender == marketEmergencyHandler, "NOT_EMERGENCY_HANDLER"); IERC20(xyt).safeApprove(spender, type(uint256).max); IERC20(token).safeApprove(spender, type(uint256).max); IERC20(underlyingYieldToken).safeApprove(spender, type(uint256).max); } function bootstrap( address user, uint256 initialXytLiquidity, uint256 initialTokenLiquidity ) external override returns (PendingTransfer[2] memory transfers, uint256 exactOutLp) { require(msg.sender == address(router), "ONLY_ROUTER"); checkNotPaused(); require(!bootstrapped, "ALREADY_BOOTSTRAPPED"); // market's lock params should be initialized at bootstrap time _initializeLock(); // at the start of the market, xytWeight = tokenWeight = Math.RONE / 2 // As such, we will write it into the reserveData writeReserveData(initialXytLiquidity, initialTokenLiquidity, Math.RONE / 2); _updateLastParamK(); // update paramK since this is the first time it's set emit Sync(initialXytLiquidity, Math.RONE / 2, initialTokenLiquidity); _afterBootstrap(); // Taking inspiration from Uniswap, we will keep MINIMUM_LIQUIDITY in the market to make sure the market is always non-empty exactOutLp = Math.sqrt(initialXytLiquidity.mul(initialTokenLiquidity)).sub( MINIMUM_LIQUIDITY ); // No one should possibly own a specific address like this 0x1 // We mint to 0x1 instead of 0x0 because sending to 0x0 is not permitted _mint(address(0x1), MINIMUM_LIQUIDITY); _mint(user, exactOutLp); transfers[0].amount = initialXytLiquidity; transfers[0].isOut = false; transfers[1].amount = initialTokenLiquidity; transfers[1].isOut = false; lastCurveShiftBlock = block.number; bootstrapped = true; } /** * @notice Join the market by specifying the desired (and max) amount of xyts * and tokens to put in. * @param _desiredXytAmount amount of XYTs user wants to contribute * @param _desiredTokenAmount amount of tokens user wants to contribute * @param _xytMinAmount min amount of XYTs user wants to be able to contribute * @param _tokenMinAmount min amount of tokens user wants to be able to contribute * @dev no curveShift to save gas because this function doesn't depend on weights of tokens * Note: the logic of this function is similar to that of Uniswap * Conditions: * checkAddRemoveSwapClaimAllowed(false) is true */ function addMarketLiquidityDual( address user, uint256 _desiredXytAmount, uint256 _desiredTokenAmount, uint256 _xytMinAmount, uint256 _tokenMinAmount ) external override returns (PendingTransfer[2] memory transfers, uint256 lpOut) { checkAddRemoveSwapClaimAllowed(false); // mint protocol fees before k is changed by a non-swap event (add liquidity) _mintProtocolFees(); (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); uint256 amountXytUsed; uint256 amountTokenUsed = _desiredXytAmount.mul(tokenBalance).div(xytBalance); if (amountTokenUsed <= _desiredTokenAmount) { // using _desiredXytAmount to determine the LP and add liquidity require(amountTokenUsed >= _tokenMinAmount, "INSUFFICIENT_TOKEN_AMOUNT"); amountXytUsed = _desiredXytAmount; lpOut = _desiredXytAmount.mul(totalSupply()).div(xytBalance); } else { // using _desiredTokenAmount to determine the LP and add liquidity amountXytUsed = _desiredTokenAmount.mul(xytBalance).div(tokenBalance); require(amountXytUsed >= _xytMinAmount, "INSUFFICIENT_YT_AMOUNT"); amountTokenUsed = _desiredTokenAmount; lpOut = _desiredTokenAmount.mul(totalSupply()).div(tokenBalance); } xytBalance = xytBalance.add(amountXytUsed); transfers[0].amount = amountXytUsed; transfers[0].isOut = false; tokenBalance = tokenBalance.add(amountTokenUsed); transfers[1].amount = amountTokenUsed; transfers[1].isOut = false; writeReserveData(xytBalance, tokenBalance, xytWeight); _updateLastParamK(); // update paramK since it has changed due to a non-swap event // Mint LP directly to the user _mint(user, lpOut); emit Sync(xytBalance, xytWeight, tokenBalance); } /** * @notice Join the market by deposit token (single) and get liquidity token * need to specify the desired amount of contributed token (xyt or token) * and minimum output liquidity token * @param _inToken address of token (xyt or token) user wants to contribute * @param _exactIn amount of tokens (xyt or token) user wants to contribute * @param _minOutLp min amount of liquidity token user expect to receive * @dev curveShift needed since function operation relies on weights */ function addMarketLiquiditySingle( address user, address _inToken, uint256 _exactIn, uint256 _minOutLp ) external override returns (PendingTransfer[2] memory transfers, uint256 exactOutLp) { checkAddRemoveSwapClaimAllowed(false); // mint protocol fees before k is changed by a non-swap event (add liquidity) _mintProtocolFees(); _curveShift(); /* * Note that in theory we could do another _mintProtocolFee in this function to take a portion of the swap fees for the implicit swap of this operation * However, we have decided to not charge the protocol fees on the swap fees for this operation. * The user will still pay the swap fees, just that all the swap fees in the implicit swap will all go back to the market (and shared among the LP holders) */ TokenReserve memory inTokenReserve = parseTokenReserveData(_inToken); uint256 totalLp = totalSupply(); // Calc out amount of LP token. exactOutLp = MarketMath._calcOutAmountLp( _exactIn, inTokenReserve, data.swapFee(), totalLp ); require(exactOutLp >= _minOutLp, "HIGH_LP_OUT_LIMIT"); // Update reserves and operate underlying LP and inToken. inTokenReserve.balance = inTokenReserve.balance.add(_exactIn); transfers[0].amount = _exactIn; transfers[0].isOut = false; // repack data updateReserveData(inTokenReserve, _inToken); _updateLastParamK(); // update paramK since it has changed not due to swap // Mint and push LP token. _mint(user, exactOutLp); (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); // unpack data emit Sync(xytBalance, xytWeight, tokenBalance); } /** * @notice Exit the market by putting in the desired amount of LP tokens * and getting back XYT and pair tokens. * @dev no curveShift to save gas because this function doesn't depend on weights of tokens * @dev this function will never be locked since we always let users withdraw their funds. That's why we skip time check in checkAddRemoveSwapClaimAllowed */ function removeMarketLiquidityDual( address user, uint256 _inLp, uint256 _minOutXyt, uint256 _minOutToken ) external override returns (PendingTransfer[2] memory transfers) { checkAddRemoveSwapClaimAllowed(true); // mint protocol fees before k is changed by a non-swap event (remove liquidity) _mintProtocolFees(); uint256 totalLp = totalSupply(); (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); // unpack data // Calc and withdraw xyt token. uint256 xytOut = _inLp.mul(xytBalance).div(totalLp); uint256 tokenOut = _inLp.mul(tokenBalance).div(totalLp); require(tokenOut >= _minOutToken, "INSUFFICIENT_TOKEN_OUT"); require(xytOut >= _minOutXyt, "INSUFFICIENT_YT_OUT"); xytBalance = xytBalance.sub(xytOut); tokenBalance = tokenBalance.sub(tokenOut); transfers[0].amount = xytOut; transfers[0].isOut = true; transfers[1].amount = tokenOut; transfers[1].isOut = true; writeReserveData(xytBalance, tokenBalance, xytWeight); // repack data _updateLastParamK(); // update paramK since it has changed due to a non-swap event _burn(user, _inLp); emit Sync(xytBalance, xytWeight, tokenBalance); } /** * @notice Exit the market by putting in the desired amount of LP tokens * and getting back XYT or pair tokens. * @param _outToken address of the token that user wants to get back * @param _inLp the exact amount of liquidity token that user wants to put back * @param _minOutAmountToken the minimum of token that user wants to get back * @dev curveShift needed since function operation relies on weights */ function removeMarketLiquiditySingle( address user, address _outToken, uint256 _inLp, uint256 _minOutAmountToken ) external override returns (PendingTransfer[2] memory transfers) { checkAddRemoveSwapClaimAllowed(false); // mint protocol fees before k is changed by a non-swap event (remove liquidity) _mintProtocolFees(); _curveShift(); /* * Note that in theory we should do another _mintProtocolFee in this function since this add single involves an implicit swap operation * The reason we don't do that is same as in addMarketLiquiditySingle */ TokenReserve memory outTokenReserve = parseTokenReserveData(_outToken); uint256 swapFee = data.swapFee(); uint256 totalLp = totalSupply(); uint256 outAmountToken = MarketMath._calcOutAmountToken(outTokenReserve, totalLp, _inLp, swapFee); require(outAmountToken >= _minOutAmountToken, "INSUFFICIENT_TOKEN_OUT"); outTokenReserve.balance = outTokenReserve.balance.sub(outAmountToken); transfers[0].amount = outAmountToken; transfers[0].isOut = true; updateReserveData(outTokenReserve, _outToken); _updateLastParamK(); // update paramK since it has changed by a non-swap event _burn(user, _inLp); (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); // unpack data emit Sync(xytBalance, xytWeight, tokenBalance); } function swapExactIn( address inToken, uint256 inAmount, address outToken, uint256 minOutAmount ) external override returns (uint256 outAmount, PendingTransfer[2] memory transfers) { checkAddRemoveSwapClaimAllowed(false); // We only need to do _mintProtocolFees if there is a curveShift that follows if (checkNeedCurveShift()) { _mintProtocolFees(); _curveShift(); _updateLastParamK(); // update paramK since it has changed due to a non-swap event } TokenReserve memory inTokenReserve = parseTokenReserveData(inToken); TokenReserve memory outTokenReserve = parseTokenReserveData(outToken); // calc out amount of token to be swapped out outAmount = MarketMath._calcExactOut( inTokenReserve, outTokenReserve, inAmount, data.swapFee() ); require(outAmount >= minOutAmount, "HIGH_OUT_LIMIT"); inTokenReserve.balance = inTokenReserve.balance.add(inAmount); outTokenReserve.balance = outTokenReserve.balance.sub(outAmount); // repack data updateReserveData(inTokenReserve, inToken); updateReserveData(outTokenReserve, outToken); // no update paramK since it has changed but due to swap transfers[0].amount = inAmount; transfers[0].isOut = false; transfers[1].amount = outAmount; transfers[1].isOut = true; (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); // unpack data emit Sync(xytBalance, xytWeight, tokenBalance); } function swapExactOut( address inToken, uint256 maxInAmount, address outToken, uint256 outAmount ) external override returns (uint256 inAmount, PendingTransfer[2] memory transfers) { checkAddRemoveSwapClaimAllowed(false); // We only need to do _mintProtocolFees if there is a curveShift that follows if (checkNeedCurveShift()) { _mintProtocolFees(); _curveShift(); _updateLastParamK(); // update paramK since it has changed due to a non-swap event } TokenReserve memory inTokenReserve = parseTokenReserveData(inToken); TokenReserve memory outTokenReserve = parseTokenReserveData(outToken); // Calc in amount. inAmount = MarketMath._calcExactIn( inTokenReserve, outTokenReserve, outAmount, data.swapFee() ); require(inAmount <= maxInAmount, "LOW_IN_LIMIT"); inTokenReserve.balance = inTokenReserve.balance.add(inAmount); outTokenReserve.balance = outTokenReserve.balance.sub(outAmount); // repack data updateReserveData(inTokenReserve, inToken); updateReserveData(outTokenReserve, outToken); // no update paramK since it has changed but due to swap transfers[0].amount = inAmount; transfers[0].isOut = false; transfers[1].amount = outAmount; transfers[1].isOut = true; (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, ) = readReserveData(); // unpack data emit Sync(xytBalance, xytWeight, tokenBalance); } /** * @notice for user to claim their interest as holder of underlyingYield token * @param user user's address * @dev only can claim through router (included in checkAddRemoveSwapClaimAllowed) * We skip time check in checkAddRemoveSwapClaimAllowed because users can always claim interests * Since the Router has already had Reentrancy protection, we don't need one here */ function redeemLpInterests(address user) external override returns (uint256 interests) { checkAddRemoveSwapClaimAllowed(true); interests = _beforeTransferDueInterests(user); _safeTransferYieldToken(user, interests); } /** * @notice get the most up-to-date reserveData of the market by doing a dry curveShift */ function getReserves() external view override returns ( uint256 xytBalance, uint256 xytWeight, uint256 tokenBalance, uint256 tokenWeight, uint256 currentBlock ) { (xytBalance, tokenBalance, xytWeight, tokenWeight) = readReserveData(); if (checkNeedCurveShift()) { (xytWeight, tokenWeight, ) = _updateWeightDry(); } currentBlock = block.number; } /** * @notice update the weights of the market */ function _updateWeight() internal { (uint256 xytBalance, uint256 tokenBalance, , ) = readReserveData(); // unpack data (uint256 xytWeightUpdated, , uint256 currentRelativePrice) = _updateWeightDry(); writeReserveData(xytBalance, tokenBalance, xytWeightUpdated); // repack data lastRelativePrice = currentRelativePrice; } // do the weight update calculation but don't update the token reserve memory function _updateWeightDry() internal view returns ( uint256 xytWeightUpdated, uint256 tokenWeightUpdated, uint256 currentRelativePrice ) { // get current timestamp currentTime uint256 currentTime = block.timestamp; uint256 endTime = expiry; uint256 startTime = xytStartTime; uint256 duration = endTime - startTime; (, , uint256 xytWeight, uint256 tokenWeight) = readReserveData(); // unpack data uint256 timeLeft; if (endTime >= currentTime) { timeLeft = endTime - currentTime; } else { timeLeft = 0; } // get time_to_mature = (endTime - currentTime) / (endTime - startTime) uint256 timeToMature = Math.rdiv(timeLeft * Math.RONE, duration * Math.RONE); // get price for now = ln(3.14 * t + 1) / ln(4.14) currentRelativePrice = Math.rdiv( Math.ln(Math.rmul(Math.PI, timeToMature).add(Math.RONE), Math.RONE), LN_PI_PLUSONE ); uint256 r = Math.rdiv(currentRelativePrice, lastRelativePrice); require(Math.RONE >= r, "MATH_ERROR"); uint256 thetaNumerator = Math.rmul(Math.rmul(xytWeight, tokenWeight), Math.RONE.sub(r)); uint256 thetaDenominator = Math.rmul(r, xytWeight).add(tokenWeight); // calc weight changes theta uint256 theta = Math.rdiv(thetaNumerator, thetaDenominator); xytWeightUpdated = xytWeight.sub(theta); tokenWeightUpdated = tokenWeight.add(theta); } /* To add/remove/swap/claim, the market must have been * bootstrapped * only Router can call it * if the function is not removeMarketLiquidityDual, then must check the market hasn't been locked yet */ function checkAddRemoveSwapClaimAllowed(bool skipOpenCheck) internal { checkNotPaused(); require(bootstrapped, "NOT_BOOTSTRAPPED"); require(msg.sender == address(router), "ONLY_ROUTER"); if (!skipOpenCheck) { require(block.timestamp < lockStartTime, "MARKET_LOCKED"); } } //curve shift will be called before any calculation using weight //Note: there must be a _mintProtocolFees() before calling _curveShift() function _curveShift() internal { if (!checkNeedCurveShift()) return; _updateWeight(); lastCurveShiftBlock = block.number; } /** @notice To be called before the dueInterest of any users is redeemed */ function _beforeTransferDueInterests(address user) internal returns (uint256 amountOut) { _updateDueInterests(user); amountOut = dueInterests[user]; dueInterests[user] = 0; // Use subMax0 to handle the extreme case of the market lacking a few wei of tokens to send out lastNYield = lastNYield.subMax0(amountOut); } /** * We will only updateParamL if the normalisedIncome / exchangeRate has increased more than a delta * This delta is expected to be very small */ function checkNeedUpdateParamL() internal returns (bool) { return _getIncomeIndexIncreaseRate() > data.interestUpdateRateDeltaForMarket(); } /** * We will only do curveShift() once every curveShiftBlockDelta blocks */ function checkNeedCurveShift() internal view returns (bool) { return block.number > lastCurveShiftBlock.add(data.curveShiftBlockDelta()); } /** * @notice use to updateParamL. Must only be called by _updateDueInterests * ParamL can be thought of as an always-increase incomeIndex for 1 LP Consideration: * Theoretically we have to updateParamL whenever the _updateDueInterests is called, since the external incomeIndex (normalisedIncome/exchangeRate) is always increasing, and there are always interests to be claimed * Yet, if we do so, the amount of interests to be claimed maybe negligible while the amount of gas spent is tremendous (100k~200k last time we checked) => Caching is actually beneficial to user * The users may lose some negligible amount of interest when they do removeLiquidity or transfer LP to others (to be exact, they will lose NO MORE THAN interestUpdateRateDeltaForMarket%). In exchange, they will save a lot of gas. * If we assume the yearly interest rate is 10%, and we would like to only update the market's interest every one hour, interestUpdateRateDeltaForMarket% = 1.10 ^ (1/ (365*24)) - 1 = 0.00108802167011 % * The correctness of caching can be thought of like this: We just pretend that there are only income once in a while, and when that income come, they will come in large amount, and we will distribute them fairly to all users */ function _updateParamL() internal { if (!checkNeedUpdateParamL()) return; // redeem the interest from XYT router.redeemDueInterests(forgeId, underlyingAsset, expiry, address(this)); uint256 currentNYield = underlyingYieldToken.balanceOf(address(this)); (uint256 firstTerm, uint256 paramR) = _getFirstTermAndParamR(currentNYield); uint256 secondTerm; /* * paramR can be thought of as the amount of interest earned by the market (but excluding the compound effect). paramR is normally small & totalSupply is normally much larger so we need to multiply them with MULTIPLIER */ if (totalSupply() != 0) secondTerm = paramR.mul(MULTIPLIER).div(totalSupply()); // firstTerm & secondTerm are not the best names, but please refer to AMM specs // to understand the meaning of these 2 params paramL = firstTerm.add(secondTerm); lastNYield = currentNYield; } // before we send LPs, we need to update LP interests for both the to and from addresses function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { super._beforeTokenTransfer(from, to, amount); checkNotPaused(); if (from != address(0)) _updateDueInterests(from); if (to != address(0)) _updateDueInterests(to); } /** @dev Must be the only way to transfer aToken/cToken out // Please refer to _safeTransfer of PendleForgeBase for the rationale of this function */ function _safeTransferYieldToken(address _user, uint256 _amount) internal { if (_amount == 0) return; _amount = Math.min(_amount, underlyingYieldToken.balanceOf(address(this))); underlyingYieldToken.safeTransfer(_user, _amount); } /** * @notice _initialize the lock of the market. Must only be called in bootstrap */ function _initializeLock() internal { uint256 duration = expiry.sub(xytStartTime); // market expiry = xyt expiry uint256 lockDuration = duration.mul(data.lockNumerator()).div(data.lockDenominator()); lockStartTime = expiry.sub(lockDuration); } /** @notice _mint new LP for protocol fee. Mint them directly to the treasury @dev this function should be very similar to Uniswap */ function _mintProtocolFees() internal { uint256 feeRatio = data.protocolSwapFee(); uint256 _lastParamK = lastParamK; if (feeRatio > 0) { if (_lastParamK != 0) { uint256 k = _calcParamK(); if (k > _lastParamK) { uint256 numer = totalSupply().mul(k.sub(_lastParamK)); uint256 denom = Math.RONE.sub(feeRatio).mul(k).div(feeRatio).add(_lastParamK); uint256 liquidity = numer / denom; address treasury = data.treasury(); if (liquidity > 0) { _mint(treasury, liquidity); } } } } else if (_lastParamK != 0) { // if fee is turned off, we need to reset lastParamK as well lastParamK = 0; } } /** Equation for paramK: paramK = xytBal ^ xytWeight * tokenBal ^ tokenW * @dev must be called whenever the above equation changes but not due to a swapping action I.e: after add/remove/bootstrap liquidity or curveShift */ function _updateLastParamK() internal { if (data.protocolSwapFee() == 0) return; lastParamK = _calcParamK(); } /** * @notice calc the value of paramK. The formula for this can be referred in the AMM specs */ function _calcParamK() internal view returns (uint256 paramK) { (uint256 xytBalance, uint256 tokenBalance, uint256 xytWeight, uint256 tokenWeight) = readReserveData(); paramK = Math .rpow(xytBalance.toFP(), xytWeight) .rmul(Math.rpow(tokenBalance.toFP(), tokenWeight)) .toInt(); } function _allowedToWithdraw(address _token) internal view override returns (bool allowed) { allowed = _token != xyt && _token != token && _token != address(this) && _token != address(underlyingYieldToken); } function _afterBootstrap() internal virtual; /** @notice update the LP interest for users (before their balances of LP changes) @dev This must be called before any transfer / mint/ burn action of LP (and this has been implemented in the beforeTokenTransfer of this contract) */ function _updateDueInterests(address user) internal virtual; /// @notice Get params to update paramL. Must only be called by updateParamL function _getFirstTermAndParamR(uint256 currentNYield) internal virtual returns (uint256 firstTerm, uint256 paramR); /// @notice Get the increase rate of normalisedIncome / exchangeRate function _getIncomeIndexIncreaseRate() internal virtual returns (uint256 increaseRate); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "./IPendleRouter.sol"; import "./IPendleRewardManager.sol"; import "./IPendleYieldContractDeployer.sol"; import "./IPendleData.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IPendleForge { /** * @dev Emitted when the Forge has minted the OT and XYT tokens. * @param forgeId The forgeId * @param underlyingAsset The address of the underlying yield token. * @param expiry The expiry of the XYT token * @param amountToTokenize The amount of yield bearing assets to tokenize * @param amountTokenMinted The amount of OT/XYT minted **/ event MintYieldTokens( bytes32 forgeId, address indexed underlyingAsset, uint256 indexed expiry, uint256 amountToTokenize, uint256 amountTokenMinted, address indexed user ); /** * @dev Emitted when the Forge has created new yield token contracts. * @param forgeId The forgeId * @param underlyingAsset The address of the underlying asset. * @param expiry The date in epoch time when the contract will expire. * @param ot The address of the ownership token. * @param xyt The address of the new future yield token. **/ event NewYieldContracts( bytes32 forgeId, address indexed underlyingAsset, uint256 indexed expiry, address ot, address xyt, address yieldBearingAsset ); /** * @dev Emitted when the Forge has redeemed the OT and XYT tokens. * @param forgeId The forgeId * @param underlyingAsset the address of the underlying asset * @param expiry The expiry of the XYT token * @param amountToRedeem The amount of OT to be redeemed. * @param redeemedAmount The amount of yield token received **/ event RedeemYieldToken( bytes32 forgeId, address indexed underlyingAsset, uint256 indexed expiry, uint256 amountToRedeem, uint256 redeemedAmount, address indexed user ); /** * @dev Emitted when interest claim is settled * @param forgeId The forgeId * @param underlyingAsset the address of the underlying asset * @param expiry The expiry of the XYT token * @param user Interest receiver Address * @param amount The amount of interest claimed **/ event DueInterestsSettled( bytes32 forgeId, address indexed underlyingAsset, uint256 indexed expiry, uint256 amount, uint256 forgeFeeAmount, address indexed user ); /** * @dev Emitted when forge fee is withdrawn * @param forgeId The forgeId * @param underlyingAsset the address of the underlying asset * @param expiry The expiry of the XYT token * @param amount The amount of interest claimed **/ event ForgeFeeWithdrawn( bytes32 forgeId, address indexed underlyingAsset, uint256 indexed expiry, uint256 amount ); function setUpEmergencyMode( address _underlyingAsset, uint256 _expiry, address spender ) external; function newYieldContracts(address underlyingAsset, uint256 expiry) external returns (address ot, address xyt); function redeemAfterExpiry( address user, address underlyingAsset, uint256 expiry ) external returns (uint256 redeemedAmount); function redeemDueInterests( address user, address underlyingAsset, uint256 expiry ) external returns (uint256 interests); function updateDueInterests( address underlyingAsset, uint256 expiry, address user ) external; function updatePendingRewards( address _underlyingAsset, uint256 _expiry, address _user ) external; function redeemUnderlying( address user, address underlyingAsset, uint256 expiry, uint256 amountToRedeem ) external returns (uint256 redeemedAmount); function mintOtAndXyt( address underlyingAsset, uint256 expiry, uint256 amountToTokenize, address to ) external returns ( address ot, address xyt, uint256 amountTokenMinted ); function withdrawForgeFee(address underlyingAsset, uint256 expiry) external; function getYieldBearingToken(address underlyingAsset) external returns (address); /** * @notice Gets a reference to the PendleRouter contract. * @return Returns the router contract reference. **/ function router() external view returns (IPendleRouter); function data() external view returns (IPendleData); function rewardManager() external view returns (IPendleRewardManager); function yieldContractDeployer() external view returns (IPendleYieldContractDeployer); function rewardToken() external view returns (IERC20); /** * @notice Gets the bytes32 ID of the forge. * @return Returns the forge and protocol identifier. **/ function forgeId() external view returns (bytes32); function dueInterests( address _underlyingAsset, uint256 expiry, address _user ) external view returns (uint256); function yieldTokenHolders(address _underlyingAsset, uint256 _expiry) external view returns (address yieldTokenHolder); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; pragma abicoder v2; import "../interfaces/IWETH.sol"; import "./IPendleData.sol"; import "../libraries/PendleStructs.sol"; import "./IPendleMarketFactory.sol"; interface IPendleRouter { /** * @notice Emitted when a market for a future yield token and an ERC20 token is created. * @param marketFactoryId Forge identifier. * @param xyt The address of the tokenized future yield token as the base asset. * @param token The address of an ERC20 token as the quote asset. * @param market The address of the newly created market. **/ event MarketCreated( bytes32 marketFactoryId, address indexed xyt, address indexed token, address indexed market ); /** * @notice Emitted when a swap happens on the market. * @param trader The address of msg.sender. * @param inToken The input token. * @param outToken The output token. * @param exactIn The exact amount being traded. * @param exactOut The exact amount received. * @param market The market address. **/ event SwapEvent( address indexed trader, address inToken, address outToken, uint256 exactIn, uint256 exactOut, address market ); /** * @dev Emitted when user adds liquidity * @param sender The user who added liquidity. * @param token0Amount the amount of token0 (xyt) provided by user * @param token1Amount the amount of token1 provided by user * @param market The market address. * @param exactOutLp The exact LP minted */ event Join( address indexed sender, uint256 token0Amount, uint256 token1Amount, address market, uint256 exactOutLp ); /** * @dev Emitted when user removes liquidity * @param sender The user who removed liquidity. * @param token0Amount the amount of token0 (xyt) given to user * @param token1Amount the amount of token1 given to user * @param market The market address. * @param exactInLp The exact Lp to remove */ event Exit( address indexed sender, uint256 token0Amount, uint256 token1Amount, address market, uint256 exactInLp ); /** * @notice Gets a reference to the PendleData contract. * @return Returns the data contract reference. **/ function data() external view returns (IPendleData); /** * @notice Gets a reference of the WETH9 token contract address. * @return WETH token reference. **/ function weth() external view returns (IWETH); /*********** * FORGE * ***********/ function newYieldContracts( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external returns (address ot, address xyt); function redeemAfterExpiry( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external returns (uint256 redeemedAmount); function redeemDueInterests( bytes32 forgeId, address underlyingAsset, uint256 expiry, address user ) external returns (uint256 interests); function redeemUnderlying( bytes32 forgeId, address underlyingAsset, uint256 expiry, uint256 amountToRedeem ) external returns (uint256 redeemedAmount); function renewYield( bytes32 forgeId, uint256 oldExpiry, address underlyingAsset, uint256 newExpiry, uint256 renewalRate ) external returns ( uint256 redeemedAmount, uint256 amountRenewed, address ot, address xyt, uint256 amountTokenMinted ); function tokenizeYield( bytes32 forgeId, address underlyingAsset, uint256 expiry, uint256 amountToTokenize, address to ) external returns ( address ot, address xyt, uint256 amountTokenMinted ); /*********** * MARKET * ***********/ function addMarketLiquidityDual( bytes32 _marketFactoryId, address _xyt, address _token, uint256 _desiredXytAmount, uint256 _desiredTokenAmount, uint256 _xytMinAmount, uint256 _tokenMinAmount ) external payable returns ( uint256 amountXytUsed, uint256 amountTokenUsed, uint256 lpOut ); function addMarketLiquiditySingle( bytes32 marketFactoryId, address xyt, address token, bool forXyt, uint256 exactInAsset, uint256 minOutLp ) external payable returns (uint256 exactOutLp); function removeMarketLiquidityDual( bytes32 marketFactoryId, address xyt, address token, uint256 exactInLp, uint256 minOutXyt, uint256 minOutToken ) external returns (uint256 exactOutXyt, uint256 exactOutToken); function removeMarketLiquiditySingle( bytes32 marketFactoryId, address xyt, address token, bool forXyt, uint256 exactInLp, uint256 minOutAsset ) external returns (uint256 exactOutXyt, uint256 exactOutToken); /** * @notice Creates a market given a protocol ID, future yield token, and an ERC20 token. * @param marketFactoryId Market Factory identifier. * @param xyt Token address of the future yield token as base asset. * @param token Token address of an ERC20 token as quote asset. * @return market Returns the address of the newly created market. **/ function createMarket( bytes32 marketFactoryId, address xyt, address token ) external returns (address market); function bootstrapMarket( bytes32 marketFactoryId, address xyt, address token, uint256 initialXytLiquidity, uint256 initialTokenLiquidity ) external payable; function swapExactIn( address tokenIn, address tokenOut, uint256 inTotalAmount, uint256 minOutTotalAmount, bytes32 marketFactoryId ) external payable returns (uint256 outTotalAmount); function swapExactOut( address tokenIn, address tokenOut, uint256 outTotalAmount, uint256 maxInTotalAmount, bytes32 marketFactoryId ) external payable returns (uint256 inTotalAmount); function redeemLpInterests(address market, address user) external returns (uint256 interests); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; interface IPendleRewardManager { event UpdateFrequencySet(address[], uint256[]); event SkippingRewardsSet(bool); event DueRewardsSettled( bytes32 forgeId, address underlyingAsset, uint256 expiry, uint256 amountOut, address user ); function redeemRewards( address _underlyingAsset, uint256 _expiry, address _user ) external returns (uint256 dueRewards); function updatePendingRewards( address _underlyingAsset, uint256 _expiry, address _user ) external; function updateParamLManual(address _underlyingAsset, uint256 _expiry) external; function setUpdateFrequency( address[] calldata underlyingAssets, uint256[] calldata frequencies ) external; function setSkippingRewards(bool skippingRewards) external; function forgeId() external returns (bytes32); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; interface IPendleYieldContractDeployer { function forgeId() external returns (bytes32); function forgeOwnershipToken( address _underlyingAsset, string memory _name, string memory _symbol, uint8 _decimals, uint256 _expiry ) external returns (address ot); function forgeFutureYieldToken( address _underlyingAsset, string memory _name, string memory _symbol, uint8 _decimals, uint256 _expiry ) external returns (address xyt); function deployYieldTokenHolder(address yieldToken, uint256 expiry) external returns (address yieldTokenHolder); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "./IPendleRouter.sol"; import "./IPendleYieldToken.sol"; import "./IPendlePausingManager.sol"; import "./IPendleMarket.sol"; interface IPendleData { /** * @notice Emitted when validity of a forge-factory pair is updated * @param _forgeId the forge id * @param _marketFactoryId the market factory id * @param _valid valid or not **/ event ForgeFactoryValiditySet(bytes32 _forgeId, bytes32 _marketFactoryId, bool _valid); /** * @notice Emitted when Pendle and PendleFactory addresses have been updated. * @param treasury The address of the new treasury contract. **/ event TreasurySet(address treasury); /** * @notice Emitted when LockParams is changed **/ event LockParamsSet(uint256 lockNumerator, uint256 lockDenominator); /** * @notice Emitted when ExpiryDivisor is changed **/ event ExpiryDivisorSet(uint256 expiryDivisor); /** * @notice Emitted when forge fee is changed **/ event ForgeFeeSet(uint256 forgeFee); /** * @notice Emitted when interestUpdateRateDeltaForMarket is changed * @param interestUpdateRateDeltaForMarket new interestUpdateRateDeltaForMarket setting **/ event InterestUpdateRateDeltaForMarketSet(uint256 interestUpdateRateDeltaForMarket); /** * @notice Emitted when market fees are changed * @param _swapFee new swapFee setting * @param _protocolSwapFee new protocolSwapFee setting **/ event MarketFeesSet(uint256 _swapFee, uint256 _protocolSwapFee); /** * @notice Emitted when the curve shift block delta is changed * @param _blockDelta new block delta setting **/ event CurveShiftBlockDeltaSet(uint256 _blockDelta); /** * @dev Emitted when new forge is added * @param marketFactoryId Human Readable Market Factory ID in Bytes * @param marketFactoryAddress The Market Factory Address */ event NewMarketFactory(bytes32 indexed marketFactoryId, address indexed marketFactoryAddress); /** * @notice Set/update validity of a forge-factory pair * @param _forgeId the forge id * @param _marketFactoryId the market factory id * @param _valid valid or not **/ function setForgeFactoryValidity( bytes32 _forgeId, bytes32 _marketFactoryId, bool _valid ) external; /** * @notice Sets the PendleTreasury contract addresses. * @param newTreasury Address of new treasury contract. **/ function setTreasury(address newTreasury) external; /** * @notice Gets a reference to the PendleRouter contract. * @return Returns the router contract reference. **/ function router() external view returns (IPendleRouter); /** * @notice Gets a reference to the PendleRouter contract. * @return Returns the router contract reference. **/ function pausingManager() external view returns (IPendlePausingManager); /** * @notice Gets the treasury contract address where fees are being sent to. * @return Address of the treasury contract. **/ function treasury() external view returns (address); /*********** * FORGE * ***********/ /** * @notice Emitted when a forge for a protocol is added. * @param forgeId Forge and protocol identifier. * @param forgeAddress The address of the added forge. **/ event ForgeAdded(bytes32 indexed forgeId, address indexed forgeAddress); /** * @notice Adds a new forge for a protocol. * @param forgeId Forge and protocol identifier. * @param forgeAddress The address of the added forge. **/ function addForge(bytes32 forgeId, address forgeAddress) external; /** * @notice Store new OT and XYT details. * @param forgeId Forge and protocol identifier. * @param ot The address of the new XYT. * @param xyt The address of the new XYT. * @param underlyingAsset Token address of the underlying asset. * @param expiry Yield contract expiry in epoch time. **/ function storeTokens( bytes32 forgeId, address ot, address xyt, address underlyingAsset, uint256 expiry ) external; /** * @notice Set a new forge fee * @param _forgeFee new forge fee **/ function setForgeFee(uint256 _forgeFee) external; /** * @notice Gets the OT and XYT tokens. * @param forgeId Forge and protocol identifier. * @param underlyingYieldToken Token address of the underlying yield token. * @param expiry Yield contract expiry in epoch time. * @return ot The OT token references. * @return xyt The XYT token references. **/ function getPendleYieldTokens( bytes32 forgeId, address underlyingYieldToken, uint256 expiry ) external view returns (IPendleYieldToken ot, IPendleYieldToken xyt); /** * @notice Gets a forge given the identifier. * @param forgeId Forge and protocol identifier. * @return forgeAddress Returns the forge address. **/ function getForgeAddress(bytes32 forgeId) external view returns (address forgeAddress); /** * @notice Checks if an XYT token is valid. * @param forgeId The forgeId of the forge. * @param underlyingAsset Token address of the underlying asset. * @param expiry Yield contract expiry in epoch time. * @return True if valid, false otherwise. **/ function isValidXYT( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external view returns (bool); /** * @notice Checks if an OT token is valid. * @param forgeId The forgeId of the forge. * @param underlyingAsset Token address of the underlying asset. * @param expiry Yield contract expiry in epoch time. * @return True if valid, false otherwise. **/ function isValidOT( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external view returns (bool); function validForgeFactoryPair(bytes32 _forgeId, bytes32 _marketFactoryId) external view returns (bool); /** * @notice Gets a reference to a specific OT. * @param forgeId Forge and protocol identifier. * @param underlyingYieldToken Token address of the underlying yield token. * @param expiry Yield contract expiry in epoch time. * @return ot Returns the reference to an OT. **/ function otTokens( bytes32 forgeId, address underlyingYieldToken, uint256 expiry ) external view returns (IPendleYieldToken ot); /** * @notice Gets a reference to a specific XYT. * @param forgeId Forge and protocol identifier. * @param underlyingAsset Token address of the underlying asset * @param expiry Yield contract expiry in epoch time. * @return xyt Returns the reference to an XYT. **/ function xytTokens( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external view returns (IPendleYieldToken xyt); /*********** * MARKET * ***********/ event MarketPairAdded(address indexed market, address indexed xyt, address indexed token); function addMarketFactory(bytes32 marketFactoryId, address marketFactoryAddress) external; function isMarket(address _addr) external view returns (bool result); function isXyt(address _addr) external view returns (bool result); function addMarket( bytes32 marketFactoryId, address xyt, address token, address market ) external; function setMarketFees(uint256 _swapFee, uint256 _protocolSwapFee) external; function setInterestUpdateRateDeltaForMarket(uint256 _interestUpdateRateDeltaForMarket) external; function setLockParams(uint256 _lockNumerator, uint256 _lockDenominator) external; function setExpiryDivisor(uint256 _expiryDivisor) external; function setCurveShiftBlockDelta(uint256 _blockDelta) external; /** * @notice Displays the number of markets currently existing. * @return Returns markets length, **/ function allMarketsLength() external view returns (uint256); function forgeFee() external view returns (uint256); function interestUpdateRateDeltaForMarket() external view returns (uint256); function expiryDivisor() external view returns (uint256); function lockNumerator() external view returns (uint256); function lockDenominator() external view returns (uint256); function swapFee() external view returns (uint256); function protocolSwapFee() external view returns (uint256); function curveShiftBlockDelta() external view returns (uint256); function getMarketByIndex(uint256 index) external view returns (address market); /** * @notice Gets a market given a future yield token and an ERC20 token. * @param xyt Token address of the future yield token as base asset. * @param token Token address of an ERC20 token as quote asset. * @return market Returns the market address. **/ function getMarket( bytes32 marketFactoryId, address xyt, address token ) external view returns (address market); /** * @notice Gets a market factory given the identifier. * @param marketFactoryId MarketFactory identifier. * @return marketFactoryAddress Returns the factory address. **/ function getMarketFactoryAddress(bytes32 marketFactoryId) external view returns (address marketFactoryAddress); function getMarketFromKey( address xyt, address token, bytes32 marketFactoryId ) external view returns (address market); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.6; struct TokenReserve { uint256 weight; uint256 balance; } struct PendingTransfer { uint256 amount; bool isOut; }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "./IPendleRouter.sol"; interface IPendleMarketFactory { /** * @notice Creates a market given a protocol ID, future yield token, and an ERC20 token. * @param xyt Token address of the futuonlyCorere yield token as base asset. * @param token Token address of an ERC20 token as quote asset. * @return market Returns the address of the newly created market. **/ function createMarket(address xyt, address token) external returns (address market); /** * @notice Gets a reference to the PendleRouter contract. * @return Returns the router contract reference. **/ function router() external view returns (IPendleRouter); function marketFactoryId() external view returns (bytes32); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IPendleBaseToken.sol"; import "./IPendleForge.sol"; interface IPendleYieldToken is IERC20, IPendleBaseToken { /** * @notice Emitted when burning OT or XYT tokens. * @param user The address performing the burn. * @param amount The amount to be burned. **/ event Burn(address indexed user, uint256 amount); /** * @notice Emitted when minting OT or XYT tokens. * @param user The address performing the mint. * @param amount The amount to be minted. **/ event Mint(address indexed user, uint256 amount); /** * @notice Burns OT or XYT tokens from user, reducing the total supply. * @param user The address performing the burn. * @param amount The amount to be burned. **/ function burn(address user, uint256 amount) external; /** * @notice Mints new OT or XYT tokens for user, increasing the total supply. * @param user The address to send the minted tokens. * @param amount The amount to be minted. **/ function mint(address user, uint256 amount) external; /** * @notice Gets the forge address of the PendleForge contract for this yield token. * @return Retuns the forge address. **/ function forge() external view returns (IPendleForge); /** * @notice Returns the address of the underlying asset. * @return Returns the underlying asset address. **/ function underlyingAsset() external view returns (address); /** * @notice Returns the address of the underlying yield token. * @return Returns the underlying yield token address. **/ function underlyingYieldToken() external view returns (address); /** * @notice let the router approve itself to spend OT/XYT/LP from any wallet * @param user user to approve **/ function approveRouter(address user) external; }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; interface IPendlePausingManager { event AddPausingAdmin(address admin); event RemovePausingAdmin(address admin); event PendingForgeEmergencyHandler(address _pendingForgeHandler); event PendingMarketEmergencyHandler(address _pendingMarketHandler); event PendingLiqMiningEmergencyHandler(address _pendingLiqMiningHandler); event ForgeEmergencyHandlerSet(address forgeEmergencyHandler); event MarketEmergencyHandlerSet(address marketEmergencyHandler); event LiqMiningEmergencyHandlerSet(address liqMiningEmergencyHandler); event PausingManagerLocked(); event ForgeHandlerLocked(); event MarketHandlerLocked(); event LiqMiningHandlerLocked(); event SetForgePaused(bytes32 forgeId, bool settingToPaused); event SetForgeAssetPaused(bytes32 forgeId, address underlyingAsset, bool settingToPaused); event SetForgeAssetExpiryPaused( bytes32 forgeId, address underlyingAsset, uint256 expiry, bool settingToPaused ); event SetForgeLocked(bytes32 forgeId); event SetForgeAssetLocked(bytes32 forgeId, address underlyingAsset); event SetForgeAssetExpiryLocked(bytes32 forgeId, address underlyingAsset, uint256 expiry); event SetMarketFactoryPaused(bytes32 marketFactoryId, bool settingToPaused); event SetMarketPaused(bytes32 marketFactoryId, address market, bool settingToPaused); event SetMarketFactoryLocked(bytes32 marketFactoryId); event SetMarketLocked(bytes32 marketFactoryId, address market); event SetLiqMiningPaused(address liqMiningContract, bool settingToPaused); event SetLiqMiningLocked(address liqMiningContract); function forgeEmergencyHandler() external view returns ( address handler, address pendingHandler, uint256 timelockDeadline ); function marketEmergencyHandler() external view returns ( address handler, address pendingHandler, uint256 timelockDeadline ); function liqMiningEmergencyHandler() external view returns ( address handler, address pendingHandler, uint256 timelockDeadline ); function permLocked() external view returns (bool); function permForgeHandlerLocked() external view returns (bool); function permMarketHandlerLocked() external view returns (bool); function permLiqMiningHandlerLocked() external view returns (bool); function isPausingAdmin(address) external view returns (bool); function setPausingAdmin(address admin, bool isAdmin) external; function requestForgeHandlerChange(address _pendingForgeHandler) external; function requestMarketHandlerChange(address _pendingMarketHandler) external; function requestLiqMiningHandlerChange(address _pendingLiqMiningHandler) external; function applyForgeHandlerChange() external; function applyMarketHandlerChange() external; function applyLiqMiningHandlerChange() external; function lockPausingManagerPermanently() external; function lockForgeHandlerPermanently() external; function lockMarketHandlerPermanently() external; function lockLiqMiningHandlerPermanently() external; function setForgePaused(bytes32 forgeId, bool paused) external; function setForgeAssetPaused( bytes32 forgeId, address underlyingAsset, bool paused ) external; function setForgeAssetExpiryPaused( bytes32 forgeId, address underlyingAsset, uint256 expiry, bool paused ) external; function setForgeLocked(bytes32 forgeId) external; function setForgeAssetLocked(bytes32 forgeId, address underlyingAsset) external; function setForgeAssetExpiryLocked( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external; function checkYieldContractStatus( bytes32 forgeId, address underlyingAsset, uint256 expiry ) external returns (bool _paused, bool _locked); function setMarketFactoryPaused(bytes32 marketFactoryId, bool paused) external; function setMarketPaused( bytes32 marketFactoryId, address market, bool paused ) external; function setMarketFactoryLocked(bytes32 marketFactoryId) external; function setMarketLocked(bytes32 marketFactoryId, address market) external; function checkMarketStatus(bytes32 marketFactoryId, address market) external returns (bool _paused, bool _locked); function setLiqMiningPaused(address liqMiningContract, bool settingToPaused) external; function setLiqMiningLocked(address liqMiningContract) external; function checkLiqMiningStatus(address liqMiningContract) external returns (bool _paused, bool _locked); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; pragma abicoder v2; import "./IPendleRouter.sol"; import "./IPendleBaseToken.sol"; import "../libraries/PendleStructs.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IPendleMarket is IERC20 { /** * @notice Emitted when reserves pool has been updated * @param reserve0 The XYT reserves. * @param weight0 The XYT weight * @param reserve1 The generic token reserves. * For the generic Token weight it can be inferred by (2^40) - weight0 **/ event Sync(uint256 reserve0, uint256 weight0, uint256 reserve1); function setUpEmergencyMode(address spender) external; function bootstrap( address user, uint256 initialXytLiquidity, uint256 initialTokenLiquidity ) external returns (PendingTransfer[2] memory transfers, uint256 exactOutLp); function addMarketLiquiditySingle( address user, address inToken, uint256 inAmount, uint256 minOutLp ) external returns (PendingTransfer[2] memory transfers, uint256 exactOutLp); function addMarketLiquidityDual( address user, uint256 _desiredXytAmount, uint256 _desiredTokenAmount, uint256 _xytMinAmount, uint256 _tokenMinAmount ) external returns (PendingTransfer[2] memory transfers, uint256 lpOut); function removeMarketLiquidityDual( address user, uint256 inLp, uint256 minOutXyt, uint256 minOutToken ) external returns (PendingTransfer[2] memory transfers); function removeMarketLiquiditySingle( address user, address outToken, uint256 exactInLp, uint256 minOutToken ) external returns (PendingTransfer[2] memory transfers); function swapExactIn( address inToken, uint256 inAmount, address outToken, uint256 minOutAmount ) external returns (uint256 outAmount, PendingTransfer[2] memory transfers); function swapExactOut( address inToken, uint256 maxInAmount, address outToken, uint256 outAmount ) external returns (uint256 inAmount, PendingTransfer[2] memory transfers); function redeemLpInterests(address user) external returns (uint256 interests); function getReserves() external view returns ( uint256 xytBalance, uint256 xytWeight, uint256 tokenBalance, uint256 tokenWeight, uint256 currentBlock ); function factoryId() external view returns (bytes32); function token() external view returns (address); function xyt() external view returns (address); }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IPendleBaseToken is IERC20 { /** * @notice Decreases the allowance granted to spender by the caller. * @param spender The address to reduce the allowance from. * @param subtractedValue The amount allowance to subtract. * @return Returns true if allowance has decreased, otherwise false. **/ function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); /** * @notice The yield contract start in epoch time. * @return Returns the yield start date. **/ function start() external view returns (uint256); /** * @notice The yield contract expiry in epoch time. * @return Returns the yield expiry date. **/ function expiry() external view returns (uint256); /** * @notice Increases the allowance granted to spender by the caller. * @param spender The address to increase the allowance from. * @param addedValue The amount allowance to add. * @return Returns true if allowance has increased, otherwise false **/ function increaseAllowance(address spender, uint256 addedValue) external returns (bool); /** * @notice Returns the number of decimals the token uses. * @return Returns the token's decimals. **/ function decimals() external view returns (uint8); /** * @notice Returns the name of the token. * @return Returns the token's name. **/ function name() external view returns (string memory); /** * @notice Returns the symbol of the token. * @return Returns the token's symbol. **/ function symbol() external view returns (string memory); /** * @notice approve using the owner's signature **/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./PermissionsV2.sol"; abstract contract WithdrawableV2 is PermissionsV2 { using SafeERC20 for IERC20; event EtherWithdraw(uint256 amount, address sendTo); event TokenWithdraw(IERC20 token, uint256 amount, address sendTo); /** * @dev Allows governance to withdraw Ether in a Pendle contract * in case of accidental ETH transfer into the contract. * @param amount The amount of Ether to withdraw. * @param sendTo The recipient address. */ function withdrawEther(uint256 amount, address payable sendTo) external onlyGovernance { (bool success, ) = sendTo.call{value: amount}(""); require(success, "WITHDRAW_FAILED"); emit EtherWithdraw(amount, sendTo); } /** * @dev Allows governance to withdraw all IERC20 compatible tokens in a Pendle * contract in case of accidental token transfer into the contract. * @param token IERC20 The address of the token contract. * @param amount The amount of IERC20 tokens to withdraw. * @param sendTo The recipient address. */ function withdrawToken( IERC20 token, uint256 amount, address sendTo ) external onlyGovernance { require(_allowedToWithdraw(address(token)), "TOKEN_NOT_ALLOWED"); token.safeTransfer(sendTo, amount); emit TokenWithdraw(token, amount, sendTo); } // must be overridden by the sub contracts, so we must consider explicitly // in each and every contract which tokens are allowed to be withdrawn function _allowedToWithdraw(address) internal view virtual returns (bool allowed); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/cryptography/ECDSA.sol"; import "../interfaces/IPendleBaseToken.sol"; import "../interfaces/IPendleRouter.sol"; /** * @title PendleBaseToken * @dev The contract implements the standard ERC20 functions, plus some * Pendle specific fields and functions, namely: * - expiry * * This abstract contract is inherited by PendleFutureYieldToken * and PendleOwnershipToken contracts. **/ abstract contract PendleBaseToken is ERC20 { using SafeMath for uint256; uint256 public immutable start; uint256 public immutable expiry; IPendleRouter public immutable router; //// Start of EIP-2612 related part, exactly the same as UniswapV2ERC20.sol bytes32 public immutable DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint256) public nonces; //// End of EIP-2612 related part constructor( address _router, string memory _name, string memory _symbol, uint8 _decimals, uint256 _start, uint256 _expiry ) ERC20(_name, _symbol) { _setupDecimals(_decimals); start = _start; expiry = _expiry; router = IPendleRouter(_router); //// Start of EIP-2612 related part, exactly the same as UniswapV2ERC20.sol, except for the noted parts below uint256 chainId; assembly { chainId := chainid() // chainid() is a function in assembly in this solidity version } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(_name)), // use our own _name here keccak256(bytes("1")), chainId, address(this) ) ); //// End of EIP-2612 related part } //// Start of EIP-2612 related part, exactly the same as UniswapV2ERC20.sol function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { require(deadline >= block.timestamp, "PERMIT_EXPIRED"); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline ) ) ) ); address recoveredAddress = ECDSA.recover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNATURE"); _approve(owner, spender, value); } //// End of EIP-2612 related part function _beforeTokenTransfer( address from, address to, uint256 ) internal virtual override { require(to != address(this), "SEND_TO_TOKEN_CONTRACT"); require(to != from, "SEND_TO_SELF"); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./MathLib.sol"; import "./PendleStructs.sol"; library MarketMath { using SafeMath for uint256; /** * @notice calculate the exact amount of tokens that user need to put in the market * in order to get back certain amount of the other token * @param inTokenReserve market reserve details of token that user wants to put in * @param outTokenReserve market reserve details of token that user wants to get back * @param exactOut exact amount of token that user wants to get back * @param swapFee swap fee ratio for swap * @dev The formula for this function can be referred in the AMM Specs */ function _calcExactIn( TokenReserve memory inTokenReserve, TokenReserve memory outTokenReserve, uint256 exactOut, uint256 swapFee ) internal pure returns (uint256 exactIn) { uint256 weightRatio = Math.rdiv(outTokenReserve.weight, inTokenReserve.weight); uint256 diff = outTokenReserve.balance.sub(exactOut); uint256 y = Math.rdiv(outTokenReserve.balance, diff); uint256 foo = Math.rpow(y, weightRatio); foo = foo.sub(Math.RONE); exactIn = Math.RONE.sub(swapFee); exactIn = Math.rdiv(Math.rmul(inTokenReserve.balance, foo), exactIn); } /** * @notice calculate the exact amount of tokens that user can get back from the market * if user put in certain amount of the other token * @param inTokenReserve market reserve details of token that user wants to put in * @param outTokenReserve market reserve details of token that user wants to get back * @param exactIn exact amount of token that user wants to put in * @param swapFee swap fee (percentage) for swap * @dev The formula for this function can be referred in the AMM Specs */ function _calcExactOut( TokenReserve memory inTokenReserve, TokenReserve memory outTokenReserve, uint256 exactIn, uint256 swapFee ) internal pure returns (uint256 exactOut) { uint256 weightRatio = Math.rdiv(inTokenReserve.weight, outTokenReserve.weight); uint256 adjustedIn = Math.RONE.sub(swapFee); adjustedIn = Math.rmul(exactIn, adjustedIn); uint256 y = Math.rdiv(inTokenReserve.balance, inTokenReserve.balance.add(adjustedIn)); uint256 foo = Math.rpow(y, weightRatio); uint256 bar = Math.RONE.sub(foo); exactOut = Math.rmul(outTokenReserve.balance, bar); } /** * @notice to calculate exact amount of lp token to be minted if single token liquidity is added to market * @param inAmount exact amount of the token that user wants to put in * @param inTokenReserve market reserve details of the token that user wants to put in * @param swapFee swap fee (percentage) for swap * @param totalSupplyLp current (before adding liquidity) lp supply * @dev swap fee applies here since add liquidity by single token is equivalent of a swap * @dev used when add liquidity by single token * @dev The formula for this function can be referred in the AMM Specs */ function _calcOutAmountLp( uint256 inAmount, TokenReserve memory inTokenReserve, uint256 swapFee, uint256 totalSupplyLp ) internal pure returns (uint256 exactOutLp) { uint256 nWeight = inTokenReserve.weight; uint256 feePortion = Math.rmul(Math.RONE.sub(nWeight), swapFee); uint256 inAmountAfterFee = Math.rmul(inAmount, Math.RONE.sub(feePortion)); uint256 inBalanceUpdated = inTokenReserve.balance.add(inAmountAfterFee); uint256 inTokenRatio = Math.rdiv(inBalanceUpdated, inTokenReserve.balance); uint256 lpTokenRatio = Math.rpow(inTokenRatio, nWeight); uint256 totalSupplyLpUpdated = Math.rmul(lpTokenRatio, totalSupplyLp); exactOutLp = totalSupplyLpUpdated.sub(totalSupplyLp); return exactOutLp; } /** * @notice to calculate exact amount of token that user can get back if * single token liquidity is removed from market * @param outTokenReserve market reserve details of the token that user wants to get back * @param totalSupplyLp current (before adding liquidity) lp supply * @param inLp exact amount of the lp token (single liquidity to remove) that user wants to put in * @param swapFee swap fee (percentage) for swap * @dev swap fee applies here since add liquidity by single token is equivalent of a swap * @dev used when remove liquidity by single token * @dev The formula for this function can be referred in the AMM Specs */ function _calcOutAmountToken( TokenReserve memory outTokenReserve, uint256 totalSupplyLp, uint256 inLp, uint256 swapFee ) internal pure returns (uint256 exactOutToken) { uint256 nWeight = outTokenReserve.weight; uint256 totalSupplyLpUpdated = totalSupplyLp.sub(inLp); uint256 lpRatio = Math.rdiv(totalSupplyLpUpdated, totalSupplyLp); uint256 outTokenRatio = Math.rpow(lpRatio, Math.rdiv(Math.RONE, nWeight)); uint256 outTokenBalanceUpdated = Math.rmul(outTokenRatio, outTokenReserve.balance); uint256 outAmountTokenBeforeSwapFee = outTokenReserve.balance.sub(outTokenBalanceUpdated); uint256 feePortion = Math.rmul(Math.RONE.sub(nWeight), swapFee); exactOutToken = Math.rmul(outAmountTokenBeforeSwapFee, Math.RONE.sub(feePortion)); return exactOutToken; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../core/PendleGovernanceManager.sol"; import "../interfaces/IPermissionsV2.sol"; abstract contract PermissionsV2 is IPermissionsV2 { PendleGovernanceManager public immutable override governanceManager; address internal initializer; constructor(address _governanceManager) { require(_governanceManager != address(0), "ZERO_ADDRESS"); initializer = msg.sender; governanceManager = PendleGovernanceManager(_governanceManager); } modifier initialized() { require(initializer == address(0), "NOT_INITIALIZED"); _; } modifier onlyGovernance() { require(msg.sender == _governance(), "ONLY_GOVERNANCE"); _; } function _governance() internal view returns (address) { return governanceManager.governance(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; contract PendleGovernanceManager { address public governance; address public pendingGovernance; event GovernanceClaimed(address newGovernance, address previousGovernance); event TransferGovernancePending(address pendingGovernance); constructor(address _governance) { require(_governance != address(0), "ZERO_ADDRESS"); governance = _governance; } modifier onlyGovernance() { require(msg.sender == governance, "ONLY_GOVERNANCE"); _; } /** * @dev Allows the pendingGovernance address to finalize the change governance process. */ function claimGovernance() external { require(pendingGovernance == msg.sender, "WRONG_GOVERNANCE"); emit GovernanceClaimed(pendingGovernance, governance); governance = pendingGovernance; pendingGovernance = address(0); } /** * @dev Allows the current governance to set the pendingGovernance address. * @param _governance The address to transfer ownership to. */ function transferGovernance(address _governance) external onlyGovernance { require(_governance != address(0), "ZERO_ADDRESS"); pendingGovernance = _governance; emit TransferGovernancePending(pendingGovernance); } }
// SPDX-License-Identifier: MIT /* * MIT License * =========== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ pragma solidity 0.7.6; pragma abicoder v2; import "../core/PendleGovernanceManager.sol"; interface IPermissionsV2 { function governanceManager() external returns (PendleGovernanceManager); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @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 to 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 { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.7.0; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; library Math { using SafeMath for uint256; uint256 internal constant BIG_NUMBER = (uint256(1) << uint256(200)); uint256 internal constant PRECISION_BITS = 40; uint256 internal constant RONE = uint256(1) << PRECISION_BITS; uint256 internal constant PI = (314 * RONE) / 10**2; uint256 internal constant PI_PLUSONE = (414 * RONE) / 10**2; uint256 internal constant PRECISION_POW = 1e2; function checkMultOverflow(uint256 _x, uint256 _y) internal pure returns (bool) { if (_y == 0) return false; return (((_x * _y) / _y) != _x); } /** @notice find the integer part of log2(p/q) => find largest x s.t p >= q * 2^x => find largest x s.t 2^x <= p / q */ function log2Int(uint256 _p, uint256 _q) internal pure returns (uint256) { uint256 res = 0; uint256 remain = _p / _q; while (remain > 0) { res++; remain /= 2; } return res - 1; } /** @notice log2 for a number that it in [1,2) @dev _x is FP, return a FP @dev function is from Kyber. Long modified the condition to be (_x >= one) && (_x < two) to avoid the case where x = 2 may lead to incorrect result */ function log2ForSmallNumber(uint256 _x) internal pure returns (uint256) { uint256 res = 0; uint256 one = (uint256(1) << PRECISION_BITS); uint256 two = 2 * one; uint256 addition = one; require((_x >= one) && (_x < two), "MATH_ERROR"); require(PRECISION_BITS < 125, "MATH_ERROR"); for (uint256 i = PRECISION_BITS; i > 0; i--) { _x = (_x * _x) / one; addition = addition / 2; if (_x >= two) { _x = _x / 2; res += addition; } } return res; } /** @notice log2 of (p/q). returns result in FP form @dev function is from Kyber. @dev _p & _q is FP, return a FP */ function logBase2(uint256 _p, uint256 _q) internal pure returns (uint256) { uint256 n = 0; if (_p > _q) { n = log2Int(_p, _q); } require(n * RONE <= BIG_NUMBER, "MATH_ERROR"); require(!checkMultOverflow(_p, RONE), "MATH_ERROR"); require(!checkMultOverflow(n, RONE), "MATH_ERROR"); require(!checkMultOverflow(uint256(1) << n, _q), "MATH_ERROR"); uint256 y = (_p * RONE) / (_q * (uint256(1) << n)); uint256 log2Small = log2ForSmallNumber(y); assert(log2Small <= BIG_NUMBER); return n * RONE + log2Small; } /** @notice calculate ln(p/q). returned result >= 0 @dev function is from Kyber. @dev _p & _q is FP, return a FP */ function ln(uint256 p, uint256 q) internal pure returns (uint256) { uint256 ln2Numerator = 6931471805599453094172; uint256 ln2Denomerator = 10000000000000000000000; uint256 log2x = logBase2(p, q); require(!checkMultOverflow(ln2Numerator, log2x), "MATH_ERROR"); return (ln2Numerator * log2x) / ln2Denomerator; } /** @notice extract the fractional part of a FP @dev value is a FP, return a FP */ function fpart(uint256 value) internal pure returns (uint256) { return value % RONE; } /** @notice convert a FP to an Int @dev value is a FP, return an Int */ function toInt(uint256 value) internal pure returns (uint256) { return value / RONE; } /** @notice convert an Int to a FP @dev value is an Int, return a FP */ function toFP(uint256 value) internal pure returns (uint256) { return value * RONE; } /** @notice return e^exp in FP form @dev estimation by formula at http://pages.mtu.edu/~shene/COURSES/cs201/NOTES/chap04/exp.html the function is based on exp function of: https://github.com/NovakDistributed/macroverse/blob/master/contracts/RealMath.sol @dev the function is expected to converge quite fast, after about 20 iteration @dev exp is a FP, return a FP */ function rpowe(uint256 exp) internal pure returns (uint256) { uint256 res = 0; uint256 curTerm = RONE; for (uint256 n = 0; ; n++) { res += curTerm; curTerm = rmul(curTerm, rdiv(exp, toFP(n + 1))); if (curTerm == 0) { break; } if (n == 500) { /* testing shows that in the most extreme case, it will take 430 turns to converge. however, it's expected that the numbers will not exceed 2^120 in normal situation the most extreme case is rpow((1<<256)-1,(1<<40)-1) (equal to rpow((2^256-1)/2^40,0.99..9)) */ revert("RPOWE_SLOW_CONVERGE"); } } return res; } /** @notice calculate base^exp with base and exp being FP int @dev to improve accuracy, base^exp = base^(int(exp)+frac(exp)) = base^int(exp) * base^frac @dev base & exp are FP, return a FP */ function rpow(uint256 base, uint256 exp) internal pure returns (uint256) { if (exp == 0) { // Anything to the 0 is 1 return RONE; } if (base == 0) { // 0 to anything except 0 is 0 return 0; } uint256 frac = fpart(exp); // get the fractional part uint256 whole = exp - frac; uint256 wholePow = rpowi(base, toInt(whole)); // whole is a FP, convert to Int uint256 fracPow; // instead of calculating base ^ frac, we will calculate e ^ (frac*ln(base)) if (base < RONE) { /* since the base is smaller than 1.0, ln(base) < 0. Since 1 / (e^(frac*ln(1/base))) = e ^ (frac*ln(base)), we will calculate 1 / (e^(frac*ln(1/base))) instead. */ uint256 newExp = rmul(frac, ln(rdiv(RONE, base), RONE)); fracPow = rdiv(RONE, rpowe(newExp)); } else { /* base is greater than 1, calculate normally */ uint256 newExp = rmul(frac, ln(base, RONE)); fracPow = rpowe(newExp); } return rmul(wholePow, fracPow); } /** @notice return base^exp with base in FP form and exp in Int @dev this function use a technique called: exponentiating by squaring complexity O(log(q)) @dev function is from Kyber. @dev base is a FP, exp is an Int, return a FP */ function rpowi(uint256 base, uint256 exp) internal pure returns (uint256) { uint256 res = exp % 2 != 0 ? base : RONE; for (exp /= 2; exp != 0; exp /= 2) { base = rmul(base, base); if (exp % 2 != 0) { res = rmul(res, base); } } return res; } /** @dev y is an Int, returns an Int @dev babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) @dev from Uniswap */ function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } /** @notice divide 2 FP, return a FP @dev function is from Balancer. @dev x & y are FP, return a FP */ function rdiv(uint256 x, uint256 y) internal pure returns (uint256) { return (y / 2).add(x.mul(RONE)).div(y); } /** @notice multiply 2 FP, return a FP @dev function is from Balancer. @dev x & y are FP, return a FP */ function rmul(uint256 x, uint256 y) internal pure returns (uint256) { return (RONE / 2).add(x.mul(y)).div(RONE); } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function subMax0(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a - b : 0; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_governanceManager","type":"address"},{"internalType":"address","name":"_xyt","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"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":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"EtherWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserve0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"weight0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserve1","type":"uint256"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"TokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":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"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"_desiredXytAmount","type":"uint256"},{"internalType":"uint256","name":"_desiredTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_xytMinAmount","type":"uint256"},{"internalType":"uint256","name":"_tokenMinAmount","type":"uint256"}],"name":"addMarketLiquidityDual","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"},{"internalType":"uint256","name":"lpOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"_inToken","type":"address"},{"internalType":"uint256","name":"_exactIn","type":"uint256"},{"internalType":"uint256","name":"_minOutLp","type":"uint256"}],"name":"addMarketLiquiditySingle","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"},{"internalType":"uint256","name":"exactOutLp","type":"uint256"}],"stateMutability":"nonpayable","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":"user","type":"address"},{"internalType":"uint256","name":"initialXytLiquidity","type":"uint256"},{"internalType":"uint256","name":"initialTokenLiquidity","type":"uint256"}],"name":"bootstrap","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"},{"internalType":"uint256","name":"exactOutLp","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bootstrapped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expiry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint256","name":"xytBalance","type":"uint256"},{"internalType":"uint256","name":"xytWeight","type":"uint256"},{"internalType":"uint256","name":"tokenBalance","type":"uint256"},{"internalType":"uint256","name":"tokenWeight","type":"uint256"},{"internalType":"uint256","name":"currentBlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governanceManager","outputs":[{"internalType":"contract PendleGovernanceManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastCurveShiftBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastNYield","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastParamK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paramL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"redeemLpInterests","outputs":[{"internalType":"uint256","name":"interests","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"_inLp","type":"uint256"},{"internalType":"uint256","name":"_minOutXyt","type":"uint256"},{"internalType":"uint256","name":"_minOutToken","type":"uint256"}],"name":"removeMarketLiquidityDual","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"_outToken","type":"address"},{"internalType":"uint256","name":"_inLp","type":"uint256"},{"internalType":"uint256","name":"_minOutAmountToken","type":"uint256"}],"name":"removeMarketLiquiditySingle","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IPendleRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"setUpEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"start","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inToken","type":"address"},{"internalType":"uint256","name":"inAmount","type":"uint256"},{"internalType":"address","name":"outToken","type":"address"},{"internalType":"uint256","name":"minOutAmount","type":"uint256"}],"name":"swapExactIn","outputs":[{"internalType":"uint256","name":"outAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inToken","type":"address"},{"internalType":"uint256","name":"maxInAmount","type":"uint256"},{"internalType":"address","name":"outToken","type":"address"},{"internalType":"uint256","name":"outAmount","type":"uint256"}],"name":"swapExactOut","outputs":[{"internalType":"uint256","name":"inAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isOut","type":"bool"}],"internalType":"struct PendingTransfer[2]","name":"transfers","type":"tuple[2]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"sendTo","type":"address"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"sendTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xyt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61026060405265010000000000600f553480156200001c57600080fd5b5060405162005b4f38038062005b4f8339810160408190526200003f9162000f07565b82828282826001600160a01b0316636c6f42396040518163ffffffff1660e01b815260040160206040518083038186803b1580156200007d57600080fd5b505afa15801562000092573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000b8919062000ee8565b6001600160a01b031663f887ea406040518163ffffffff1660e01b815260040160206040518083038186803b158015620000f157600080fd5b505afa15801562000106573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200012c919062000ee8565b6040518060400160405280600d81526020016c14195b991b194813585c9ad95d609a1b8152506040518060400160405280600a8152602001691411539113114b53141560b21b815250601242876001600160a01b031663e184c9be6040518163ffffffff1660e01b815260040160206040518083038186803b158015620001b257600080fd5b505afa158015620001c7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001ed919062000f5a565b8451859085906200020690600390602085019062000e3c565b5080516200021c90600490602084019062000e3c565b50506005805460ff1916601217905550620002378362000a14565b608091825260a09081526001600160601b0319606096871b1660c0908152855160209687012060408051808201825260018152603160f81b9089015280517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818a0152808201929092527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6988201989098524693810193909352308383015286518084039092018252919091019094525050815191012060e0526001600160a01b0381166200033c576040805162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015290519081900360640190fd5b60078054336001600160a01b031990911617905560601b6001600160601b031916610100526001600160a01b038216620003935760405162461bcd60e51b81526004016200038a9062000f9f565b60405180910390fd5b6001600160a01b038116620003bc5760405162461bcd60e51b81526004016200038a9062000f9f565b816001600160a01b031663ddf0fa836040518163ffffffff1660e01b815260040160206040518083038186803b158015620003f657600080fd5b505afa1580156200040b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000431919062000ee8565b6001600160a01b0316816001600160a01b03161415620004655760405162461bcd60e51b81526004016200038a9062000f73565b6000826001600160a01b0316636c6f42396040518163ffffffff1660e01b815260040160206040518083038186803b158015620004a157600080fd5b505afa158015620004b6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004dc919062000ee8565b6001600160601b0319606082811b82166101405285811b82166101805284901b16610160526040805163beb9a97360e01b815290519192506001600160a01b0383169163beb9a97391600480820192602092909190829003018186803b1580156200054657600080fd5b505afa1580156200055b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000581919062000f5a565b6101a08181525050826001600160a01b0316637158da7c6040518163ffffffff1660e01b815260040160206040518083038186803b158015620005c357600080fd5b505afa158015620005d8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005fe919062000ee8565b6001600160a01b03166101c0816001600160a01b031660601b81525050826001600160a01b031663ddf0fa836040518163ffffffff1660e01b815260040160206040518083038186803b1580156200065557600080fd5b505afa1580156200066a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000690919062000ee8565b6001600160a01b03166101e0816001600160a01b031660601b81525050806001600160a01b03166373d4a13a6040518163ffffffff1660e01b815260040160206040518083038186803b158015620006e757600080fd5b505afa158015620006fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000722919062000ee8565b6001600160a01b0316610200816001600160a01b031660601b81525050806001600160a01b03166373d4a13a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200077957600080fd5b505afa1580156200078e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007b4919062000ee8565b6001600160a01b031663be66c60f6040518163ffffffff1660e01b815260040160206040518083038186803b158015620007ed57600080fd5b505afa15801562000802573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000828919062000ee8565b6001600160a01b0316610220816001600160a01b031660601b81525050826001600160a01b031663be9a65556040518163ffffffff1660e01b815260040160206040518083038186803b1580156200087f57600080fd5b505afa15801562000894573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008ba919062000f5a565b6102408181525050336001600160a01b031663a6ce5c0b6040518163ffffffff1660e01b815260040160206040518083038186803b158015620008fc57600080fd5b505afa15801562000911573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000937919062000f5a565b61012081815250506000816001600160a01b031663f887ea406040518163ffffffff1660e01b815260040160206040518083038186803b1580156200097b57600080fd5b505afa15801562000990573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009b6919062000ee8565b9050620009df81600019866001600160a01b031662000a2a60201b620019cd179092919060201c565b62000a0681600019856001600160a01b031662000a2a60201b620019cd179092919060201c565b505050505050505062000fde565b6005805460ff191660ff92909216919091179055565b80158062000ab4575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801562000a8457600080fd5b505afa15801562000a99573d6000803e3d6000fd5b505050506040513d602081101562000ab057600080fd5b5051155b62000af15760405162461bcd60e51b815260040180806020018281038252603681526020018062005b196036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b1790915262000b4991859162000b4e16565b505050565b600062000baa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000c0a60201b62001ae0179092919060201c565b80519091501562000b495780806020019051602081101562000bcb57600080fd5b505162000b495760405162461bcd60e51b815260040180806020018281038252602a81526020018062005aef602a913960400191505060405180910390fd5b606062000c1b848460008562000c25565b90505b9392505050565b60608247101562000c685760405162461bcd60e51b815260040180806020018281038252602681526020018062005ac96026913960400191505060405180910390fd5b62000c738562000d8c565b62000cc5576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831062000d055780518252601f19909201916020918201910162000ce4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811462000d69576040519150601f19603f3d011682016040523d82523d6000602084013e62000d6e565b606091505b50909250905062000d8182828662000d92565b979650505050505050565b3b151590565b6060831562000da357508162000c1e565b82511562000db45782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101562000e0057818101518382015260200162000de6565b50505050905090810190601f16801562000e2e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b828054600181600116156101000203166002900490600052602060002090601f01602090048101928262000e74576000855562000ebf565b82601f1062000e8f57805160ff191683800117855562000ebf565b8280016001018555821562000ebf579182015b8281111562000ebf57825182559160200191906001019062000ea2565b5062000ecd92915062000ed1565b5090565b5b8082111562000ecd576000815560010162000ed2565b60006020828403121562000efa578081fd5b815162000c1e8162000fc5565b60008060006060848603121562000f1c578182fd5b835162000f298162000fc5565b602085015190935062000f3c8162000fc5565b604085015190925062000f4f8162000fc5565b809150509250925092565b60006020828403121562000f6c578081fd5b5051919050565b60208082526012908201527124a72b20a624a22faa27a5a2a72fa820a4a960711b604082015260600190565b6020808252600c908201526b5a45524f5f4144445245535360a01b604082015260600190565b6001600160a01b038116811462000fdb57600080fd5b50565b60805160a05160c05160601c60e0516101005160601c610120516101405160601c6101605160601c6101805160601c6101a0516101c05160601c6101e05160601c6102005160601c6102205160601c6102405161497d6200114c60003980611bf05280612cb55250806113a3528061146f5280612bc45250806107ce52806109825280610d8252806118795280611b295280611ec25280611fc652806122185280612ce25280612d765280613d995250806115a45280612a96528061306e528061311c5280613c0852508061364b5280613b4f525080613b2d525080610779528061153852806123ed528061257c5280612a0652508061156e52806119ab5280612a4352508061361e5250806104f152806113d05280612bf15250806115d4528061297a525080610bb852806116d25250806110d652806119875280611e585280613b005250806117db5280611bcf5280612c945280612e135280613b71525080611228525061497d6000f3fe608060405234801561001057600080fd5b50600436106102485760003560e01c806370a082311161013b578063ce56c454116100b8578063e184c9be1161007c578063e184c9be146104b1578063f04bcd7c146104b9578063f85c9ce2146104cc578063f887ea40146104df578063fc0c546a146104e757610248565b8063ce56c4541461045d578063d02fba5114610470578063d2e6d1c314610483578063d505accf1461048b578063dd62ed3e1461049e57610248565b806395d89b41116100ff57806395d89b4114610414578063a457c2d71461041c578063a6f319bb1461042f578063a9059cbb14610442578063be9a65551461045557610248565b806370a08231146103cb5780637ecebe00146103de578063834c2955146103f157806389abe8be146104045780638f373bf31461040c57610248565b806330adf81f116101c95780633ccdbb281161018d5780633ccdbb281461038b578063437e5b92146103a057806348fa6ede146103a8578063541a7ca6146103bb57806362c7fa76146103c357610248565b806330adf81f1461034b578063313ce5671461035357806335142c8c146103685780633644e51514610370578063395093511461037857610248565b80630d9b13d9116102105780630d9b13d9146102da5780630dd2cbb9146102ef5780631569f6a41461030f57806318160ddd1461033057806323b872dd1461033857610248565b806304ce07f11461024d57806306fdde031461026b5780630902f1ac14610280578063095ea7b3146102995780630aa725f2146102b9575b600080fd5b6102556104ef565b60405161026291906142e8565b60405180910390f35b610273610513565b604051610262919061432f565b6102886105a9565b6040516102629594939291906146b2565b6102ac6102a7366004614097565b6105e8565b60405161026291906142dd565b6102cc6102c7366004614177565b610606565b6040516102629291906142c2565b6102e2610777565b60405161026291906142a0565b6103026102fd366004613fdd565b61079b565b60405161026291906142b4565b61032261031d3660046140c2565b610927565b604051610262929190614688565b610255610aeb565b6102ac610346366004613f5b565b610af1565b610255610b79565b61035b610b9d565b60405161026291906146d5565b6102ac610ba6565b610255610bb6565b6102ac610386366004614097565b610bda565b61039e6103993660046141ec565b610c28565b005b610255610d38565b6102cc6103b6366004613fdd565b610d3e565b610255610e86565b610255610e8c565b6102556103d9366004613eeb565b610e92565b6102556103ec366004613eeb565b610eb1565b6103026103ff36600461413d565b610ec3565b610255610fec565b610255610ff2565b610273610ff8565b6102ac61042a366004614097565b611059565b6102cc61043d366004614109565b6110c1565b6102ac610450366004614097565b611212565b610255611226565b61039e61046b366004614245565b61124a565b61039e61047e366004613eeb565b611389565b6102e26115d2565b61039e610499366004614022565b6115f6565b6102556104ac366004613f23565b6117ae565b6102556117d9565b6102556104c7366004613eeb565b6117fd565b6103226104da3660046140c2565b61181e565b6102e2611985565b6102e26119a9565b7f000000000000000000000000000000000000000000000000000000000000000081565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059f5780601f106105745761010080835404028352916020019161059f565b820191906000526020600020905b81548152906001019060200180831161058257829003601f168201915b5050505050905090565b60008060008060006105b9611af7565b9297509550935091506105ca611b22565b156105de576105d7611bc8565b5090945091505b4390509091929394565b60006105fc6105f5611d2c565b8484611d30565b5060015b92915050565b61060e613e7d565b600061061a6000611e1c565b610622611ebe565b600080600061062f611af7565b509194509250905060008061064e856106488d87612083565b906120dc565b90508981116106a057878110156106805760405162461bcd60e51b8152600401610677906144cc565b60405180910390fd5b8a915061069985610648610692610aeb565b8e90612083565b95506106eb565b6106ae846106488c88612083565b9150888210156106d05760405162461bcd60e51b81526004016106779061449c565b50886106e8846106486106e1610aeb565b8d90612083565b95505b6106f58583612143565b87518390528751600060209091015294506107108482612143565b60208089018051849052516000910152935061072d85858561219d565b610735612216565b61073f8c876122be565b6000805160206147f08339815191528584866040516107609392919061469c565b60405180910390a150505050509550959350505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6107a3613e7d565b6107ad6000611e1c565b6107b5611ebe565b6107bd6123ae565b60006107c8856123cd565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561082557600080fd5b505afa158015610839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085d919061422d565b90506000610869610aeb565b9050600061087984838986612462565b90508581101561089b5760405162461bcd60e51b815260040161067790614447565b60208401516108aa9082612507565b6020858101919091528551829052855160019101526108c98489612564565b6108d1612216565b6108db89886125f2565b60008060006108e8611af7565b509250925092506000805160206147f08339815191528382846040516109109392919061469c565b60405180910390a150505050505050949350505050565b6000610931613e7d565b61093b6000611e1c565b610943611b22565b1561096057610950611ebe565b6109586123ae565b610960612216565b600061096b876123cd565b90506000610978866123cd565b9050610a168282877f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109d957600080fd5b505afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a11919061422d565b6126ee565b935086841115610a385760405162461bcd60e51b815260040161067790614382565b6020820151610a479085612143565b602080840191909152810151610a5d9086612507565b6020820152610a6c8289612564565b610a768187612564565b825184905282516000602090910152848360015b602090810291909101519190915283810151600191015260008080610aad611af7565b509250925092506000805160206147f0833981519152838284604051610ad59392919061469c565b60405180910390a1505050505094509492505050565b60025490565b6000610afe848484612784565b610b6e84610b0a611d2c565b610b6985604051806060016040528060288152602001614831602891396001600160a01b038a16600090815260016020526040812090610b48611d2c565b6001600160a01b0316815260208101919091526040016000205491906128df565b611d30565b5060015b9392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460ff1690565b600754600160a01b900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006105fc610be7611d2c565b84610b698560016000610bf8611d2c565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612143565b610c30612976565b6001600160a01b0316336001600160a01b031614610c87576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b610c9083612a02565b610cd5576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b610ce96001600160a01b0384168284612ad0565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b600d5481565b610d46613e7d565b6000610d526000611e1c565b610d5a611ebe565b610d626123ae565b6000610d6d866123cd565b90506000610d79610aeb565b9050610e1786837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dd957600080fd5b505afa158015610ded573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e11919061422d565b84612b22565b925084831015610e395760405162461bcd60e51b815260040161067790614582565b6020820151610e489087612143565b602083810191909152845187905284516000910152610e678288612564565b610e6f612216565b610e7988846122be565b6000806000610aad611af7565b60085481565b60105481565b6001600160a01b0381166000908152602081905260409020545b919050565b60066020526000908152604090205481565b610ecb613e7d565b610ed56001611e1c565b610edd611ebe565b6000610ee7610aeb565b90506000806000610ef6611af7565b50919450925090506000610f0e856106488b87612083565b90506000610f20866106488c87612083565b905087811015610f425760405162461bcd60e51b815260040161067790614447565b88821015610f625760405162461bcd60e51b8152600401610677906145ad565b610f6c8583612507565b9450610f788482612507565b8751839052875160016020918201819052818a01805185905251909101529350610fa385858561219d565b610fab612216565b610fb58b8b6125f2565b6000805160206147f0833981519152858486604051610fd69392919061469c565b60405180910390a1505050505050949350505050565b600c5481565b60095481565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059f5780601f106105745761010080835404028352916020019161059f565b60006105fc611066611d2c565b84610b69856040518060600160405280602581526020016149236025913960016000611090611d2c565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906128df565b6110c9613e7d565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146111135760405162461bcd60e51b815260040161067790614477565b61111b612baa565b600754600160a01b900460ff16156111455760405162461bcd60e51b815260040161067790614554565b61114d612c8d565b61115d848464800000000061219d565b611165612216565b6040516000805160206147f08339815191529061118c90869064800000000090879061469c565b60405180910390a161119c612e3f565b6111ba6103e86111b46111af8787612083565b612e51565b90612507565b90506111c960016103e86122be565b6111d385826122be565b8151939093528051600060209182018190528183018051949094529251019190915243600d556007805460ff60a01b1916600160a01b17905592909150565b60006105fc61121f611d2c565b8484612784565b7f000000000000000000000000000000000000000000000000000000000000000081565b611252612976565b6001600160a01b0316336001600160a01b0316146112a9576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d80600081146112f4576040519150601f19603f3d011682016040523d82523d6000602084013e6112f9565b606091505b5050905080611341576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b6040516333a2ae8d60e11b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906367455d1a906113fa907f00000000000000000000000000000000000000000000000000000000000000009030906004016142f1565b6040805180830381600087803b15801561141357600080fd5b505af1158015611427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144b91906141ba565b9150508061146b5760405162461bcd60e51b8152600401610677906143a8565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166331c7f53a6040518163ffffffff1660e01b815260040160606040518083038186803b1580156114c657600080fd5b505afa1580156114da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fe9190613f9b565b5090915050336001600160a01b0382161461152b5760405162461bcd60e51b8152600401610677906145da565b6115616001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016846000196119cd565b6115976001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016846000196119cd565b6115cd6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016846000196119cd565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b4284101561163c576040805162461bcd60e51b815260206004820152600e60248201526d14115493525517d156141254915160921b604482015290519081900360640190fd5b6001600160a01b03808816600081815260066020908152604080832080546001810190915581517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98185015280830195909552948b166060850152608084018a905260a084019490945260c08084018990528451808503909101815260e08401855280519082012061190160f01b6101008501527f00000000000000000000000000000000000000000000000000000000000000006101028501526101228085019190915284518085039091018152610142909301909352815191909201209061172882868686612ea2565b90506001600160a01b038116158015906117535750886001600160a01b0316816001600160a01b0316145b611798576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b6117a3898989611d30565b505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006118096001611e1c565b61181282613020565b9050610eac828261305e565b6000611828613e7d565b6118326000611e1c565b61183a611b22565b1561185757611847611ebe565b61184f6123ae565b611857612216565b6000611862876123cd565b9050600061186f866123cd565b905061190d8282897f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118d057600080fd5b505afa1580156118e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611908919061422d565b613143565b93508484101561192f5760405162461bcd60e51b815260040161067790614660565b602082015161193e9088612143565b6020808401919091528101516119549085612507565b60208201526119638289612564565b61196d8187612564565b82518790528251600060209091015283836001610a8a565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b801580611a53575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611a2557600080fd5b505afa158015611a39573d6000803e3d6000fd5b505050506040513d6020811015611a4f57600080fd5b5051155b611a8e5760405162461bcd60e51b81526004018080602001828103825260368152602001806148ed6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526115cd9084906131d2565b6060611aef8484600085613283565b949350505050565b600e54609481901c91602882901c60016001606c1b03169164ffffffffff1690600160281b82900390565b6000611bc17f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d8168c486040518163ffffffff1660e01b815260040160206040518083038186803b158015611b8057600080fd5b505afa158015611b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb8919061422d565b600d5490612143565b4311905090565b60008080427f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000008082038480611c1c611af7565b9350935050506000868610611c345750858503611c38565b5060005b6000611c4d600160281b8381029087026133de565b9050611c89611c7d611c73600160281b611c6d650323d70a3d7086613400565b90612143565b600160281b613423565b65016bb2b81a526133de565b98506000611c998a600f546133de565b9050600160281b811115611cbf5760405162461bcd60e51b8152600401610677906143fc565b6000611ce1611cce8787613400565b611cdc600160281b85612507565b613400565b90506000611cf386611c6d858a613400565b90506000611d0183836133de565b9050611d0d8882612507565b9e50611d198782612143565b9d50505050505050505050505050909192565b3390565b6001600160a01b038316611d755760405162461bcd60e51b815260040180806020018281038252602481526020018061489f6024913960400191505060405180910390fd5b6001600160a01b038216611dba5760405162461bcd60e51b815260040180806020018281038252602281526020018061473e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b611e24612baa565b600754600160a01b900460ff16611e4d5760405162461bcd60e51b81526004016106779061452a565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611e955760405162461bcd60e51b815260040161067790614477565b80611ebb576010544210611ebb5760405162461bcd60e51b815260040161067790614420565b50565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b06459b56040518163ffffffff1660e01b815260040160206040518083038186803b158015611f1957600080fd5b505afa158015611f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f51919061422d565b600c54909150811561207357801561206e576000611f6d613485565b90508181111561206c576000611f94611f868385612507565b611f8e610aeb565b90612083565b90506000611fb284611c6d8761064887611f8e600160281b84612507565b90506000818381611fbf57fe5b04905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b15801561201d57600080fd5b505afa158015612031573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120559190613f07565b905081156120675761206781836122be565b505050505b505b61207f565b801561207f576000600c555b5050565b60008261209257506000610600565b8282028284828161209f57fe5b0414610b725760405162461bcd60e51b81526004018080602001828103825260218152602001806148106021913960400191505060405180910390fd5b6000808211612132576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161213b57fe5b049392505050565b600082820183811015610b72576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b8260001080156121b4575060016001606c1b038311155b6121d05760405162461bcd60e51b815260040161067790614636565b8160001080156121e7575060016001606c1b038211155b6122035760405162461bcd60e51b8152600401610677906143cf565b60949290921b60289190911b1717600e55565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b06459b56040518163ffffffff1660e01b815260040160206040518083038186803b15801561226f57600080fd5b505afa158015612283573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a7919061422d565b6122b0576122bc565b6122b8613485565b600c555b565b6001600160a01b038216612319576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b612325600083836134db565b6002546123329082612143565b6002556001600160a01b0382166000908152602081905260409020546123589082612143565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6123b6611b22565b6123bf576122bc565b6123c761351e565b43600d55565b6123d5613eaa565b6000806000806123e3611af7565b93509350935093507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b03161415612441576040518060400160405280838152602001858152509450612459565b60405180604001604052808281526020018481525094505b50505050919050565b8351600090816124728686612507565b9050600061248082886133de565b9050600061249b82612496600160281b876133de565b613552565b905060006124ad828b60200151613400565b905060006124c8828c6020015161250790919063ffffffff16565b905060006124e36124dd600160281b89612507565b8a613400565b90506124f782611cdc600160281b84612507565b9c9b505050505050505050505050565b60008282111561255e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600080600080612572611af7565b93509350935093507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316856001600160a01b031614156125c45785516020870151945091506125df565b508451602086015192506125dc600160281b82612507565b91505b6125ea84848461219d565b505050505050565b6001600160a01b0382166126375760405162461bcd60e51b81526004018080602001828103825260218152602001806148596021913960400191505060405180910390fd5b612643826000836134db565b6126808160405180606001604052806022815260200161471c602291396001600160a01b03851660009081526020819052604090205491906128df565b6001600160a01b0383166000908152602081905260409020556002546126a69082612507565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600080612703856000015187600001516133de565b9050600061271e85876020015161250790919063ffffffff16565b905060006127308760200151836133de565b9050600061273e8285613552565b905061274e81600160281b612507565b905061275e600160281b87612507565b94506127776127718a6020015183613400565b866133de565b9998505050505050505050565b6001600160a01b0383166127c95760405162461bcd60e51b815260040180806020018281038252602581526020018061487a6025913960400191505060405180910390fd5b6001600160a01b03821661280e5760405162461bcd60e51b81526004018080602001828103825260238152602001806146f96023913960400191505060405180910390fd5b6128198383836134db565b61285681604051806060016040528060268152602001614760602691396001600160a01b03861660009081526020819052604090205491906128df565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546128859082612143565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561296e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561293357818101518382015260200161291b565b50505050905090810190601f1680156129605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b1580156129d157600080fd5b505afa1580156129e5573d6000803e3d6000fd5b505050506040513d60208110156129fb57600080fd5b5051905090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614158015612a7857507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b8015612a8d57506001600160a01b0382163014155b801561060057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141592915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115cd9084906131d2565b825160009081612b3f612b39600160281b84612507565b86613400565b90506000612b5588611cdc600160281b85612507565b90506000612b7082896020015161214390919063ffffffff16565b90506000612b82828a602001516133de565b90506000612b908287613552565b90506000612b9e828a613400565b90506124f7818a612507565b6040516333a2ae8d60e11b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906367455d1a90612c1b907f00000000000000000000000000000000000000000000000000000000000000009030906004016142f1565b6040805180830381600087803b158015612c3457600080fd5b505af1158015612c48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c6c91906141ba565b5090508015611ebb5760405162461bcd60e51b815260040161067790614503565b6000612cd97f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612507565b90506000612e0c7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166338c143f46040518163ffffffff1660e01b815260040160206040518083038186803b158015612d3957600080fd5b505afa158015612d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d71919061422d565b6106487f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ff845ced6040518163ffffffff1660e01b815260040160206040518083038186803b158015612dcd57600080fd5b505afa158015612de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e05919061422d565b8590612083565b9050612e387f000000000000000000000000000000000000000000000000000000000000000082612507565b6010555050565b6001600855612e4c613604565b601155565b60006003821115612e94575080600160028204015b81811015612e8e57809150600281828581612e7d57fe5b040181612e8657fe5b049050612e66565b50610eac565b8115610eac57506001919050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115612f035760405162461bcd60e51b81526004018080602001828103825260228152602001806147866022913960400191505060405180910390fd5b8360ff16601b1480612f1857508360ff16601c145b612f535760405162461bcd60e51b81526004018080602001828103825260228152602001806147ce6022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015612faf573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613017576040805162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015290519081900360640190fd5b95945050505050565b600061302b826136ca565b506001600160a01b0381166000908152600b602052604081208054919055600954613056908261379b565b600955919050565b806130685761207f565b61310d817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016130b891906142a0565b60206040518083038186803b1580156130d057600080fd5b505afa1580156130e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613108919061422d565b6137ac565b905061207f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383612ad0565b600080613158866000015186600001516133de565b9050600061316a600160281b85612507565b90506131768582613400565b60208801519091506000906131949061318f8185612143565b6133de565b905060006131a28285613552565b905060006131b4600160281b83612507565b90506131c4896020015182613400565b9a9950505050505050505050565b6000613227826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611ae09092919063ffffffff16565b8051909150156115cd5780806020019051602081101561324657600080fd5b50516115cd5760405162461bcd60e51b815260040180806020018281038252602a8152602001806148c3602a913960400191505060405180910390fd5b6060824710156132c45760405162461bcd60e51b81526004018080602001828103825260268152602001806147a86026913960400191505060405180910390fd5b6132cd856137c2565b61331e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061335c5780518252601f19909201916020918201910161333d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146133be576040519150601f19603f3d011682016040523d82523d6000602084013e6133c3565b606091505b50915091506133d38282866137c8565b979650505050505050565b6000610b72826106486133f586600160281b612083565b6002865b0490612143565b6000610b72600160281b6106486134178686612083565b6002600160281b6133f9565b6000690177c17eb2ae5edd211c69021e19e0c9bab240000082613446868661382e565b90506134528382613935565b1561346f5760405162461bcd60e51b8152600401610677906143fc565b818184028161347a57fe5b049695505050505050565b6000806000806000613495611af7565b93509350935093506134d26134cd6134b56134af8661395a565b84613552565b6134c76134c18861395a565b86613552565b90613400565b613963565b94505050505090565b6134e683838361396d565b6134ee612baa565b6001600160a01b0383161561350657613506836136ca565b6001600160a01b038216156115cd576115cd826136ca565b600080613529611af7565b50509150915060008061353a611bc8565b925050915061354a84848461219d565b600f55505050565b6000816135645750600160281b610600565b8261357157506000610600565b600061357c83613a1a565b905080830360006135958661359084613963565b613a24565b90506000600160281b8710156135d75760006135bc85611cdc611c73600160281b8c6133de565b90506135cf600160281b61318f83613a77565b9150506135fa565b60006135eb85611cdc8a600160281b613423565b90506135f681613a77565b9150505b6133d38282613400565b60405163efb7601d60e01b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063efb7601d90613673907f0000000000000000000000000000000000000000000000000000000000000000906004016142a0565b602060405180830381600087803b15801561368d57600080fd5b505af11580156136a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c5919061422d565b905090565b6136d2613ad8565b6008546001600160a01b0382166000908152600a60205260409020548061371257506001600160a01b0382166000908152600a6020526040902055611ebb565b600061371d84610e92565b9050600061372b8484612507565b9050600061374668056bc75e2d631000006106488585612083565b6001600160a01b0387166000908152600b602052604090205490915061376c9082612143565b6001600160a01b0387166000908152600b6020908152604080832093909355600a905220949094555050505050565b60008183101561255e576000610b72565b60008183106137bb5781610b72565b5090919050565b3b151590565b606083156137d7575081610b72565b8251156137e75782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561293357818101518382015260200161291b565b60008082841115613846576138438484613ce4565b90505b600160c81b600160281b820211156138705760405162461bcd60e51b8152600401610677906143fc565b61387e84600160281b613935565b1561389b5760405162461bcd60e51b8152600401610677906143fc565b6138a981600160281b613935565b156138c65760405162461bcd60e51b8152600401610677906143fc565b6138d36001821b84613935565b156138f05760405162461bcd60e51b8152600401610677906143fc565b600083821b600160281b86028161390357fe5b049050600061391182613d17565b9050600160c81b81111561392157fe5b600160281b92909202909101949350505050565b60008161394457506000610600565b82828385028161395057fe5b0414159392505050565b600160281b0290565b600160281b900490565b6001600160a01b0382163014156139c4576040805162461bcd60e51b815260206004820152601660248201527514d1539117d513d7d513d2d15397d0d3d395149050d560521b604482015290519081900360640190fd5b826001600160a01b0316826001600160a01b031614156115cd576040805162461bcd60e51b815260206004820152600c60248201526b29a2a7222faa27afa9a2a62360a11b604482015290519081900360640190fd5b64ffffffffff1690565b60008060028306613a3957600160281b613a3b565b835b90506002830492505b8215610b7257613a548485613400565b93506002830615613a6c57613a698185613400565b90505b600283049250613a44565b600080600160281b815b91810191613a9982611cdc8761318f6001860161395a565b915081613aa557613acf565b806101f41415613ac75760405162461bcd60e51b815260040161067790614609565b600101613a81565b50909392505050565b613ae0613d95565b613ae9576122bc565b6040516304946b9f60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631251ae7c90613b9b907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000907f0000000000000000000000000000000000000000000000000000000000000000903090600401614308565b602060405180830381600087803b158015613bb557600080fd5b505af1158015613bc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bed919061422d565b506040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190613c3d9030906004016142a0565b60206040518083038186803b158015613c5557600080fd5b505afa158015613c69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c8d919061422d565b9050600080613c9b83613e36565b915091506000613ca9610aeb565b15613ccf57613ccc613cb9610aeb565b6106488468056bc75e2d63100000612083565b90505b613cd98382612143565b600855505050600955565b60008080838581613cf157fe5b0490505b8015613d0b576001919091019060029004613cf5565b50600019019392505050565b600080600160281b6502000000000081808610801590613d3657508186105b613d525760405162461bcd60e51b8152600401610677906143fc565b60285b8015613d8a578387880281613d6657fe5b049650600282049150828710613d8157600287049650938101935b60001901613d55565b509295945050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399c8054f6040518163ffffffff1660e01b815260040160206040518083038186803b158015613df057600080fd5b505afa158015613e04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e28919061422d565b613e30613e5e565b11905090565b600854600954600090613e4a908490612507565b9050613e54613604565b6011559092909150565b60006136c560286001901b6111b4601154613e77613604565b906133de565b60405180604001604052806002905b613e94613ec4565b815260200190600190039081613e8c5790505090565b604051806040016040528060008152602001600081525090565b604080518082019091526000808252602082015290565b80518015158114610eac57600080fd5b600060208284031215613efc578081fd5b8135610b72816146e3565b600060208284031215613f18578081fd5b8151610b72816146e3565b60008060408385031215613f35578081fd5b8235613f40816146e3565b91506020830135613f50816146e3565b809150509250929050565b600080600060608486031215613f6f578081fd5b8335613f7a816146e3565b92506020840135613f8a816146e3565b929592945050506040919091013590565b600080600060608486031215613faf578283fd5b8351613fba816146e3565b6020850151909350613fcb816146e3565b80925050604084015190509250925092565b60008060008060808587031215613ff2578081fd5b8435613ffd816146e3565b9350602085013561400d816146e3565b93969395505050506040820135916060013590565b600080600080600080600060e0888a03121561403c578283fd5b8735614047816146e3565b96506020880135614057816146e3565b95506040880135945060608801359350608088013560ff8116811461407a578384fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156140a9578182fd5b82356140b4816146e3565b946020939093013593505050565b600080600080608085870312156140d7578384fd5b84356140e2816146e3565b93506020850135925060408501356140f9816146e3565b9396929550929360600135925050565b60008060006060848603121561411d578283fd5b8335614128816146e3565b95602085013595506040909401359392505050565b60008060008060808587031215614152578182fd5b843561415d816146e3565b966020860135965060408601359560600135945092505050565b600080600080600060a0868803121561418e578283fd5b8535614199816146e3565b97602087013597506040870135966060810135965060800135945092505050565b600080604083850312156141cc578182fd5b6141d583613edb565b91506141e360208401613edb565b90509250929050565b600080600060608486031215614200578081fd5b833561420b816146e3565b9250602084013591506040840135614222816146e3565b809150509250925092565b60006020828403121561423e578081fd5b5051919050565b60008060408385031215614257578182fd5b823591506020830135613f50816146e3565b8060005b600281101561429a578151805185526020908101511515818601526040909401939091019060010161426d565b50505050565b6001600160a01b0391909116815260200190565b608081016106008284614269565b60a081016142d08285614269565b8260808301529392505050565b901515815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b9384526001600160a01b039283166020850152604084019190915216606082015260800190565b6000602080835283518082850152825b8181101561435b5785810183015185820160400152820161433f565b8181111561436c5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600c908201526b1313d5d7d25397d31253525560a21b604082015260600190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252601390820152722a27a5a2a72fa120a620a721a2afa2a92927a960691b604082015260600190565b6020808252600a908201526926a0aa242fa2a92927a960b11b604082015260600190565b6020808252600d908201526c13505492d15517d313d0d2d151609a1b604082015260600190565b602080825260169082015275125394d551919250d251539517d513d2d15397d3d55560521b604082015260600190565b6020808252600b908201526a27a7262cafa927aaaa22a960a91b604082015260600190565b602080825260169082015275125394d551919250d251539517d65517d05353d5539560521b604082015260600190565b60208082526019908201527f494e53554646494349454e545f544f4b454e5f414d4f554e5400000000000000604082015260600190565b6020808252600d908201526c13505492d15517d4105554d151609a1b604082015260600190565b60208082526010908201526f1393d517d093d3d514d514905414115160821b604082015260600190565b6020808252601490820152731053149150511657d093d3d514d514905414115160621b604082015260600190565b602080825260119082015270121251d217d31417d3d55517d312535255607a1b604082015260600190565b602080825260139082015272125394d551919250d251539517d65517d3d555606a1b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b60208082526013908201527252504f57455f534c4f575f434f4e564552474560681b604082015260600190565b60208082526010908201526f2caa2fa120a620a721a2afa2a92927a960811b604082015260600190565b6020808252600e908201526d121251d217d3d55517d31253525560921b604082015260600190565b82815260a08101610b726020830184614269565b9283526020830191909152604082015260600190565b948552602085019390935260408401919091526060830152608082015260a00190565b60ff91909116815260200190565b6001600160a01b0381168114611ebb57600080fdfe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545434453413a20696e76616c6964207369676e6174757265202773272076616c7565416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c45434453413a20696e76616c6964207369676e6174757265202776272076616c75659ea8a9dd7d3733c6dd274b7139f05a2bfce1a4bb22f0f7bdc1ccd49c267b858d536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c97d323cb35f6bd9cd68635ec2339494ed9321c2bfbc4810feebadb93a57f1f764736f6c63430007060033416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000000009b528bf0639fc31ae6d698c48d830873227741f100000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102485760003560e01c806370a082311161013b578063ce56c454116100b8578063e184c9be1161007c578063e184c9be146104b1578063f04bcd7c146104b9578063f85c9ce2146104cc578063f887ea40146104df578063fc0c546a146104e757610248565b8063ce56c4541461045d578063d02fba5114610470578063d2e6d1c314610483578063d505accf1461048b578063dd62ed3e1461049e57610248565b806395d89b41116100ff57806395d89b4114610414578063a457c2d71461041c578063a6f319bb1461042f578063a9059cbb14610442578063be9a65551461045557610248565b806370a08231146103cb5780637ecebe00146103de578063834c2955146103f157806389abe8be146104045780638f373bf31461040c57610248565b806330adf81f116101c95780633ccdbb281161018d5780633ccdbb281461038b578063437e5b92146103a057806348fa6ede146103a8578063541a7ca6146103bb57806362c7fa76146103c357610248565b806330adf81f1461034b578063313ce5671461035357806335142c8c146103685780633644e51514610370578063395093511461037857610248565b80630d9b13d9116102105780630d9b13d9146102da5780630dd2cbb9146102ef5780631569f6a41461030f57806318160ddd1461033057806323b872dd1461033857610248565b806304ce07f11461024d57806306fdde031461026b5780630902f1ac14610280578063095ea7b3146102995780630aa725f2146102b9575b600080fd5b6102556104ef565b60405161026291906142e8565b60405180910390f35b610273610513565b604051610262919061432f565b6102886105a9565b6040516102629594939291906146b2565b6102ac6102a7366004614097565b6105e8565b60405161026291906142dd565b6102cc6102c7366004614177565b610606565b6040516102629291906142c2565b6102e2610777565b60405161026291906142a0565b6103026102fd366004613fdd565b61079b565b60405161026291906142b4565b61032261031d3660046140c2565b610927565b604051610262929190614688565b610255610aeb565b6102ac610346366004613f5b565b610af1565b610255610b79565b61035b610b9d565b60405161026291906146d5565b6102ac610ba6565b610255610bb6565b6102ac610386366004614097565b610bda565b61039e6103993660046141ec565b610c28565b005b610255610d38565b6102cc6103b6366004613fdd565b610d3e565b610255610e86565b610255610e8c565b6102556103d9366004613eeb565b610e92565b6102556103ec366004613eeb565b610eb1565b6103026103ff36600461413d565b610ec3565b610255610fec565b610255610ff2565b610273610ff8565b6102ac61042a366004614097565b611059565b6102cc61043d366004614109565b6110c1565b6102ac610450366004614097565b611212565b610255611226565b61039e61046b366004614245565b61124a565b61039e61047e366004613eeb565b611389565b6102e26115d2565b61039e610499366004614022565b6115f6565b6102556104ac366004613f23565b6117ae565b6102556117d9565b6102556104c7366004613eeb565b6117fd565b6103226104da3660046140c2565b61181e565b6102e2611985565b6102e26119a9565b7f436f6d706f756e6400000000000000000000000000000000000000000000000081565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059f5780601f106105745761010080835404028352916020019161059f565b820191906000526020600020905b81548152906001019060200180831161058257829003601f168201915b5050505050905090565b60008060008060006105b9611af7565b9297509550935091506105ca611b22565b156105de576105d7611bc8565b5090945091505b4390509091929394565b60006105fc6105f5611d2c565b8484611d30565b5060015b92915050565b61060e613e7d565b600061061a6000611e1c565b610622611ebe565b600080600061062f611af7565b509194509250905060008061064e856106488d87612083565b906120dc565b90508981116106a057878110156106805760405162461bcd60e51b8152600401610677906144cc565b60405180910390fd5b8a915061069985610648610692610aeb565b8e90612083565b95506106eb565b6106ae846106488c88612083565b9150888210156106d05760405162461bcd60e51b81526004016106779061449c565b50886106e8846106486106e1610aeb565b8d90612083565b95505b6106f58583612143565b87518390528751600060209091015294506107108482612143565b60208089018051849052516000910152935061072d85858561219d565b610735612216565b61073f8c876122be565b6000805160206147f08339815191528584866040516107609392919061469c565b60405180910390a150505050509550959350505050565b7f00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe81565b6107a3613e7d565b6107ad6000611e1c565b6107b5611ebe565b6107bd6123ae565b60006107c8856123cd565b905060007f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561082557600080fd5b505afa158015610839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085d919061422d565b90506000610869610aeb565b9050600061087984838986612462565b90508581101561089b5760405162461bcd60e51b815260040161067790614447565b60208401516108aa9082612507565b6020858101919091528551829052855160019101526108c98489612564565b6108d1612216565b6108db89886125f2565b60008060006108e8611af7565b509250925092506000805160206147f08339815191528382846040516109109392919061469c565b60405180910390a150505050505050949350505050565b6000610931613e7d565b61093b6000611e1c565b610943611b22565b1561096057610950611ebe565b6109586123ae565b610960612216565b600061096b876123cd565b90506000610978866123cd565b9050610a168282877f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109d957600080fd5b505afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a11919061422d565b6126ee565b935086841115610a385760405162461bcd60e51b815260040161067790614382565b6020820151610a479085612143565b602080840191909152810151610a5d9086612507565b6020820152610a6c8289612564565b610a768187612564565b825184905282516000602090910152848360015b602090810291909101519190915283810151600191015260008080610aad611af7565b509250925092506000805160206147f0833981519152838284604051610ad59392919061469c565b60405180910390a1505050505094509492505050565b60025490565b6000610afe848484612784565b610b6e84610b0a611d2c565b610b6985604051806060016040528060288152602001614831602891396001600160a01b038a16600090815260016020526040812090610b48611d2c565b6001600160a01b0316815260208101919091526040016000205491906128df565b611d30565b5060015b9392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055460ff1690565b600754600160a01b900460ff1681565b7f188c4696ef4ad8a454a2d634b1855d27c2cee54e465ce166dabe725dcdc7d41781565b60006105fc610be7611d2c565b84610b698560016000610bf8611d2c565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612143565b610c30612976565b6001600160a01b0316336001600160a01b031614610c87576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b610c9083612a02565b610cd5576040805162461bcd60e51b81526020600482015260116024820152701513d2d15397d393d517d0531313d5d151607a1b604482015290519081900360640190fd5b610ce96001600160a01b0384168284612ad0565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b600d5481565b610d46613e7d565b6000610d526000611e1c565b610d5a611ebe565b610d626123ae565b6000610d6d866123cd565b90506000610d79610aeb565b9050610e1786837f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dd957600080fd5b505afa158015610ded573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e11919061422d565b84612b22565b925084831015610e395760405162461bcd60e51b815260040161067790614582565b6020820151610e489087612143565b602083810191909152845187905284516000910152610e678288612564565b610e6f612216565b610e7988846122be565b6000806000610aad611af7565b60085481565b60105481565b6001600160a01b0381166000908152602081905260409020545b919050565b60066020526000908152604090205481565b610ecb613e7d565b610ed56001611e1c565b610edd611ebe565b6000610ee7610aeb565b90506000806000610ef6611af7565b50919450925090506000610f0e856106488b87612083565b90506000610f20866106488c87612083565b905087811015610f425760405162461bcd60e51b815260040161067790614447565b88821015610f625760405162461bcd60e51b8152600401610677906145ad565b610f6c8583612507565b9450610f788482612507565b8751839052875160016020918201819052818a01805185905251909101529350610fa385858561219d565b610fab612216565b610fb58b8b6125f2565b6000805160206147f0833981519152858486604051610fd69392919061469c565b60405180910390a1505050505050949350505050565b600c5481565b60095481565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059f5780601f106105745761010080835404028352916020019161059f565b60006105fc611066611d2c565b84610b69856040518060600160405280602581526020016149236025913960016000611090611d2c565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906128df565b6110c9613e7d565b6000336001600160a01b037f0000000000000000000000001b6d3e5da9004668e14ca39d1553e9a46fe842b316146111135760405162461bcd60e51b815260040161067790614477565b61111b612baa565b600754600160a01b900460ff16156111455760405162461bcd60e51b815260040161067790614554565b61114d612c8d565b61115d848464800000000061219d565b611165612216565b6040516000805160206147f08339815191529061118c90869064800000000090879061469c565b60405180910390a161119c612e3f565b6111ba6103e86111b46111af8787612083565b612e51565b90612507565b90506111c960016103e86122be565b6111d385826122be565b8151939093528051600060209182018190528183018051949094529251019190915243600d556007805460ff60a01b1916600160a01b17905592909150565b60006105fc61121f611d2c565b8484612784565b7f0000000000000000000000000000000000000000000000000000000060e465f081565b611252612976565b6001600160a01b0316336001600160a01b0316146112a9576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d80600081146112f4576040519150601f19603f3d011682016040523d82523d6000602084013e6112f9565b606091505b5050905080611341576040805162461bcd60e51b815260206004820152600f60248201526e15d2551211149055d7d19052531151608a1b604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b6040516333a2ae8d60e11b81526000906001600160a01b037f0000000000000000000000000ef44218209d7d64737dd36f179d5e448df3eed416906367455d1a906113fa907f436f6d706f756e640000000000000000000000000000000000000000000000009030906004016142f1565b6040805180830381600087803b15801561141357600080fd5b505af1158015611427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144b91906141ba565b9150508061146b5760405162461bcd60e51b8152600401610677906143a8565b60007f0000000000000000000000000ef44218209d7d64737dd36f179d5e448df3eed46001600160a01b03166331c7f53a6040518163ffffffff1660e01b815260040160606040518083038186803b1580156114c657600080fd5b505afa1580156114da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fe9190613f9b565b5090915050336001600160a01b0382161461152b5760405162461bcd60e51b8152600401610677906145da565b6115616001600160a01b037f00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe16846000196119cd565b6115976001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816846000196119cd565b6115cd6001600160a01b037f0000000000000000000000005d3a536e4d6dbd6114cc1ead35777bab948e364316846000196119cd565b505050565b7f0000000000000000000000009b528bf0639fc31ae6d698c48d830873227741f181565b4284101561163c576040805162461bcd60e51b815260206004820152600e60248201526d14115493525517d156141254915160921b604482015290519081900360640190fd5b6001600160a01b03808816600081815260066020908152604080832080546001810190915581517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98185015280830195909552948b166060850152608084018a905260a084019490945260c08084018990528451808503909101815260e08401855280519082012061190160f01b6101008501527f188c4696ef4ad8a454a2d634b1855d27c2cee54e465ce166dabe725dcdc7d4176101028501526101228085019190915284518085039091018152610142909301909352815191909201209061172882868686612ea2565b90506001600160a01b038116158015906117535750886001600160a01b0316816001600160a01b0316145b611798576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b6117a3898989611d30565b505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7f0000000000000000000000000000000000000000000000000000000061ccf68081565b60006118096001611e1c565b61181282613020565b9050610eac828261305e565b6000611828613e7d565b6118326000611e1c565b61183a611b22565b1561185757611847611ebe565b61184f6123ae565b611857612216565b6000611862876123cd565b9050600061186f866123cd565b905061190d8282897f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166354cf2aeb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156118d057600080fd5b505afa1580156118e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611908919061422d565b613143565b93508484101561192f5760405162461bcd60e51b815260040161067790614660565b602082015161193e9088612143565b6020808401919091528101516119549085612507565b60208201526119638289612564565b61196d8187612564565b82518790528251600060209091015283836001610a8a565b7f0000000000000000000000001b6d3e5da9004668e14ca39d1553e9a46fe842b381565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b801580611a53575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611a2557600080fd5b505afa158015611a39573d6000803e3d6000fd5b505050506040513d6020811015611a4f57600080fd5b5051155b611a8e5760405162461bcd60e51b81526004018080602001828103825260368152602001806148ed6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526115cd9084906131d2565b6060611aef8484600085613283565b949350505050565b600e54609481901c91602882901c60016001606c1b03169164ffffffffff1690600160281b82900390565b6000611bc17f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b031663d8168c486040518163ffffffff1660e01b815260040160206040518083038186803b158015611b8057600080fd5b505afa158015611b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb8919061422d565b600d5490612143565b4311905090565b60008080427f0000000000000000000000000000000000000000000000000000000061ccf6807f0000000000000000000000000000000000000000000000000000000060e436068082038480611c1c611af7565b9350935050506000868610611c345750858503611c38565b5060005b6000611c4d600160281b8381029087026133de565b9050611c89611c7d611c73600160281b611c6d650323d70a3d7086613400565b90612143565b600160281b613423565b65016bb2b81a526133de565b98506000611c998a600f546133de565b9050600160281b811115611cbf5760405162461bcd60e51b8152600401610677906143fc565b6000611ce1611cce8787613400565b611cdc600160281b85612507565b613400565b90506000611cf386611c6d858a613400565b90506000611d0183836133de565b9050611d0d8882612507565b9e50611d198782612143565b9d50505050505050505050505050909192565b3390565b6001600160a01b038316611d755760405162461bcd60e51b815260040180806020018281038252602481526020018061489f6024913960400191505060405180910390fd5b6001600160a01b038216611dba5760405162461bcd60e51b815260040180806020018281038252602281526020018061473e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b611e24612baa565b600754600160a01b900460ff16611e4d5760405162461bcd60e51b81526004016106779061452a565b336001600160a01b037f0000000000000000000000001b6d3e5da9004668e14ca39d1553e9a46fe842b31614611e955760405162461bcd60e51b815260040161067790614477565b80611ebb576010544210611ebb5760405162461bcd60e51b815260040161067790614420565b50565b60007f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b031663b06459b56040518163ffffffff1660e01b815260040160206040518083038186803b158015611f1957600080fd5b505afa158015611f2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f51919061422d565b600c54909150811561207357801561206e576000611f6d613485565b90508181111561206c576000611f94611f868385612507565b611f8e610aeb565b90612083565b90506000611fb284611c6d8761064887611f8e600160281b84612507565b90506000818381611fbf57fe5b04905060007f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b15801561201d57600080fd5b505afa158015612031573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120559190613f07565b905081156120675761206781836122be565b505050505b505b61207f565b801561207f576000600c555b5050565b60008261209257506000610600565b8282028284828161209f57fe5b0414610b725760405162461bcd60e51b81526004018080602001828103825260218152602001806148106021913960400191505060405180910390fd5b6000808211612132576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161213b57fe5b049392505050565b600082820183811015610b72576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b8260001080156121b4575060016001606c1b038311155b6121d05760405162461bcd60e51b815260040161067790614636565b8160001080156121e7575060016001606c1b038211155b6122035760405162461bcd60e51b8152600401610677906143cf565b60949290921b60289190911b1717600e55565b7f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b031663b06459b56040518163ffffffff1660e01b815260040160206040518083038186803b15801561226f57600080fd5b505afa158015612283573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a7919061422d565b6122b0576122bc565b6122b8613485565b600c555b565b6001600160a01b038216612319576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b612325600083836134db565b6002546123329082612143565b6002556001600160a01b0382166000908152602081905260409020546123589082612143565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6123b6611b22565b6123bf576122bc565b6123c761351e565b43600d55565b6123d5613eaa565b6000806000806123e3611af7565b93509350935093507f00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe6001600160a01b0316866001600160a01b03161415612441576040518060400160405280838152602001858152509450612459565b60405180604001604052808281526020018481525094505b50505050919050565b8351600090816124728686612507565b9050600061248082886133de565b9050600061249b82612496600160281b876133de565b613552565b905060006124ad828b60200151613400565b905060006124c8828c6020015161250790919063ffffffff16565b905060006124e36124dd600160281b89612507565b8a613400565b90506124f782611cdc600160281b84612507565b9c9b505050505050505050505050565b60008282111561255e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600080600080612572611af7565b93509350935093507f00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe6001600160a01b0316856001600160a01b031614156125c45785516020870151945091506125df565b508451602086015192506125dc600160281b82612507565b91505b6125ea84848461219d565b505050505050565b6001600160a01b0382166126375760405162461bcd60e51b81526004018080602001828103825260218152602001806148596021913960400191505060405180910390fd5b612643826000836134db565b6126808160405180606001604052806022815260200161471c602291396001600160a01b03851660009081526020819052604090205491906128df565b6001600160a01b0383166000908152602081905260409020556002546126a69082612507565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600080612703856000015187600001516133de565b9050600061271e85876020015161250790919063ffffffff16565b905060006127308760200151836133de565b9050600061273e8285613552565b905061274e81600160281b612507565b905061275e600160281b87612507565b94506127776127718a6020015183613400565b866133de565b9998505050505050505050565b6001600160a01b0383166127c95760405162461bcd60e51b815260040180806020018281038252602581526020018061487a6025913960400191505060405180910390fd5b6001600160a01b03821661280e5760405162461bcd60e51b81526004018080602001828103825260238152602001806146f96023913960400191505060405180910390fd5b6128198383836134db565b61285681604051806060016040528060268152602001614760602691396001600160a01b03861660009081526020819052604090205491906128df565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546128859082612143565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561296e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561293357818101518382015260200161291b565b50505050905090810190601f1680156129605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60007f0000000000000000000000009b528bf0639fc31ae6d698c48d830873227741f16001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b1580156129d157600080fd5b505afa1580156129e5573d6000803e3d6000fd5b505050506040513d60208110156129fb57600080fd5b5051905090565b60007f00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe6001600160a01b0316826001600160a01b031614158015612a7857507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316826001600160a01b031614155b8015612a8d57506001600160a01b0382163014155b801561060057507f0000000000000000000000005d3a536e4d6dbd6114cc1ead35777bab948e36436001600160a01b0316826001600160a01b0316141592915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115cd9084906131d2565b825160009081612b3f612b39600160281b84612507565b86613400565b90506000612b5588611cdc600160281b85612507565b90506000612b7082896020015161214390919063ffffffff16565b90506000612b82828a602001516133de565b90506000612b908287613552565b90506000612b9e828a613400565b90506124f7818a612507565b6040516333a2ae8d60e11b81526000906001600160a01b037f0000000000000000000000000ef44218209d7d64737dd36f179d5e448df3eed416906367455d1a90612c1b907f436f6d706f756e640000000000000000000000000000000000000000000000009030906004016142f1565b6040805180830381600087803b158015612c3457600080fd5b505af1158015612c48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c6c91906141ba565b5090508015611ebb5760405162461bcd60e51b815260040161067790614503565b6000612cd97f0000000000000000000000000000000000000000000000000000000061ccf6807f0000000000000000000000000000000000000000000000000000000060e43606612507565b90506000612e0c7f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166338c143f46040518163ffffffff1660e01b815260040160206040518083038186803b158015612d3957600080fd5b505afa158015612d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d71919061422d565b6106487f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b031663ff845ced6040518163ffffffff1660e01b815260040160206040518083038186803b158015612dcd57600080fd5b505afa158015612de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e05919061422d565b8590612083565b9050612e387f0000000000000000000000000000000000000000000000000000000061ccf68082612507565b6010555050565b6001600855612e4c613604565b601155565b60006003821115612e94575080600160028204015b81811015612e8e57809150600281828581612e7d57fe5b040181612e8657fe5b049050612e66565b50610eac565b8115610eac57506001919050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115612f035760405162461bcd60e51b81526004018080602001828103825260228152602001806147866022913960400191505060405180910390fd5b8360ff16601b1480612f1857508360ff16601c145b612f535760405162461bcd60e51b81526004018080602001828103825260228152602001806147ce6022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015612faf573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613017576040805162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015290519081900360640190fd5b95945050505050565b600061302b826136ca565b506001600160a01b0381166000908152600b602052604081208054919055600954613056908261379b565b600955919050565b806130685761207f565b61310d817f0000000000000000000000005d3a536e4d6dbd6114cc1ead35777bab948e36436001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016130b891906142a0565b60206040518083038186803b1580156130d057600080fd5b505afa1580156130e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613108919061422d565b6137ac565b905061207f6001600160a01b037f0000000000000000000000005d3a536e4d6dbd6114cc1ead35777bab948e3643168383612ad0565b600080613158866000015186600001516133de565b9050600061316a600160281b85612507565b90506131768582613400565b60208801519091506000906131949061318f8185612143565b6133de565b905060006131a28285613552565b905060006131b4600160281b83612507565b90506131c4896020015182613400565b9a9950505050505050505050565b6000613227826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611ae09092919063ffffffff16565b8051909150156115cd5780806020019051602081101561324657600080fd5b50516115cd5760405162461bcd60e51b815260040180806020018281038252602a8152602001806148c3602a913960400191505060405180910390fd5b6060824710156132c45760405162461bcd60e51b81526004018080602001828103825260268152602001806147a86026913960400191505060405180910390fd5b6132cd856137c2565b61331e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b6020831061335c5780518252601f19909201916020918201910161333d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146133be576040519150601f19603f3d011682016040523d82523d6000602084013e6133c3565b606091505b50915091506133d38282866137c8565b979650505050505050565b6000610b72826106486133f586600160281b612083565b6002865b0490612143565b6000610b72600160281b6106486134178686612083565b6002600160281b6133f9565b6000690177c17eb2ae5edd211c69021e19e0c9bab240000082613446868661382e565b90506134528382613935565b1561346f5760405162461bcd60e51b8152600401610677906143fc565b818184028161347a57fe5b049695505050505050565b6000806000806000613495611af7565b93509350935093506134d26134cd6134b56134af8661395a565b84613552565b6134c76134c18861395a565b86613552565b90613400565b613963565b94505050505090565b6134e683838361396d565b6134ee612baa565b6001600160a01b0383161561350657613506836136ca565b6001600160a01b038216156115cd576115cd826136ca565b600080613529611af7565b50509150915060008061353a611bc8565b925050915061354a84848461219d565b600f55505050565b6000816135645750600160281b610600565b8261357157506000610600565b600061357c83613a1a565b905080830360006135958661359084613963565b613a24565b90506000600160281b8710156135d75760006135bc85611cdc611c73600160281b8c6133de565b90506135cf600160281b61318f83613a77565b9150506135fa565b60006135eb85611cdc8a600160281b613423565b90506135f681613a77565b9150505b6133d38282613400565b60405163efb7601d60e01b81526000906001600160a01b037f000000000000000000000000c02ac197a4d32d93d473779fbea2dca1fb313ed5169063efb7601d90613673907f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f906004016142a0565b602060405180830381600087803b15801561368d57600080fd5b505af11580156136a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c5919061422d565b905090565b6136d2613ad8565b6008546001600160a01b0382166000908152600a60205260409020548061371257506001600160a01b0382166000908152600a6020526040902055611ebb565b600061371d84610e92565b9050600061372b8484612507565b9050600061374668056bc75e2d631000006106488585612083565b6001600160a01b0387166000908152600b602052604090205490915061376c9082612143565b6001600160a01b0387166000908152600b6020908152604080832093909355600a905220949094555050505050565b60008183101561255e576000610b72565b60008183106137bb5781610b72565b5090919050565b3b151590565b606083156137d7575081610b72565b8251156137e75782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561293357818101518382015260200161291b565b60008082841115613846576138438484613ce4565b90505b600160c81b600160281b820211156138705760405162461bcd60e51b8152600401610677906143fc565b61387e84600160281b613935565b1561389b5760405162461bcd60e51b8152600401610677906143fc565b6138a981600160281b613935565b156138c65760405162461bcd60e51b8152600401610677906143fc565b6138d36001821b84613935565b156138f05760405162461bcd60e51b8152600401610677906143fc565b600083821b600160281b86028161390357fe5b049050600061391182613d17565b9050600160c81b81111561392157fe5b600160281b92909202909101949350505050565b60008161394457506000610600565b82828385028161395057fe5b0414159392505050565b600160281b0290565b600160281b900490565b6001600160a01b0382163014156139c4576040805162461bcd60e51b815260206004820152601660248201527514d1539117d513d7d513d2d15397d0d3d395149050d560521b604482015290519081900360640190fd5b826001600160a01b0316826001600160a01b031614156115cd576040805162461bcd60e51b815260206004820152600c60248201526b29a2a7222faa27afa9a2a62360a11b604482015290519081900360640190fd5b64ffffffffff1690565b60008060028306613a3957600160281b613a3b565b835b90506002830492505b8215610b7257613a548485613400565b93506002830615613a6c57613a698185613400565b90505b600283049250613a44565b600080600160281b815b91810191613a9982611cdc8761318f6001860161395a565b915081613aa557613acf565b806101f41415613ac75760405162461bcd60e51b815260040161067790614609565b600101613a81565b50909392505050565b613ae0613d95565b613ae9576122bc565b6040516304946b9f60e21b81526001600160a01b037f0000000000000000000000001b6d3e5da9004668e14ca39d1553e9a46fe842b31690631251ae7c90613b9b907f436f6d706f756e64563200000000000000000000000000000000000000000000907f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f907f0000000000000000000000000000000000000000000000000000000061ccf680903090600401614308565b602060405180830381600087803b158015613bb557600080fd5b505af1158015613bc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bed919061422d565b506040516370a0823160e01b81526000906001600160a01b037f0000000000000000000000005d3a536e4d6dbd6114cc1ead35777bab948e364316906370a0823190613c3d9030906004016142a0565b60206040518083038186803b158015613c5557600080fd5b505afa158015613c69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c8d919061422d565b9050600080613c9b83613e36565b915091506000613ca9610aeb565b15613ccf57613ccc613cb9610aeb565b6106488468056bc75e2d63100000612083565b90505b613cd98382612143565b600855505050600955565b60008080838581613cf157fe5b0490505b8015613d0b576001919091019060029004613cf5565b50600019019392505050565b600080600160281b6502000000000081808610801590613d3657508186105b613d525760405162461bcd60e51b8152600401610677906143fc565b60285b8015613d8a578387880281613d6657fe5b049650600282049150828710613d8157600287049650938101935b60001901613d55565b509295945050505050565b60007f000000000000000000000000e8a6916576832aa5504092c1cccc46e3bb9491d66001600160a01b03166399c8054f6040518163ffffffff1660e01b815260040160206040518083038186803b158015613df057600080fd5b505afa158015613e04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e28919061422d565b613e30613e5e565b11905090565b600854600954600090613e4a908490612507565b9050613e54613604565b6011559092909150565b60006136c560286001901b6111b4601154613e77613604565b906133de565b60405180604001604052806002905b613e94613ec4565b815260200190600190039081613e8c5790505090565b604051806040016040528060008152602001600081525090565b604080518082019091526000808252602082015290565b80518015158114610eac57600080fd5b600060208284031215613efc578081fd5b8135610b72816146e3565b600060208284031215613f18578081fd5b8151610b72816146e3565b60008060408385031215613f35578081fd5b8235613f40816146e3565b91506020830135613f50816146e3565b809150509250929050565b600080600060608486031215613f6f578081fd5b8335613f7a816146e3565b92506020840135613f8a816146e3565b929592945050506040919091013590565b600080600060608486031215613faf578283fd5b8351613fba816146e3565b6020850151909350613fcb816146e3565b80925050604084015190509250925092565b60008060008060808587031215613ff2578081fd5b8435613ffd816146e3565b9350602085013561400d816146e3565b93969395505050506040820135916060013590565b600080600080600080600060e0888a03121561403c578283fd5b8735614047816146e3565b96506020880135614057816146e3565b95506040880135945060608801359350608088013560ff8116811461407a578384fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156140a9578182fd5b82356140b4816146e3565b946020939093013593505050565b600080600080608085870312156140d7578384fd5b84356140e2816146e3565b93506020850135925060408501356140f9816146e3565b9396929550929360600135925050565b60008060006060848603121561411d578283fd5b8335614128816146e3565b95602085013595506040909401359392505050565b60008060008060808587031215614152578182fd5b843561415d816146e3565b966020860135965060408601359560600135945092505050565b600080600080600060a0868803121561418e578283fd5b8535614199816146e3565b97602087013597506040870135966060810135965060800135945092505050565b600080604083850312156141cc578182fd5b6141d583613edb565b91506141e360208401613edb565b90509250929050565b600080600060608486031215614200578081fd5b833561420b816146e3565b9250602084013591506040840135614222816146e3565b809150509250925092565b60006020828403121561423e578081fd5b5051919050565b60008060408385031215614257578182fd5b823591506020830135613f50816146e3565b8060005b600281101561429a578151805185526020908101511515818601526040909401939091019060010161426d565b50505050565b6001600160a01b0391909116815260200190565b608081016106008284614269565b60a081016142d08285614269565b8260808301529392505050565b901515815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b9384526001600160a01b039283166020850152604084019190915216606082015260800190565b6000602080835283518082850152825b8181101561435b5785810183015185820160400152820161433f565b8181111561436c5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600c908201526b1313d5d7d25397d31253525560a21b604082015260600190565b6020808252600d908201526c4e4f545f454d455247454e435960981b604082015260600190565b6020808252601390820152722a27a5a2a72fa120a620a721a2afa2a92927a960691b604082015260600190565b6020808252600a908201526926a0aa242fa2a92927a960b11b604082015260600190565b6020808252600d908201526c13505492d15517d313d0d2d151609a1b604082015260600190565b602080825260169082015275125394d551919250d251539517d513d2d15397d3d55560521b604082015260600190565b6020808252600b908201526a27a7262cafa927aaaa22a960a91b604082015260600190565b602080825260169082015275125394d551919250d251539517d65517d05353d5539560521b604082015260600190565b60208082526019908201527f494e53554646494349454e545f544f4b454e5f414d4f554e5400000000000000604082015260600190565b6020808252600d908201526c13505492d15517d4105554d151609a1b604082015260600190565b60208082526010908201526f1393d517d093d3d514d514905414115160821b604082015260600190565b6020808252601490820152731053149150511657d093d3d514d514905414115160621b604082015260600190565b602080825260119082015270121251d217d31417d3d55517d312535255607a1b604082015260600190565b602080825260139082015272125394d551919250d251539517d65517d3d555606a1b604082015260600190565b6020808252601590820152742727aa2fa2a6a2a923a2a721acafa420a7222622a960591b604082015260600190565b60208082526013908201527252504f57455f534c4f575f434f4e564552474560681b604082015260600190565b60208082526010908201526f2caa2fa120a620a721a2afa2a92927a960811b604082015260600190565b6020808252600e908201526d121251d217d3d55517d31253525560921b604082015260600190565b82815260a08101610b726020830184614269565b9283526020830191909152604082015260600190565b948552602085019390935260408401919091526060830152608082015260a00190565b60ff91909116815260200190565b6001600160a01b0381168114611ebb57600080fdfe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545434453413a20696e76616c6964207369676e6174757265202773272076616c7565416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c45434453413a20696e76616c6964207369676e6174757265202776272076616c75659ea8a9dd7d3733c6dd274b7139f05a2bfce1a4bb22f0f7bdc1ccd49c267b858d536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c97d323cb35f6bd9cd68635ec2339494ed9321c2bfbc4810feebadb93a57f1f764736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000009b528bf0639fc31ae6d698c48d830873227741f100000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
-----Decoded View---------------
Arg [0] : _governanceManager (address): 0x9b528BF0639fC31Ae6D698c48D830873227741F1
Arg [1] : _xyt (address): 0x31654eB46a3a450265C6Dfc4fC4FbBFe371e26Fe
Arg [2] : _token (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000009b528bf0639fc31ae6d698c48d830873227741f1
Arg [1] : 00000000000000000000000031654eb46a3a450265c6dfc4fc4fbbfe371e26fe
Arg [2] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.