ERC-20
Overview
Max Total Supply
817.005059431786309001 BPT-TUSD
Holders
7
Market
Price
$0.00 @ 0.000000 FTM
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
211.786675533148207585 BPT-TUSDValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
StablePool
Compiler Version
v0.7.1+commit.f4a555be
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol"; import "@balancer-labs/v2-pool-utils/contracts/BaseGeneralPool.sol"; import "@balancer-labs/v2-pool-utils/contracts/BaseMinimalSwapInfoPool.sol"; import "./StableMath.sol"; import "./StablePoolUserDataHelpers.sol"; contract StablePool is BaseGeneralPool, BaseMinimalSwapInfoPool, StableMath { using FixedPoint for uint256; using StablePoolUserDataHelpers for bytes; using WordCodec for bytes32; // This contract uses timestamps to slowly update its Amplification parameter over time. These changes must occur // over a minimum time period much larger than the blocktime, making timestamp manipulation a non-issue. // solhint-disable not-rely-on-time // Amplification factor changes must happen over a minimum period of one day, and can at most divide or multiple the // current value by 2 every day. // WARNING: this only limits *a single* amplification change to have a maximum rate of change of twice the original // value daily. It is possible to perform multiple amplification changes in sequence to increase this value more // rapidly: for example, by doubling the value every day it can increase by a factor of 8 over three days (2^3). uint256 private constant _MIN_UPDATE_TIME = 1 days; uint256 private constant _MAX_AMP_UPDATE_DAILY_RATE = 2; bytes32 private _packedAmplificationData; event AmpUpdateStarted(uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime); event AmpUpdateStopped(uint256 currentValue); // To track how many tokens are owed to the Vault as protocol fees, we measure and store the value of the invariant // after every join and exit. All invariant growth that happens between join and exit events is due to swap fees. uint256 private _lastInvariant; // Because the invariant depends on the amplification parameter, and this value may change over time, we should only // compare invariants that were computed using the same value. We therefore store it whenever we store // _lastInvariant. uint256 private _lastInvariantAmp; enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT } enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT } constructor( IVault vault, string memory name, string memory symbol, IERC20[] memory tokens, uint256 amplificationParameter, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BasePool( vault, // Because we're inheriting from both BaseGeneralPool and BaseMinimalSwapInfoPool we can choose any // specialization setting. Since this Pool never registers or deregisters any tokens after construction, // picking Two Token when the Pool only has two tokens is free gas savings. tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.GENERAL, name, symbol, tokens, new address[](tokens.length), swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { _require(tokens.length <= _MAX_STABLE_TOKENS, Errors.MAX_STABLE_TOKENS); _require(amplificationParameter >= _MIN_AMP, Errors.MIN_AMP); _require(amplificationParameter <= _MAX_AMP, Errors.MAX_AMP); uint256 initialAmp = Math.mul(amplificationParameter, _AMP_PRECISION); _setAmplificationData(initialAmp); } // Base Pool handlers // Swap - General Pool specialization (from BaseGeneralPool) function _onSwapGivenIn( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) internal view virtual override whenNotPaused returns (uint256) { (uint256 currentAmp, ) = _getAmplificationParameter(); uint256 amountOut = StableMath._calcOutGivenIn(currentAmp, balances, indexIn, indexOut, swapRequest.amount); return amountOut; } function _onSwapGivenOut( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) internal view virtual override whenNotPaused returns (uint256) { (uint256 currentAmp, ) = _getAmplificationParameter(); uint256 amountIn = StableMath._calcInGivenOut(currentAmp, balances, indexIn, indexOut, swapRequest.amount); return amountIn; } // Swap - Two Token Pool specialization (from BaseMinimalSwapInfoPool) function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual override returns (uint256) { _require(_getTotalTokens() == 2, Errors.NOT_TWO_TOKENS); (uint256[] memory balances, uint256 indexIn, uint256 indexOut) = _getSwapBalanceArrays( swapRequest, balanceTokenIn, balanceTokenOut ); return _onSwapGivenIn(swapRequest, balances, indexIn, indexOut); } function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual override returns (uint256) { _require(_getTotalTokens() == 2, Errors.NOT_TWO_TOKENS); (uint256[] memory balances, uint256 indexIn, uint256 indexOut) = _getSwapBalanceArrays( swapRequest, balanceTokenIn, balanceTokenOut ); return _onSwapGivenOut(swapRequest, balances, indexIn, indexOut); } function _getSwapBalanceArrays( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) private view returns ( uint256[] memory balances, uint256 indexIn, uint256 indexOut ) { balances = new uint256[](2); if (_token0 == swapRequest.tokenIn) { indexIn = 0; indexOut = 1; balances[0] = balanceTokenIn; balances[1] = balanceTokenOut; } else { // _token0 == swapRequest.tokenOut indexOut = 0; indexIn = 1; balances[0] = balanceTokenOut; balances[1] = balanceTokenIn; } } // Initialize function _onInitializePool( bytes32, address, address, uint256[] memory scalingFactors, bytes memory userData ) internal virtual override whenNotPaused returns (uint256, uint256[] memory) { // It would be strange for the Pool to be paused before it is initialized, but for consistency we prevent // initialization in this case. StablePool.JoinKind kind = userData.joinKind(); _require(kind == StablePool.JoinKind.INIT, Errors.UNINITIALIZED); uint256[] memory amountsIn = userData.initialAmountsIn(); InputHelpers.ensureInputLengthMatch(amountsIn.length, _getTotalTokens()); _upscaleArray(amountsIn, scalingFactors); (uint256 currentAmp, ) = _getAmplificationParameter(); uint256 invariantAfterJoin = StableMath._calculateInvariant(currentAmp, amountsIn, true); // Set the initial BPT to the value of the invariant. uint256 bptAmountOut = invariantAfterJoin; _updateLastInvariant(invariantAfterJoin, currentAmp); return (bptAmountOut, amountsIn); } // Join function _onJoinPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual override whenNotPaused returns ( uint256, uint256[] memory, uint256[] memory ) { // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous join // or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids spending gas to // calculate the fee amounts during each individual swap. uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); (uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, scalingFactors, userData); // Update the invariant with the balances the Pool will have after the join, in order to compute the // protocol swap fee amounts due in future joins and exits. _updateInvariantAfterJoin(balances, amountsIn); return (bptAmountOut, amountsIn, dueProtocolFeeAmounts); } function _doJoin( uint256[] memory balances, uint256[] memory scalingFactors, bytes memory userData ) private view returns (uint256, uint256[] memory) { JoinKind kind = userData.joinKind(); if (kind == JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) { return _joinExactTokensInForBPTOut(balances, scalingFactors, userData); } else if (kind == JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) { return _joinTokenInForExactBPTOut(balances, userData); } else { _revert(Errors.UNHANDLED_JOIN_KIND); } } function _joinExactTokensInForBPTOut( uint256[] memory balances, uint256[] memory scalingFactors, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256[] memory amountsIn, uint256 minBPTAmountOut) = userData.exactTokensInForBptOut(); InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length); _upscaleArray(amountsIn, scalingFactors); (uint256 currentAmp, ) = _getAmplificationParameter(); uint256 bptAmountOut = StableMath._calcBptOutGivenExactTokensIn( currentAmp, balances, amountsIn, totalSupply(), _swapFeePercentage ); _require(bptAmountOut >= minBPTAmountOut, Errors.BPT_OUT_MIN_AMOUNT); return (bptAmountOut, amountsIn); } function _joinTokenInForExactBPTOut(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { (uint256 bptAmountOut, uint256 tokenIndex) = userData.tokenInForExactBptOut(); // Note that there is no maximum amountIn parameter: this is handled by `IVault.joinPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); uint256[] memory amountsIn = new uint256[](_getTotalTokens()); (uint256 currentAmp, ) = _getAmplificationParameter(); amountsIn[tokenIndex] = StableMath._calcTokenInGivenExactBptOut( currentAmp, balances, tokenIndex, bptAmountOut, totalSupply(), _swapFeePercentage ); return (bptAmountOut, amountsIn); } // Exit function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual override returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits are not completely disabled while the contract is paused: proportional exits (exact BPT in for tokens // out) remain functional. if (_isNotPaused()) { // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous // join or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids // spending gas calculating fee amounts during each individual swap dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); } else { // If the contract is paused, swap protocol fee amounts are not charged to avoid extra calculations and // reduce the potential for errors. dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); } (bptAmountIn, amountsOut) = _doExit(balances, scalingFactors, userData); // Update the invariant with the balances the Pool will have after the exit, in order to compute the // protocol swap fee amounts due in future joins and exits. _updateInvariantAfterExit(balances, amountsOut); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts); } function _doExit( uint256[] memory balances, uint256[] memory scalingFactors, bytes memory userData ) private view returns (uint256, uint256[] memory) { ExitKind kind = userData.exitKind(); if (kind == ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) { return _exitExactBPTInForTokenOut(balances, userData); } else if (kind == ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) { return _exitExactBPTInForTokensOut(balances, userData); } else { // ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT return _exitBPTInForExactTokensOut(balances, scalingFactors, userData); } } function _exitExactBPTInForTokenOut(uint256[] memory balances, bytes memory userData) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256 bptAmountIn, uint256 tokenIndex) = userData.exactBptInForTokenOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); // We exit in a single token, so initialize amountsOut with zeros uint256[] memory amountsOut = new uint256[](_getTotalTokens()); // And then assign the result to the selected token (uint256 currentAmp, ) = _getAmplificationParameter(); amountsOut[tokenIndex] = StableMath._calcTokenOutGivenExactBptIn( currentAmp, balances, tokenIndex, bptAmountIn, totalSupply(), _swapFeePercentage ); return (bptAmountIn, amountsOut); } function _exitExactBPTInForTokensOut(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This exit function is the only one that is not disabled if the contract is paused: it remains unrestricted // in an attempt to provide users with a mechanism to retrieve their tokens in case of an emergency. // This particular exit function is the only one that remains available because it is the simplest one, and // therefore the one with the lowest likelihood of errors. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. uint256[] memory amountsOut = StableMath._calcTokensOutGivenExactBptIn(balances, bptAmountIn, totalSupply()); return (bptAmountIn, amountsOut); } function _exitBPTInForExactTokensOut( uint256[] memory balances, uint256[] memory scalingFactors, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256[] memory amountsOut, uint256 maxBPTAmountIn) = userData.bptInForExactTokensOut(); InputHelpers.ensureInputLengthMatch(amountsOut.length, _getTotalTokens()); _upscaleArray(amountsOut, scalingFactors); (uint256 currentAmp, ) = _getAmplificationParameter(); uint256 bptAmountIn = StableMath._calcBptInGivenExactTokensOut( currentAmp, balances, amountsOut, totalSupply(), _swapFeePercentage ); _require(bptAmountIn <= maxBPTAmountIn, Errors.BPT_IN_MAX_AMOUNT); return (bptAmountIn, amountsOut); } // Helpers /** * @dev Stores the last measured invariant, and the amplification parameter used to compute it. */ function _updateLastInvariant(uint256 invariant, uint256 amplificationParameter) private { _lastInvariant = invariant; _lastInvariantAmp = amplificationParameter; } /** * @dev Returns the amount of protocol fees to pay, given the value of the last stored invariant and the current * balances. */ function _getDueProtocolFeeAmounts(uint256[] memory balances, uint256 protocolSwapFeePercentage) private view returns (uint256[] memory) { // Initialize with zeros uint256[] memory dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); // Early return if the protocol swap fee percentage is zero, saving gas. if (protocolSwapFeePercentage == 0) { return dueProtocolFeeAmounts; } // Instead of paying the protocol swap fee in all tokens proportionally, we will pay it in a single one. This // will reduce gas costs for single asset joins and exits, as at most only two Pool balances will change (the // token joined/exited, and the token in which fees will be paid). // The protocol fee is charged using the token with the highest balance in the pool. uint256 chosenTokenIndex = 0; uint256 maxBalance = balances[0]; for (uint256 i = 1; i < _getTotalTokens(); ++i) { uint256 currentBalance = balances[i]; if (currentBalance > maxBalance) { chosenTokenIndex = i; maxBalance = currentBalance; } } // Set the fee amount to pay in the selected token dueProtocolFeeAmounts[chosenTokenIndex] = StableMath._calcDueTokenProtocolSwapFeeAmount( _lastInvariantAmp, balances, _lastInvariant, chosenTokenIndex, protocolSwapFeePercentage ); return dueProtocolFeeAmounts; } /** * @dev Computes and stores the value of the invariant after a join, which is required to compute due protocol fees * in the future. */ function _updateInvariantAfterJoin(uint256[] memory balances, uint256[] memory amountsIn) private { _mutateAmounts(balances, amountsIn, FixedPoint.add); (uint256 currentAmp, ) = _getAmplificationParameter(); // This invariant is used only to compute the final balance when calculating the protocol fees. These are // rounded down, so we round the invariant up. _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp); } /** * @dev Computes and stores the value of the invariant after an exit, which is required to compute due protocol fees * in the future. */ function _updateInvariantAfterExit(uint256[] memory balances, uint256[] memory amountsOut) private { _mutateAmounts(balances, amountsOut, FixedPoint.sub); (uint256 currentAmp, ) = _getAmplificationParameter(); // This invariant is used only to compute the final balance when calculating the protocol fees. These are // rounded down, so we round the invariant up. _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp); } /** * @dev Mutates `amounts` by applying `mutation` with each entry in `arguments`. * * Equivalent to `amounts = amounts.map(mutation)`. */ function _mutateAmounts( uint256[] memory toMutate, uint256[] memory arguments, function(uint256, uint256) pure returns (uint256) mutation ) private view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { toMutate[i] = mutation(toMutate[i], arguments[i]); } } /** * @dev This function returns the appreciation of one BPT relative to the * underlying tokens. This starts at 1 when the pool is created and grows over time */ function getRate() public view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // When calculating the current BPT rate, we may not have paid the protocol fees, therefore // the invariant should be smaller than its current value. Then, we round down overall. (uint256 currentAmp, ) = _getAmplificationParameter(); _upscaleArray(balances, _scalingFactors()); uint256 invariant = StableMath._calculateInvariant(currentAmp, balances, false); return invariant.divDown(totalSupply()); } // Amplification /** * @dev Begins changing the amplification parameter to `rawEndValue` over time. The value will change linearly until * `endTime` is reached, when it will be `rawEndValue`. * * NOTE: Internally, the amplification parameter is represented using higher precision. The values returned by * `getAmplificationParameter` have to be corrected to account for this when comparing to `rawEndValue`. */ function startAmplificationParameterUpdate(uint256 rawEndValue, uint256 endTime) external authenticate { _require(rawEndValue >= _MIN_AMP, Errors.MIN_AMP); _require(rawEndValue <= _MAX_AMP, Errors.MAX_AMP); uint256 duration = Math.sub(endTime, block.timestamp); _require(duration >= _MIN_UPDATE_TIME, Errors.AMP_END_TIME_TOO_CLOSE); (uint256 currentValue, bool isUpdating) = _getAmplificationParameter(); _require(!isUpdating, Errors.AMP_ONGOING_UPDATE); uint256 endValue = Math.mul(rawEndValue, _AMP_PRECISION); // daily rate = (endValue / currentValue) / duration * 1 day // We perform all multiplications first to not reduce precision, and round the division up as we want to avoid // large rates. Note that these are regular integer multiplications and divisions, not fixed point. uint256 dailyRate = endValue > currentValue ? Math.divUp(Math.mul(1 days, endValue), Math.mul(currentValue, duration)) : Math.divUp(Math.mul(1 days, currentValue), Math.mul(endValue, duration)); _require(dailyRate <= _MAX_AMP_UPDATE_DAILY_RATE, Errors.AMP_RATE_TOO_HIGH); _setAmplificationData(currentValue, endValue, block.timestamp, endTime); } /** * @dev Stops the amplification parameter change process, keeping the current value. */ function stopAmplificationParameterUpdate() external authenticate { (uint256 currentValue, bool isUpdating) = _getAmplificationParameter(); _require(isUpdating, Errors.AMP_NO_ONGOING_UPDATE); _setAmplificationData(currentValue); } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) { return (actionId == getActionId(StablePool.startAmplificationParameterUpdate.selector)) || (actionId == getActionId(StablePool.stopAmplificationParameterUpdate.selector)) || super._isOwnerOnlyAction(actionId); } function getAmplificationParameter() external view returns ( uint256 value, bool isUpdating, uint256 precision ) { (value, isUpdating) = _getAmplificationParameter(); precision = _AMP_PRECISION; } function _getAmplificationParameter() internal view returns (uint256 value, bool isUpdating) { (uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime) = _getAmplificationData(); // Note that block.timestamp >= startTime, since startTime is set to the current time when an update starts if (block.timestamp < endTime) { isUpdating = true; // We can skip checked arithmetic as: // - block.timestamp is always larger or equal to startTime // - endTime is alawys larger than startTime // - the value delta is bounded by the largest amplification paramater, which never causes the // multiplication to overflow. // This also means that the following computation will never revert nor yield invalid results. if (endValue > startValue) { value = startValue + ((endValue - startValue) * (block.timestamp - startTime)) / (endTime - startTime); } else { value = startValue - ((startValue - endValue) * (block.timestamp - startTime)) / (endTime - startTime); } } else { isUpdating = false; value = endValue; } } function _setAmplificationData(uint256 value) private { _setAmplificationData(value, value, block.timestamp, block.timestamp); emit AmpUpdateStopped(value); } function _setAmplificationData( uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime ) private { _packedAmplificationData = WordCodec.encodeUint(uint64(startValue), 0) | WordCodec.encodeUint(uint64(endValue), 64) | WordCodec.encodeUint(uint64(startTime), 64 * 2) | WordCodec.encodeUint(uint64(endTime), 64 * 3); emit AmpUpdateStarted(startValue, endValue, startTime, endTime); } function _getAmplificationData() private view returns ( uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime ) { startValue = _packedAmplificationData.decodeUint64(0); endValue = _packedAmplificationData.decodeUint64(64); startTime = _packedAmplificationData.decodeUint64(64 * 2); endTime = _packedAmplificationData.decodeUint64(64 * 3); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "./LogExpMath.sol"; import "../helpers/BalancerErrors.sol"; /* solhint-disable private-vars-leading-underscore */ library FixedPoint { uint256 internal constant ONE = 1e18; // 18 decimal places uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14) // Minimum base for the power function when the exponent is 'free' (larger than ONE). uint256 internal constant MIN_POW_BASE_FREE_EXPONENT = 0.7e18; function add(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); return product / ONE; } function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); if (product == 0) { return 0; } else { // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((product - 1) / ONE) + 1; } } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow return aInflated / b; } } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((aInflated - 1) / b) + 1; } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above * the true value (that is, the error function expected - actual is always positive). */ function powDown(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); if (raw < maxError) { return 0; } else { return sub(raw, maxError); } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below * the true value (that is, the error function expected - actual is always negative). */ function powUp(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); return add(raw, maxError); } /** * @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1. * * Useful when computing the complement for values with some level of relative error, as it strips this error and * prevents intermediate negative values. */ function complement(uint256 x) internal pure returns (uint256) { return (x < ONE) ? (ONE - x) : 0; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "../openzeppelin/IERC20.sol"; import "./BalancerErrors.sol"; library InputHelpers { function ensureInputLengthMatch(uint256 a, uint256 b) internal pure { _require(a == b, Errors.INPUT_LENGTH_MISMATCH); } function ensureInputLengthMatch( uint256 a, uint256 b, uint256 c ) internal pure { _require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH); } function ensureArrayIsSorted(IERC20[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(address[] memory array) internal pure { if (array.length < 2) { return; } address previous = array[0]; for (uint256 i = 1; i < array.length; ++i) { address current = array[i]; _require(previous < current, Errors.UNSORTED_ARRAY); previous = current; } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; /** * @dev Library for encoding and decoding values stored inside a 256 bit word. Typically used to pack multiple values in * a single storage slot, saving gas by performing less storage accesses. * * Each value is defined by its size and the least significant bit in the word, also known as offset. For example, two * 128 bit values may be encoded in a word by assigning one an offset of 0, and the other an offset of 128. */ library WordCodec { // Masks are values with the least significant N bits set. They can be used to extract an encoded value from a word, // or to insert a new one replacing the old. uint256 private constant _MASK_1 = 2**(1) - 1; uint256 private constant _MASK_10 = 2**(10) - 1; uint256 private constant _MASK_22 = 2**(22) - 1; uint256 private constant _MASK_31 = 2**(31) - 1; uint256 private constant _MASK_53 = 2**(53) - 1; uint256 private constant _MASK_64 = 2**(64) - 1; // Largest positive values that can be represented as N bits signed integers. int256 private constant _MAX_INT_22 = 2**(21) - 1; int256 private constant _MAX_INT_53 = 2**(52) - 1; // In-place insertion /** * @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new * word. */ function insertBoolean( bytes32 word, bool value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_1 << offset)); return clearedWord | bytes32(uint256(value ? 1 : 0) << offset); } // Unsigned /** * @dev Inserts a 10 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 10 bits. */ function insertUint10( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_10 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 31 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 31 bits. */ function insertUint31( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_31 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 64 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 64 bits. */ function insertUint64( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_64 << offset)); return clearedWord | bytes32(value << offset); } // Signed /** * @dev Inserts a 22 bits signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 22 bits. */ function insertInt22( bytes32 word, int256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_22 << offset)); // Integer values need masking to remove the upper bits of negative values. return clearedWord | bytes32((uint256(value) & _MASK_22) << offset); } // Encoding // Unsigned /** * @dev Encodes an unsigned integer shifted by an offset. This performs no size checks: it is up to the caller to * ensure that the values are bounded. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeUint(uint256 value, uint256 offset) internal pure returns (bytes32) { return bytes32(value << offset); } // Signed /** * @dev Encodes a 22 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt22(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_22) << offset); } /** * @dev Encodes a 53 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt53(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_53) << offset); } // Decoding /** * @dev Decodes and returns a boolean shifted by an offset from a 256 bit word. */ function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool) { return (uint256(word >> offset) & _MASK_1) == 1; } // Unsigned /** * @dev Decodes and returns a 10 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint10(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_10; } /** * @dev Decodes and returns a 31 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint31(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_31; } /** * @dev Decodes and returns a 64 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint64(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_64; } // Signed /** * @dev Decodes and returns a 22 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt22(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_22); // In case the decoded value is greater than the max positive integer that can be represented with 22 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_22 ? (value | int256(~_MASK_22)) : value; } /** * @dev Decodes and returns a 53 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt53(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_53); // In case the decoded value is greater than the max positive integer that can be represented with 53 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_53 ? (value | int256(~_MASK_53)) : value; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./BasePool.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IGeneralPool.sol"; /** * @dev Extension of `BasePool`, adding a handler for `IGeneralPool.onSwap`. * * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the General * specialization setting. */ abstract contract BaseGeneralPool is IGeneralPool, BasePool { // Swap Hooks function onSwap( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) external view virtual override returns (uint256) { _validateIndexes(indexIn, indexOut, _getTotalTokens()); uint256[] memory scalingFactors = _scalingFactors(); return swapRequest.kind == IVault.SwapKind.GIVEN_IN ? _swapGivenIn(swapRequest, balances, indexIn, indexOut, scalingFactors) : _swapGivenOut(swapRequest, balances, indexIn, indexOut, scalingFactors); } function _swapGivenIn( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut, uint256[] memory scalingFactors ) internal view returns (uint256) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. swapRequest.amount = _subtractSwapFeeAmount(swapRequest.amount); _upscaleArray(balances, scalingFactors); swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexIn]); uint256 amountOut = _onSwapGivenIn(swapRequest, balances, indexIn, indexOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactors[indexOut]); } function _swapGivenOut( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut, uint256[] memory scalingFactors ) internal view returns (uint256) { _upscaleArray(balances, scalingFactors); swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexOut]); uint256 amountIn = _onSwapGivenOut(swapRequest, balances, indexIn, indexOut); // amountIn tokens are entering the Pool, so we round up. amountIn = _downscaleUp(amountIn, scalingFactors[indexIn]); // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis. return _addSwapFeeAmount(amountIn); } /* * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known. * * Returns the amount of tokens that will be taken from the Pool in return. * * All amounts inside `swapRequest` and `balances` are upscaled. The swap fee has already been deducted from * `swapRequest.amount`. * * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the * Vault. */ function _onSwapGivenIn( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) internal view virtual returns (uint256); /* * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known. * * Returns the amount of tokens that will be granted to the Pool in return. * * All amounts inside `swapRequest` and `balances` are upscaled. * * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee * and returning it to the Vault. */ function _onSwapGivenOut( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) internal view virtual returns (uint256); function _validateIndexes( uint256 indexIn, uint256 indexOut, uint256 limit ) private pure { _require(indexIn < limit && indexOut < limit, Errors.OUT_OF_BOUNDS); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./BasePool.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IMinimalSwapInfoPool.sol"; /** * @dev Extension of `BasePool`, adding a handler for `IMinimalSwapInfoPool.onSwap`. * * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the Two Token or Minimal * Swap Info specialization settings. */ abstract contract BaseMinimalSwapInfoPool is IMinimalSwapInfoPool, BasePool { // Swap Hooks function onSwap( SwapRequest memory request, uint256 balanceTokenIn, uint256 balanceTokenOut ) external view virtual override returns (uint256) { uint256 scalingFactorTokenIn = _scalingFactor(request.tokenIn); uint256 scalingFactorTokenOut = _scalingFactor(request.tokenOut); if (request.kind == IVault.SwapKind.GIVEN_IN) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. request.amount = _subtractSwapFeeAmount(request.amount); // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenIn); uint256 amountOut = _onSwapGivenIn(request, balanceTokenIn, balanceTokenOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactorTokenOut); } else { // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenOut); uint256 amountIn = _onSwapGivenOut(request, balanceTokenIn, balanceTokenOut); // amountIn tokens are entering the Pool, so we round up. amountIn = _downscaleUp(amountIn, scalingFactorTokenIn); // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis. return _addSwapFeeAmount(amountIn); } } /* * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known. * * Returns the amount of tokens that will be taken from the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. The swap fee has already * been deducted from `swapRequest.amount`. * * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the * Vault. */ function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); /* * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known. * * Returns the amount of tokens that will be granted to the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. * * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee * and returning it to the Vault. */ function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; // This is a contract to emulate file-level functions. Convert to a library // after the migration to solc v0.7.1. // solhint-disable private-vars-leading-underscore // solhint-disable var-name-mixedcase contract StableMath { using FixedPoint for uint256; uint256 internal constant _MIN_AMP = 1; uint256 internal constant _MAX_AMP = 5000; uint256 internal constant _AMP_PRECISION = 1e3; uint256 internal constant _MAX_STABLE_TOKENS = 5; // Note on unchecked arithmetic: // This contract performs a large number of additions, subtractions, multiplications and divisions, often inside // loops. Since many of these operations are gas-sensitive (as they happen e.g. during a swap), it is important to // not make any unnecessary checks. We rely on a set of invariants to avoid having to use checked arithmetic (the // Math library), including: // - the number of tokens is bounded by _MAX_STABLE_TOKENS // - the amplification parameter is bounded by _MAX_AMP * _AMP_PRECISION, which fits in 23 bits // - the token balances are bounded by 2^112 (guaranteed by the Vault) times 1e18 (the maximum scaling factor), // which fits in 172 bits // // This means e.g. we can safely multiply a balance by the amplification parameter without worrying about overflow. // Computes the invariant given the current balances, using the Newton-Raphson approximation. // The amplification parameter equals: A n^(n-1) function _calculateInvariant( uint256 amplificationParameter, uint256[] memory balances, bool roundUp ) internal pure returns (uint256) { /********************************************************************************************** // invariant // // D = invariant D^(n+1) // // A = amplification coefficient A n^n S + D = A D n^n + ----------- // // S = sum of balances n^n P // // P = product of balances // // n = number of tokens // *********x************************************************************************************/ // We support rounding up or down. uint256 sum = 0; uint256 numTokens = balances.length; for (uint256 i = 0; i < numTokens; i++) { sum = sum.add(balances[i]); } if (sum == 0) { return 0; } uint256 prevInvariant = 0; uint256 invariant = sum; uint256 ampTimesTotal = amplificationParameter * numTokens; for (uint256 i = 0; i < 255; i++) { uint256 P_D = balances[0] * numTokens; for (uint256 j = 1; j < numTokens; j++) { P_D = Math.div(Math.mul(Math.mul(P_D, balances[j]), numTokens), invariant, roundUp); } prevInvariant = invariant; invariant = Math.div( Math.mul(Math.mul(numTokens, invariant), invariant).add( Math.div(Math.mul(Math.mul(ampTimesTotal, sum), P_D), _AMP_PRECISION, roundUp) ), Math.mul(numTokens + 1, invariant).add( // No need to use checked arithmetic for the amp precision, the amp is guaranteed to be at least 1 Math.div(Math.mul(ampTimesTotal - _AMP_PRECISION, P_D), _AMP_PRECISION, !roundUp) ), roundUp ); if (invariant > prevInvariant) { if (invariant - prevInvariant <= 1) { return invariant; } } else if (prevInvariant - invariant <= 1) { return invariant; } } _revert(Errors.STABLE_GET_BALANCE_DIDNT_CONVERGE); } // Computes how many tokens can be taken out of a pool if `tokenAmountIn` are sent, given the current balances. // The amplification parameter equals: A n^(n-1) function _calcOutGivenIn( uint256 amplificationParameter, uint256[] memory balances, uint256 tokenIndexIn, uint256 tokenIndexOut, uint256 tokenAmountIn ) internal pure returns (uint256) { /************************************************************************************************************** // outGivenIn token x for y - polynomial equation to solve // // ay = amount out to calculate // // by = balance token out // // y = by - ay (finalBalanceOut) // // D = invariant D D^(n+1) // // A = amplification coefficient y^2 + ( S - ---------- - D) * y - ------------- = 0 // // n = number of tokens (A * n^n) A * n^2n * P // // S = sum of final balances but y // // P = product of final balances but y // **************************************************************************************************************/ // Amount out, so we round down overall. // Given that we need to have a greater final balance out, the invariant needs to be rounded up uint256 invariant = _calculateInvariant(amplificationParameter, balances, true); balances[tokenIndexIn] = balances[tokenIndexIn].add(tokenAmountIn); uint256 finalBalanceOut = _getTokenBalanceGivenInvariantAndAllOtherBalances( amplificationParameter, balances, invariant, tokenIndexOut ); // No need to use checked arithmetic since `tokenAmountIn` was actually added to the same balance right before // calling `_getTokenBalanceGivenInvariantAndAllOtherBalances` which doesn't alter the balances array. balances[tokenIndexIn] = balances[tokenIndexIn] - tokenAmountIn; return balances[tokenIndexOut].sub(finalBalanceOut).sub(1); } // Computes how many tokens must be sent to a pool if `tokenAmountOut` are sent given the // current balances, using the Newton-Raphson approximation. // The amplification parameter equals: A n^(n-1) function _calcInGivenOut( uint256 amplificationParameter, uint256[] memory balances, uint256 tokenIndexIn, uint256 tokenIndexOut, uint256 tokenAmountOut ) internal pure returns (uint256) { /************************************************************************************************************** // inGivenOut token x for y - polynomial equation to solve // // ax = amount in to calculate // // bx = balance token in // // x = bx + ax (finalBalanceIn) // // D = invariant D D^(n+1) // // A = amplification coefficient x^2 + ( S - ---------- - D) * x - ------------- = 0 // // n = number of tokens (A * n^n) A * n^2n * P // // S = sum of final balances but x // // P = product of final balances but x // **************************************************************************************************************/ // Amount in, so we round up overall. // Given that we need to have a greater final balance in, the invariant needs to be rounded up uint256 invariant = _calculateInvariant(amplificationParameter, balances, true); balances[tokenIndexOut] = balances[tokenIndexOut].sub(tokenAmountOut); uint256 finalBalanceIn = _getTokenBalanceGivenInvariantAndAllOtherBalances( amplificationParameter, balances, invariant, tokenIndexIn ); // No need to use checked arithmetic since `tokenAmountOut` was actually subtracted from the same balance right // before calling `_getTokenBalanceGivenInvariantAndAllOtherBalances` which doesn't alter the balances array. balances[tokenIndexOut] = balances[tokenIndexOut] + tokenAmountOut; return finalBalanceIn.sub(balances[tokenIndexIn]).add(1); } function _calcBptOutGivenExactTokensIn( uint256 amp, uint256[] memory balances, uint256[] memory amountsIn, uint256 bptTotalSupply, uint256 swapFeePercentage ) internal pure returns (uint256) { // BPT out, so we round down overall. // First loop calculates the sum of all token balances, which will be used to calculate // the current weights of each token, relative to this sum uint256 sumBalances = 0; for (uint256 i = 0; i < balances.length; i++) { sumBalances = sumBalances.add(balances[i]); } // Calculate the weighted balance ratio without considering fees uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length); // The weighted sum of token balance ratios without fee uint256 invariantRatioWithFees = 0; for (uint256 i = 0; i < balances.length; i++) { uint256 currentWeight = balances[i].divDown(sumBalances); balanceRatiosWithFee[i] = balances[i].add(amountsIn[i]).divDown(balances[i]); invariantRatioWithFees = invariantRatioWithFees.add(balanceRatiosWithFee[i].mulDown(currentWeight)); } // Second loop calculates new amounts in, taking into account the fee on the percentage excess uint256[] memory newBalances = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { uint256 amountInWithoutFee; // Check if the balance ratio is greater than the ideal ratio to charge fees or not if (balanceRatiosWithFee[i] > invariantRatioWithFees) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithFees.sub(FixedPoint.ONE)); uint256 taxableAmount = amountsIn[i].sub(nonTaxableAmount); // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50% amountInWithoutFee = nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE - swapFeePercentage)); } else { amountInWithoutFee = amountsIn[i]; } newBalances[i] = balances[i].add(amountInWithoutFee); } // Get current and new invariants, taking swap fees into account uint256 currentInvariant = _calculateInvariant(amp, balances, true); uint256 newInvariant = _calculateInvariant(amp, newBalances, false); uint256 invariantRatio = newInvariant.divDown(currentInvariant); // If the invariant didn't increase for any reason, we simply don't mint BPT if (invariantRatio > FixedPoint.ONE) { return bptTotalSupply.mulDown(invariantRatio - FixedPoint.ONE); } else { return 0; } } function _calcTokenInGivenExactBptOut( uint256 amp, uint256[] memory balances, uint256 tokenIndex, uint256 bptAmountOut, uint256 bptTotalSupply, uint256 swapFeePercentage ) internal pure returns (uint256) { // Token in, so we round up overall. // Get the current invariant uint256 currentInvariant = _calculateInvariant(amp, balances, true); // Calculate new invariant uint256 newInvariant = bptTotalSupply.add(bptAmountOut).divUp(bptTotalSupply).mulUp(currentInvariant); // Calculate amount in without fee. uint256 newBalanceTokenIndex = _getTokenBalanceGivenInvariantAndAllOtherBalances( amp, balances, newInvariant, tokenIndex ); uint256 amountInWithoutFee = newBalanceTokenIndex.sub(balances[tokenIndex]); // First calculate the sum of all token balances, which will be used to calculate // the current weight of each token uint256 sumBalances = 0; for (uint256 i = 0; i < balances.length; i++) { sumBalances = sumBalances.add(balances[i]); } // We can now compute how much extra balance is being deposited and used in virtual swaps, and charge swap fees // accordingly. uint256 currentWeight = balances[tokenIndex].divDown(sumBalances); uint256 taxablePercentage = currentWeight.complement(); uint256 taxableAmount = amountInWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountInWithoutFee.sub(taxableAmount); // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50% return nonTaxableAmount.add(taxableAmount.divUp(FixedPoint.ONE - swapFeePercentage)); } /* Flow of calculations: amountsTokenOut -> amountsOutProportional -> amountOutPercentageExcess -> amountOutBeforeFee -> newInvariant -> amountBPTIn */ function _calcBptInGivenExactTokensOut( uint256 amp, uint256[] memory balances, uint256[] memory amountsOut, uint256 bptTotalSupply, uint256 swapFeePercentage ) internal pure returns (uint256) { // BPT in, so we round up overall. // First loop calculates the sum of all token balances, which will be used to calculate // the current weights of each token relative to this sum uint256 sumBalances = 0; for (uint256 i = 0; i < balances.length; i++) { sumBalances = sumBalances.add(balances[i]); } // Calculate the weighted balance ratio without considering fees uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length); uint256 invariantRatioWithoutFees = 0; for (uint256 i = 0; i < balances.length; i++) { uint256 currentWeight = balances[i].divUp(sumBalances); balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]); invariantRatioWithoutFees = invariantRatioWithoutFees.add(balanceRatiosWithoutFee[i].mulUp(currentWeight)); } // Second loop calculates new amounts in, taking into account the fee on the percentage excess uint256[] memory newBalances = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it to // 'token out'. This results in slightly larger price impact. uint256 amountOutWithFee; if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement()); uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount); // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50% amountOutWithFee = nonTaxableAmount.add(taxableAmount.divUp(FixedPoint.ONE - swapFeePercentage)); } else { amountOutWithFee = amountsOut[i]; } newBalances[i] = balances[i].sub(amountOutWithFee); } // Get current and new invariants, taking into account swap fees uint256 currentInvariant = _calculateInvariant(amp, balances, true); uint256 newInvariant = _calculateInvariant(amp, newBalances, false); uint256 invariantRatio = newInvariant.divDown(currentInvariant); // return amountBPTIn return bptTotalSupply.mulUp(invariantRatio.complement()); } function _calcTokenOutGivenExactBptIn( uint256 amp, uint256[] memory balances, uint256 tokenIndex, uint256 bptAmountIn, uint256 bptTotalSupply, uint256 swapFeePercentage ) internal pure returns (uint256) { // Token out, so we round down overall. // Get the current and new invariants. Since we need a bigger new invariant, we round the current one up. uint256 currentInvariant = _calculateInvariant(amp, balances, true); uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(currentInvariant); // Calculate amount out without fee uint256 newBalanceTokenIndex = _getTokenBalanceGivenInvariantAndAllOtherBalances( amp, balances, newInvariant, tokenIndex ); uint256 amountOutWithoutFee = balances[tokenIndex].sub(newBalanceTokenIndex); // First calculate the sum of all token balances, which will be used to calculate // the current weight of each token uint256 sumBalances = 0; for (uint256 i = 0; i < balances.length; i++) { sumBalances = sumBalances.add(balances[i]); } // We can now compute how much excess balance is being withdrawn as a result of the virtual swaps, which result // in swap fees. uint256 currentWeight = balances[tokenIndex].divDown(sumBalances); uint256 taxablePercentage = currentWeight.complement(); // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it // to 'token out'. This results in slightly larger price impact. Fees are rounded up. uint256 taxableAmount = amountOutWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountOutWithoutFee.sub(taxableAmount); // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50% return nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE - swapFeePercentage)); } function _calcTokensOutGivenExactBptIn( uint256[] memory balances, uint256 bptAmountIn, uint256 bptTotalSupply ) internal pure returns (uint256[] memory) { /********************************************************************************************** // exactBPTInForTokensOut // // (per token) // // aO = tokenAmountOut / bptIn \ // // b = tokenBalance a0 = b * | --------------------- | // // bptIn = bptAmountIn \ bptTotalSupply / // // bpt = bptTotalSupply // **********************************************************************************************/ // Since we're computing an amount out, we round down overall. This means rounding down on both the // multiplication and division. uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply); uint256[] memory amountsOut = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { amountsOut[i] = balances[i].mulDown(bptRatio); } return amountsOut; } // The amplification parameter equals: A n^(n-1) function _calcDueTokenProtocolSwapFeeAmount( uint256 amplificationParameter, uint256[] memory balances, uint256 lastInvariant, uint256 tokenIndex, uint256 protocolSwapFeePercentage ) internal pure returns (uint256) { /************************************************************************************************************** // oneTokenSwapFee - polynomial equation to solve // // af = fee amount to calculate in one token // // bf = balance of fee token // // f = bf - af (finalBalanceFeeToken) // // D = old invariant D D^(n+1) // // A = amplification coefficient f^2 + ( S - ---------- - D) * f - ------------- = 0 // // n = number of tokens (A * n^n) A * n^2n * P // // S = sum of final balances but f // // P = product of final balances but f // **************************************************************************************************************/ // Protocol swap fee amount, so we round down overall. uint256 finalBalanceFeeToken = _getTokenBalanceGivenInvariantAndAllOtherBalances( amplificationParameter, balances, lastInvariant, tokenIndex ); if (balances[tokenIndex] <= finalBalanceFeeToken) { // This shouldn't happen outside of rounding errors, but have this safeguard nonetheless to prevent the Pool // from entering a locked state in which joins and exits revert while computing accumulated swap fees. return 0; } // Result is rounded down uint256 accumulatedTokenSwapFees = balances[tokenIndex] - finalBalanceFeeToken; return accumulatedTokenSwapFees.mulDown(protocolSwapFeePercentage).divDown(FixedPoint.ONE); } // Private functions // This function calculates the balance of a given token (tokenIndex) // given all the other balances and the invariant function _getTokenBalanceGivenInvariantAndAllOtherBalances( uint256 amplificationParameter, uint256[] memory balances, uint256 invariant, uint256 tokenIndex ) internal pure returns (uint256) { // Rounds result up overall uint256 ampTimesTotal = amplificationParameter * balances.length; uint256 sum = balances[0]; uint256 P_D = balances[0] * balances.length; for (uint256 j = 1; j < balances.length; j++) { P_D = Math.divDown(Math.mul(Math.mul(P_D, balances[j]), balances.length), invariant); sum = sum.add(balances[j]); } // No need to use safe math, based on the loop above `sum` is greater than or equal to `balances[tokenIndex]` sum = sum - balances[tokenIndex]; uint256 inv2 = Math.mul(invariant, invariant); // We remove the balance fromm c by multiplying it uint256 c = Math.mul( Math.mul(Math.divUp(inv2, Math.mul(ampTimesTotal, P_D)), _AMP_PRECISION), balances[tokenIndex] ); uint256 b = sum.add(Math.mul(Math.divDown(invariant, ampTimesTotal), _AMP_PRECISION)); // We iterate to find the balance uint256 prevTokenBalance = 0; // We multiply the first iteration outside the loop with the invariant to set the value of the // initial approximation. uint256 tokenBalance = Math.divUp(inv2.add(c), invariant.add(b)); for (uint256 i = 0; i < 255; i++) { prevTokenBalance = tokenBalance; tokenBalance = Math.divUp( Math.mul(tokenBalance, tokenBalance).add(c), Math.mul(tokenBalance, 2).add(b).sub(invariant) ); if (tokenBalance > prevTokenBalance) { if (tokenBalance - prevTokenBalance <= 1) { return tokenBalance; } } else if (prevTokenBalance - tokenBalance <= 1) { return tokenBalance; } } _revert(Errors.STABLE_GET_BALANCE_DIDNT_CONVERGE); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./StablePool.sol"; library StablePoolUserDataHelpers { function joinKind(bytes memory self) internal pure returns (StablePool.JoinKind) { return abi.decode(self, (StablePool.JoinKind)); } function exitKind(bytes memory self) internal pure returns (StablePool.ExitKind) { return abi.decode(self, (StablePool.ExitKind)); } // Joins function initialAmountsIn(bytes memory self) internal pure returns (uint256[] memory amountsIn) { (, amountsIn) = abi.decode(self, (StablePool.JoinKind, uint256[])); } function exactTokensInForBptOut(bytes memory self) internal pure returns (uint256[] memory amountsIn, uint256 minBPTAmountOut) { (, amountsIn, minBPTAmountOut) = abi.decode(self, (StablePool.JoinKind, uint256[], uint256)); } function tokenInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut, uint256 tokenIndex) { (, bptAmountOut, tokenIndex) = abi.decode(self, (StablePool.JoinKind, uint256, uint256)); } // Exits function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) { (, bptAmountIn, tokenIndex) = abi.decode(self, (StablePool.ExitKind, uint256, uint256)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (StablePool.ExitKind, uint256)); } function bptInForExactTokensOut(bytes memory self) internal pure returns (uint256[] memory amountsOut, uint256 maxBPTAmountIn) { (, amountsOut, maxBPTAmountIn) = abi.decode(self, (StablePool.ExitKind, uint256[], uint256)); } }
// SPDX-License-Identifier: MIT // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated // documentation files (the “Software”), to deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the // Software. // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /* solhint-disable */ /** * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument). * * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural * exponentiation and logarithm (where the base is Euler's number). * * @author Fernando Martinelli - @fernandomartinelli * @author Sergio Yuhjtman - @sergioyuhjtman * @author Daniel Fernandez - @dmf7z */ library LogExpMath { // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying // two numbers, and multiply by ONE when dividing them. // All arguments and return values are 18 decimal fixed point numbers. int256 constant ONE_18 = 1e18; // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the // case of ln36, 36 decimals. int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36; // The domain of natural exponentiation is bound by the word size and number of decimals used. // // Because internally the result will be stored using 20 decimals, the largest possible result is // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221. // The smallest possible result is 10^(-18), which makes largest negative argument // ln(10^(-18)) = -41.446531673892822312. // We use 130.0 and -41.0 to have some safety margin. int256 constant MAX_NATURAL_EXPONENT = 130e18; int256 constant MIN_NATURAL_EXPONENT = -41e18; // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point // 256 bit integer. int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17; int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17; uint256 constant MILD_EXPONENT_BOUND = 2**254 / uint256(ONE_20); // 18 decimal constants int256 constant x0 = 128000000000000000000; // 2ˆ7 int256 constant a0 = 38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals) int256 constant x1 = 64000000000000000000; // 2ˆ6 int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals) // 20 decimal constants int256 constant x2 = 3200000000000000000000; // 2ˆ5 int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2) int256 constant x3 = 1600000000000000000000; // 2ˆ4 int256 constant a3 = 888611052050787263676000000; // eˆ(x3) int256 constant x4 = 800000000000000000000; // 2ˆ3 int256 constant a4 = 298095798704172827474000; // eˆ(x4) int256 constant x5 = 400000000000000000000; // 2ˆ2 int256 constant a5 = 5459815003314423907810; // eˆ(x5) int256 constant x6 = 200000000000000000000; // 2ˆ1 int256 constant a6 = 738905609893065022723; // eˆ(x6) int256 constant x7 = 100000000000000000000; // 2ˆ0 int256 constant a7 = 271828182845904523536; // eˆ(x7) int256 constant x8 = 50000000000000000000; // 2ˆ-1 int256 constant a8 = 164872127070012814685; // eˆ(x8) int256 constant x9 = 25000000000000000000; // 2ˆ-2 int256 constant a9 = 128402541668774148407; // eˆ(x9) int256 constant x10 = 12500000000000000000; // 2ˆ-3 int256 constant a10 = 113314845306682631683; // eˆ(x10) int256 constant x11 = 6250000000000000000; // 2ˆ-4 int256 constant a11 = 106449445891785942956; // eˆ(x11) /** * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent. * * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`. */ function pow(uint256 x, uint256 y) internal pure returns (uint256) { if (y == 0) { // We solve the 0^0 indetermination by making it equal one. return uint256(ONE_18); } if (x == 0) { return 0; } // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to // arrive at that result. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means // x^y = exp(y * ln(x)). // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range. _require(x < 2**255, Errors.X_OUT_OF_BOUNDS); int256 x_int256 = int256(x); // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end. // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range. _require(y < MILD_EXPONENT_BOUND, Errors.Y_OUT_OF_BOUNDS); int256 y_int256 = int256(y); int256 logx_times_y; if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) { int256 ln_36_x = _ln_36(x_int256); // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the // (downscaled) last 18 decimals. logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18); } else { logx_times_y = _ln(x_int256) * y_int256; } logx_times_y /= ONE_18; // Finally, we compute exp(y * ln(x)) to arrive at x^y _require( MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, Errors.PRODUCT_OUT_OF_BOUNDS ); return uint256(exp(logx_times_y)); } /** * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent. * * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`. */ function exp(int256 x) internal pure returns (int256) { _require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, Errors.INVALID_EXPONENT); if (x < 0) { // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT). // Fixed point division requires multiplying by ONE_18. return ((ONE_18 * ONE_18) / exp(-x)); } // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n, // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7 // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the // decomposition. // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this // decomposition, which will be lower than the smallest x_n. // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1. // We mutate x by subtracting x_n, making it the remainder of the decomposition. // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause // intermediate overflows. Instead we store them as plain integers, with 0 decimals. // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the // decomposition. // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct // it and compute the accumulated product. int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) { x -= x1; firstAN = a1; } else { firstAN = 1; // One with no decimal places } // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the // smaller terms. x *= 100; // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point // one. Recall that fixed point multiplication requires dividing by ONE_20. int256 product = ONE_20; if (x >= x2) { x -= x2; product = (product * a2) / ONE_20; } if (x >= x3) { x -= x3; product = (product * a3) / ONE_20; } if (x >= x4) { x -= x4; product = (product * a4) / ONE_20; } if (x >= x5) { x -= x5; product = (product * a5) / ONE_20; } if (x >= x6) { x -= x6; product = (product * a6) / ONE_20; } if (x >= x7) { x -= x7; product = (product * a7) / ONE_20; } if (x >= x8) { x -= x8; product = (product * a8) / ONE_20; } if (x >= x9) { x -= x9; product = (product * a9) / ONE_20; } // x10 and x11 are unnecessary here since we have high enough precision already. // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!). int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places. int256 term; // Each term in the sum, where the nth term is (x^n / n!). // The first term is simply x. term = x; seriesSum += term; // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number, // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not. term = ((term * x) / ONE_20) / 2; seriesSum += term; term = ((term * x) / ONE_20) / 3; seriesSum += term; term = ((term * x) / ONE_20) / 4; seriesSum += term; term = ((term * x) / ONE_20) / 5; seriesSum += term; term = ((term * x) / ONE_20) / 6; seriesSum += term; term = ((term * x) / ONE_20) / 7; seriesSum += term; term = ((term * x) / ONE_20) / 8; seriesSum += term; term = ((term * x) / ONE_20) / 9; seriesSum += term; term = ((term * x) / ONE_20) / 10; seriesSum += term; term = ((term * x) / ONE_20) / 11; seriesSum += term; term = ((term * x) / ONE_20) / 12; seriesSum += term; // 12 Taylor terms are sufficient for 18 decimal precision. // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication), // and then drop two digits to return an 18 decimal value. return (((product * seriesSum) / ONE_20) * firstAN) / 100; } /** * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument. */ function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = _ln_36(base); } else { logBase = _ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = _ln_36(arg); } else { logArg = _ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; } /** * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function ln(int256 a) internal pure returns (int256) { // The real natural logarithm is not defined for negative numbers or zero. _require(a > 0, Errors.OUT_OF_BOUNDS); if (LN_36_LOWER_BOUND < a && a < LN_36_UPPER_BOUND) { return _ln_36(a) / ONE_18; } else { return _ln(a); } } /** * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function _ln(int256 a) private pure returns (int256) { if (a < ONE_18) { // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive call. // Fixed point division requires multiplying by ONE_18. return (-_ln((ONE_18 * ONE_18) / a)); } // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two, which // we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n (that is, // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers cannot // be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a. // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of this // decomposition, which will be lower than the smallest a_n. // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1. // We mutate a by subtracting a_n, making it the remainder of the decomposition. // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed point // numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply them by // ONE_18 to convert them to fixed point. // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so divide // by it and compute the accumulated sum. int256 sum = 0; if (a >= a0 * ONE_18) { a /= a0; // Integer, not fixed point division sum += x0; } if (a >= a1 * ONE_18) { a /= a1; // Integer, not fixed point division sum += x1; } // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this format. sum *= 100; a *= 100; // Because further a_n are 20 digit fixed point numbers, we multiply by ONE_20 when dividing by them. if (a >= a2) { a = (a * ONE_20) / a2; sum += x2; } if (a >= a3) { a = (a * ONE_20) / a3; sum += x3; } if (a >= a4) { a = (a * ONE_20) / a4; sum += x4; } if (a >= a5) { a = (a * ONE_20) / a5; sum += x5; } if (a >= a6) { a = (a * ONE_20) / a6; sum += x6; } if (a >= a7) { a = (a * ONE_20) / a7; sum += x7; } if (a >= a8) { a = (a * ONE_20) / a8; sum += x8; } if (a >= a9) { a = (a * ONE_20) / a9; sum += x9; } if (a >= a10) { a = (a * ONE_20) / a10; sum += x10; } if (a >= a11) { a = (a * ONE_20) / a11; sum += x11; } // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor series // that converges rapidly for values of `a` close to one - the same one used in ln_36. // Let z = (a - 1) / (a + 1). // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires // division by ONE_20. int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20); int256 z_squared = (z * z) / ONE_20; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_20; seriesSum += num / 3; num = (num * z_squared) / ONE_20; seriesSum += num / 5; num = (num * z_squared) / ONE_20; seriesSum += num / 7; num = (num * z_squared) / ONE_20; seriesSum += num / 9; num = (num * z_squared) / ONE_20; seriesSum += num / 11; // 6 Taylor terms are sufficient for 36 decimal precision. // Finally, we multiply by 2 (non fixed point) to compute ln(remainder) seriesSum *= 2; // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder (both // with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18 decimal // value. return (sum + seriesSum) / 100; } /** * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument, * for x close to one. * * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND. */ function _ln_36(int256 x) private pure returns (int256) { // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits // worthwhile. // First, we transform x to a 36 digit fixed point value. x *= ONE_18; // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1). // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires // division by ONE_36. int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36); int256 z_squared = (z * z) / ONE_36; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_36; seriesSum += num / 3; num = (num * z_squared) / ONE_36; seriesSum += num / 5; num = (num * z_squared) / ONE_36; seriesSum += num / 7; num = (num * z_squared) / ONE_36; seriesSum += num / 9; num = (num * z_squared) / ONE_36; seriesSum += num / 11; num = (num * z_squared) / ONE_36; seriesSum += num / 13; num = (num * z_squared) / ONE_36; seriesSum += num / 15; // 8 Taylor terms are sufficient for 36 decimal precision. // All that remains is multiplying by 2 (non fixed point). return seriesSum * 2; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; // solhint-disable /** * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are * supported. */ function _require(bool condition, uint256 errorCode) pure { if (!condition) _revert(errorCode); } /** * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported. */ function _revert(uint256 errorCode) pure { // We're going to dynamically create a revert string based on the error code, with the following format: // 'BAL#{errorCode}' // where the code is left-padded with zeroes to three digits (so they range from 000 to 999). // // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a // number (8 to 16 bits) than the individual string characters. // // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a // safe place to rely on it without worrying about how its usage might affect e.g. memory contents. assembly { // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for // the '0' character. let units := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let tenths := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let hundreds := add(mod(errorCode, 10), 0x30) // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the // characters to it, each shifted by a multiple of 8. // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte // array). let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds)))) // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded // message will have the following layout: // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ] // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten. mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000) // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away). mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) // The string length is fixed: 7 characters. mstore(0x24, 7) // Finally, the string itself is stored. mstore(0x44, revertReason) // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of // the encoded message is therefore 4 + 32 + 32 + 32 = 100. revert(0, 100) } } library Errors { // Math uint256 internal constant ADD_OVERFLOW = 0; uint256 internal constant SUB_OVERFLOW = 1; uint256 internal constant SUB_UNDERFLOW = 2; uint256 internal constant MUL_OVERFLOW = 3; uint256 internal constant ZERO_DIVISION = 4; uint256 internal constant DIV_INTERNAL = 5; uint256 internal constant X_OUT_OF_BOUNDS = 6; uint256 internal constant Y_OUT_OF_BOUNDS = 7; uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8; uint256 internal constant INVALID_EXPONENT = 9; // Input uint256 internal constant OUT_OF_BOUNDS = 100; uint256 internal constant UNSORTED_ARRAY = 101; uint256 internal constant UNSORTED_TOKENS = 102; uint256 internal constant INPUT_LENGTH_MISMATCH = 103; uint256 internal constant ZERO_TOKEN = 104; // Shared pools uint256 internal constant MIN_TOKENS = 200; uint256 internal constant MAX_TOKENS = 201; uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202; uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203; uint256 internal constant MINIMUM_BPT = 204; uint256 internal constant CALLER_NOT_VAULT = 205; uint256 internal constant UNINITIALIZED = 206; uint256 internal constant BPT_IN_MAX_AMOUNT = 207; uint256 internal constant BPT_OUT_MIN_AMOUNT = 208; uint256 internal constant EXPIRED_PERMIT = 209; uint256 internal constant NOT_TWO_TOKENS = 210; // Pools uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309; uint256 internal constant UNHANDLED_JOIN_KIND = 310; uint256 internal constant ZERO_INVARIANT = 311; uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312; uint256 internal constant ORACLE_NOT_INITIALIZED = 313; uint256 internal constant ORACLE_QUERY_TOO_OLD = 314; uint256 internal constant ORACLE_INVALID_INDEX = 315; uint256 internal constant ORACLE_BAD_SECS = 316; uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317; uint256 internal constant AMP_ONGOING_UPDATE = 318; uint256 internal constant AMP_RATE_TOO_HIGH = 319; uint256 internal constant AMP_NO_ONGOING_UPDATE = 320; uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321; uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322; uint256 internal constant RELAYER_NOT_CONTRACT = 323; uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324; uint256 internal constant REBALANCING_RELAYER_REENTERED = 325; // Lib uint256 internal constant REENTRANCY = 400; uint256 internal constant SENDER_NOT_ALLOWED = 401; uint256 internal constant PAUSED = 402; uint256 internal constant PAUSE_WINDOW_EXPIRED = 403; uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404; uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405; uint256 internal constant INSUFFICIENT_BALANCE = 406; uint256 internal constant INSUFFICIENT_ALLOWANCE = 407; uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408; uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409; uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410; uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411; uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412; uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413; uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414; uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415; uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416; uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417; uint256 internal constant SAFE_ERC20_CALL_FAILED = 418; uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419; uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420; uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421; uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422; uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423; uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424; uint256 internal constant BUFFER_PERIOD_EXPIRED = 425; uint256 internal constant CALLER_IS_NOT_OWNER = 426; uint256 internal constant NEW_OWNER_IS_ZERO = 427; uint256 internal constant CODE_DEPLOYMENT_FAILED = 428; // Vault uint256 internal constant INVALID_POOL_ID = 500; uint256 internal constant CALLER_NOT_POOL = 501; uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502; uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503; uint256 internal constant INVALID_SIGNATURE = 504; uint256 internal constant EXIT_BELOW_MIN = 505; uint256 internal constant JOIN_ABOVE_MAX = 506; uint256 internal constant SWAP_LIMIT = 507; uint256 internal constant SWAP_DEADLINE = 508; uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509; uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510; uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511; uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512; uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513; uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514; uint256 internal constant INVALID_POST_LOAN_BALANCE = 515; uint256 internal constant INSUFFICIENT_ETH = 516; uint256 internal constant UNALLOCATED_ETH = 517; uint256 internal constant ETH_TRANSFER = 518; uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519; uint256 internal constant TOKENS_MISMATCH = 520; uint256 internal constant TOKEN_NOT_REGISTERED = 521; uint256 internal constant TOKEN_ALREADY_REGISTERED = 522; uint256 internal constant TOKENS_ALREADY_SET = 523; uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524; uint256 internal constant NONZERO_TOKEN_BALANCE = 525; uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526; uint256 internal constant POOL_NO_TOKENS = 527; uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528; // Fees uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600; uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601; uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/TemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IBasePool.sol"; import "./BalancerPoolToken.sol"; import "./BasePoolAuthorization.sol"; import "@balancer-labs/v2-asset-manager-utils/contracts/IAssetManager.sol"; // This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage // reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus a total // count, resulting in a large number of state variables. // solhint-disable max-states-count /** * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with an immutable set * of registered tokens, no Asset Managers, an admin-controlled swap fee percentage, and an emergency pause mechanism. * * Note that neither swap fees nor the pause mechanism are used by this contract. They are passed through so that * derived contracts can use them via the `_addSwapFeeAmount` and `_subtractSwapFeeAmount` functions, and the * `whenNotPaused` modifier. * * No admin permissions are checked here: instead, this contract delegates that to the Vault's own Authorizer. * * Because this contract doesn't implement the swap hooks, derived contracts should generally inherit from * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces * and implement the swap callbacks themselves. */ abstract contract BasePool is IBasePool, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable { using FixedPoint for uint256; uint256 private constant _MIN_TOKENS = 2; uint256 private constant _MAX_TOKENS = 8; // 1e18 corresponds to 1.0, or a 100% fee uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001% uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10% uint256 private constant _MINIMUM_BPT = 1e6; uint256 internal _swapFeePercentage; IVault private immutable _vault; bytes32 private immutable _poolId; uint256 private immutable _totalTokens; IERC20 internal immutable _token0; IERC20 internal immutable _token1; IERC20 internal immutable _token2; IERC20 internal immutable _token3; IERC20 internal immutable _token4; IERC20 internal immutable _token5; IERC20 internal immutable _token6; IERC20 internal immutable _token7; // All token balances are normalized to behave as if the token had 18 decimals. We assume a token's decimals will // not change throughout its lifetime, and store the corresponding scaling factor for each at construction time. // These factors are always greater than or equal to one: tokens with more than 18 decimals are not supported. uint256 private immutable _scalingFactor0; uint256 private immutable _scalingFactor1; uint256 private immutable _scalingFactor2; uint256 private immutable _scalingFactor3; uint256 private immutable _scalingFactor4; uint256 private immutable _scalingFactor5; uint256 private immutable _scalingFactor6; uint256 private immutable _scalingFactor7; event SwapFeePercentageChanged(uint256 swapFeePercentage); constructor( IVault vault, IVault.PoolSpecialization specialization, string memory name, string memory symbol, IERC20[] memory tokens, address[] memory assetManagers, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) // Base Pools are expected to be deployed using factories. By using the factory address as the action // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in // any Pool created by the same factory), while still making action identifiers unique among different factories // if the selectors match, preventing accidental errors. Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration) { _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS); _require(tokens.length <= _MAX_TOKENS, Errors.MAX_TOKENS); // The Vault only requires the token list to be ordered for the Two Token Pools specialization. However, // to make the developer experience consistent, we are requiring this condition for all the native pools. // Also, since these Pools will register tokens only once, we can ensure the Pool tokens will follow the same // order. We rely on this property to make Pools simpler to write, as it lets us assume that the // order of token-specific parameters (such as token weights) will not change. InputHelpers.ensureArrayIsSorted(tokens); _setSwapFeePercentage(swapFeePercentage); bytes32 poolId = vault.registerPool(specialization); vault.registerTokens(poolId, tokens, assetManagers); // Set immutable state variables - these cannot be read from during construction uint256 totalTokens = tokens.length; _vault = vault; _poolId = poolId; _totalTokens = totalTokens; // Immutable variables cannot be initialized inside an if statement, so we must do conditional assignments _token0 = totalTokens > 0 ? tokens[0] : IERC20(0); _token1 = totalTokens > 1 ? tokens[1] : IERC20(0); _token2 = totalTokens > 2 ? tokens[2] : IERC20(0); _token3 = totalTokens > 3 ? tokens[3] : IERC20(0); _token4 = totalTokens > 4 ? tokens[4] : IERC20(0); _token5 = totalTokens > 5 ? tokens[5] : IERC20(0); _token6 = totalTokens > 6 ? tokens[6] : IERC20(0); _token7 = totalTokens > 7 ? tokens[7] : IERC20(0); _scalingFactor0 = totalTokens > 0 ? _computeScalingFactor(tokens[0]) : 0; _scalingFactor1 = totalTokens > 1 ? _computeScalingFactor(tokens[1]) : 0; _scalingFactor2 = totalTokens > 2 ? _computeScalingFactor(tokens[2]) : 0; _scalingFactor3 = totalTokens > 3 ? _computeScalingFactor(tokens[3]) : 0; _scalingFactor4 = totalTokens > 4 ? _computeScalingFactor(tokens[4]) : 0; _scalingFactor5 = totalTokens > 5 ? _computeScalingFactor(tokens[5]) : 0; _scalingFactor6 = totalTokens > 6 ? _computeScalingFactor(tokens[6]) : 0; _scalingFactor7 = totalTokens > 7 ? _computeScalingFactor(tokens[7]) : 0; } // Getters / Setters function getVault() public view returns (IVault) { return _vault; } function getPoolId() public view override returns (bytes32) { return _poolId; } function _getTotalTokens() internal view returns (uint256) { return _totalTokens; } function getSwapFeePercentage() external view returns (uint256) { return _swapFeePercentage; } function setSwapFeePercentage(uint256 swapFeePercentage) public virtual authenticate whenNotPaused { _setSwapFeePercentage(swapFeePercentage); } function _setSwapFeePercentage(uint256 swapFeePercentage) private { _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE); _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE); _swapFeePercentage = swapFeePercentage; emit SwapFeePercentageChanged(swapFeePercentage); } function setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig) public virtual authenticate whenNotPaused { _setAssetManagerPoolConfig(token, poolConfig); } function _setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig) private { bytes32 poolId = getPoolId(); (, , , address assetManager) = getVault().getPoolTokenInfo(poolId, token); IAssetManager(assetManager).setConfig(poolId, poolConfig); } function setPaused(bool paused) external authenticate { _setPaused(paused); } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) { return (actionId == getActionId(this.setSwapFeePercentage.selector)) || (actionId == getActionId(this.setAssetManagerPoolConfig.selector)); } // Join / Exit Hooks modifier onlyVault(bytes32 poolId) { _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT); _require(poolId == getPoolId(), Errors.INVALID_POOL_ID); _; } function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); if (totalSupply() == 0) { (uint256 bptAmountOut, uint256[] memory amountsIn) = _onInitializePool( poolId, sender, recipient, scalingFactors, userData ); // On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum // as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from // ever being fully drained. _require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); return (amountsIn, new uint256[](_getTotalTokens())); } else { _upscaleArray(balances, scalingFactors); (uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) = _onJoinPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it. _mintPoolTokens(recipient, bptAmountOut); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsIn, dueProtocolFeeAmounts); } } function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it. _burnPoolTokens(sender, bptAmountIn); // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(amountsOut, scalingFactors); _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsOut, dueProtocolFeeAmounts); } // Query functions /** * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the * Vault with the same arguments, along with the number of tokens `sender` would have to supply. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryJoin( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptOut, uint256[] memory amountsIn) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onJoinPool, _downscaleUpArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptOut, amountsIn); } /** * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the * Vault with the same arguments, along with the number of tokens `recipient` would receive. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryExit( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptIn, uint256[] memory amountsOut) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onExitPool, _downscaleDownArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptIn, amountsOut); } // Internal hooks to be overridden by derived contracts - all token amounts (except BPT) in these interfaces are // upscaled. /** * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero. * * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return. * * Minted BPT will be sent to `recipient`, except for _MINIMUM_BPT, which will be deducted from this amount and sent * to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP from * ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire Pool's * lifetime. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. */ function _onInitializePool( bytes32 poolId, address sender, address recipient, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns (uint256 bptAmountOut, uint256[] memory amountsIn); /** * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`). * * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of * tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * Minted BPT will be sent to `recipient`. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns ( uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts ); /** * @dev Called whenever the Pool is exited. * * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and * the number of tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * BPT will be burnt from `sender`. * * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled * (rounding down) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, uint256[] memory scalingFactors, bytes memory userData ) internal virtual returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ); // Internal functions /** * @dev Adds swap fee amount to `amount`, returning a higher value. */ function _addSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount + fee amount, so we round up (favoring a higher fee amount). return amount.divUp(FixedPoint.ONE.sub(_swapFeePercentage)); } /** * @dev Subtracts swap fee amount from `amount`, returning a lower value. */ function _subtractSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount - fee amount, so we round up (favoring a higher fee amount). uint256 feeAmount = amount.mulUp(_swapFeePercentage); return amount.sub(feeAmount); } // Scaling /** * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if * it had 18 decimals. */ function _computeScalingFactor(IERC20 token) private view returns (uint256) { // Tokens that don't implement the `decimals` method are not supported. uint256 tokenDecimals = ERC20(address(token)).decimals(); // Tokens with more than 18 decimals are not supported. uint256 decimalsDifference = Math.sub(18, tokenDecimals); return FixedPoint.ONE * 10**decimalsDifference; } /** * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the * Pool. * * All scaling factors are fixed-point values with 18 decimals, to allow for this function to be overridden by * derived contracts that need to apply further scaling, making these factors potentially non-integer. * * The largest 'base' scaling factor (i.e. in tokens with less than 18 decimals) is 10**18, which in fixed-point is * 10**36. This value can be multiplied with a 112 bit Vault balance with no overflow by a factor of ~1e7, making * even relatively 'large' factors safe to use. * * The 1e7 figure is the result of 2**256 / (1e18 * 1e18 * 2**112). */ function _scalingFactor(IERC20 token) internal view virtual returns (uint256) { // prettier-ignore if (token == _token0) { return _scalingFactor0; } else if (token == _token1) { return _scalingFactor1; } else if (token == _token2) { return _scalingFactor2; } else if (token == _token3) { return _scalingFactor3; } else if (token == _token4) { return _scalingFactor4; } else if (token == _token5) { return _scalingFactor5; } else if (token == _token6) { return _scalingFactor6; } else if (token == _token7) { return _scalingFactor7; } else { _revert(Errors.INVALID_TOKEN); } } /** * @dev Same as `_scalingFactor()`, except for all registered tokens (in the same order as registered). The Vault * will always pass balances in this order when calling any of the Pool hooks. */ function _scalingFactors() internal view virtual returns (uint256[] memory) { uint256 totalTokens = _getTotalTokens(); uint256[] memory scalingFactors = new uint256[](totalTokens); // prettier-ignore { if (totalTokens > 0) { scalingFactors[0] = _scalingFactor0; } else { return scalingFactors; } if (totalTokens > 1) { scalingFactors[1] = _scalingFactor1; } else { return scalingFactors; } if (totalTokens > 2) { scalingFactors[2] = _scalingFactor2; } else { return scalingFactors; } if (totalTokens > 3) { scalingFactors[3] = _scalingFactor3; } else { return scalingFactors; } if (totalTokens > 4) { scalingFactors[4] = _scalingFactor4; } else { return scalingFactors; } if (totalTokens > 5) { scalingFactors[5] = _scalingFactor5; } else { return scalingFactors; } if (totalTokens > 6) { scalingFactors[6] = _scalingFactor6; } else { return scalingFactors; } if (totalTokens > 7) { scalingFactors[7] = _scalingFactor7; } else { return scalingFactors; } } return scalingFactors; } /** * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed * scaling or not. */ function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { // Upscale rounding wouldn't necessarily always go in the same direction: in a swap for example the balance of // token in should be rounded up, and that of token out rounded down. This is the only place where we round in // the same direction for all amounts, as the impact of this rounding is expected to be minimal (and there's no // rounding error unless `_scalingFactor()` is overriden). return FixedPoint.mulDown(amount, scalingFactor); } /** * @dev Same as `_upscale`, but for an entire array. This function does not return anything, but instead *mutates* * the `amounts` array. */ function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.mulDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded down. */ function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return FixedPoint.divDown(amount, scalingFactor); } /** * @dev Same as `_downscaleDown`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.divDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded up. */ function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return FixedPoint.divUp(amount, scalingFactor); } /** * @dev Same as `_downscaleUp`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleUpArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = FixedPoint.divUp(amounts[i], scalingFactors[i]); } } function _getAuthorizer() internal view override returns (IAuthorizer) { // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which // accounts can call permissioned functions: for example, to perform emergency pauses. // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under // Governance control. return getVault().getAuthorizer(); } function _queryAction( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData, function(bytes32, address, address, uint256[] memory, uint256, uint256, uint256[] memory, bytes memory) internal returns (uint256, uint256[] memory, uint256[] memory) _action, function(uint256[] memory, uint256[] memory) internal view _downscaleArray ) private { // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed // explanation. if (msg.sender != address(this)) { // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of // the preceding if statement will be executed instead. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = address(this).call(msg.data); // solhint-disable-next-line no-inline-assembly assembly { // This call should always revert to decode the bpt and token amounts from the revert reason switch success case 0 { // Note we are manually writing the memory slot 0. We can safely overwrite whatever is // stored there as we take full control of the execution and then immediately return. // We copy the first 4 bytes to check if it matches with the expected signature, otherwise // there was another revert reason and we should forward it. returndatacopy(0, 0, 0x04) let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // If the first 4 bytes don't match with the expected signature, we forward the revert reason. if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } // The returndata contains the signature, followed by the raw memory representation of the // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded // representation of these. // An ABI-encoded response will include one additional field to indicate the starting offset of // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the // returndata. // // In returndata: // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ] // [ 4 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // // We now need to return (ABI-encoded values): // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ] // [ 32 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // We copy 32 bytes for the `bptAmount` from returndata into memory. // Note that we skip the first 4 bytes for the error signature returndatacopy(0, 0x04, 32) // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after // the initial 64 bytes. mstore(0x20, 64) // We now copy the raw memory array for the `tokenAmounts` from returndata into memory. // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount. returndatacopy(0x40, 0x24, sub(returndatasize(), 36)) // We finally return the ABI-encoded uint256 and the array, which has a total length equal to // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the // error signature. return(0, add(returndatasize(), 28)) } default { // This call should always revert, but we fail nonetheless if that didn't happen invalid() } } } else { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, scalingFactors, userData ); _downscaleArray(tokenAmounts, scalingFactors); // solhint-disable-next-line no-inline-assembly assembly { // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32 let size := mul(mload(tokenAmounts), 32) // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there // will be at least one available slot due to how the memory scratch space works. // We can safely overwrite whatever is stored in this slot as we will revert immediately after that. let start := sub(tokenAmounts, 0x20) mstore(start, bptAmount) // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb // We use the previous slot to `bptAmount`. mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb) start := sub(start, 0x04) // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return // the `bptAmount`, the array 's length, and the error signature. revert(start, add(size, 68)) } } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IBasePool.sol"; /** * @dev IPools with the General specialization setting should implement this interface. * * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool. * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will * grant to the pool in a 'given out' swap. * * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is * indeed the Vault. */ interface IGeneralPool is IBasePool { function onSwap( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) external returns (uint256 amount); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library */ library Math { /** * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the addition of two signed integers, reverting on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; } /** * @dev Returns the largest of two numbers of 256 bits. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers of 256 bits. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW); return c; } function div( uint256 a, uint256 b, bool roundUp ) internal pure returns (uint256) { return roundUp ? divUp(a, b) : divDown(a, b); } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); return a / b; } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { return 1 + (a - 1) / b; } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./ITemporarilyPausable.sol"; /** * @dev Allows for a contract to be paused during an initial period after deployment, disabling functionality. Can be * used as an emergency switch in case a security vulnerability or threat is identified. * * The contract can only be paused during the Pause Window, a period that starts at deployment. It can also be * unpaused and repaused any number of times during this period. This is intended to serve as a safety measure: it lets * system managers react quickly to potentially dangerous situations, knowing that this action is reversible if careful * analysis later determines there was a false alarm. * * If the contract is paused when the Pause Window finishes, it will remain in the paused state through an additional * Buffer Period, after which it will be automatically unpaused forever. This is to ensure there is always enough time * to react to an emergency, even if the threat is discovered shortly before the Pause Window expires. * * Note that since the contract can only be paused within the Pause Window, unpausing during the Buffer Period is * irreversible. */ abstract contract TemporarilyPausable is ITemporarilyPausable { // The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. // solhint-disable not-rely-on-time uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused; constructor(uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { _require(pauseWindowDuration <= _MAX_PAUSE_WINDOW_DURATION, Errors.MAX_PAUSE_WINDOW_DURATION); _require(bufferPeriodDuration <= _MAX_BUFFER_PERIOD_DURATION, Errors.MAX_BUFFER_PERIOD_DURATION); uint256 pauseWindowEndTime = block.timestamp + pauseWindowDuration; _pauseWindowEndTime = pauseWindowEndTime; _bufferPeriodEndTime = pauseWindowEndTime + bufferPeriodDuration; } /** * @dev Reverts if the contract is paused. */ modifier whenNotPaused() { _ensureNotPaused(); _; } /** * @dev Returns the current contract pause status, as well as the end times of the Pause Window and Buffer * Period. */ function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ) { paused = !_isNotPaused(); pauseWindowEndTime = _getPauseWindowEndTime(); bufferPeriodEndTime = _getBufferPeriodEndTime(); } /** * @dev Sets the pause state to `paused`. The contract can only be paused until the end of the Pause Window, and * unpaused until the end of the Buffer Period. * * Once the Buffer Period expires, this function reverts unconditionally. */ function _setPaused(bool paused) internal { if (paused) { _require(block.timestamp < _getPauseWindowEndTime(), Errors.PAUSE_WINDOW_EXPIRED); } else { _require(block.timestamp < _getBufferPeriodEndTime(), Errors.BUFFER_PERIOD_EXPIRED); } _paused = paused; emit PausedStateChanged(paused); } /** * @dev Reverts if the contract is paused. */ function _ensureNotPaused() internal view { _require(_isNotPaused(), Errors.PAUSED); } /** * @dev Returns true if the contract is unpaused. * * Once the Buffer Period expires, the gas cost of calling this function is reduced dramatically, as storage is no * longer accessed. */ function _isNotPaused() internal view returns (bool) { // After the Buffer Period, the (inexpensive) timestamp check short-circuits the storage access. return block.timestamp > _getBufferPeriodEndTime() || !_paused; } // These getters lead to reduced bytecode size by inlining the immutable variables in a single place. function _getPauseWindowEndTime() private view returns (uint256) { return _pauseWindowEndTime; } function _getBufferPeriodEndTime() private view returns (uint256) { return _bufferPeriodEndTime; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; import "./IERC20.sol"; import "./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 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_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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 returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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(msg.sender, 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(msg.sender, 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, msg.sender, _allowances[sender][msg.sender].sub(amount, Errors.ERC20_TRANSFER_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(msg.sender, spender, _allowances[msg.sender][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( msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, Errors.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), Errors.ERC20_TRANSFER_FROM_ZERO_ADDRESS); _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, Errors.ERC20_TRANSFER_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 { _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), Errors.ERC20_BURN_FROM_ZERO_ADDRESS); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, Errors.ERC20_BURN_EXCEEDS_ALLOWANCE); _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 { _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 { _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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ISignaturesValidator.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ITemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IWETH.sol"; import "./IAsset.sol"; import "./IAuthorizer.sol"; import "./IFlashLoanRecipient.sol"; import "./IProtocolFeesCollector.sol"; pragma solidity ^0.7.0; /** * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that * don't override one of these declarations. */ interface IVault is ISignaturesValidator, ITemporarilyPausable { // Generalities about the Vault: // // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning // a boolean value: in these scenarios, a non-reverting call is assumed to be successful. // // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g. // while execution control is transferred to a token contract during a swap) will result in a revert. View // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results. // Contracts calling view functions in the Vault must make sure the Vault has not already been entered. // // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools. // Authorizer // // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller // can perform a given action. /** * @dev Returns the Vault's Authorizer. */ function getAuthorizer() external view returns (IAuthorizer); /** * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this. * * Emits an `AuthorizerChanged` event. */ function setAuthorizer(IAuthorizer newAuthorizer) external; /** * @dev Emitted when a new authorizer is set by `setAuthorizer`. */ event AuthorizerChanged(IAuthorizer indexed newAuthorizer); // Relayers // // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions, // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield // this power, two things must occur: // - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This // means that Balancer governance must approve each individual contract to act as a relayer for the intended // functions. // - Each user must approve the relayer to act on their behalf. // This double protection means users cannot be tricked into approving malicious relayers (because they will not // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised // Authorizer or governance drain user funds, since they would also need to be approved by each individual user. /** * @dev Returns true if `user` has approved `relayer` to act as a relayer for them. */ function hasApprovedRelayer(address user, address relayer) external view returns (bool); /** * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise. * * Emits a `RelayerApprovalChanged` event. */ function setRelayerApproval( address sender, address relayer, bool approved ) external; /** * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`. */ event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved); // Internal Balance // // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users. // // Internal Balance management features batching, which means a single contract call can be used to perform multiple // operations of different kinds, with different senders and recipients, at once. /** * @dev Returns `user`'s Internal Balance for a set of tokens. */ function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory); /** * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer) * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as * it lets integrators reuse a user's Vault allowance. * * For each operation, if the caller is not `sender`, it must be an authorized relayer for them. */ function manageUserBalance(UserBalanceOp[] memory ops) external payable; /** * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received without manual WETH wrapping or unwrapping. */ struct UserBalanceOp { UserBalanceOpKind kind; IAsset asset; uint256 amount; address sender; address payable recipient; } // There are four possible operations in `manageUserBalance`: // // - DEPOSIT_INTERNAL // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`. // // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is // relevant for relayers). // // Emits an `InternalBalanceChanged` event. // // // - WITHDRAW_INTERNAL // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`. // // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send // it to the recipient as ETH. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_INTERNAL // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`. // // Reverts if the ETH sentinel value is passed. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_EXTERNAL // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by // relayers, as it lets them reuse a user's Vault allowance. // // Reverts if the ETH sentinel value is passed. // // Emits an `ExternalBalanceTransfer` event. enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL } /** * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through * interacting with Pools using Internal Balance. * * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH * address. */ event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta); /** * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account. */ event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount); // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be * changed. * * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`, * depending on the chosen specialization setting. This contract is known as the Pool's contract. * * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words, * multiple Pools may share the same contract. * * Emits a `PoolRegistered` event. */ function registerPool(PoolSpecialization specialization) external returns (bytes32); /** * @dev Emitted when a Pool is registered by calling `registerPool`. */ event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization); /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); /** * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens, * exit by receiving registered tokens, and can only swap registered tokens. * * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in * ascending order. * * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`, * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore * expected to be highly secured smart contracts with sound design principles, and the decision to register an * Asset Manager should not be made lightly. * * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a * different Asset Manager. * * Emits a `TokensRegistered` event. */ function registerTokens( bytes32 poolId, IERC20[] memory tokens, address[] memory assetManagers ) external; /** * @dev Emitted when a Pool registers tokens by calling `registerTokens`. */ event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers); /** * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens * must be deregistered in the same `deregisterTokens` call. * * A deregistered token can be re-registered later on, possibly with a different Asset Manager. * * Emits a `TokensDeregistered` event. */ function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external; /** * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`. */ event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens); /** * @dev Returns detailed information for a Pool's registered token. * * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token` * equals the sum of `cash` and `managed`. * * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`, * `managed` or `total` balance to be greater than 2^112 - 1. * * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a * change for this purpose, and will update `lastChangeBlock`. * * `assetManager` is the Pool's token Asset Manager. */ function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); /** * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of * the tokens' `balances` changed. * * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order. * * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same * order as passed to `registerTokens`. * * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo` * instead. */ function getPoolTokens(bytes32 poolId) external view returns ( IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); /** * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized * Pool shares. * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces * these maximums. * * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent * back to the caller (not the sender, which is important for relayers). * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final * `assets` array might not be sorted. Pools with no registered tokens cannot be joined. * * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be * withdrawn from Internal Balance: attempting to do so will trigger a revert. * * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed * directly to the Pool's contract, as is `recipient`. * * Emits a `PoolBalanceChanged` event. */ function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { IAsset[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { IAsset[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } /** * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively. */ event PoolBalanceChanged( bytes32 indexed poolId, address indexed liquidityProvider, IERC20[] tokens, int256[] deltas, uint256[] protocolFeeAmounts ); enum PoolBalanceChangeKind { JOIN, EXIT } // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; IAsset assetIn; IAsset assetOut; uint256 amount; bytes userData; } /** * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either * the amount of tokens sent to or received from the Pool, depending on the `kind` value. * * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at * the same index in the `assets` array. * * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or * `amountOut` depending on the swap kind. * * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`. * * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses, * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to * or unwrapped from WETH by the Vault. * * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies * the minimum or maximum amount of each token the vault is allowed to transfer. * * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the * equivalent `swap` call. * * Emits `Swap` events. */ function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); /** * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the * `assets` array passed to that function, and ETH assets are converted to WETH. * * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out * from the previous swap, depending on the swap kind. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } /** * @dev Emitted for each individual swap performed by `swap` or `batchSwap`. */ event Swap( bytes32 indexed poolId, IERC20 indexed tokenIn, IERC20 indexed tokenOut, uint256 amountIn, uint256 amountOut ); /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. * * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH) * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it * receives are the same that an equivalent `batchSwap` call would receive. * * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct. * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens, * approve them for the Vault, or even know a user's address. * * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute * eth_call instead of eth_sendTransaction. */ function queryBatchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds ) external returns (int256[] memory assetDeltas); // Flash Loans /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoan( IFlashLoanRecipient recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount); // Asset Management // // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore // not constrained to the tokens they are managing, but extends to the entire Pool's holdings. // // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit, // for example by lending unused tokens out for interest, or using them to participate in voting protocols. // // This concept is unrelated to the IAsset interface. /** * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates. * * Pool Balance management features batching, which means a single contract call can be used to perform multiple * operations of different kinds, with different Pools and tokens, at once. * * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`. */ function managePoolBalance(PoolBalanceOp[] memory ops) external; struct PoolBalanceOp { PoolBalanceOpKind kind; bytes32 poolId; IERC20 token; uint256 amount; } /** * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged. * * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged. * * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total. * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss). */ enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE } /** * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`. */ event PoolBalanceManaged( bytes32 indexed poolId, address indexed assetManager, IERC20 indexed token, int256 cashDelta, int256 managedDelta ); // Protocol Fees // // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by // permissioned accounts. // // There are two kinds of protocol fees: // // - flash loan fees: charged on all flash loans, as a percentage of the amounts lent. // // - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather, // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as // exiting a Pool in debt without first paying their share. /** * @dev Returns the current protocol fee module. */ function getProtocolFeesCollector() external view returns (IProtocolFeesCollector); /** * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an * error in some part of the system. * * The Vault can only be paused during an initial time period, after which pausing is forever disabled. * * While the contract is paused, the following features are disabled: * - depositing and transferring internal balance * - transferring external balance (using the Vault's allowance) * - swaps * - joining Pools * - Asset Manager interactions * * Internal Balance can still be withdrawn, and Pools exited. */ function setPaused(bool paused) external; /** * @dev Returns the Vault's WETH instance. */ function WETH() external view returns (IWETH); // solhint-disable-previous-line func-name-mixedcase }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IVault.sol"; import "./IPoolSwapStructs.sol"; /** * @dev Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is not * the complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit from * either IGeneralPool or IMinimalSwapInfoPool */ interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`. * * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join. * * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account * designated to receive any benefits (typically pool shares). `currentBalances` contains the total balances * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as minting pool shares. */ function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts); /** * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`, * as well as collect the reported amount in protocol fees, which the Pool should calculate based on * `protocolSwapFeePercentage`. * * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share. * * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account * to which the Vault will send the proceeds. `currentBalances` contains the total token balances for each token * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as burning pool shares. */ function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts); function getPoolId() external view returns (bytes32); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20Permit.sol"; /** * @title Highly opinionated token implementation * @author Balancer Labs * @dev * - Includes functions to increase and decrease allowance as a workaround * for the well-known issue with `approve`: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not * decreased by calls to transferFrom * - Lets a token holder use `transferFrom` to send their own tokens, * without first setting allowance * - Emits 'Approval' events whenever allowance is changed by `transferFrom` */ contract BalancerPoolToken is ERC20, ERC20Permit { constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) ERC20Permit(tokenName) { // solhint-disable-previous-line no-empty-blocks } // Overrides /** * @dev Override to allow for 'infinite allowance' and let the token owner use `transferFrom` with no self-allowance */ function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { uint256 currentAllowance = allowance(sender, msg.sender); _require(msg.sender == sender || currentAllowance >= amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE); _transfer(sender, recipient, amount); if (msg.sender != sender && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount _approve(sender, msg.sender, currentAllowance - amount); } return true; } /** * @dev Override to allow decreasing allowance by more than the current amount (setting it to zero) */ function decreaseAllowance(address spender, uint256 amount) public override returns (bool) { uint256 currentAllowance = allowance(msg.sender, spender); if (amount >= currentAllowance) { _approve(msg.sender, spender, 0); } else { // No risk of underflow due to if condition _approve(msg.sender, spender, currentAllowance - amount); } return true; } // Internal functions function _mintPoolTokens(address recipient, uint256 amount) internal { _mint(recipient, amount); } function _burnPoolTokens(address sender, uint256 amount) internal { _burn(sender, amount); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/Authentication.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IAuthorizer.sol"; import "./BasePool.sol"; /** * @dev Base authorization layer implementation for Pools. * * The owner account can call some of the permissioned functions - access control of the rest is delegated to the * Authorizer. Note that this owner is immutable: more sophisticated permission schemes, such as multiple ownership, * granular roles, etc., could be built on top of this by making the owner a smart contract. * * Access control of all other permissioned functions is delegated to an Authorizer. It is also possible to delegate * control of *all* permissioned functions to the Authorizer by setting the owner address to `_DELEGATE_OWNER`. */ abstract contract BasePoolAuthorization is Authentication { address private immutable _owner; address private constant _DELEGATE_OWNER = 0xBA1BA1ba1BA1bA1bA1Ba1BA1ba1BA1bA1ba1ba1B; constructor(address owner) { _owner = owner; } function getOwner() public view returns (address) { return _owner; } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { if ((getOwner() != _DELEGATE_OWNER) && _isOwnerOnlyAction(actionId)) { // Only the owner can perform "owner only" actions, unless the owner is delegated. return msg.sender == getOwner(); } else { // Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated. return _getAuthorizer().canPerform(actionId, account, address(this)); } } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual returns (bool); function _getAuthorizer() internal view virtual returns (IAuthorizer); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IAssetManager { /** * @notice Emitted when asset manager is rebalanced */ event Rebalance(bytes32 poolId); /** * @notice Sets the config */ function setConfig(bytes32 poolId, bytes calldata config) external; /** * @notice Returns the asset manager's token */ function getToken() external view returns (IERC20); /** * @return the current assets under management of this asset manager */ function getAUM(bytes32 poolId) external view returns (uint256); /** * @return poolCash - The up-to-date cash balance of the pool * @return poolManaged - The up-to-date managed balance of the pool */ function getPoolBalances(bytes32 poolId) external view returns (uint256 poolCash, uint256 poolManaged); /** * @return The difference in tokens between the target investment * and the currently invested amount (i.e. the amount that can be invested) */ function maxInvestableBalance(bytes32 poolId) external view returns (int256); /** * @notice Updates the Vault on the value of the pool's investment returns */ function updateBalanceOfPool(bytes32 poolId) external; /** * @notice Determines whether the pool should rebalance given the provided balances */ function shouldRebalance(uint256 cash, uint256 managed) external view returns (bool); /** * @notice Rebalances funds between the pool and the asset manager to maintain target investment percentage. * @param poolId - the poolId of the pool to be rebalanced * @param force - a boolean representing whether a rebalance should be forced even when the pool is near balance */ function rebalance(bytes32 poolId, bool force) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; /** * @dev Interface for the TemporarilyPausable helper. */ interface ITemporarilyPausable { /** * @dev Emitted every time the pause state changes by `_setPaused`. */ event PausedStateChanged(bool paused); /** * @dev Returns the current paused state. */ function getPausedState() external view returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @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, 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, Errors.ADD_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) { return sub(a, b, Errors.SUB_OVERFLOW); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, uint256 errorCode) internal pure returns (uint256) { _require(b <= a, errorCode); uint256 c = a - b; return c; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; /** * @dev Interface for the SignatureValidator helper, used to support meta-transactions. */ interface ISignaturesValidator { /** * @dev Returns the EIP712 domain separator. */ function getDomainSeparator() external view returns (bytes32); /** * @dev Returns the next nonce used by an address to sign messages. */ function getNextNonce(address user) external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "../openzeppelin/IERC20.sol"; /** * @dev Interface for WETH9. * See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; /** * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like * types. * * This concept is unrelated to a Pool's Asset Managers. */ interface IAsset { // solhint-disable-previous-line no-empty-blocks }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; interface IAuthorizer { /** * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`. */ function canPerform( bytes32 actionId, address account, address where ) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; // Inspired by Aave Protocol's IFlashLoanReceiver. import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; import "./IAuthorizer.sol"; interface IProtocolFeesCollector { event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external; function setSwapFeePercentage(uint256 newSwapFeePercentage) external; function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external; function getSwapFeePercentage() external view returns (uint256); function getFlashLoanFeePercentage() external view returns (uint256); function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts); function getAuthorizer() external view returns (IAuthorizer); function vault() external view returns (IVault); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; interface IPoolSwapStructs { // This is not really an interface - it just defines common structs used by other interfaces: IGeneralPool and // IMinimalSwapInfoPool. // // This data structure represents a request for a token swap, where `kind` indicates the swap type ('given in' or // 'given out') which indicates whether or not the amount sent by the pool is known. // // The pool receives `tokenIn` and sends `tokenOut`. `amount` is the number of `tokenIn` tokens the pool will take // in, or the number of `tokenOut` tokens the Pool will send out, depending on the given swap `kind`. // // All other fields are not strictly necessary for most swaps, but are provided to support advanced scenarios in // some Pools. // // `poolId` is the ID of the Pool involved in the swap - this is useful for Pool contracts that implement more than // one Pool. // // The meaning of `lastChangeBlock` depends on the Pool specialization: // - Two Token or Minimal Swap Info: the last block in which either `tokenIn` or `tokenOut` changed its total // balance. // - General: the last block in which *any* of the Pool's registered tokens changed its total balance. // // `from` is the origin address for the funds the Pool receives, and `to` is the destination address // where the Pool sends the outgoing tokens. // // `userData` is extra data provided by the caller - typically a signature from a trusted party. struct SwapRequest { IVault.SwapKind kind; IERC20 tokenIn; IERC20 tokenOut; uint256 amount; // Misc data bytes32 poolId; uint256 lastChangeBlock; address from; address to; bytes userData; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./ERC20.sol"; import "./IERC20Permit.sol"; import "./EIP712.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { mapping(address => uint256) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { // solhint-disable-next-line not-rely-on-time _require(block.timestamp <= deadline, Errors.EXPIRED_PERMIT); uint256 nonce = _nonces[owner]; bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, nonce, deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ecrecover(hash, v, r, s); _require((signer != address(0)) && (signer == owner), Errors.INVALID_SIGNATURE); _nonces[owner] = nonce + 1; _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view override returns (uint256) { return _nonces[owner]; } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _HASHED_NAME = keccak256(bytes(name)); _HASHED_VERSION = keccak256(bytes(version)); _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, _getChainId(), address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { // Silence state mutability warning without generating bytecode. // See https://github.com/ethereum/solidity/issues/10090#issuecomment-741789128 and // https://github.com/ethereum/solidity/issues/2691 this; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./IAuthentication.sol"; /** * @dev Building block for performing access control on external functions. * * This contract is used via the `authenticate` modifier (or the `_authenticateCaller` function), which can be applied * to external functions to only make them callable by authorized accounts. * * Derived contracts must implement the `_canPerform` function, which holds the actual access control logic. */ abstract contract Authentication is IAuthentication { bytes32 private immutable _actionIdDisambiguator; /** * @dev The main purpose of the `actionIdDisambiguator` is to prevent accidental function selector collisions in * multi contract systems. * * There are two main uses for it: * - if the contract is a singleton, any unique identifier can be used to make the associated action identifiers * unique. The contract's own address is a good option. * - if the contract belongs to a family that shares action identifiers for the same functions, an identifier * shared by the entire family (and no other contract) should be used instead. */ constructor(bytes32 actionIdDisambiguator) { _actionIdDisambiguator = actionIdDisambiguator; } /** * @dev Reverts unless the caller is allowed to call this function. Should only be applied to external functions. */ modifier authenticate() { _authenticateCaller(); _; } /** * @dev Reverts unless the caller is allowed to call the entry point function. */ function _authenticateCaller() internal view { bytes32 actionId = getActionId(msg.sig); _require(_canPerform(actionId, msg.sender), Errors.SENDER_NOT_ALLOWED); } function getActionId(bytes4 selector) public view override returns (bytes32) { // Each external function is dynamically assigned an action identifier as the hash of the disambiguator and the // function selector. Disambiguation is necessary to avoid potential collisions in the function selectors of // multiple contracts. return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); } function _canPerform(bytes32 actionId, address user) internal view virtual returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; interface IAuthentication { /** * @dev Returns the action identifier associated with the external function described by `selector`. */ function getActionId(bytes4 selector) external view returns (bytes32); }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IBasePool.sol"; /** * @dev Pool contracts with the MinimalSwapInfo or TwoToken specialization settings should implement this interface. * * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool. * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will grant * to the pool in a 'given out' swap. * * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is * indeed the Vault. */ interface IMinimalSwapInfoPool is IBasePool { function onSwap( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) external returns (uint256 amount); }
{ "optimizer": { "enabled": true, "runs": 9999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IVault","name":"vault","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"amplificationParameter","type":"uint256"},{"internalType":"uint256","name":"swapFeePercentage","type":"uint256"},{"internalType":"uint256","name":"pauseWindowDuration","type":"uint256"},{"internalType":"uint256","name":"bufferPeriodDuration","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"startValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"AmpUpdateStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentValue","type":"uint256"}],"name":"AmpUpdateStopped","type":"event"},{"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":"bool","name":"paused","type":"bool"}],"name":"PausedStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"swapFeePercentage","type":"uint256"}],"name":"SwapFeePercentageChanged","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":[{"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":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"getActionId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAmplificationParameter","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"isUpdating","type":"bool"},{"internalType":"uint256","name":"precision","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuthorizer","outputs":[{"internalType":"contract IAuthorizer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPausedState","outputs":[{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"uint256","name":"pauseWindowEndTime","type":"uint256"},{"internalType":"uint256","name":"bufferPeriodEndTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"contract IVault","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":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"onExitPool","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"onJoinPool","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IERC20","name":"tokenIn","type":"address"},{"internalType":"contract IERC20","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IPoolSwapStructs.SwapRequest","name":"swapRequest","type":"tuple"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"indexIn","type":"uint256"},{"internalType":"uint256","name":"indexOut","type":"uint256"}],"name":"onSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IERC20","name":"tokenIn","type":"address"},{"internalType":"contract IERC20","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IPoolSwapStructs.SwapRequest","name":"request","type":"tuple"},{"internalType":"uint256","name":"balanceTokenIn","type":"uint256"},{"internalType":"uint256","name":"balanceTokenOut","type":"uint256"}],"name":"onSwap","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":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"queryExit","outputs":[{"internalType":"uint256","name":"bptIn","type":"uint256"},{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"queryJoin","outputs":[{"internalType":"uint256","name":"bptOut","type":"uint256"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bytes","name":"poolConfig","type":"bytes"}],"name":"setAssetManagerPoolConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"swapFeePercentage","type":"uint256"}],"name":"setSwapFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rawEndValue","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"startAmplificationParameterUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopAmplificationParameterUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"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"}]
Contract Creation Code
6103e06040527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9610120523480156200003757600080fd5b50604051620056cc380380620056cc8339810160408190526200005a9162000bf3565b8886516002146200006d57600062000070565b60025b8989898a516001600160401b03811180156200008b57600080fd5b50604051908082528060200260200182016040528015620000b6578160200160208202803683370190505b506040805180820190915260018152603160f81b602080830191909152336080526001600160601b031960608a901b1660a05285518c928c928c928c92859285928c928c92849283929183918691620001159160039185019062000a11565b5080516200012b90600490602084019062000a11565b50506005805460ff1916601217905550815160209283012060c052805191012060e05250507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61010052506200018a6276a70083111561019462000699565b6200019e62278d0082111561019562000699565b4290910161014081905201610160528551620001c0906002111560c862000699565b620001d860088751111560c96200069960201b60201c565b620001ee86620006ae60201b62000f831760201c565b620001f984620006ba565b6040516309b2760f60e01b81526000906001600160a01b038c16906309b2760f906200022a908d9060040162000d8f565b602060405180830381600087803b1580156200024557600080fd5b505af11580156200025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000280919062000bda565b604051633354e3e960e11b81529091506001600160a01b038c16906366a9c7d290620002b59084908b908b9060040162000cf3565b600060405180830381600087803b158015620002d057600080fd5b505af1158015620002e5573d6000803e3d6000fd5b505088516001600160601b031960608f901b16610180526101a08490526101c0819052915050806200031957600062000330565b876000815181106200032757fe5b60200260200101515b60601b6001600160601b0319166101e052600181116200035257600062000369565b876001815181106200036057fe5b60200260200101515b60601b6001600160601b03191661020052600281116200038b576000620003a2565b876002815181106200039957fe5b60200260200101515b60601b6001600160601b0319166102205260038111620003c4576000620003db565b87600381518110620003d257fe5b60200260200101515b60601b6001600160601b0319166102405260048111620003fd57600062000414565b876004815181106200040b57fe5b60200260200101515b60601b6001600160601b0319166102605260058111620004365760006200044d565b876005815181106200044457fe5b60200260200101515b60601b6001600160601b03191661028052600681116200046f57600062000486565b876006815181106200047d57fe5b60200260200101515b60601b6001600160601b0319166102a05260078111620004a8576000620004bf565b87600781518110620004b657fe5b60200260200101515b60601b6001600160601b0319166102c05280620004de57600062000504565b6200050488600081518110620004f057fe5b60200260200101516200072960201b60201c565b6102e05260018111620005195760006200052b565b6200052b88600181518110620004f057fe5b61030052600281116200054057600062000552565b6200055288600281518110620004f057fe5b61032052600381116200056757600062000579565b6200057988600381518110620004f057fe5b61034052600481116200058e576000620005a0565b620005a088600481518110620004f057fe5b6103605260058111620005b5576000620005c7565b620005c788600581518110620004f057fe5b6103805260068111620005dc576000620005ee565b620005ee88600681518110620004f057fe5b6103a052600781116200060357600062000615565b6200061588600781518110620004f057fe5b6103c05250508f516200063c9a5060051015985061012f9750506200069995505050505050565b6200064e600186101561012c62000699565b6200066161138886111561012d62000699565b60006200067c866103e8620007d560201b62000f8d1760201c565b9050620006898162000806565b5050505050505050505062000e11565b81620006aa57620006aa8162000845565b5050565b80620006aa8162000898565b620006cf64e8d4a5100082101560cb62000699565b620006e767016345785d8a000082111560ca62000699565b60088190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906200071e90839062000da4565b60405180910390a150565b600080826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200076657600080fd5b505afa1580156200077b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007a1919062000cd0565b60ff1690506000620007c06012836200092560201b62000fb11760201c565b600a0a670de0b6b3a764000002949350505050565b6000828202620007fd841580620007f5575083858381620007f257fe5b04145b600362000699565b90505b92915050565b62000814818042806200093d565b7fa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233816040516200071e919062000da4565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600281511015620008a95762000922565b600081600081518110620008b957fe5b602002602001015190506000600190505b82518110156200091f576000838281518110620008e357fe5b6020026020010151905062000914816001600160a01b0316846001600160a01b03161060656200069960201b60201c565b9150600101620008ca565b50505b50565b60006200093783831115600162000699565b50900390565b6200095e816001600160401b031660c062000a0d60201b62000fc71760201c565b6200097f836001600160401b0316608062000a0d60201b62000fc71760201c565b620009a0856001600160401b0316604062000a0d60201b62000fc71760201c565b620009c1876001600160401b0316600062000a0d60201b62000fc71760201c565b1717176009556040517f1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf290620009ff90869086908690869062000dad565b60405180910390a150505050565b1b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1062000a5457805160ff191683800117855562000a84565b8280016001018555821562000a84579182015b8281111562000a8457825182559160200191906001019062000a67565b5062000a9292915062000a96565b5090565b5b8082111562000a92576000815560010162000a97565b8051620008008162000dfb565b600082601f83011262000acb578081fd5b81516001600160401b0381111562000ae1578182fd5b602080820262000af382820162000dc8565b8381529350818401858301828701840188101562000b1057600080fd5b600092505b8483101562000b4057805162000b2b8162000dfb565b82526001929092019190830190830162000b15565b505050505092915050565b600082601f83011262000b5c578081fd5b81516001600160401b0381111562000b72578182fd5b602062000b88601f8301601f1916820162000dc8565b9250818352848183860101111562000b9f57600080fd5b60005b8281101562000bbf57848101820151848201830152810162000ba2565b8281111562000bd15760008284860101525b50505092915050565b60006020828403121562000bec578081fd5b5051919050565b60008060008060008060008060006101208a8c03121562000c12578485fd5b62000c1e8b8b62000aad565b60208b01519099506001600160401b038082111562000c3b578687fd5b62000c498d838e0162000b4b565b995060408c015191508082111562000c5f578687fd5b62000c6d8d838e0162000b4b565b985060608c015191508082111562000c83578687fd5b5062000c928c828d0162000aba565b96505060808a0151945060a08a0151935060c08a0151925060e08a0151915062000cc18b6101008c0162000aad565b90509295985092959850929598565b60006020828403121562000ce2578081fd5b815160ff81168114620007fd578182fd5b60006060820185835260206060818501528186518084526080860191508288019350845b8181101562000d3f5762000d2c855162000def565b8352938301939183019160010162000d17565b505084810360408601528551808252908201925081860190845b8181101562000d815762000d6e835162000def565b8552938301939183019160010162000d59565b509298975050505050505050565b602081016003831062000d9e57fe5b91905290565b90815260200190565b93845260208401929092526040830152606082015260800190565b6040518181016001600160401b038111828210171562000de757600080fd5b604052919050565b6001600160a01b031690565b6001600160a01b03811681146200092257600080fd5b60805160a05160601c60c05160e051610100516101205161014051610160516101805160601c6101a0516101c0516101e05160601c6102005160601c6102205160601c6102405160601c6102605160601c6102805160601c6102a05160601c6102c05160601c6102e05161030051610320516103405161036051610380516103a0516103c05161475462000f786000398061124b528061221a52508061120852806121b95250806111c5528061215852508061118252806120f752508061113f52806120965250806110fc52806120355250806110b95280611fd45250806110685280611f735250806121df52508061217e52508061211d5250806120bc52508061205b525080611ffa525080611f99525080611f385280612b73525080610fcd5250806107b5525080610ae15250806114f15250806114cd525080610cf352508061174a52508061178c52508061176b525080610abd525080610a4752506147546000f3fe608060405234801561001057600080fd5b50600436106102265760003560e01c80636daccffa1161012a57806395d89b41116100bd578063aaabadc51161008c578063d5c096c411610071578063d5c096c41461046f578063dd62ed3e14610482578063eb0f24d61461049557610226565b8063aaabadc514610454578063d505accf1461045c57610226565b806395d89b41146104135780639d2c110c1461041b578063a457c2d71461042e578063a9059cbb1461044157610226565b8063851c1bb3116100f9578063851c1bb3146103d057806387ec6817146103e3578063893d20e8146103f65780638d928af81461040b57610226565b80636daccffa1461037257806370a082311461038957806374f3b0091461039c5780637ecebe00146103bd57610226565b8063313ce567116101bd578063395093511161018c57806355c676281161017157806355c67628146103415780636028bfd414610349578063679aefce1461036a57610226565b8063395093511461031b57806350dd6ed91461032e57610226565b8063313ce567146102e35780633644e515146102f857806338e9922e1461030057806338fff2d01461031357610226565b806318160ddd116101f957806318160ddd1461029e5780631c0de051146102a657806323b872dd146102bd5780632f1a0bc9146102d057610226565b806301ec954a1461022b57806306fdde0314610254578063095ea7b31461026957806316c38b3c14610289575b600080fd5b61023e6102393660046142d9565b61049d565b60405161024b9190614566565b60405180910390f35b61025c6104fc565b60405161024b919061463c565b61027c610277366004613f52565b6105b1565b60405161024b9190614543565b61029c610297366004614049565b6105c8565b005b61023e6105dc565b6102ae6105e2565b60405161024b9392919061454e565b61027c6102cb366004613e9d565b61060b565b61029c6102de3660046143ae565b61069f565b6102eb610782565b60405161024b9190614699565b61023e61078b565b61029c61030e366004614396565b61079a565b61023e6107b3565b61027c610329366004613f52565b6107d7565b61029c61033c366004614180565b610812565b61023e610830565b61035c610357366004614081565b610836565b60405161024b92919061464f565b61023e61086d565b61037a61094b565b60405161024b93929190614668565b61023e610397366004613e49565b610966565b6103af6103aa366004614081565b610985565b60405161024b92919061451e565b61023e6103cb366004613e49565b610a28565b61023e6103de366004614124565b610a43565b61035c6103f1366004614081565b610a95565b6103fe610abb565b60405161024b919061450a565b6103fe610adf565b61025c610b03565b61023e61042936600461434a565b610b82565b61027c61043c366004613f52565b610c69565b61027c61044f366004613f52565b610ca7565b6103fe610cb4565b61029c61046a366004613edd565b610cbe565b6103af61047d366004614081565b610e07565b61023e610490366004613e65565b610f2c565b61029c610f57565b60006104b183836104ac610fcb565b610fef565b60606104bb61100c565b90506000865160018111156104cc57fe5b146104e3576104de8686868685611289565b6104f0565b6104f08686868685611300565b9150505b949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b505050505090505b90565b60006105be338484611364565b5060015b92915050565b6105d06113cc565b6105d981611412565b50565b60025490565b60008060006105ef6114ae565b1592506105fa6114cb565b91506106046114ef565b9050909192565b6000806106188533610f2c565b905061063c336001600160a01b03871614806106345750838210155b61019e611513565b610647858585611521565b336001600160a01b0386161480159061068057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b15610692576106928533858403611364565b60019150505b9392505050565b6106a76113cc565b6106b7600183101561012c611513565b6106c861138883111561012d611513565b60006106d48242610fb1565b90506106e86201518082101561013d611513565b6000806106f3611601565b91509150610704811561013e611513565b6000610712866103e8610f8d565b905060008382116107415761073c61072d6201518086610f8d565b6107378488610f8d565b611675565b61075b565b61075b6107516201518084610f8d565b6107378688610f8d565b905061076d600282111561013f611513565b610779848342896116a8565b50505050505050565b60055460ff1690565b6000610795611746565b905090565b6107a26113cc565b6107aa6117e3565b6105d9816117f8565b7f000000000000000000000000000000000000000000000000000000000000000090565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105be91859061080d9086611856565b611364565b61081a6113cc565b6108226117e3565b61082c8282611868565b5050565b60085490565b6000606061084c8651610847610fcb565b611980565b6108618989898989898961198d611a31611a92565b97509795505050505050565b60006060610879610adf565b6001600160a01b031663f94d466861088f6107b3565b6040518263ffffffff1660e01b81526004016108ab9190614566565b60006040518083038186803b1580156108c357600080fd5b505afa1580156108d7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108ff9190810190613f7d565b50915050600061090d611601565b5090506109218261091c61100c565b611c22565b600061092f82846000611c83565b905061094361093c6105dc565b8290611e1f565b935050505090565b6000806000610958611601565b90949093506103e892509050565b6001600160a01b0381166000908152602081905260409020545b919050565b606080886109af610994610adf565b6001600160a01b0316336001600160a01b03161460cd611513565b6109c46109ba6107b3565b82146101f4611513565b60606109ce61100c565b90506109da8882611c22565b60006060806109ef8e8e8e8e8e8e8a8f61198d565b9250925092506109ff8d84611e70565b610a098285611a31565b610a138185611a31565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b60007f000000000000000000000000000000000000000000000000000000000000000082604051602001610a78929190614494565b604051602081830303815290604052805190602001209050919050565b60006060610aa68651610847610fcb565b61086189898989898989611e7a611ed3611a92565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b600080610b928560200151611f34565b90506000610ba38660400151611f34565b9050600086516001811115610bb457fe5b1415610c1a57610bc78660600151612249565b6060870152610bd6858361226d565b9450610be2848261226d565b9350610bf286606001518361226d565b60608701526000610c04878787612279565b9050610c1081836122bd565b9350505050610698565b610c24858361226d565b9450610c30848261226d565b9350610c4086606001518261226d565b60608701526000610c528787876122c9565b9050610c5e81846122f8565b9050610c1081612304565b600080610c763385610f2c565b9050808310610c9057610c8b33856000611364565b610c9d565b610c9d3385858403611364565b5060019392505050565b60006105be338484611521565b600061079561232d565b610ccc8442111560d1611513565b6001600160a01b0387166000908152600660209081526040808320549051909291610d23917f0000000000000000000000000000000000000000000000000000000000000000918c918c918c9188918d910161458e565b6040516020818303038152906040528051906020012090506000610d46826123a7565b9050600060018288888860405160008152602001604052604051610d6d949392919061461e565b6020604051602081039080840390855afa158015610d8f573d6000803e3d6000fd5b5050604051601f1901519150610dd190506001600160a01b03821615801590610dc957508b6001600160a01b0316826001600160a01b0316145b6101f8611513565b6001600160a01b038b166000908152600660205260409020600185019055610dfa8b8b8b611364565b5050505050505050505050565b60608088610e16610994610adf565b610e216109ba6107b3565b6060610e2b61100c565b9050610e356105dc565b610edc5760006060610e4a8d8d8d868b6123c3565b91509150610e5f620f424083101560cc611513565b610e6d6000620f4240612452565b610e7c8b620f42408403612452565b610e868184611ed3565b80610e8f610fcb565b67ffffffffffffffff81118015610ea557600080fd5b50604051908082528060200260200182016040528015610ecf578160200160208202803683370190505b5095509550505050610a1b565b610ee68882611c22565b6000606080610efb8e8e8e8e8e8e8a8f611e7a565b925092509250610f0b8c84612452565b610f158285611ed3565b610f1f8185611a31565b9095509350610a1b915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610f5f6113cc565b600080610f6a611601565b91509150610f7a81610140611513565b61082c8261245c565b8061082c81612497565b6000828202610698841580610faa575083858381610fa757fe5b04145b6003611513565b6000610fc1838311156001611513565b50900390565b1b90565b7f000000000000000000000000000000000000000000000000000000000000000090565b611007818410801561100057508183105b6064611513565b505050565b60606000611018610fcb565b905060608167ffffffffffffffff8111801561103357600080fd5b5060405190808252806020026020018201604052801561105d578160200160208202803683370190505b50905081156110a5577f00000000000000000000000000000000000000000000000000000000000000008160008151811061109457fe5b6020026020010181815250506110ae565b91506105ae9050565b60018211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816001815181106110e557fe5b60200260200101818152505060028211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160028151811061112857fe5b60200260200101818152505060038211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160038151811061116b57fe5b60200260200101818152505060048211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816004815181106111ae57fe5b60200260200101818152505060058211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816005815181106111f157fe5b60200260200101818152505060068211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160068151811061123457fe5b60200260200101818152505060078211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160078151811061127757fe5b60200260200101818152505091505090565b60006112958583611c22565b6112b686606001518385815181106112a957fe5b602002602001015161226d565b606087015260006112c987878787612510565b90506112e8818487815181106112db57fe5b60200260200101516122f8565b90506112f381612304565b9150505b95945050505050565b600061130f8660600151612249565b606087015261131e8583611c22565b61133286606001518386815181106112a957fe5b606087015260006113458787878761253a565b90506112f38184868151811061135757fe5b60200260200101516122bd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906113bf908590614566565b60405180910390a3505050565b60006113fb6000357fffffffff0000000000000000000000000000000000000000000000000000000016610a43565b90506105d961140a8233612564565b610191611513565b80156114325761142d6114236114cb565b4210610193611513565b611447565b61144761143d6114ef565b42106101a9611513565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64906114a3908390614543565b60405180910390a150565b60006114b86114ef565b42118061079557505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b8161082c5761082c81612654565b6115386001600160a01b0384161515610198611513565b61154f6001600160a01b0383161515610199611513565b61155a838383611007565b6001600160a01b03831660009081526020819052604090205461158090826101a06126c1565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546115af9082611856565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906113bf908590614566565b6000806000806000806116126126d7565b93509350935093508042101561166557600194508383111561164957818103824203858503028161163f57fe5b0484019550611660565b818103824203848603028161165a57fe5b04840395505b61166d565b600094508295505b505050509091565b60006116848215156004611513565b82611691575060006105c2565b81600184038161169d57fe5b0460010190506105c2565b6116bd8167ffffffffffffffff1660c0610fc7565b6116d28367ffffffffffffffff166080610fc7565b6116e78567ffffffffffffffff166040610fc7565b6116fc8767ffffffffffffffff166000610fc7565b1717176009556040517f1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf29061173890869086908690869061467e565b60405180910390a150505050565b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006117b361272e565b306040516020016117c89594939291906145c2565b60405160208183030381529060405280519060200120905090565b6117f66117ee6114ae565b610192611513565b565b61180b64e8d4a5100082101560cb611513565b61182167016345785d8a000082111560ca611513565b60088190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906114a3908390614566565b60008282016106988482101583611513565b60006118726107b3565b9050600061187e610adf565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b81526004016118ab929190614607565b60806040518083038186803b1580156118c357600080fd5b505afa1580156118d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fb91906143cf565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d492506119489150859087906004016145ee565b600060405180830381600087803b15801561196257600080fd5b505af1158015611976573d6000803e3d6000fd5b5050505050505050565b61082c8183146067611513565b600060608061199a6114ae565b156119bd576119a98887612732565b90506119b88882610fb161281f565b611a09565b6119c5610fcb565b67ffffffffffffffff811180156119db57600080fd5b50604051908082528060200260200182016040528015611a05578160200160208202803683370190505b5090505b611a1488868661288a565b9093509150611a2388836128f6565b985098509895505050505050565b60005b611a3c610fcb565b81101561100757611a73838281518110611a5257fe5b6020026020010151838381518110611a6657fe5b6020026020010151611e1f565b838281518110611a7f57fe5b6020908102919091010152600101611a34565b333014611b81576000306001600160a01b0316600036604051611ab69291906144c4565b6000604051808303816000865af19150503d8060008114611af3576040519150601f19603f3d011682016040523d82523d6000602084013e611af8565b606091505b505090508060008114611b0757fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611b63573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611b8b61100c565b9050611b978782611c22565b60006060611baf8c8c8c8c8c8c898d8d63ffffffff16565b5091509150611bc281848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60005b611c2d610fcb565b81101561100757611c64838281518110611c4357fe5b6020026020010151838381518110611c5757fe5b6020026020010151612925565b838281518110611c7057fe5b6020908102919091010152600101611c25565b81516000908190815b81811015611cc457611cba868281518110611ca357fe5b60200260200101518461185690919063ffffffff16565b9250600101611c8c565b5081611cd557600092505050610698565b600082878302825b60ff811015611e07576000858a600081518110611cf657fe5b60200260200101510290506000600190505b86811015611d4a57611d40611d39611d33848e8581518110611d2657fe5b6020026020010151610f8d565b89610f8d565b868c612951565b9150600101611d08565b50839450611dbd611d8c611d73611d6a611d64878c610f8d565b85610f8d565b6103e88d612951565b611d86611d808a89610f8d565b88610f8d565b90611856565b611db7611daa611da06103e8880386610f8d565b6103e88e15612951565b611d868a60010189610f8d565b8b612951565b935084841115611de557600185850311611de05783975050505050505050610698565b611dfe565b600184860311611dfe5783975050505050505050610698565b50600101611cdd565b50611e13610142612654565b50505050509392505050565b6000611e2e8215156004611513565b82611e3b575060006105c2565b670de0b6b3a764000083810290611e5e90858381611e5557fe5b04146005611513565b828181611e6757fe5b049150506105c2565b61082c8282612971565b6000606080611e876117e3565b6060611e938988612732565b9050611ea28982610fb161281f565b60006060611eb18b8989612a2d565b91509150611ebf8b82612a86565b909d909c50909a5098505050505050505050565b60005b611ede610fcb565b81101561100757611f15838281518110611ef457fe5b6020026020010151838381518110611f0857fe5b6020026020010151612a93565b838281518110611f2157fe5b6020908102919091010152600101611ed6565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611f9757507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611ff857507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561205957507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156120ba57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561211b57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561217c57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156121dd57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561223e57507f0000000000000000000000000000000000000000000000000000000000000000610980565b610980610135612654565b60008061226160085484612ae190919063ffffffff16565b90506106988382610fb1565b60006106988383612925565b6000612290612286610fcb565b60021460d2611513565b60606000806122a0878787612b3b565b9250925092506122b28784848461253a565b979650505050505050565b60006106988383611e1f565b60006122d6612286610fcb565b60606000806122e6878787612b3b565b9250925092506122b287848484612510565b60006106988383612a93565b60006105c2612326600854670de0b6b3a7640000610fb190919063ffffffff16565b8390612a93565b6000612337610adf565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561236f57600080fd5b505afa158015612383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107959190614164565b60006123b1611746565b82604051602001610a789291906144d4565b600060606123cf6117e3565b60006123da84612c28565b90506123f560008260028111156123ed57fe5b1460ce611513565b606061240085612c3e565b905061240f8151610847610fcb565b6124198187611c22565b6000612423611601565b509050600061243482846001611c83565b9050806124418184612c54565b9b929a509198505050505050505050565b61082c8282612c5f565b612468818242426116a8565b7fa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233816040516114a39190614566565b6002815110156124a6576105d9565b6000816000815181106124b557fe5b602002602001015190506000600190505b82518110156110075760008382815181106124dd57fe5b60200260200101519050612506816001600160a01b0316846001600160a01b0316106065611513565b91506001016124c6565b600061251a6117e3565b6000612524611601565b50905060006122b2828787878b60600151612ced565b60006125446117e3565b600061254e611601565b50905060006122b2828787878b60600151612db1565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b612583610abb565b6001600160a01b03161415801561259e575061259e83612e59565b156125c6576125ab610abb565b6001600160a01b0316336001600160a01b03161490506105c2565b6125ce61232d565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b81526004016125fd9392919061456f565b60206040518083038186803b15801561261557600080fd5b505afa158015612629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264d9190614065565b90506105c2565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60006126d08484111583611513565b5050900390565b6000806000806126f36000600954612ec790919063ffffffff16565b600954909450612704906040612ec7565b600954909350612715906080612ec7565b6009549092506127269060c0612ec7565b905090919293565b4690565b60608061273d610fcb565b67ffffffffffffffff8111801561275357600080fd5b5060405190808252806020026020018201604052801561277d578160200160208202803683370190505b5090508261278c5790506105c2565b6000808560008151811061279c57fe5b602002602001015190506000600190505b6127b5610fcb565b8110156127ec5760008782815181106127ca57fe5b60200260200101519050828111156127e3578193508092505b506001016127ad565b506127fe600b5487600a548589612ed5565b83838151811061280a57fe5b60209081029190910101525090949350505050565b60005b61282a610fcb565b8110156128845761286584828151811061284057fe5b602002602001015184838151811061285457fe5b60200260200101518463ffffffff16565b84828151811061287157fe5b6020908102919091010152600101612822565b50505050565b60006060600061289984612c28565b905060008160028111156128a957fe5b14156128c3576128b98685612f49565b92509250506128ee565b60018160028111156128d157fe5b14156128e1576128b9868561300f565b6128b9868686613041565b505b935093915050565b6129038282610fb161281f565b600061290d611601565b50905061100761291f82856001611c83565b82612c54565b600082820261293f841580610faa575083858381610fa757fe5b670de0b6b3a764000090049392505050565b6000816129675761296284846130b8565b6104f4565b6104f48484611675565b6129886001600160a01b038316151561019b611513565b61299482600083611007565b6001600160a01b0382166000908152602081905260409020546129ba90826101a16126c1565b6001600160a01b0383166000908152602081905260409020556002546129e090826130d8565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b60405180910390a35050565b600060606000612a3c84612c28565b90506001816002811115612a4c57fe5b1415612a5d576128b98686866130e6565b6002816002811115612a6b57fe5b1415612a7b576128b9868561314b565b6128ec610136612654565b612903828261185661281f565b6000612aa28215156004611513565b82612aaf575060006105c2565b670de0b6b3a764000083810290612ac990858381611e5557fe5b826001820381612ad557fe5b046001019150506105c2565b6000828202612afb841580610faa575083858381610fa757fe5b80612b0a5760009150506105c2565b670de0b6b3a76400007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201612ad5565b6040805160028082526060828101909352600091829181602001602082028036833701905050925085602001516001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161415612be25760009150600190508483600081518110612bb757fe5b6020026020010181815250508383600181518110612bd157fe5b602002602001018181525050612c1f565b60009050600191508383600081518110612bf857fe5b6020026020010181815250508483600181518110612c1257fe5b6020026020010181815250505b93509350939050565b6000818060200190518101906105c291906141ce565b6060818060200190518101906106989190614294565b600a91909155600b55565b612c6b60008383611007565b600254612c789082611856565b6002556001600160a01b038216600090815260208190526040902054612c9e9082611856565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b600080612cfc87876001611c83565b9050612d2483878681518110612d0e57fe5b6020026020010151610fb190919063ffffffff16565b868581518110612d3057fe5b6020026020010181815250506000612d4a888884896131db565b905083878681518110612d5957fe5b602002602001015101878681518110612d6e57fe5b602002602001018181525050612da56001611d86898981518110612d8e57fe5b602002602001015184610fb190919063ffffffff16565b98975050505050505050565b600080612dc087876001611c83565b9050612de883878781518110612dd257fe5b602002602001015161185690919063ffffffff16565b868681518110612df457fe5b6020026020010181815250506000612e0e888884886131db565b905083878781518110612e1d57fe5b602002602001015103878781518110612e3257fe5b602002602001018181525050612da56001612e53838a8981518110612d0e57fe5b90610fb1565b6000612e847f2f1a0bc900000000000000000000000000000000000000000000000000000000610a43565b821480612eb85750612eb57feb0f24d600000000000000000000000000000000000000000000000000000000610a43565b82145b806105c257506105c28261338b565b1c67ffffffffffffffff1690565b600080612ee4878787876131db565b905080868581518110612ef357fe5b602002602001015111612f0a5760009150506112f7565b600081878681518110612f1957fe5b6020026020010151039050612da5670de0b6b3a7640000612f43868461292590919063ffffffff16565b90611e1f565b60006060612f556117e3565b600080612f61856133ef565b91509150612f79612f70610fcb565b82106064611513565b6060612f83610fcb565b67ffffffffffffffff81118015612f9957600080fd5b50604051908082528060200260200182016040528015612fc3578160200160208202803683370190505b5090506000612fd0611601565b509050612fea81898587612fe26105dc565b600854613411565b828481518110612ff657fe5b6020908102919091010152509196919550909350505050565b60006060600061301e8461352d565b90506060613034868361302f6105dc565b613543565b9196919550909350505050565b6000606061304d6117e3565b6060600061305a856135f5565b9150915061306b8251610847610fcb565b6130758287611c22565b600061307f611601565b509050600061309a828a866130926105dc565b60085461360d565b90506130aa8382111560cf611513565b989297509195505050505050565b60006130c78215156004611513565b8183816130d057fe5b049392505050565b6000610698838360016126c1565b600060608060006130f6856135f5565b9150915061310c613105610fcb565b8351611980565b6131168287611c22565b6000613120611601565b509050600061313b828a866131336105dc565b6008546138a3565b90506130aa8382101560d0611513565b6000606060008061315b856133ef565b9150915061316a612f70610fcb565b6060613174610fcb565b67ffffffffffffffff8111801561318a57600080fd5b506040519080825280602002602001820160405280156131b4578160200160208202803683370190505b50905060006131c1611601565b509050612fea818985876131d36105dc565b600854613b32565b6000808451860290506000856000815181106131f357fe5b60200260200101519050600086518760008151811061320e57fe5b60200260200101510290506000600190505b87518110156132675761324c61324661323f848b8581518110611d2657fe5b8a51610f8d565b886130b8565b915061325d888281518110611ca357fe5b9250600101613220565b5086858151811061327457fe5b602002602001015182039150600061328c8788610f8d565b905060006132b86132ac6132a4846107378988610f8d565b6103e8610f8d565b8a8981518110611d2657fe5b905060006132d36132cc6132a48b896130b8565b8690611856565b90506000806132ef6132e58686611856565b6107378d86611856565b905060005b60ff81101561336f5781925061332461331186611d868586610f8d565b6107378e612e5388611d86886002610f8d565b91508282111561334d57600183830311613348575097506104f49650505050505050565b613367565b600182840311613367575097506104f49650505050505050565b6001016132f4565b5061337b610142612654565b5050505050505050949350505050565b60006133b67f38e9922e00000000000000000000000000000000000000000000000000000000610a43565b8214806105c257506133e77f50dd6ed900000000000000000000000000000000000000000000000000000000610a43565b909114919050565b60008082806020019051810190613406919061425e565b909590945092505050565b60008061342088886001611c83565b905060006134428261343c87613436818b610fb1565b90612a93565b90612ae1565b905060006134528a8a848b6131db565b90506000613466828b8b81518110612d0e57fe5b90506000805b8b518110156134a55761349b8c828151811061348457fe5b60200260200101518361185690919063ffffffff16565b915060010161346c565b5060006134ce828d8d815181106134b857fe5b6020026020010151611e1f90919063ffffffff16565b905060006134db82613c0f565b905060006134e98583612ae1565b905060006134f78683610fb1565b905061351861351183670de0b6b3a76400008e9003612925565b8290611856565b99505050505050505050509695505050505050565b6000818060200190518101906106989190614231565b606060006135518484611e1f565b90506060855167ffffffffffffffff8111801561356d57600080fd5b50604051908082528060200260200182016040528015613597578160200160208202803683370190505b50905060005b86518110156135eb576135cc838883815181106135b657fe5b602002602001015161292590919063ffffffff16565b8282815181106135d857fe5b602090810291909101015260010161359d565b5095945050505050565b606060008280602001905181019061340691906141ea565b600080805b86518110156136345761362a87828151811061348457fe5b9150600101613612565b506060855167ffffffffffffffff8111801561364f57600080fd5b50604051908082528060200260200182016040528015613679578160200160208202803683370190505b5090506000805b88518110156137405760006136b1858b848151811061369b57fe5b6020026020010151612a9390919063ffffffff16565b90506136ed8a83815181106136c257fe5b60200260200101516134368b85815181106136d957fe5b60200260200101518d8681518110612d0e57fe5b8483815181106136f957fe5b60200260200101818152505061373561372e8286858151811061371857fe5b6020026020010151612ae190919063ffffffff16565b8490611856565b925050600101613680565b506060885167ffffffffffffffff8111801561375b57600080fd5b50604051908082528060200260200182016040528015613785578160200160208202803683370190505b50905060005b89518110156138505760008482815181106137a257fe5b60200260200101518411156138095760006137cb6137bf86613c0f565b8d85815181106135b657fe5b905060006137df828d8681518110612d0e57fe5b90506138006137f982670de0b6b3a76400008d9003612a93565b8390611856565b92505050613820565b89828151811061381557fe5b602002602001015190505b613830818c8481518110612d0e57fe5b83838151811061383c57fe5b60209081029190910101525060010161378b565b50600061385f8b8b6001611c83565b9050600061386f8c846000611c83565b9050600061387d8284611e1f565b905061389261388b82613c0f565b8b90612ae1565b9d9c50505050505050505050505050565b600080805b86518110156138ca576138c087828151811061348457fe5b91506001016138a8565b506060855167ffffffffffffffff811180156138e557600080fd5b5060405190808252806020026020018201604052801561390f578160200160208202803683370190505b5090506000805b88518110156139a3576000613931858b84815181106134b857fe5b905061396d8a838151811061394257fe5b6020026020010151612f438b858151811061395957fe5b60200260200101518d8681518110612dd257fe5b84838151811061397957fe5b60200260200101818152505061399861372e828685815181106135b657fe5b925050600101613916565b506060885167ffffffffffffffff811180156139be57600080fd5b506040519080825280602002602001820160405280156139e8578160200160208202803683370190505b50905060005b8951811015613aa957600083858381518110613a0657fe5b60200260200101511115613a62576000613a2b6137bf86670de0b6b3a7640000610fb1565b90506000613a3f828d8681518110612d0e57fe5b9050613a596137f982670de0b6b3a76400008d9003612925565b92505050613a79565b898281518110613a6e57fe5b602002602001015190505b613a89818c8481518110612dd257fe5b838381518110613a9557fe5b6020908102919091010152506001016139ee565b506000613ab88b8b6001611c83565b90506000613ac88c846000611c83565b90506000613ad68284611e1f565b9050670de0b6b3a7640000811115613b2257613b148a7ffffffffffffffffffffffffffffffffffffffffffffffffff21f494c589c00008301612925565b9750505050505050506112f7565b60009750505050505050506112f7565b600080613b4188886001611c83565b90506000613b578261343c87613436818b611856565b90506000613b678a8a848b6131db565b90506000613b918a8a81518110613b7a57fe5b602002602001015183610fb190919063ffffffff16565b90506000805b8b51811015613bb957613baf8c828151811061348457fe5b9150600101613b97565b506000613bcc828d8d815181106134b857fe5b90506000613bd982613c0f565b90506000613be78583612ae1565b90506000613bf58683610fb1565b905061351861351183670de0b6b3a76400008e9003612a93565b6000670de0b6b3a76400008210613c275760006105c2565b50670de0b6b3a76400000390565b80356105c2816146ee565b600082601f830112613c50578081fd5b8135613c63613c5e826146ce565b6146a7565b818152915060208083019084810181840286018201871015613c8457600080fd5b60005b84811015613ca357813584529282019290820190600101613c87565b505050505092915050565b600082601f830112613cbe578081fd5b8151613ccc613c5e826146ce565b818152915060208083019084810181840286018201871015613ced57600080fd5b60005b84811015613ca357815184529282019290820190600101613cf0565b600082601f830112613d1c578081fd5b813567ffffffffffffffff811115613d32578182fd5b613d456020601f19601f840116016146a7565b9150808252836020828501011115613d5c57600080fd5b8060208401602084013760009082016020015292915050565b8035600281106105c257600080fd5b6000610120808385031215613d97578182fd5b613da0816146a7565b915050613dad8383613d75565b8152613dbc8360208401613c35565b6020820152613dce8360408401613c35565b6040820152606082013560608201526080820135608082015260a082013560a0820152613dfe8360c08401613c35565b60c0820152613e108360e08401613c35565b60e08201526101008083013567ffffffffffffffff811115613e3157600080fd5b613e3d85828601613d0c565b82840152505092915050565b600060208284031215613e5a578081fd5b8135610698816146ee565b60008060408385031215613e77578081fd5b8235613e82816146ee565b91506020830135613e92816146ee565b809150509250929050565b600080600060608486031215613eb1578081fd5b8335613ebc816146ee565b92506020840135613ecc816146ee565b929592945050506040919091013590565b600080600080600080600060e0888a031215613ef7578283fd5b8735613f02816146ee565b96506020880135613f12816146ee565b95506040880135945060608801359350608088013560ff81168114613f35578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613f64578182fd5b8235613f6f816146ee565b946020939093013593505050565b600080600060608486031215613f91578081fd5b835167ffffffffffffffff80821115613fa8578283fd5b818601915086601f830112613fbb578283fd5b8151613fc9613c5e826146ce565b80828252602080830192508086018b828387028901011115613fe9578788fd5b8796505b84871015614014578051614000816146ee565b845260019690960195928101928101613fed565b50890151909750935050508082111561402b578283fd5b5061403886828701613cae565b925050604084015190509250925092565b60006020828403121561405a578081fd5b813561069881614703565b600060208284031215614076578081fd5b815161069881614703565b600080600080600080600060e0888a03121561409b578081fd5b8735965060208801356140ad816146ee565b955060408801356140bd816146ee565b9450606088013567ffffffffffffffff808211156140d9578283fd5b6140e58b838c01613c40565b955060808a0135945060a08a0135935060c08a0135915080821115614108578283fd5b506141158a828b01613d0c565b91505092959891949750929550565b600060208284031215614135578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610698578182fd5b600060208284031215614175578081fd5b8151610698816146ee565b60008060408385031215614192578182fd5b823561419d816146ee565b9150602083013567ffffffffffffffff8111156141b8578182fd5b6141c485828601613d0c565b9150509250929050565b6000602082840312156141df578081fd5b815161069881614711565b6000806000606084860312156141fe578081fd5b835161420981614711565b602085015190935067ffffffffffffffff811115614225578182fd5b61403886828701613cae565b60008060408385031215614243578182fd5b825161424e81614711565b6020939093015192949293505050565b600080600060608486031215614272578081fd5b835161427d81614711565b602085015160409095015190969495509392505050565b600080604083850312156142a6578182fd5b82516142b181614711565b602084015190925067ffffffffffffffff8111156142cd578182fd5b6141c485828601613cae565b600080600080608085870312156142ee578182fd5b843567ffffffffffffffff80821115614305578384fd5b61431188838901613d84565b95506020870135915080821115614326578384fd5b5061433387828801613c40565b949794965050505060408301359260600135919050565b60008060006060848603121561435e578081fd5b833567ffffffffffffffff811115614374578182fd5b61438086828701613d84565b9660208601359650604090950135949350505050565b6000602082840312156143a7578081fd5b5035919050565b600080604083850312156143c0578182fd5b50508035926020909101359150565b600080600080608085870312156143e4578182fd5b8451935060208501519250604085015191506060850151614404816146ee565b939692955090935050565b6000815180845260208085019450808401835b8381101561443e57815187529582019590820190600101614422565b509495945050505050565b60008151808452815b8181101561446e57602081850181015186830182015201614452565b8181111561447f5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b600060408252614531604083018561440f565b82810360208401526112f7818561440f565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6000838252604060208301526104f46040830184614449565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526106986020830184614449565b6000838252604060208301526104f4604083018461440f565b9283529015156020830152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156146c657600080fd5b604052919050565b600067ffffffffffffffff8211156146e4578081fd5b5060209081020190565b6001600160a01b03811681146105d957600080fd5b80151581146105d957600080fd5b600381106105d957600080fdfea264697066735822122074699730ea8aa4fa00d2702d985bebe2cf30c6abf09e7ee52a1750d232c882ff64736f6c6343000701003300000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000221b262dd800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a7760000000000000000000000000000000000000000000000000000000000000022546865204772616e6420537465616479204f7263686573747261206f66205455534400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084250542d54555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000004068da6c83afcfa0e13ba15a6696662335d5b750000000000000000000000009879abdea01a879644185341f7af7d8343556b7a
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102265760003560e01c80636daccffa1161012a57806395d89b41116100bd578063aaabadc51161008c578063d5c096c411610071578063d5c096c41461046f578063dd62ed3e14610482578063eb0f24d61461049557610226565b8063aaabadc514610454578063d505accf1461045c57610226565b806395d89b41146104135780639d2c110c1461041b578063a457c2d71461042e578063a9059cbb1461044157610226565b8063851c1bb3116100f9578063851c1bb3146103d057806387ec6817146103e3578063893d20e8146103f65780638d928af81461040b57610226565b80636daccffa1461037257806370a082311461038957806374f3b0091461039c5780637ecebe00146103bd57610226565b8063313ce567116101bd578063395093511161018c57806355c676281161017157806355c67628146103415780636028bfd414610349578063679aefce1461036a57610226565b8063395093511461031b57806350dd6ed91461032e57610226565b8063313ce567146102e35780633644e515146102f857806338e9922e1461030057806338fff2d01461031357610226565b806318160ddd116101f957806318160ddd1461029e5780631c0de051146102a657806323b872dd146102bd5780632f1a0bc9146102d057610226565b806301ec954a1461022b57806306fdde0314610254578063095ea7b31461026957806316c38b3c14610289575b600080fd5b61023e6102393660046142d9565b61049d565b60405161024b9190614566565b60405180910390f35b61025c6104fc565b60405161024b919061463c565b61027c610277366004613f52565b6105b1565b60405161024b9190614543565b61029c610297366004614049565b6105c8565b005b61023e6105dc565b6102ae6105e2565b60405161024b9392919061454e565b61027c6102cb366004613e9d565b61060b565b61029c6102de3660046143ae565b61069f565b6102eb610782565b60405161024b9190614699565b61023e61078b565b61029c61030e366004614396565b61079a565b61023e6107b3565b61027c610329366004613f52565b6107d7565b61029c61033c366004614180565b610812565b61023e610830565b61035c610357366004614081565b610836565b60405161024b92919061464f565b61023e61086d565b61037a61094b565b60405161024b93929190614668565b61023e610397366004613e49565b610966565b6103af6103aa366004614081565b610985565b60405161024b92919061451e565b61023e6103cb366004613e49565b610a28565b61023e6103de366004614124565b610a43565b61035c6103f1366004614081565b610a95565b6103fe610abb565b60405161024b919061450a565b6103fe610adf565b61025c610b03565b61023e61042936600461434a565b610b82565b61027c61043c366004613f52565b610c69565b61027c61044f366004613f52565b610ca7565b6103fe610cb4565b61029c61046a366004613edd565b610cbe565b6103af61047d366004614081565b610e07565b61023e610490366004613e65565b610f2c565b61029c610f57565b60006104b183836104ac610fcb565b610fef565b60606104bb61100c565b90506000865160018111156104cc57fe5b146104e3576104de8686868685611289565b6104f0565b6104f08686868685611300565b9150505b949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b505050505090505b90565b60006105be338484611364565b5060015b92915050565b6105d06113cc565b6105d981611412565b50565b60025490565b60008060006105ef6114ae565b1592506105fa6114cb565b91506106046114ef565b9050909192565b6000806106188533610f2c565b905061063c336001600160a01b03871614806106345750838210155b61019e611513565b610647858585611521565b336001600160a01b0386161480159061068057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b15610692576106928533858403611364565b60019150505b9392505050565b6106a76113cc565b6106b7600183101561012c611513565b6106c861138883111561012d611513565b60006106d48242610fb1565b90506106e86201518082101561013d611513565b6000806106f3611601565b91509150610704811561013e611513565b6000610712866103e8610f8d565b905060008382116107415761073c61072d6201518086610f8d565b6107378488610f8d565b611675565b61075b565b61075b6107516201518084610f8d565b6107378688610f8d565b905061076d600282111561013f611513565b610779848342896116a8565b50505050505050565b60055460ff1690565b6000610795611746565b905090565b6107a26113cc565b6107aa6117e3565b6105d9816117f8565b7fcf9d4940fe4c194c83d4d3b1de4c2dff4233f61200020000000000000000025390565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105be91859061080d9086611856565b611364565b61081a6113cc565b6108226117e3565b61082c8282611868565b5050565b60085490565b6000606061084c8651610847610fcb565b611980565b6108618989898989898961198d611a31611a92565b97509795505050505050565b60006060610879610adf565b6001600160a01b031663f94d466861088f6107b3565b6040518263ffffffff1660e01b81526004016108ab9190614566565b60006040518083038186803b1580156108c357600080fd5b505afa1580156108d7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108ff9190810190613f7d565b50915050600061090d611601565b5090506109218261091c61100c565b611c22565b600061092f82846000611c83565b905061094361093c6105dc565b8290611e1f565b935050505090565b6000806000610958611601565b90949093506103e892509050565b6001600160a01b0381166000908152602081905260409020545b919050565b606080886109af610994610adf565b6001600160a01b0316336001600160a01b03161460cd611513565b6109c46109ba6107b3565b82146101f4611513565b60606109ce61100c565b90506109da8882611c22565b60006060806109ef8e8e8e8e8e8e8a8f61198d565b9250925092506109ff8d84611e70565b610a098285611a31565b610a138185611a31565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b60007f00000000000000000000000055df810876354fc3e249f701dd78dede57991f8d82604051602001610a78929190614494565b604051602081830303815290604052805190602001209050919050565b60006060610aa68651610847610fcb565b61086189898989898989611e7a611ed3611a92565b7f000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a77690565b7f00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce90565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b600080610b928560200151611f34565b90506000610ba38660400151611f34565b9050600086516001811115610bb457fe5b1415610c1a57610bc78660600151612249565b6060870152610bd6858361226d565b9450610be2848261226d565b9350610bf286606001518361226d565b60608701526000610c04878787612279565b9050610c1081836122bd565b9350505050610698565b610c24858361226d565b9450610c30848261226d565b9350610c4086606001518261226d565b60608701526000610c528787876122c9565b9050610c5e81846122f8565b9050610c1081612304565b600080610c763385610f2c565b9050808310610c9057610c8b33856000611364565b610c9d565b610c9d3385858403611364565b5060019392505050565b60006105be338484611521565b600061079561232d565b610ccc8442111560d1611513565b6001600160a01b0387166000908152600660209081526040808320549051909291610d23917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918c918c918c9188918d910161458e565b6040516020818303038152906040528051906020012090506000610d46826123a7565b9050600060018288888860405160008152602001604052604051610d6d949392919061461e565b6020604051602081039080840390855afa158015610d8f573d6000803e3d6000fd5b5050604051601f1901519150610dd190506001600160a01b03821615801590610dc957508b6001600160a01b0316826001600160a01b0316145b6101f8611513565b6001600160a01b038b166000908152600660205260409020600185019055610dfa8b8b8b611364565b5050505050505050505050565b60608088610e16610994610adf565b610e216109ba6107b3565b6060610e2b61100c565b9050610e356105dc565b610edc5760006060610e4a8d8d8d868b6123c3565b91509150610e5f620f424083101560cc611513565b610e6d6000620f4240612452565b610e7c8b620f42408403612452565b610e868184611ed3565b80610e8f610fcb565b67ffffffffffffffff81118015610ea557600080fd5b50604051908082528060200260200182016040528015610ecf578160200160208202803683370190505b5095509550505050610a1b565b610ee68882611c22565b6000606080610efb8e8e8e8e8e8e8a8f611e7a565b925092509250610f0b8c84612452565b610f158285611ed3565b610f1f8185611a31565b9095509350610a1b915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610f5f6113cc565b600080610f6a611601565b91509150610f7a81610140611513565b61082c8261245c565b8061082c81612497565b6000828202610698841580610faa575083858381610fa757fe5b04145b6003611513565b6000610fc1838311156001611513565b50900390565b1b90565b7f000000000000000000000000000000000000000000000000000000000000000290565b611007818410801561100057508183105b6064611513565b505050565b60606000611018610fcb565b905060608167ffffffffffffffff8111801561103357600080fd5b5060405190808252806020026020018201604052801561105d578160200160208202803683370190505b50905081156110a5577f000000000000000000000000000000000000000c9f2c9cd04674edea400000008160008151811061109457fe5b6020026020010181815250506110ae565b91506105ae9050565b60018211156110a5577f0000000000000000000000000000000000000000000000000de0b6b3a7640000816001815181106110e557fe5b60200260200101818152505060028211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160028151811061112857fe5b60200260200101818152505060038211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160038151811061116b57fe5b60200260200101818152505060048211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816004815181106111ae57fe5b60200260200101818152505060058211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816005815181106111f157fe5b60200260200101818152505060068211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160068151811061123457fe5b60200260200101818152505060078211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160078151811061127757fe5b60200260200101818152505091505090565b60006112958583611c22565b6112b686606001518385815181106112a957fe5b602002602001015161226d565b606087015260006112c987878787612510565b90506112e8818487815181106112db57fe5b60200260200101516122f8565b90506112f381612304565b9150505b95945050505050565b600061130f8660600151612249565b606087015261131e8583611c22565b61133286606001518386815181106112a957fe5b606087015260006113458787878761253a565b90506112f38184868151811061135757fe5b60200260200101516122bd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906113bf908590614566565b60405180910390a3505050565b60006113fb6000357fffffffff0000000000000000000000000000000000000000000000000000000016610a43565b90506105d961140a8233612564565b610191611513565b80156114325761142d6114236114cb565b4210610193611513565b611447565b61144761143d6114ef565b42106101a9611513565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64906114a3908390614543565b60405180910390a150565b60006114b86114ef565b42118061079557505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000006216422f90565b7f000000000000000000000000000000000000000000000000000000006216422f90565b8161082c5761082c81612654565b6115386001600160a01b0384161515610198611513565b61154f6001600160a01b0383161515610199611513565b61155a838383611007565b6001600160a01b03831660009081526020819052604090205461158090826101a06126c1565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546115af9082611856565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906113bf908590614566565b6000806000806000806116126126d7565b93509350935093508042101561166557600194508383111561164957818103824203858503028161163f57fe5b0484019550611660565b818103824203848603028161165a57fe5b04840395505b61166d565b600094508295505b505050509091565b60006116848215156004611513565b82611691575060006105c2565b81600184038161169d57fe5b0460010190506105c2565b6116bd8167ffffffffffffffff1660c0610fc7565b6116d28367ffffffffffffffff166080610fc7565b6116e78567ffffffffffffffff166040610fc7565b6116fc8767ffffffffffffffff166000610fc7565b1717176009556040517f1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf29061173890869086908690869061467e565b60405180910390a150505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f06ba696fa722b6236fb33a043ea9b10314f57e720e3afc4a78fad321f87a95317fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66117b361272e565b306040516020016117c89594939291906145c2565b60405160208183030381529060405280519060200120905090565b6117f66117ee6114ae565b610192611513565b565b61180b64e8d4a5100082101560cb611513565b61182167016345785d8a000082111560ca611513565b60088190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906114a3908390614566565b60008282016106988482101583611513565b60006118726107b3565b9050600061187e610adf565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b81526004016118ab929190614607565b60806040518083038186803b1580156118c357600080fd5b505afa1580156118d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fb91906143cf565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d492506119489150859087906004016145ee565b600060405180830381600087803b15801561196257600080fd5b505af1158015611976573d6000803e3d6000fd5b5050505050505050565b61082c8183146067611513565b600060608061199a6114ae565b156119bd576119a98887612732565b90506119b88882610fb161281f565b611a09565b6119c5610fcb565b67ffffffffffffffff811180156119db57600080fd5b50604051908082528060200260200182016040528015611a05578160200160208202803683370190505b5090505b611a1488868661288a565b9093509150611a2388836128f6565b985098509895505050505050565b60005b611a3c610fcb565b81101561100757611a73838281518110611a5257fe5b6020026020010151838381518110611a6657fe5b6020026020010151611e1f565b838281518110611a7f57fe5b6020908102919091010152600101611a34565b333014611b81576000306001600160a01b0316600036604051611ab69291906144c4565b6000604051808303816000865af19150503d8060008114611af3576040519150601f19603f3d011682016040523d82523d6000602084013e611af8565b606091505b505090508060008114611b0757fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611b63573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611b8b61100c565b9050611b978782611c22565b60006060611baf8c8c8c8c8c8c898d8d63ffffffff16565b5091509150611bc281848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60005b611c2d610fcb565b81101561100757611c64838281518110611c4357fe5b6020026020010151838381518110611c5757fe5b6020026020010151612925565b838281518110611c7057fe5b6020908102919091010152600101611c25565b81516000908190815b81811015611cc457611cba868281518110611ca357fe5b60200260200101518461185690919063ffffffff16565b9250600101611c8c565b5081611cd557600092505050610698565b600082878302825b60ff811015611e07576000858a600081518110611cf657fe5b60200260200101510290506000600190505b86811015611d4a57611d40611d39611d33848e8581518110611d2657fe5b6020026020010151610f8d565b89610f8d565b868c612951565b9150600101611d08565b50839450611dbd611d8c611d73611d6a611d64878c610f8d565b85610f8d565b6103e88d612951565b611d86611d808a89610f8d565b88610f8d565b90611856565b611db7611daa611da06103e8880386610f8d565b6103e88e15612951565b611d868a60010189610f8d565b8b612951565b935084841115611de557600185850311611de05783975050505050505050610698565b611dfe565b600184860311611dfe5783975050505050505050610698565b50600101611cdd565b50611e13610142612654565b50505050509392505050565b6000611e2e8215156004611513565b82611e3b575060006105c2565b670de0b6b3a764000083810290611e5e90858381611e5557fe5b04146005611513565b828181611e6757fe5b049150506105c2565b61082c8282612971565b6000606080611e876117e3565b6060611e938988612732565b9050611ea28982610fb161281f565b60006060611eb18b8989612a2d565b91509150611ebf8b82612a86565b909d909c50909a5098505050505050505050565b60005b611ede610fcb565b81101561100757611f15838281518110611ef457fe5b6020026020010151838381518110611f0857fe5b6020026020010151612a93565b838281518110611f2157fe5b6020908102919091010152600101611ed6565b60007f00000000000000000000000004068da6c83afcfa0e13ba15a6696662335d5b756001600160a01b0316826001600160a01b03161415611f9757507f000000000000000000000000000000000000000c9f2c9cd04674edea40000000610980565b7f0000000000000000000000009879abdea01a879644185341f7af7d8343556b7a6001600160a01b0316826001600160a01b03161415611ff857507f0000000000000000000000000000000000000000000000000de0b6b3a7640000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561205957507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156120ba57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561211b57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561217c57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156121dd57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561223e57507f0000000000000000000000000000000000000000000000000000000000000000610980565b610980610135612654565b60008061226160085484612ae190919063ffffffff16565b90506106988382610fb1565b60006106988383612925565b6000612290612286610fcb565b60021460d2611513565b60606000806122a0878787612b3b565b9250925092506122b28784848461253a565b979650505050505050565b60006106988383611e1f565b60006122d6612286610fcb565b60606000806122e6878787612b3b565b9250925092506122b287848484612510565b60006106988383612a93565b60006105c2612326600854670de0b6b3a7640000610fb190919063ffffffff16565b8390612a93565b6000612337610adf565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561236f57600080fd5b505afa158015612383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107959190614164565b60006123b1611746565b82604051602001610a789291906144d4565b600060606123cf6117e3565b60006123da84612c28565b90506123f560008260028111156123ed57fe5b1460ce611513565b606061240085612c3e565b905061240f8151610847610fcb565b6124198187611c22565b6000612423611601565b509050600061243482846001611c83565b9050806124418184612c54565b9b929a509198505050505050505050565b61082c8282612c5f565b612468818242426116a8565b7fa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233816040516114a39190614566565b6002815110156124a6576105d9565b6000816000815181106124b557fe5b602002602001015190506000600190505b82518110156110075760008382815181106124dd57fe5b60200260200101519050612506816001600160a01b0316846001600160a01b0316106065611513565b91506001016124c6565b600061251a6117e3565b6000612524611601565b50905060006122b2828787878b60600151612ced565b60006125446117e3565b600061254e611601565b50905060006122b2828787878b60600151612db1565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b612583610abb565b6001600160a01b03161415801561259e575061259e83612e59565b156125c6576125ab610abb565b6001600160a01b0316336001600160a01b03161490506105c2565b6125ce61232d565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b81526004016125fd9392919061456f565b60206040518083038186803b15801561261557600080fd5b505afa158015612629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264d9190614065565b90506105c2565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60006126d08484111583611513565b5050900390565b6000806000806126f36000600954612ec790919063ffffffff16565b600954909450612704906040612ec7565b600954909350612715906080612ec7565b6009549092506127269060c0612ec7565b905090919293565b4690565b60608061273d610fcb565b67ffffffffffffffff8111801561275357600080fd5b5060405190808252806020026020018201604052801561277d578160200160208202803683370190505b5090508261278c5790506105c2565b6000808560008151811061279c57fe5b602002602001015190506000600190505b6127b5610fcb565b8110156127ec5760008782815181106127ca57fe5b60200260200101519050828111156127e3578193508092505b506001016127ad565b506127fe600b5487600a548589612ed5565b83838151811061280a57fe5b60209081029190910101525090949350505050565b60005b61282a610fcb565b8110156128845761286584828151811061284057fe5b602002602001015184838151811061285457fe5b60200260200101518463ffffffff16565b84828151811061287157fe5b6020908102919091010152600101612822565b50505050565b60006060600061289984612c28565b905060008160028111156128a957fe5b14156128c3576128b98685612f49565b92509250506128ee565b60018160028111156128d157fe5b14156128e1576128b9868561300f565b6128b9868686613041565b505b935093915050565b6129038282610fb161281f565b600061290d611601565b50905061100761291f82856001611c83565b82612c54565b600082820261293f841580610faa575083858381610fa757fe5b670de0b6b3a764000090049392505050565b6000816129675761296284846130b8565b6104f4565b6104f48484611675565b6129886001600160a01b038316151561019b611513565b61299482600083611007565b6001600160a01b0382166000908152602081905260409020546129ba90826101a16126c1565b6001600160a01b0383166000908152602081905260409020556002546129e090826130d8565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b60405180910390a35050565b600060606000612a3c84612c28565b90506001816002811115612a4c57fe5b1415612a5d576128b98686866130e6565b6002816002811115612a6b57fe5b1415612a7b576128b9868561314b565b6128ec610136612654565b612903828261185661281f565b6000612aa28215156004611513565b82612aaf575060006105c2565b670de0b6b3a764000083810290612ac990858381611e5557fe5b826001820381612ad557fe5b046001019150506105c2565b6000828202612afb841580610faa575083858381610fa757fe5b80612b0a5760009150506105c2565b670de0b6b3a76400007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201612ad5565b6040805160028082526060828101909352600091829181602001602082028036833701905050925085602001516001600160a01b03167f00000000000000000000000004068da6c83afcfa0e13ba15a6696662335d5b756001600160a01b03161415612be25760009150600190508483600081518110612bb757fe5b6020026020010181815250508383600181518110612bd157fe5b602002602001018181525050612c1f565b60009050600191508383600081518110612bf857fe5b6020026020010181815250508483600181518110612c1257fe5b6020026020010181815250505b93509350939050565b6000818060200190518101906105c291906141ce565b6060818060200190518101906106989190614294565b600a91909155600b55565b612c6b60008383611007565b600254612c789082611856565b6002556001600160a01b038216600090815260208190526040902054612c9e9082611856565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b600080612cfc87876001611c83565b9050612d2483878681518110612d0e57fe5b6020026020010151610fb190919063ffffffff16565b868581518110612d3057fe5b6020026020010181815250506000612d4a888884896131db565b905083878681518110612d5957fe5b602002602001015101878681518110612d6e57fe5b602002602001018181525050612da56001611d86898981518110612d8e57fe5b602002602001015184610fb190919063ffffffff16565b98975050505050505050565b600080612dc087876001611c83565b9050612de883878781518110612dd257fe5b602002602001015161185690919063ffffffff16565b868681518110612df457fe5b6020026020010181815250506000612e0e888884886131db565b905083878781518110612e1d57fe5b602002602001015103878781518110612e3257fe5b602002602001018181525050612da56001612e53838a8981518110612d0e57fe5b90610fb1565b6000612e847f2f1a0bc900000000000000000000000000000000000000000000000000000000610a43565b821480612eb85750612eb57feb0f24d600000000000000000000000000000000000000000000000000000000610a43565b82145b806105c257506105c28261338b565b1c67ffffffffffffffff1690565b600080612ee4878787876131db565b905080868581518110612ef357fe5b602002602001015111612f0a5760009150506112f7565b600081878681518110612f1957fe5b6020026020010151039050612da5670de0b6b3a7640000612f43868461292590919063ffffffff16565b90611e1f565b60006060612f556117e3565b600080612f61856133ef565b91509150612f79612f70610fcb565b82106064611513565b6060612f83610fcb565b67ffffffffffffffff81118015612f9957600080fd5b50604051908082528060200260200182016040528015612fc3578160200160208202803683370190505b5090506000612fd0611601565b509050612fea81898587612fe26105dc565b600854613411565b828481518110612ff657fe5b6020908102919091010152509196919550909350505050565b60006060600061301e8461352d565b90506060613034868361302f6105dc565b613543565b9196919550909350505050565b6000606061304d6117e3565b6060600061305a856135f5565b9150915061306b8251610847610fcb565b6130758287611c22565b600061307f611601565b509050600061309a828a866130926105dc565b60085461360d565b90506130aa8382111560cf611513565b989297509195505050505050565b60006130c78215156004611513565b8183816130d057fe5b049392505050565b6000610698838360016126c1565b600060608060006130f6856135f5565b9150915061310c613105610fcb565b8351611980565b6131168287611c22565b6000613120611601565b509050600061313b828a866131336105dc565b6008546138a3565b90506130aa8382101560d0611513565b6000606060008061315b856133ef565b9150915061316a612f70610fcb565b6060613174610fcb565b67ffffffffffffffff8111801561318a57600080fd5b506040519080825280602002602001820160405280156131b4578160200160208202803683370190505b50905060006131c1611601565b509050612fea818985876131d36105dc565b600854613b32565b6000808451860290506000856000815181106131f357fe5b60200260200101519050600086518760008151811061320e57fe5b60200260200101510290506000600190505b87518110156132675761324c61324661323f848b8581518110611d2657fe5b8a51610f8d565b886130b8565b915061325d888281518110611ca357fe5b9250600101613220565b5086858151811061327457fe5b602002602001015182039150600061328c8788610f8d565b905060006132b86132ac6132a4846107378988610f8d565b6103e8610f8d565b8a8981518110611d2657fe5b905060006132d36132cc6132a48b896130b8565b8690611856565b90506000806132ef6132e58686611856565b6107378d86611856565b905060005b60ff81101561336f5781925061332461331186611d868586610f8d565b6107378e612e5388611d86886002610f8d565b91508282111561334d57600183830311613348575097506104f49650505050505050565b613367565b600182840311613367575097506104f49650505050505050565b6001016132f4565b5061337b610142612654565b5050505050505050949350505050565b60006133b67f38e9922e00000000000000000000000000000000000000000000000000000000610a43565b8214806105c257506133e77f50dd6ed900000000000000000000000000000000000000000000000000000000610a43565b909114919050565b60008082806020019051810190613406919061425e565b909590945092505050565b60008061342088886001611c83565b905060006134428261343c87613436818b610fb1565b90612a93565b90612ae1565b905060006134528a8a848b6131db565b90506000613466828b8b81518110612d0e57fe5b90506000805b8b518110156134a55761349b8c828151811061348457fe5b60200260200101518361185690919063ffffffff16565b915060010161346c565b5060006134ce828d8d815181106134b857fe5b6020026020010151611e1f90919063ffffffff16565b905060006134db82613c0f565b905060006134e98583612ae1565b905060006134f78683610fb1565b905061351861351183670de0b6b3a76400008e9003612925565b8290611856565b99505050505050505050509695505050505050565b6000818060200190518101906106989190614231565b606060006135518484611e1f565b90506060855167ffffffffffffffff8111801561356d57600080fd5b50604051908082528060200260200182016040528015613597578160200160208202803683370190505b50905060005b86518110156135eb576135cc838883815181106135b657fe5b602002602001015161292590919063ffffffff16565b8282815181106135d857fe5b602090810291909101015260010161359d565b5095945050505050565b606060008280602001905181019061340691906141ea565b600080805b86518110156136345761362a87828151811061348457fe5b9150600101613612565b506060855167ffffffffffffffff8111801561364f57600080fd5b50604051908082528060200260200182016040528015613679578160200160208202803683370190505b5090506000805b88518110156137405760006136b1858b848151811061369b57fe5b6020026020010151612a9390919063ffffffff16565b90506136ed8a83815181106136c257fe5b60200260200101516134368b85815181106136d957fe5b60200260200101518d8681518110612d0e57fe5b8483815181106136f957fe5b60200260200101818152505061373561372e8286858151811061371857fe5b6020026020010151612ae190919063ffffffff16565b8490611856565b925050600101613680565b506060885167ffffffffffffffff8111801561375b57600080fd5b50604051908082528060200260200182016040528015613785578160200160208202803683370190505b50905060005b89518110156138505760008482815181106137a257fe5b60200260200101518411156138095760006137cb6137bf86613c0f565b8d85815181106135b657fe5b905060006137df828d8681518110612d0e57fe5b90506138006137f982670de0b6b3a76400008d9003612a93565b8390611856565b92505050613820565b89828151811061381557fe5b602002602001015190505b613830818c8481518110612d0e57fe5b83838151811061383c57fe5b60209081029190910101525060010161378b565b50600061385f8b8b6001611c83565b9050600061386f8c846000611c83565b9050600061387d8284611e1f565b905061389261388b82613c0f565b8b90612ae1565b9d9c50505050505050505050505050565b600080805b86518110156138ca576138c087828151811061348457fe5b91506001016138a8565b506060855167ffffffffffffffff811180156138e557600080fd5b5060405190808252806020026020018201604052801561390f578160200160208202803683370190505b5090506000805b88518110156139a3576000613931858b84815181106134b857fe5b905061396d8a838151811061394257fe5b6020026020010151612f438b858151811061395957fe5b60200260200101518d8681518110612dd257fe5b84838151811061397957fe5b60200260200101818152505061399861372e828685815181106135b657fe5b925050600101613916565b506060885167ffffffffffffffff811180156139be57600080fd5b506040519080825280602002602001820160405280156139e8578160200160208202803683370190505b50905060005b8951811015613aa957600083858381518110613a0657fe5b60200260200101511115613a62576000613a2b6137bf86670de0b6b3a7640000610fb1565b90506000613a3f828d8681518110612d0e57fe5b9050613a596137f982670de0b6b3a76400008d9003612925565b92505050613a79565b898281518110613a6e57fe5b602002602001015190505b613a89818c8481518110612dd257fe5b838381518110613a9557fe5b6020908102919091010152506001016139ee565b506000613ab88b8b6001611c83565b90506000613ac88c846000611c83565b90506000613ad68284611e1f565b9050670de0b6b3a7640000811115613b2257613b148a7ffffffffffffffffffffffffffffffffffffffffffffffffff21f494c589c00008301612925565b9750505050505050506112f7565b60009750505050505050506112f7565b600080613b4188886001611c83565b90506000613b578261343c87613436818b611856565b90506000613b678a8a848b6131db565b90506000613b918a8a81518110613b7a57fe5b602002602001015183610fb190919063ffffffff16565b90506000805b8b51811015613bb957613baf8c828151811061348457fe5b9150600101613b97565b506000613bcc828d8d815181106134b857fe5b90506000613bd982613c0f565b90506000613be78583612ae1565b90506000613bf58683610fb1565b905061351861351183670de0b6b3a76400008e9003612a93565b6000670de0b6b3a76400008210613c275760006105c2565b50670de0b6b3a76400000390565b80356105c2816146ee565b600082601f830112613c50578081fd5b8135613c63613c5e826146ce565b6146a7565b818152915060208083019084810181840286018201871015613c8457600080fd5b60005b84811015613ca357813584529282019290820190600101613c87565b505050505092915050565b600082601f830112613cbe578081fd5b8151613ccc613c5e826146ce565b818152915060208083019084810181840286018201871015613ced57600080fd5b60005b84811015613ca357815184529282019290820190600101613cf0565b600082601f830112613d1c578081fd5b813567ffffffffffffffff811115613d32578182fd5b613d456020601f19601f840116016146a7565b9150808252836020828501011115613d5c57600080fd5b8060208401602084013760009082016020015292915050565b8035600281106105c257600080fd5b6000610120808385031215613d97578182fd5b613da0816146a7565b915050613dad8383613d75565b8152613dbc8360208401613c35565b6020820152613dce8360408401613c35565b6040820152606082013560608201526080820135608082015260a082013560a0820152613dfe8360c08401613c35565b60c0820152613e108360e08401613c35565b60e08201526101008083013567ffffffffffffffff811115613e3157600080fd5b613e3d85828601613d0c565b82840152505092915050565b600060208284031215613e5a578081fd5b8135610698816146ee565b60008060408385031215613e77578081fd5b8235613e82816146ee565b91506020830135613e92816146ee565b809150509250929050565b600080600060608486031215613eb1578081fd5b8335613ebc816146ee565b92506020840135613ecc816146ee565b929592945050506040919091013590565b600080600080600080600060e0888a031215613ef7578283fd5b8735613f02816146ee565b96506020880135613f12816146ee565b95506040880135945060608801359350608088013560ff81168114613f35578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613f64578182fd5b8235613f6f816146ee565b946020939093013593505050565b600080600060608486031215613f91578081fd5b835167ffffffffffffffff80821115613fa8578283fd5b818601915086601f830112613fbb578283fd5b8151613fc9613c5e826146ce565b80828252602080830192508086018b828387028901011115613fe9578788fd5b8796505b84871015614014578051614000816146ee565b845260019690960195928101928101613fed565b50890151909750935050508082111561402b578283fd5b5061403886828701613cae565b925050604084015190509250925092565b60006020828403121561405a578081fd5b813561069881614703565b600060208284031215614076578081fd5b815161069881614703565b600080600080600080600060e0888a03121561409b578081fd5b8735965060208801356140ad816146ee565b955060408801356140bd816146ee565b9450606088013567ffffffffffffffff808211156140d9578283fd5b6140e58b838c01613c40565b955060808a0135945060a08a0135935060c08a0135915080821115614108578283fd5b506141158a828b01613d0c565b91505092959891949750929550565b600060208284031215614135578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610698578182fd5b600060208284031215614175578081fd5b8151610698816146ee565b60008060408385031215614192578182fd5b823561419d816146ee565b9150602083013567ffffffffffffffff8111156141b8578182fd5b6141c485828601613d0c565b9150509250929050565b6000602082840312156141df578081fd5b815161069881614711565b6000806000606084860312156141fe578081fd5b835161420981614711565b602085015190935067ffffffffffffffff811115614225578182fd5b61403886828701613cae565b60008060408385031215614243578182fd5b825161424e81614711565b6020939093015192949293505050565b600080600060608486031215614272578081fd5b835161427d81614711565b602085015160409095015190969495509392505050565b600080604083850312156142a6578182fd5b82516142b181614711565b602084015190925067ffffffffffffffff8111156142cd578182fd5b6141c485828601613cae565b600080600080608085870312156142ee578182fd5b843567ffffffffffffffff80821115614305578384fd5b61431188838901613d84565b95506020870135915080821115614326578384fd5b5061433387828801613c40565b949794965050505060408301359260600135919050565b60008060006060848603121561435e578081fd5b833567ffffffffffffffff811115614374578182fd5b61438086828701613d84565b9660208601359650604090950135949350505050565b6000602082840312156143a7578081fd5b5035919050565b600080604083850312156143c0578182fd5b50508035926020909101359150565b600080600080608085870312156143e4578182fd5b8451935060208501519250604085015191506060850151614404816146ee565b939692955090935050565b6000815180845260208085019450808401835b8381101561443e57815187529582019590820190600101614422565b509495945050505050565b60008151808452815b8181101561446e57602081850181015186830182015201614452565b8181111561447f5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b600060408252614531604083018561440f565b82810360208401526112f7818561440f565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6000838252604060208301526104f46040830184614449565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526106986020830184614449565b6000838252604060208301526104f4604083018461440f565b9283529015156020830152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156146c657600080fd5b604052919050565b600067ffffffffffffffff8211156146e4578081fd5b5060209081020190565b6001600160a01b03811681146105d957600080fd5b80151581146105d957600080fd5b600381106105d957600080fdfea264697066735822122074699730ea8aa4fa00d2702d985bebe2cf30c6abf09e7ee52a1750d232c882ff64736f6c63430007010033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000221b262dd800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a7760000000000000000000000000000000000000000000000000000000000000022546865204772616e6420537465616479204f7263686573747261206f66205455534400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084250542d54555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000004068da6c83afcfa0e13ba15a6696662335d5b750000000000000000000000009879abdea01a879644185341f7af7d8343556b7a
-----Decoded View---------------
Arg [0] : vault (address): 0x20dd72Ed959b6147912C2e529F0a0C651c33c9ce
Arg [1] : name (string): The Grand Steady Orchestra of TUSD
Arg [2] : symbol (string): BPT-TUSD
Arg [3] : tokens (address[]): 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75,0x9879aBDea01a879644185341F7aF7d8343556B7a
Arg [4] : amplificationParameter (uint256): 1000
Arg [5] : swapFeePercentage (uint256): 600000000000000
Arg [6] : pauseWindowDuration (uint256): 0
Arg [7] : bufferPeriodDuration (uint256): 0
Arg [8] : owner (address): 0xCd983793ADb846dcE4830c22F30C7Ef0C864a776
-----Encoded View---------------
17 Constructor Arguments found :
Arg [0] : 00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [3] : 00000000000000000000000000000000000000000000000000000000000001c0
Arg [4] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [5] : 000000000000000000000000000000000000000000000000000221b262dd8000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000022
Arg [10] : 546865204772616e6420537465616479204f7263686573747261206f66205455
Arg [11] : 5344000000000000000000000000000000000000000000000000000000000000
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [13] : 4250542d54555344000000000000000000000000000000000000000000000000
Arg [14] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [15] : 00000000000000000000000004068da6c83afcfa0e13ba15a6696662335d5b75
Arg [16] : 0000000000000000000000009879abdea01a879644185341f7af7d8343556b7a
Deployed Bytecode Sourcemap
1161:26372:34:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1243:582:2;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2138:81:19;;;:::i;:::-;;;;;;;:::i;4172:164::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;9282:89:4:-;;;;;;:::i;:::-;;:::i;:::-;;3181:98:19;;;:::i;3124:363:12:-;;;:::i;:::-;;;;;;;;;:::i;1842:655:1:-;;;;;;:::i;:::-;;:::i;22807:1268:34:-;;;;;;:::i;:::-;;:::i;3040:81:19:-;;;:::i;:::-;;;;;;;:::i;2359:113:20:-;;;:::i;8235:156:4:-;;;;;;:::i;:::-;;:::i;7925:91::-;;;:::i;5584:211:19:-;;;;;;:::i;:::-;;:::i;8777:214:4:-;;;;;;:::i;:::-;;:::i;8123:106::-;;;:::i;15547:904::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;21762:589:34:-;;;:::i;24810:288::-;;;:::i;:::-;;;;;;;;;:::i;3337:117:19:-;;;;;;:::i;:::-;;:::i;12172:1197:4:-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;2127:108:20:-;;;;;;:::i;:::-;;:::i;2457:430:6:-;;;;;;:::i;:::-;;:::i;14022:902:4:-;;;;;;:::i;:::-;;:::i;1746:80:5:-;;;:::i;:::-;;;;;;;:::i;7840:79:4:-;;;:::i;2332:85:19:-;;;:::i;1299:1781:3:-;;;;;;:::i;:::-;;:::i;2623:429:1:-;;;;;;:::i;:::-;;:::i;3657:170:19:-;;;;;;:::i;:::-;;:::i;1832:101:5:-;;;:::i;1313:753:20:-;;;;;;:::i;:::-;;:::i;9882:2284:4:-;;;;;;:::i;:::-;;:::i;3885:149:19:-;;;;;;:::i;:::-;;:::i;24186:259:34:-;;;:::i;1243:582:2:-;1431:7;1450:54;1467:7;1476:8;1486:17;:15;:17::i;:::-;1450:16;:54::i;:::-;1514:31;1548:17;:15;:17::i;:::-;1514:51;-1:-1:-1;1615:24:2;1595:16;;:44;;;;;;;;;:223;;1747:71;1761:11;1774:8;1784:7;1793:8;1803:14;1747:13;:71::i;:::-;1595:223;;;1658:70;1671:11;1684:8;1694:7;1703:8;1713:14;1658:12;:70::i;:::-;1576:242;;;1243:582;;;;;;;:::o;2138:81:19:-;2207:5;2200:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2175:13;;2200:12;;2207:5;;2200:12;;2207:5;2200:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2138:81;;:::o;4172:164::-;4255:4;4271:37;4280:10;4292:7;4301:6;4271:8;:37::i;:::-;-1:-1:-1;4325:4:19;4172:164;;;;;:::o;9282:89:4:-;2126:21:6;:19;:21::i;:::-;9346:18:4::1;9357:6;9346:10;:18::i;:::-;9282:89:::0;:::o;3181:98:19:-;3260:12;;3181:98;:::o;3124:363:12:-;3227:11;3252:26;3292:27;3354:14;:12;:14::i;:::-;3353:15;3344:24;;3399;:22;:24::i;:::-;3378:45;;3455:25;:23;:25::i;:::-;3433:47;;3124:363;;;:::o;1842:655:1:-;1970:4;1986:24;2013:29;2023:6;2031:10;2013:9;:29::i;:::-;1986:56;-1:-1:-1;2052:101:1;2061:10;-1:-1:-1;;;;;2061:20:1;;;;:50;;;2105:6;2085:16;:26;;2061:50;8078:3:7;2052:8:1;:101::i;:::-;2164:36;2174:6;2182:9;2193:6;2164:9;:36::i;:::-;2215:10;-1:-1:-1;;;;;2215:20:1;;;;;;:55;;;2267:2;2239:16;:31;;2215:55;2211:258;;;2403:55;2412:6;2420:10;2451:6;2432:16;:25;2403:8;:55::i;:::-;2486:4;2479:11;;;1842:655;;;;;;:::o;22807:1268:34:-;2126:21:6;:19;:21::i;:::-;22920:49:34::1;1128:1:33;22929:11:34;:23;;5687:3:7;22920:8:34;:49::i;:::-;22979;1172:4:33;22988:11:34;:23;;5732:3:7;22979:8:34;:49::i;:::-;23039:16;23058:34;23067:7;23076:15;23058:8;:34::i;:::-;23039:53;;23102:69;2182:6;23111:8;:28;;6640:3:7;23102:8:34;:69::i;:::-;23183:20;23205:15:::0;23224:28:::1;:26;:28::i;:::-;23182:70;;;;23262:48;23272:10;23271:11;6696:3:7;23262:8:34;:48::i;:::-;23321:16;23340:37;23349:11;1225:3:33;23340:8:34;:37::i;:::-;23321:56;;23684:17;23715:12;23704:8;:23;:197;;23829:72;23840:30;23849:6;23857:12;23840:8;:30::i;:::-;23872:28;23881:8;23891;23872;:28::i;:::-;23829:10;:72::i;:::-;23704:197;;;23742:72;23753:26;23762:6;23770:8;23753;:26::i;:::-;23781:32;23790:12;23804:8;23781;:32::i;23742:72::-;23684:217;;23911:75;2248:1;23920:9;:39;;6751:3:7;23911:8:34;:75::i;:::-;23997:71;24019:12;24033:8;24043:15;24060:7;23997:21;:71::i;:::-;2157:1:6;;;;;22807:1268:34::0;;:::o;3040:81:19:-;3105:9;;;;3040:81;:::o;2359:113:20:-;2419:7;2445:20;:18;:20::i;:::-;2438:27;;2359:113;:::o;8235:156:4:-;2126:21:6;:19;:21::i;:::-;2940:18:12::1;:16;:18::i;:::-;8344:40:4::2;8366:17;8344:21;:40::i;7925:91::-:0;8002:7;7925:91;:::o;5584:211:19:-;5697:10;5672:4;5718:23;;;:11;:23;;;;;;;;-1:-1:-1;;;;;5718:32:19;;;;;;;;;;5672:4;;5688:79;;5709:7;;5718:48;;5755:10;5718:36;:48::i;:::-;5688:8;:79::i;8777:214:4:-;2126:21:6;:19;:21::i;:::-;2940:18:12::1;:16;:18::i;:::-;8939:45:4::2;8966:5;8973:10;8939:26;:45::i;:::-;8777:214:::0;;:::o;8123:106::-;8204:18;;8123:106;:::o;15547:904::-;15807:13;15822:27;15861:71;15897:8;:15;15914:17;:15;:17::i;:::-;15861:35;:71::i;:::-;15943:255;15969:6;15989;16009:9;16032:8;16054:15;16083:25;16122:8;16144:11;16169:19;15943:12;:255::i;:::-;15547:904;;;;;;;;;;:::o;21762:589:34:-;21802:7;21824:25;21855:10;:8;:10::i;:::-;-1:-1:-1;;;;;21855:24:34;;21880:11;:9;:11::i;:::-;21855:37;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;21855:37:34;;;;;;;;;;;;:::i;:::-;21821:71;;;;22100:18;22124:28;:26;:28::i;:::-;22099:53;;;22163:42;22177:8;22187:17;:15;:17::i;:::-;22163:13;:42::i;:::-;22216:17;22236:59;22267:10;22279:8;22289:5;22236:30;:59::i;:::-;22216:79;;22312:32;22330:13;:11;:13::i;:::-;22312:9;;:17;:32::i;:::-;22305:39;;;;;21762:589;:::o;24810:288::-;24907:13;24934:15;24963:17;25027:28;:26;:28::i;:::-;25005:50;;;;-1:-1:-1;1225:3:33;;-1:-1:-1;24810:288:34;-1:-1:-1;24810:288:34:o;3337:117:19:-;-1:-1:-1;;;;;3429:18:19;;3403:7;3429:18;;;;;;;;;;;3337:117;;;;:::o;12172:1197:4:-;12466:16;12484;12449:6;9725:68;9756:10;:8;:10::i;:::-;-1:-1:-1;;;;;9734:33:4;:10;-1:-1:-1;;;;;9734:33:4;;5362:3:7;9725:8:4;:68::i;:::-;9803:55;9822:11;:9;:11::i;:::-;9812:6;:21;9028:3:7;9803:8:4;:55::i;:::-;12512:31:::1;12546:17;:15;:17::i;:::-;12512:51;;12573:39;12587:8;12597:14;12573:13;:39::i;:::-;12624:19;12645:27;12674:38:::0;12716:224:::1;12741:6;12761;12781:9;12804:8;12826:15;12855:25;12894:14;12922:8;12716:11;:224::i;:::-;12623:317;;;;;;13046:36;13062:6;13070:11;13046:15;:36::i;:::-;13194:47;13214:10;13226:14;13194:19;:47::i;:::-;13251:58;13271:21;13294:14;13251:19;:58::i;:::-;13328:10:::0;;-1:-1:-1;13340:21:4;-1:-1:-1;;;9868:1:4::1;12172:1197:::0;;;;;;;;;;;:::o;2127:108:20:-;-1:-1:-1;;;;;2214:14:20;2188:7;2214:14;;;:7;:14;;;;;;;2127:108::o;2457:430:6:-;2525:7;2846:22;2870:8;2829:50;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2819:61;;;;;;2812:68;;2457:430;;;:::o;14022:902:4:-;14282:14;14298:26;14336:71;14372:8;:15;14389:17;:15;:17::i;14336:71::-;14418:253;14444:6;14464;14484:9;14507:8;14529:15;14558:25;14597:8;14619:11;14644:17;14418:12;:253::i;1746:80:5:-;1813:6;1746:80;:::o;7840:79:4:-;7906:6;7840:79;:::o;2332:85:19:-;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2371:13;;2396:14;;2403:7;;2396:14;;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;1299:1781:3;1462:7;1481:28;1512:31;1527:7;:15;;;1512:14;:31::i;:::-;1481:62;;1553:29;1585:32;1600:7;:16;;;1585:14;:32::i;:::-;1553:64;-1:-1:-1;1648:24:3;1632:12;;:40;;;;;;;;;1628:1446;;;1817:38;1840:7;:14;;;1817:22;:38::i;:::-;1800:14;;;:55;1934:46;1943:14;1959:20;1934:8;:46::i;:::-;1917:63;;2012:48;2021:15;2038:21;2012:8;:48::i;:::-;1994:66;;2091:46;2100:7;:14;;;2116:20;2091:8;:46::i;:::-;2074:14;;;:63;2152:17;2172:56;2074:7;2196:14;2212:15;2172:14;:56::i;:::-;2152:76;;2322:48;2337:9;2348:21;2322:14;:48::i;:::-;2315:55;;;;;;;1628:1446;2465:46;2474:14;2490:20;2465:8;:46::i;:::-;2448:63;;2543:48;2552:15;2569:21;2543:8;:48::i;:::-;2525:66;;2622:47;2631:7;:14;;;2647:21;2622:8;:47::i;:::-;2605:14;;;:64;2684:16;2703:57;2605:7;2728:14;2744:15;2703;:57::i;:::-;2684:76;;2856:44;2869:8;2879:20;2856:12;:44::i;:::-;2845:55;;3036:27;3054:8;3036:17;:27::i;2623:429:1:-;2708:4;2724:24;2751:30;2761:10;2773:7;2751:9;:30::i;:::-;2724:57;;2806:16;2796:6;:26;2792:232;;2838:32;2847:10;2859:7;2868:1;2838:8;:32::i;:::-;2792:232;;;2957:56;2966:10;2978:7;3006:6;2987:16;:25;2957:8;:56::i;:::-;-1:-1:-1;3041:4:1;;2623:429;-1:-1:-1;;;2623:429:1:o;3657:170:19:-;3743:4;3759:40;3769:10;3781:9;3792:6;3759:9;:40::i;1832:101:5:-;1880:11;1910:16;:14;:16::i;1313:753:20:-;1575:60;1603:8;1584:15;:27;;5576:3:7;1575:8:20;:60::i;:::-;-1:-1:-1;;;;;1662:14:20;;1646:13;1662:14;;;:7;:14;;;;;;;;;1717:68;;1662:14;;1646:13;1717:68;;1728:16;;1670:5;;1753:7;;1762:5;;1662:14;;1776:8;;1717:68;;:::i;:::-;;;;;;;;;;;;;1707:79;;;;;;1686:100;;1797:12;1812:28;1829:10;1812:16;:28::i;:::-;1797:43;;1851:14;1868:24;1878:4;1884:1;1887;1890;1868:24;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1868:24:20;;-1:-1:-1;;1868:24:20;;;-1:-1:-1;1902:79:20;;-1:-1:-1;;;;;;1912:20:20;;;;;;1911:43;;;1948:5;-1:-1:-1;;;;;1938:15:20;:6;-1:-1:-1;;;;;1938:15:20;;1911:43;9261:3:7;1902:8:20;:79::i;:::-;-1:-1:-1;;;;;1992:14:20;;;;;;:7;:14;;;;;2017:1;2009:9;;1992:26;;2028:31;2000:5;2044:7;2053:5;2028:8;:31::i;:::-;1313:753;;;;;;;;;;;:::o;9882:2284:4:-;10176:16;10194;10159:6;9725:68;9756:10;:8;:10::i;9725:68::-;9803:55;9822:11;:9;:11::i;9803:55::-;10222:31:::1;10256:17;:15;:17::i;:::-;10222:51;;10288:13;:11;:13::i;:::-;10284:1876;;10323:20;10345:26;10375:164;10410:6;10434;10458:9;10485:14;10517:8;10375:17;:164::i;:::-;10322:217;;;;10834:58;3072:3;10843:12;:28;;5308:3:7;10834:8:4;:58::i;:::-;10906:41;10930:1;3072:3;10906:15;:41::i;:::-;10961:55;10977:9;3072:3;10988:12;:27;10961:15;:55::i;:::-;11103:44;11121:9;11132:14;11103:17;:44::i;:::-;11170:9;11195:17;:15;:17::i;:::-;11181:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;11181:32:4::1;;11162:52;;;;;;;;;10284:1876;11245:39;11259:8;11269:14;11245:13;:39::i;:::-;11299:20;11321:26;11349:38:::0;11391:260:::1;11420:6;11444;11468:9;11495:8;11521:15;11554:25;11597:14;11629:8;11391:11;:260::i;:::-;11298:353;;;;;;11765:40;11781:9;11792:12;11765:15;:40::i;:::-;11892:44;11910:9;11921:14;11892:17;:44::i;:::-;12035:58;12055:21;12078:14;12035:19;:58::i;:::-;12116:9:::0;;-1:-1:-1;12127:21:4;-1:-1:-1;12108:41:4::1;::::0;-1:-1:-1;;12108:41:4::1;3885:149:19::0;-1:-1:-1;;;;;4000:18:19;;;3974:7;4000:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3885:149::o;24186:259:34:-;2126:21:6;:19;:21::i;:::-;24263:20:34::1;24285:15:::0;24304:28:::1;:26;:28::i;:::-;24262:70;;;;24342:50;24351:10;6810:3:7;24342:8:34;:50::i;:::-;24403:35;24425:12;24403:21;:35::i;1105:274:11:-:0;1315:5;1339:33;1315:5;1339:19;:33::i;1793:180:16:-;1851:7;1882:5;;;1897:51;1906:6;;;:20;;;1925:1;1920;1916;:5;;;;;;:10;1906:20;4437:1:7;1897:8:16;:51::i;948:166::-;1006:7;1025:37;1039:1;1034;:6;;4340:1:7;1025:8:16;:37::i;:::-;-1:-1:-1;1084:5:16;;;948:166::o;4721:131:13:-;4829:15;;4721:131::o;8022:95:4:-;8098:12;8022:95;:::o;4715:203:2:-;4844:67;4863:5;4853:7;:15;:35;;;;;4883:5;4872:8;:16;4853:35;4808:3:7;4844:8:2;:67::i;:::-;4715:203;;;:::o;23562:1130:4:-;23620:16;23648:19;23670:17;:15;:17::i;:::-;23648:39;;23697:31;23745:11;23731:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;23731:26:4;-1:-1:-1;23697:60:4;-1:-1:-1;23813:15:4;;23809:93;;23852:15;23832:14;23847:1;23832:17;;;;;;;;;;;;;:35;;;;;23809:93;;;23885:14;-1:-1:-1;23878:21:4;;-1:-1:-1;23878:21:4;23809:93;23933:1;23919:11;:15;23915:93;;;23958:15;23938:14;23953:1;23938:17;;;;;;;;;;;;;:35;;;;;24039:1;24025:11;:15;24021:93;;;24064:15;24044:14;24059:1;24044:17;;;;;;;;;;;;;:35;;;;;24145:1;24131:11;:15;24127:93;;;24170:15;24150:14;24165:1;24150:17;;;;;;;;;;;;;:35;;;;;24251:1;24237:11;:15;24233:93;;;24276:15;24256:14;24271:1;24256:17;;;;;;;;;;;;;:35;;;;;24357:1;24343:11;:15;24339:93;;;24382:15;24362:14;24377:1;24362:17;;;;;;;;;;;;;:35;;;;;24463:1;24449:11;:15;24445:93;;;24488:15;24468:14;24483:1;24468:17;;;;;;;;;;;;;:35;;;;;24569:1;24555:11;:15;24551:93;;;24594:15;24574:14;24589:1;24574:17;;;;;;;;;;;;;:35;;;;;24671:14;-1:-1:-1;;23562:1130:4;:::o;2610:746:2:-;2829:7;2848:39;2862:8;2872:14;2848:13;:39::i;:::-;2918:54;2927:11;:18;;;2947:14;2962:8;2947:24;;;;;;;;;;;;;;2918:8;:54::i;:::-;2897:18;;;:75;2983:16;3002:57;2897:11;3031:8;3041:7;3050:8;3002:15;:57::i;:::-;2983:76;;3147:47;3160:8;3170:14;3185:7;3170:23;;;;;;;;;;;;;;3147:12;:47::i;:::-;3136:58;;3322:27;3340:8;3322:17;:27::i;:::-;3315:34;;;2610:746;;;;;;;;:::o;1831:773::-;2049:7;2197:42;2220:11;:18;;;2197:22;:42::i;:::-;2176:18;;;:63;2250:39;2264:8;2274:14;2250:13;:39::i;:::-;2320:53;2329:11;:18;;;2349:14;2364:7;2349:23;;;;;;;2320:53;2299:18;;;:74;2384:17;2404:56;2299:11;2432:8;2442:7;2451:8;2404:14;:56::i;:::-;2384:76;;2546:51;2561:9;2572:14;2587:8;2572:24;;;;;;;;;;;;;;2546:14;:51::i;9345:213:19:-;-1:-1:-1;;;;;9468:18:19;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;;:36;;;9519:32;;;;;9498:6;;9519:32;:::i;:::-;;;;;;;;9345:213;;;:::o;2270:181:6:-;2325:16;2344:20;2356:7;;;;2344:11;:20::i;:::-;2325:39;;2374:70;2383:33;2395:8;2405:10;2383:11;:33::i;:::-;7257:3:7;2374:8:6;:70::i;3763:358:12:-;3819:6;3815:232;;;3841:81;3868:24;:22;:24::i;:::-;3850:15;:42;7359:3:7;3841:8:12;:81::i;:::-;3815:232;;;3953:83;3980:25;:23;:25::i;:::-;3962:15;:43;8789:3:7;3953:8:12;:83::i;:::-;4057:7;:16;;;;;;;;;;4088:26;;;;;;4057:16;;4088:26;:::i;:::-;;;;;;;;3763:358;:::o;4514:237::-;4561:4;4707:25;:23;:25::i;:::-;4689:15;:43;:55;;;-1:-1:-1;;4737:7:12;;;;4736:8;;4514:237::o;4864:108::-;4946:19;4864:108;:::o;4978:110::-;5061:20;4978:110;:::o;836:101:7:-;905:9;900:34;;916:18;924:9;916:7;:18::i;7068:559:19:-;7195:71;-1:-1:-1;;;;;7204:20:19;;;;7674:3:7;7195:8:19;:71::i;:::-;7276:72;-1:-1:-1;;;;;7285:23:19;;;;7742:3:7;7276:8:19;:72::i;:::-;7359:47;7380:6;7388:9;7399:6;7359:20;:47::i;:::-;-1:-1:-1;;;;;7437:17:19;;:9;:17;;;;;;;;;;;:68;;7459:6;8220:3:7;7437:21:19;:68::i;:::-;-1:-1:-1;;;;;7417:17:19;;;:9;:17;;;;;;;;;;;:88;;;;7538:20;;;;;;;:32;;7563:6;7538:24;:32::i;:::-;-1:-1:-1;;;;;7515:20:19;;;:9;:20;;;;;;;;;;;;:55;;;;7585:35;;;;;;;;;;7613:6;;7585:35;:::i;25104:1248:34:-;25165:13;25180:15;25208:18;25228:16;25246:17;25265:15;25284:23;:21;:23::i;:::-;25207:100;;;;;;;;25457:7;25439:15;:25;25435:911;;;25493:4;25480:17;;25969:10;25958:8;:21;25954:303;;;26091:9;26081:7;:19;26066:9;26048:15;:27;26033:10;26022:8;:21;26021:55;26020:81;;;;;;26007:10;:94;25999:102;;25954:303;;;26232:9;26222:7;:19;26207:9;26189:15;:27;26176:8;26163:10;:21;26162:55;26161:81;;;;;;26148:10;:94;26140:102;;25954:303;25435:911;;;26300:5;26287:18;;26327:8;26319:16;;25435:911;25104:1248;;;;;;:::o;2311:232:16:-;2371:7;2390:38;2399:6;;;4486:1:7;2390:8:16;:38::i;:::-;2443:6;2439:98;;-1:-1:-1;2472:1:16;2465:8;;2439:98;2525:1;2520;2516;:5;2515:11;;;;;;2511:1;:15;2504:22;;;;26543:503:34;26920:45;26948:7;26920:45;;26958:6;26920:20;:45::i;:::-;26858:47;26886:9;26858:47;;26898:6;26858:20;:47::i;:::-;26801:42;26829:8;26801:42;;26840:2;26801:20;:42::i;:::-;26743:43;26771:10;26743:43;;26784:1;26743:20;:43::i;:::-;:100;:162;:222;26704:24;:261;26981:58;;;;;;26998:10;;27010:8;;27020:9;;27031:7;;26981:58;:::i;:::-;;;;;;;;26543:503;;;;:::o;2386:188:18:-;2447:7;2494:10;2506:12;2520:15;2537:13;:11;:13::i;:::-;2560:4;2483:83;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2473:94;;;;;;2466:101;;2386:188;:::o;4190:98:12:-;4242:39;4251:14;:12;:14::i;:::-;7301:3:7;4242:8:12;:39::i;:::-;4190:98::o;8397:374:4:-;8473:87;2941:4;8482:17;:45;;5259:3:7;8473:8:4;:87::i;:::-;8570;3014:4;8579:17;:45;;5198:3:7;8570:8:4;:87::i;:::-;8668:18;:38;;;8721:43;;;;;;8689:17;;8721:43;:::i;915:167:23:-;973:7;1004:5;;;1019:37;1028:6;;;;973:7;1019:8;:37::i;8997:279:4:-;9090:14;9107:11;:9;:11::i;:::-;9090:28;;9135:20;9159:10;:8;:10::i;:::-;-1:-1:-1;;;;;9159:27:4;;9187:6;9195:5;9159:42;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;9212:57;;;;;9128:73;;-1:-1:-1;;;;;;9212:37:4;;;-1:-1:-1;9212:37:4;;-1:-1:-1;9212:57:4;;-1:-1:-1;9250:6:4;;9258:10;;9212:57;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8997:279;;;;:::o;780:131:11:-;858:46;872:1;867;:6;4972:3:7;858:8:11;:46::i;12263:1857:34:-;12588:19;12621:27;12662:38;12884:14;:12;:14::i;:::-;12880:851;;;13250:62;13276:8;13286:25;13250;:62::i;:::-;13226:86;;13406:63;13421:8;13431:21;13454:14;13406;:63::i;:::-;12880:851;;;13702:17;:15;:17::i;:::-;13688:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;13688:32:34;;13664:56;;12880:851;13769:43;13777:8;13787:14;13803:8;13769:7;:43::i;:::-;13741:71;;-1:-1:-1;13741:71:34;-1:-1:-1;14000:47:34;14026:8;13741:71;14000:25;:47::i;:::-;12263:1857;;;;;;;;;;;;:::o;26388:253:4:-;26505:9;26500:135;26524:17;:15;:17::i;:::-;26520:1;:21;26500:135;;;26575:49;26594:7;26602:1;26594:10;;;;;;;;;;;;;;26606:14;26621:1;26606:17;;;;;;;;;;;;;;26575:18;:49::i;:::-;26562:7;26570:1;26562:10;;;;;;;;;;;;;;;;;:62;26543:3;;26500:135;;27921:6885;28620:10;28642:4;28620:27;28616:6184;;28916:12;28942:4;-1:-1:-1;;;;;28934:18:4;28953:8;;28934:28;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;28915:47;;;29180:7;29213:1;29208:3336;;;;32704:9;29208:3336;29684:4;29681:1;29678;29663:26;29737:1;29731:8;29741:66;29727:81;29969:66;29959:77;;29953:2;;30092:16;30089:1;30086;30071:38;30148:16;30145:1;30138:27;29953:2;;31559;31553:4;31550:1;31535:27;31756:2;31750:4;31743:16;32180:2;32162:16;32158:25;32152:4;32146;32131:53;32518:2;32500:16;32496:25;32493:1;32486:36;29046:3703;32779:31;32813:17;:15;:17::i;:::-;32779:51;;32844:39;32858:8;32868:14;32844:13;:39::i;:::-;32899:17;32918:29;32953:256;32978:6;33002;33026:9;33053:8;33079:15;33112:25;33155:14;33187:8;32953:7;:256;;:::i;:::-;32898:311;;;;;33224:45;33240:12;33254:14;33224:15;:45;;:::i;:::-;33750:19;;-1:-1:-1;;34137:23:4;;34177:24;;;34423:66;34405:16;;;34398:92;33771:2;33746:28;34516:16;;;34772:2;34762:13;;34516:16;34748:28;25602:247;25713:9;25708:135;25732:17;:15;:17::i;:::-;25728:1;:21;25708:135;;;25783:49;25802:7;25810:1;25802:10;;;;;;;;;;;;;;25814:14;25829:1;25814:17;;;;;;;;;;;;;;25783:18;:49::i;:::-;25770:7;25778:1;25770:10;;;;;;;;;;;;;;;;;:62;25751:3;;25708:135;;2308:2606:33;3404:15;;2463:7;;;;;3429:91;3453:9;3449:1;:13;3429:91;;;3489:20;3497:8;3506:1;3497:11;;;;;;;;;;;;;;3489:3;:7;;:20;;;;:::i;:::-;3483:26;-1:-1:-1;3464:3:33;;3429:91;;;-1:-1:-1;3533:8:33;3529:47;;3564:1;3557:8;;;;;;3529:47;3586:21;3641:3;3678:34;;;3586:21;3723:1125;3747:3;3743:1;:7;3723:1125;;;3771:11;3799:9;3785:8;3794:1;3785:11;;;;;;;;;;;;;;:23;3771:37;;3827:9;3839:1;3827:13;;3822:156;3846:9;3842:1;:13;3822:156;;;3886:77;3895:47;3904:26;3913:3;3918:8;3927:1;3918:11;;;;;;;;;;;;;;3904:8;:26::i;:::-;3932:9;3895:8;:47::i;:::-;3944:9;3955:7;3886:8;:77::i;:::-;3880:83;-1:-1:-1;3857:3:33;;3822:156;;;;4007:9;3991:25;;4042:534;4068:173;4145:78;4154:43;4163:28;4172:13;4187:3;4163:8;:28::i;:::-;4193:3;4154:8;:43::i;:::-;1225:3;4215:7;4145:8;:78::i;:::-;4068:51;4077:30;4086:9;4097;4077:8;:30::i;:::-;4109:9;4068:8;:51::i;:::-;:55;;:173::i;:::-;4259:278;4438:81;4447:45;1225:3;4456:13;:30;4488:3;4447:8;:45::i;:::-;1225:3;4511:7;4510:8;4438;:81::i;:::-;4259:34;4268:9;4280:1;4268:13;4283:9;4259:8;:34::i;:278::-;4555:7;4042:8;:534::i;:::-;4030:546;;4607:13;4595:9;:25;4591:247;;;4673:1;4656:13;4644:9;:25;:30;4640:93;;4705:9;4698:16;;;;;;;;;;;4640:93;4591:247;;;4786:1;4773:9;4757:13;:25;:30;4753:85;;4814:9;4807:16;;;;;;;;;;;4753:85;-1:-1:-1;3752:3:33;;3723:1125;;;;4858:49;6950:3:7;4858:7:33;:49::i;:::-;2308:2606;;;;;;;;;;:::o;2455:355:14:-;2517:7;2536:38;2545:6;;;4486:1:7;2536:8:14;:38::i;:::-;2589:6;2585:219;;-1:-1:-1;2618:1:14;2611:8;;2585:219;863:4;2670:7;;;;2691:51;;2670:1;:7;:1;2700:13;;;;;:20;4534:1:7;2691:8:14;:51::i;:::-;2792:1;2780:9;:13;;;;;;2773:20;;;;;3201:104:1;3277:21;3283:6;3291;3277:5;:21::i;8551:1410:34:-;8898:7;8919:16;8949;2940:18:12;:16;:18::i;:::-;9296:38:34::1;9337:62;9363:8;9373:25;9337;:62::i;:::-;9296:103;;9485:63;9500:8;9510:21;9533:14;9485;:63::i;:::-;9559:20;9581:26;9611:43;9619:8;9629:14;9645:8;9611:7;:43::i;:::-;9558:96;;;;9842:46;9868:8;9878:9;9842:25;:46::i;:::-;9907:12:::0;;;;-1:-1:-1;9932:21:34;;-1:-1:-1;8551:1410:34;-1:-1:-1;;;;;;;;;8551:1410:34:o;27172:249:4:-;27287:9;27282:133;27306:17;:15;:17::i;:::-;27302:1;:21;27282:133;;;27357:47;27374:7;27382:1;27374:10;;;;;;;;;;;;;;27386:14;27401:1;27386:17;;;;;;;;;;;;;;27357:16;:47::i;:::-;27344:7;27352:1;27344:10;;;;;;;;;;;;;;;;;:60;27325:3;;27282:133;;22660:679;22729:7;22788;-1:-1:-1;;;;;22779:16:4;:5;-1:-1:-1;;;;;22779:16:4;;22775:558;;;-1:-1:-1;22806:15:4;22799:22;;22775:558;22851:7;-1:-1:-1;;;;;22842:16:4;:5;-1:-1:-1;;;;;22842:16:4;;22838:495;;;-1:-1:-1;22869:15:4;22862:22;;22838:495;22914:7;-1:-1:-1;;;;;22905:16:4;:5;-1:-1:-1;;;;;22905:16:4;;22901:432;;;-1:-1:-1;22932:15:4;22925:22;;22901:432;22977:7;-1:-1:-1;;;;;22968:16:4;:5;-1:-1:-1;;;;;22968:16:4;;22964:369;;;-1:-1:-1;22995:15:4;22988:22;;22964:369;23040:7;-1:-1:-1;;;;;23031:16:4;:5;-1:-1:-1;;;;;23031:16:4;;23027:306;;;-1:-1:-1;23058:15:4;23051:22;;23027:306;23103:7;-1:-1:-1;;;;;23094:16:4;:5;-1:-1:-1;;;;;23094:16:4;;23090:243;;;-1:-1:-1;23121:15:4;23114:22;;23090:243;23166:7;-1:-1:-1;;;;;23157:16:4;:5;-1:-1:-1;;;;;23157:16:4;;23153:180;;;-1:-1:-1;23184:15:4;23177:22;;23153:180;23229:7;-1:-1:-1;;;;;23220:16:4;:5;-1:-1:-1;;;;;23220:16:4;;23216:117;;;-1:-1:-1;23247:15:4;23240:22;;23216:117;23293:29;6176:3:7;23293:7:4;:29::i;21020:279::-;21091:7;21202:17;21222:32;21235:18;;21222:6;:12;;:32;;;;:::i;:::-;21202:52;-1:-1:-1;21271:21:4;:6;21202:52;21271:10;:21::i;24854:579::-;24934:7;25385:41;25404:6;25412:13;25385:18;:41::i;5612:519:34:-;5787:7;5806:55;5815:17;:15;:17::i;:::-;5836:1;5815:22;5628:3:7;5806:8:34;:55::i;:::-;5873:25;5900:15;5917:16;5937:113;5972:11;5997:14;6025:15;5937:21;:113::i;:::-;5872:178;;;;;;6068:56;6083:11;6096:8;6106:7;6115:8;6068:14;:56::i;:::-;6061:63;5612:519;-1:-1:-1;;;;;;;5612:519:34:o;26053:160:4:-;26139:7;26165:41;26184:6;26192:13;26165:18;:41::i;6137:520:34:-;6313:7;6332:55;6341:17;:15;:17::i;6332:55::-;6399:25;6426:15;6443:16;6463:113;6498:11;6523:14;6551:15;6463:21;:113::i;:::-;6398:178;;;;;;6593:57;6609:11;6622:8;6632:7;6641:8;6593:15;:57::i;26843:156:4:-;26927:7;26953:39;26970:6;26978:13;26953:16;:39::i;20677:243::-;20743:7;20861:52;20874:38;20893:18;;863:4:14;20874:18:4;;:38;;;;:::i;:::-;20861:6;;:12;:52::i;27427:488::-;27485:11;27882:10;:8;:10::i;:::-;-1:-1:-1;;;;;27882:24:4;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;3199:183:18:-;3276:7;3341:20;:18;:20::i;:::-;3363:10;3312:62;;;;;;;;;:::i;7427:1105:34:-;7632:7;7641:16;2940:18:12;:16;:18::i;:::-;7824:24:34::1;7851:19;:8;:17;:19::i;:::-;7824:46:::0;-1:-1:-1;7880:64:34::1;7897:24;7889:4;:32;;;;;;;;;5413:3:7;7880:8:34;:64::i;:::-;7955:26;7984:27;:8;:25;:27::i;:::-;7955:56;;8021:72;8057:9;:16;8075:17;:15;:17::i;8021:72::-;8103:40;8117:9;8128:14;8103:13;:40::i;:::-;8155:18;8179:28;:26;:28::i;:::-;8154:53;;;8217:26;8246:59;8277:10;8289:9;8300:4;8246:30;:59::i;:::-;8217:88:::0;-1:-1:-1;8217:88:34;8430:52:::1;8217:88:::0;8471:10;8430:20:::1;:52::i;:::-;8501:12:::0;8515:9;;-1:-1:-1;7427:1105:34;;-1:-1:-1;;;;;;;;;7427:1105:34:o;3085:110:1:-;3164:24;3170:9;3181:6;3164:5;:24::i;26358:179:34:-;26422:69;26444:5;26451;26458:15;26475;26422:21;:69::i;:::-;26507:23;26524:5;26507:23;;;;;;:::i;1385:374:11:-;1481:1;1466:5;:12;:16;1462:53;;;1498:7;;1462:53;1525:16;1544:5;1550:1;1544:8;;;;;;;;;;;;;;1525:27;;1567:9;1579:1;1567:13;;1562:191;1586:5;:12;1582:1;:16;1562:191;;;1619:15;1637:5;1643:1;1637:8;;;;;;;;;;;;;;1619:26;;1659:51;1679:7;-1:-1:-1;;;;;1668:18:11;:8;-1:-1:-1;;;;;1668:18:11;;4860:3:7;1659:8:11;:51::i;:::-;1735:7;-1:-1:-1;1600:3:11;;1562:191;;5099:431:34;5310:7;2940:18:12;:16;:18::i;:::-;5330::34::1;5354:28;:26;:28::i;:::-;5329:53;;;5392:16;5411:87;5438:10;5450:8;5460:7;5469:8;5479:11;:18;;;5411:26;:87::i;4661:432::-:0;4871:7;2940:18:12;:16;:18::i;:::-;4891::34::1;4915:28;:26;:28::i;:::-;4890:53;;;4953:17;4973:87;5000:10;5012:8;5022:7;5031:8;5041:11;:18;;;4973:26;:87::i;1939:544:5:-:0;2027:4;1633:42;2048:10;:8;:10::i;:::-;-1:-1:-1;;;;;2048:29:5;;;2047:63;;;;;2082:28;2101:8;2082:18;:28::i;:::-;2043:434;;;2242:10;:8;:10::i;:::-;-1:-1:-1;;;;;2228:24:5;:10;-1:-1:-1;;;;;2228:24:5;;2221:31;;;;2043:434;2405:16;:14;:16::i;:::-;-1:-1:-1;;;;;2405:27:5;;2433:8;2443:7;2460:4;2405:61;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2398:68;;;;1044:3172:7;3563:66;3558:3;3551:79;;;3769:66;3763:4;3756:80;3911:1;3905:4;3898:15;2969:73;2180:2;2213:18;;;2258;;;2185:4;2254:29;;;3010:1;3006:14;2165:18;;;;2995:26;;;;2306:18;;;;2353;;;2349:29;;;3027:2;3023:17;2991:50;;;;2969:73;2964:3;2960:83;3978:4;3971:26;4204:3;;4194:14;1765:176:23;1842:7;1861:27;1875:1;1870;:6;;1878:9;1861:8;:27::i;:::-;-1:-1:-1;;1910:5:23;;;1765:176::o;27052:479:34:-;27144:18;27176:16;27206:17;27237:15;27290:40;27328:1;27290:24;;:37;;:40;;;;:::i;:::-;27351:24;;27277:53;;-1:-1:-1;27351:41:34;;27389:2;27351:37;:41::i;:::-;27414:24;;27340:52;;-1:-1:-1;27414:45:34;;27452:6;27414:37;:45::i;:::-;27479:24;;27402:57;;-1:-1:-1;27479:45:34;;27517:6;27479:37;:45::i;:::-;27469:55;;27052:479;;;;:::o;3388:427:18:-;3790:9;;3765:44::o;18179:1572:34:-;18322:16;18387:38;18442:17;:15;:17::i;:::-;18428:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;18428:32:34;-1:-1:-1;18387:73:34;-1:-1:-1;18556:30:34;18552:89;;18609:21;-1:-1:-1;18602:28:34;;18552:89;19056:24;19094:18;19115:8;19124:1;19115:11;;;;;;;;;;;;;;19094:32;;19141:9;19153:1;19141:13;;19136:253;19160:17;:15;:17::i;:::-;19156:1;:21;19136:253;;;19198:22;19223:8;19232:1;19223:11;;;;;;;;;;;;;;19198:36;;19269:10;19252:14;:27;19248:131;;;19318:1;19299:20;;19350:14;19337:27;;19248:131;-1:-1:-1;19179:3:34;;19136:253;;;;19500:205;19559:17;;19590:8;19612:14;;19640:16;19670:25;19500:45;:205::i;:::-;19458:21;19480:16;19458:39;;;;;;;;;;;;;;;;;:247;-1:-1:-1;19723:21:34;;18179:1572;-1:-1:-1;;;;18179:1572:34:o;21254:320::-;21451:9;21446:122;21470:17;:15;:17::i;:::-;21466:1;:21;21446:122;;;21522:35;21531:8;21540:1;21531:11;;;;;;;;;;;;;;21544:9;21554:1;21544:12;;;;;;;;;;;;;;21522:8;:35;;:::i;:::-;21508:8;21517:1;21508:11;;;;;;;;;;;;;;;;;:49;21489:3;;21446:122;;;;21254:320;;;:::o;14126:660::-;14278:7;14287:16;14315:13;14331:19;:8;:17;:19::i;:::-;14315:35;-1:-1:-1;14373:39:34;14365:4;:47;;;;;;;;;14361:419;;;14435:46;14462:8;14472;14435:26;:46::i;:::-;14428:53;;;;;;;14361:419;14510:36;14502:4;:44;;;;;;;;;14498:282;;;14569:47;14597:8;14607;14569:27;:47::i;14498:282::-;14706:63;14734:8;14744:14;14760:8;14706:27;:63::i;14498:282::-;14126:660;;;;;;;;:::o;20581:503::-;20690:52;20705:8;20715:10;20727:14;20690;:52::i;:::-;20754:18;20778:28;:26;:28::i;:::-;20753:53;;;20985:92;21006:58;21037:10;21049:8;21059:4;21006:30;:58::i;:::-;21066:10;20985:20;:92::i;1617:209:14:-;1679:7;1716:5;;;1731:57;1740:6;;;:26;;;1765:1;1760;1750:7;:11;;;;1731:57;863:4;1806:13;;;;-1:-1:-1;;;1617:209:14:o;1979:172:16:-;2081:7;2107;:37;;2131:13;2139:1;2142;2131:7;:13::i;:::-;2107:37;;;2117:11;2123:1;2126;2117:5;:11::i;8512:410:19:-;8587:68;-1:-1:-1;;;;;8596:21:19;;;;7872:3:7;8587:8:19;:68::i;:::-;8666:49;8687:7;8704:1;8708:6;8666:20;:49::i;:::-;-1:-1:-1;;;;;8747:18:19;;:9;:18;;;;;;;;;;;:67;;8770:6;8286:3:7;8747:22:19;:67::i;:::-;-1:-1:-1;;;;;8726:18:19;;:9;:18;;;;;;;;;;:88;8839:12;;:24;;8856:6;8839:16;:24::i;:::-;8824:12;:39;8878:37;;8904:1;;-1:-1:-1;;;;;8878:37:19;;;;;;;8908:6;;8878:37;:::i;:::-;;;;;;;;8512:410;;:::o;9967:585:34:-;10119:7;10128:16;10156:13;10172:19;:8;:17;:19::i;:::-;10156:35;-1:-1:-1;10214:36:34;10206:4;:44;;;;;;;;;10202:344;;;10273:63;10301:8;10311:14;10327:8;10273:27;:63::i;10202:344::-;10365:35;10357:4;:43;;;;;;;;;10353:193;;;10423:46;10450:8;10460;10423:26;:46::i;10353:193::-;10500:35;6233:3:7;10500:7:34;:35::i;19915:501::-;20023:51;20038:8;20048:9;20059:14;20023;:51::i;2816:682:14:-;2876:7;2895:38;2904:6;;;4486:1:7;2895:8:14;:38::i;:::-;2948:6;2944:548;;-1:-1:-1;2977:1:14;2970:8;;2944:548;863:4;3029:7;;;;3050:51;;3029:1;:7;:1;3059:13;;;3050:51;3475:1;3470;3458:9;:13;3457:19;;;;;;3480:1;3456:25;3449:32;;;;;1832:617;1892:7;1929:5;;;1944:57;1953:6;;;:26;;;1978:1;1973;1963:7;:11;;;;1944:57;2016:12;2012:431;;2051:1;2044:8;;;;;2012:431;863:4;2409:11;;;2408:19;;6663:739:34;6984:16;;;6998:1;6984:16;;;6864:25;6984:16;;;;;;6903:15;;;;6984:16;;;;;;;;;;;;-1:-1:-1;6984:16:34;6973:27;;7026:11;:19;;;-1:-1:-1;;;;;7015:30:34;:7;-1:-1:-1;;;;;7015:30:34;;7011:385;;;7071:1;7061:11;;7097:1;7086:12;;7127:14;7113:8;7122:1;7113:11;;;;;;;;;;;;;:28;;;;;7169:15;7155:8;7164:1;7155:11;;;;;;;;;;;;;:29;;;;;7011:385;;;7273:1;7262:12;;7298:1;7288:11;;7328:15;7314:8;7323:1;7314:11;;;;;;;;;;;;;:29;;;;;7371:14;7357:8;7366:1;7357:11;;;;;;;;;;;;;:28;;;;;7011:385;6663:739;;;;;;;:::o;829:144:35:-;889:19;938:4;927:39;;;;;;;;;;;;:::i;1143:179::-;1211:26;1276:4;1265:50;;;;;;;;;;;;:::i;17839:184:34:-;17938:14;:26;;;;17974:17;:42;17839:184::o;7898:294:19:-;7973:49;8002:1;8006:7;8015:6;7973:20;:49::i;:::-;8048:12;;:24;;8065:6;8048:16;:24::i;:::-;8033:12;:39;-1:-1:-1;;;;;8103:18:19;;:9;:18;;;;;;;;;;;:30;;8126:6;8103:22;:30::i;:::-;-1:-1:-1;;;;;8082:18:19;;:9;:18;;;;;;;;;;;:51;;;;8148:37;;8082:18;;:9;8148:37;;;;8178:6;;8148:37;:::i;7762:2462:33:-;7984:7;9474:17;9494:59;9514:22;9538:8;9548:4;9494:19;:59::i;:::-;9474:79;;9590:43;9618:14;9590:8;9599:13;9590:23;;;;;;;;;;;;;;:27;;:43;;;;:::i;:::-;9564:8;9573:13;9564:23;;;;;;;;;;;;;:69;;;;;9644:22;9669:166;9732:22;9768:8;9790:9;9813:12;9669:49;:166::i;:::-;9644:191;;10136:14;10110:8;10119:13;10110:23;;;;;;;;;;;;;;:40;10084:8;10093:13;10084:23;;;;;;;;;;;;;:66;;;;;10168:49;10215:1;10168:42;10187:8;10196:12;10187:22;;;;;;;;;;;;;;10168:14;:18;;:42;;;;:::i;:49::-;10161:56;7762:2462;-1:-1:-1;;;;;;;;7762:2462:33:o;5089:2455::-;5310:7;6804:17;6824:59;6844:22;6868:8;6878:4;6824:19;:59::i;:::-;6804:79;;6919:41;6946:13;6919:8;6928:12;6919:22;;;;;;;;;;;;;;:26;;:41;;;;:::i;:::-;6894:8;6903:12;6894:22;;;;;;;;;;;;;:66;;;;;6971:23;6997:167;7060:22;7096:8;7118:9;7141:13;6997:49;:167::i;:::-;6971:193;;7455:13;7430:8;7439:12;7430:22;;;;;;;;;;;;;;:38;7405:8;7414:12;7405:22;;;;;;;;;;;;;:63;;;;;7486:51;7535:1;7486:44;7514:15;7486:8;7495:13;7486:23;;;;;;;:44;:48;;:51::i;24451:353:34:-;24537:4;24585:66;24597:53;24585:11;:66::i;:::-;24573:8;:78;24572:175;;;-1:-1:-1;24681:65:34;24693:52;24681:11;:65::i;:::-;24669:8;:77;24572:175;:225;;;;24763:34;24788:8;24763:24;:34::i;6658:142:13:-;6767:14;1609:11;6759:34;;6658:142::o;21244:2412:33:-;21494:7;22898:28;22929:168;22992:22;23028:8;23050:13;23077:10;22929:49;:168::i;:::-;22898:199;;23136:20;23112:8;23121:10;23112:20;;;;;;;;;;;;;;:44;23108:319;;23415:1;23408:8;;;;;23108:319;23471:32;23529:20;23506:8;23515:10;23506:20;;;;;;;;;;;;;;:43;23471:78;;23566:83;863:4:14;23566:59:33;23599:25;23566:24;:32;;:59;;;;:::i;:::-;:67;;:83::i;14792:1073:34:-;14946:7;14955:16;2940:18:12;:16;:18::i;:::-;15058:19:34::1;15079:18:::0;15101:32:::1;:8;:30;:32::i;:::-;15057:76;;;;15244:62;15266:17;:15;:17::i;:::-;15253:10;:30;4808:3:7;15244:8:34;:62::i;:::-;15391:27;15435:17;:15;:17::i;:::-;15421:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;15421:32:34::1;;15391:62;;15525:18;15549:28;:26;:28::i;:::-;15524:53;;;15612:203;15665:10;15689:8;15711:10;15735:11;15760:13;:11;:13::i;:::-;15787:18;;15612:39;:203::i;:::-;15587:10;15598;15587:22;;;;;;;;;::::0;;::::1;::::0;;;;;:228;-1:-1:-1;15834:11:34;;;;-1:-1:-1;14792:1073:34;;-1:-1:-1;;;;14792:1073:34:o;15871:908::-;16004:7;16013:16;16456:19;16478:33;:8;:31;:33::i;:::-;16456:55;;16622:27;16652:78;16693:8;16703:11;16716:13;:11;:13::i;:::-;16652:40;:78::i;:::-;16748:11;;;;-1:-1:-1;15871:908:34;;-1:-1:-1;;;;15871:908:34:o;16785:916::-;16971:7;16980:16;2940:18:12;:16;:18::i;:::-;17079:27:34::1;17108:22;17134:33;:8;:31;:33::i;:::-;17078:89;;;;17177:73;17213:10;:17;17232;:15;:17::i;17177:73::-;17260:41;17274:10;17286:14;17260:13;:41::i;:::-;17313:18;17337:28;:26;:28::i;:::-;17312:53;;;17375:19;17397:179;17451:10;17475:8;17497:10;17521:13;:11;:13::i;:::-;17548:18;;17397:40;:179::i;:::-;17375:201;;17586:65;17610:14;17595:11;:29;;5468:3:7;17586:8:34;:65::i;:::-;17670:11:::0;17683:10;;-1:-1:-1;16785:916:34;;-1:-1:-1;;;;;;16785:916:34:o;2157:148:16:-;2219:7;2238:38;2247:6;;;4486:1:7;2238:8:16;:38::i;:::-;2297:1;2293;:5;;;;;;;2157:148;-1:-1:-1;;;2157:148:16:o;1353:121:23:-;1411:7;1437:30;1441:1;1444;4340::7;1437:3:23;:30::i;10558:835:34:-;10730:7;10739:16;10768:26;10796:23;10823:33;:8;:31;:33::i;:::-;10767:89;;;;10866:72;10902:17;:15;:17::i;:::-;10921:9;:16;10866:35;:72::i;:::-;10949:40;10963:9;10974:14;10949:13;:40::i;:::-;11001:18;11025:28;:26;:28::i;:::-;11000:53;;;11063:20;11086:178;11140:10;11164:8;11186:9;11209:13;:11;:13::i;:::-;11236:18;;11086:40;:178::i;:::-;11063:201;;11275:68;11300:15;11284:12;:31;;5524:3:7;11275:8:34;:68::i;11399:845::-;11531:7;11540:16;11573:20;11595:18;11617:32;:8;:30;:32::i;:::-;11572:77;;;;11759:62;11781:17;:15;:17::i;11759:62::-;11832:26;11875:17;:15;:17::i;:::-;11861:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11861:32:34;;11832:61;;11904:18;11928:28;:26;:28::i;:::-;11903:53;;;11990:204;12043:10;12067:8;12089:10;12113:12;12139:13;:11;:13::i;:::-;12166:18;;11990:39;:204::i;23816:2084:33:-;24034:7;24090:21;24139:8;:15;24114:22;:40;24090:64;;24164:11;24178:8;24187:1;24178:11;;;;;;;;;;;;;;24164:25;;24199:11;24227:8;:15;24213:8;24222:1;24213:11;;;;;;;;;;;;;;:29;24199:43;;24257:9;24269:1;24257:13;;24252:195;24276:8;:15;24272:1;:19;24252:195;;;24318:78;24331:53;24340:26;24349:3;24354:8;24363:1;24354:11;;;;;;;24340:26;24368:8;:15;24331:8;:53::i;:::-;24386:9;24318:12;:78::i;:::-;24312:84;;24416:20;24424:8;24433:1;24424:11;;;;;;;24416:20;24410:26;-1:-1:-1;24293:3:33;;24252:195;;;;24586:8;24595:10;24586:20;;;;;;;;;;;;;;24580:3;:26;24574:32;;24617:12;24632:30;24641:9;24652;24632:8;:30::i;:::-;24617:45;;24731:9;24743:138;24765:72;24774:46;24785:4;24791:28;24800:13;24815:3;24791:8;:28::i;24774:46::-;1225:3;24765:8;:72::i;:::-;24851:8;24860:10;24851:20;;;;;;;24743:138;24731:150;;24891:9;24903:73;24911:64;24920:38;24933:9;24944:13;24920:12;:38::i;24911:64::-;24903:3;;:7;:73::i;:::-;24891:85;-1:-1:-1;25029:24:33;;25227:41;25238:11;:4;25247:1;25238:8;:11::i;:::-;25251:16;:9;25265:1;25251:13;:16::i;25227:41::-;25204:64;;25284:9;25279:555;25303:3;25299:1;:7;25279:555;;;25346:12;25327:31;;25388:150;25416:43;25457:1;25416:36;25425:12;25439;25416:8;:36::i;:43::-;25477:47;25514:9;25477:32;25507:1;25477:25;25486:12;25500:1;25477:8;:25::i;25388:150::-;25373:165;;25572:16;25557:12;:31;25553:271;;;25647:1;25627:16;25612:12;:31;:36;25608:102;;-1:-1:-1;25679:12:33;-1:-1:-1;25672:19:33;;-1:-1:-1;;;;;;;25672:19:33;25608:102;25553:271;;;25769:1;25753:12;25734:16;:31;:36;25730:94;;-1:-1:-1;25797:12:33;-1:-1:-1;25790:19:33;;-1:-1:-1;;;;;;;25790:19:33;25730:94;25308:3;;25279:555;;;;25844:49;6950:3:7;25844:7:33;:49::i;:::-;23816:2084;;;;;;;;;;;;;;:::o;9377:271:4:-;9463:4;9511:47;9523:34;9511:11;:47::i;:::-;9499:8;:59;9498:143;;;-1:-1:-1;9588:52:4;9600:39;9588:11;:52::i;:::-;9576:64;;;;9377:271;-1:-1:-1;9377:271:4:o;1838:218:35:-;1911:19;1932:18;2003:4;1992:57;;;;;;;;;;;;:::i;:::-;1962:87;;;;-1:-1:-1;1838:218:35;-1:-1:-1;;;1838:218:35:o;17660:2060:33:-;17907:7;18089:24;18116:40;18136:3;18141:8;18151:4;18116:19;:40::i;:::-;18089:67;-1:-1:-1;18166:20:33;18189:77;18089:67;18189:53;18227:14;18189:31;18227:14;18208:11;18189:18;:31::i;:::-;:37;;:53::i;:::-;:59;;:77::i;:::-;18166:100;;18321:28;18352:148;18415:3;18432:8;18454:12;18480:10;18352:49;:148::i;:::-;18321:179;;18510:27;18540:46;18565:20;18540:8;18549:10;18540:20;;;;;;;:46;18510:76;;18731:19;18769:9;18764:113;18788:8;:15;18784:1;:19;18764:113;;;18838:28;18854:8;18863:1;18854:11;;;;;;;;;;;;;;18838;:15;;:28;;;;:::i;:::-;18824:42;-1:-1:-1;18805:3:33;;18764:113;;;;19032:21;19056:41;19085:11;19056:8;19065:10;19056:20;;;;;;;;;;;;;;:28;;:41;;;;:::i;:::-;19032:65;;19107:25;19135:26;:13;:24;:26::i;:::-;19107:54;-1:-1:-1;19372:21:33;19396:44;:19;19107:54;19396:25;:44::i;:::-;19372:68;-1:-1:-1;19450:24:33;19477:38;:19;19372:68;19477:23;:38::i;:::-;19450:65;-1:-1:-1;19634:79:33;19655:57;:13;863:4:14;19677:34:33;;;19655:21;:57::i;:::-;19634:16;;:20;:79::i;:::-;19627:86;;;;;;;;;;;17660:2060;;;;;;;;:::o;2062:178:35:-;2136:19;2196:4;2185:48;;;;;;;;;;;;:::i;19726:1459:33:-;19890:16;20900;20919:35;:11;20939:14;20919:19;:35::i;:::-;20900:54;;20965:27;21009:8;:15;20995:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20995:30:33;;20965:60;;21040:9;21035:116;21059:8;:15;21055:1;:19;21035:116;;;21111:29;21131:8;21111;21120:1;21111:11;;;;;;;;;;;;;;:19;;:29;;;;:::i;:::-;21095:10;21106:1;21095:13;;;;;;;;;;;;;;;;;:45;21076:3;;21035:116;;;-1:-1:-1;21168:10:33;19726:1459;-1:-1:-1;;;;;19726:1459:33:o;2246:264:35:-;2344:27;2373:22;2455:4;2444:59;;;;;;;;;;;;:::i;15004:2650:33:-;15232:7;;;15490:113;15514:8;:15;15510:1;:19;15490:113;;;15564:28;15580:8;15589:1;15580:11;;;;;;;15564:28;15550:42;-1:-1:-1;15531:3:33;;15490:113;;;;15686:40;15743:10;:17;15729:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;15729:32:33;;15686:75;;15771:33;15823:9;15818:337;15842:8;:15;15838:1;:19;15818:337;;;15878:21;15902:30;15920:11;15902:8;15911:1;15902:11;;;;;;;;;;;;;;:17;;:30;;;;:::i;:::-;15878:54;;15975:49;16012:8;16021:1;16012:11;;;;;;;;;;;;;;15975:30;15991:10;16002:1;15991:13;;;;;;;;;;;;;;15975:8;15984:1;15975:11;;;;;;;:49;15946:23;15970:1;15946:26;;;;;;;;;;;;;:78;;;;;16066;16096:47;16129:13;16096:23;16120:1;16096:26;;;;;;;;;;;;;;:32;;:47;;;;:::i;:::-;16066:25;;:29;:78::i;:::-;16038:106;-1:-1:-1;;15859:3:33;;15818:337;;;;16268:28;16313:8;:15;16299:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16299:30:33;;16268:61;;16344:9;16339:911;16363:8;:15;16359:1;:19;16339:911;;;16587:24;16657:23;16681:1;16657:26;;;;;;;;;;;;;;16629:25;:54;16625:550;;;16703:24;16730:59;16750:38;:25;:36;:38::i;:::-;16730:8;16739:1;16730:11;;;;;;;:59;16703:86;;16807:21;16831:35;16849:16;16831:10;16842:1;16831:13;;;;;;;:35;16807:59;-1:-1:-1;17012:77:33;17033:55;16807:59;863:4:14;17053:34:33;;;17033:19;:55::i;:::-;17012:16;;:20;:77::i;:::-;16993:96;;16625:550;;;;;17147:10;17158:1;17147:13;;;;;;;;;;;;;;17128:32;;16625:550;17206:33;17222:16;17206:8;17215:1;17206:11;;;;;;;:33;17189:11;17201:1;17189:14;;;;;;;;;;;;;;;;;:50;-1:-1:-1;16380:3:33;;16339:911;;;;17333:24;17360:40;17380:3;17385:8;17395:4;17360:19;:40::i;:::-;17333:67;;17410:20;17433:44;17453:3;17458:11;17471:5;17433:19;:44::i;:::-;17410:67;-1:-1:-1;17487:22:33;17512:38;17410:67;17533:16;17512:20;:38::i;:::-;17487:63;;17598:49;17619:27;:14;:25;:27::i;:::-;17598:14;;:20;:49::i;:::-;17591:56;15004:2650;-1:-1:-1;;;;;;;;;;;;;15004:2650:33:o;10230:2779::-;10457:7;;;10719:113;10743:8;:15;10739:1;:19;10719:113;;;10793:28;10809:8;10818:1;10809:11;;;;;;;10793:28;10779:42;-1:-1:-1;10760:3:33;;10719:113;;;;10915:37;10969:9;:16;10955:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10955:31:33;;10915:71;;11060:30;11109:9;11104:330;11128:8;:15;11124:1;:19;11104:330;;;11164:21;11188:32;11208:11;11188:8;11197:1;11188:11;;;;;;;:32;11164:56;;11260:50;11298:8;11307:1;11298:11;;;;;;;;;;;;;;11260:29;11276:9;11286:1;11276:12;;;;;;;;;;;;;;11260:8;11269:1;11260:11;;;;;;;:50;11234:20;11255:1;11234:23;;;;;;;;;;;;;:76;;;;;11349:74;11376:46;11408:13;11376:20;11397:1;11376:23;;;;;;;11349:74;11324:99;-1:-1:-1;;11145:3:33;;11104:330;;;;11547:28;11592:8;:15;11578:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11578:30:33;;11547:61;;11623:9;11618:826;11642:8;:15;11638:1;:19;11618:826;;;11678:26;11845:22;11819:20;11840:1;11819:23;;;;;;;;;;;;;;:48;11815:552;;;11887:24;11914:63;11934:42;:22;863:4:14;11934:26:33;:42::i;11914:63::-;11887:90;;11995:21;12019:34;12036:16;12019:9;12029:1;12019:12;;;;;;;:34;11995:58;-1:-1:-1;12201:79:33;12222:57;11995:58;863:4:14;12244:34:33;;;12222:21;:57::i;12201:79::-;12180:100;;11815:552;;;;;12340:9;12350:1;12340:12;;;;;;;;;;;;;;12319:33;;11815:552;12398:35;12414:18;12398:8;12407:1;12398:11;;;;;;;:35;12381:11;12393:1;12381:14;;;;;;;;;;;;;;;;;:52;-1:-1:-1;11659:3:33;;11618:826;;;;12527:24;12554:40;12574:3;12579:8;12589:4;12554:19;:40::i;:::-;12527:67;;12604:20;12627:44;12647:3;12652:11;12665:5;12627:19;:44::i;:::-;12604:67;-1:-1:-1;12681:22:33;12706:38;12604:67;12727:16;12706:20;:38::i;:::-;12681:63;;863:4:14;12844:14:33;:31;12840:163;;;12898:55;:14;12921:31;;;12898:22;:55::i;:::-;12891:62;;;;;;;;;;;12840:163;12991:1;12984:8;;;;;;;;;;;13015:1811;13263:7;13365:24;13392:40;13412:3;13417:8;13427:4;13392:19;:40::i;:::-;13365:67;-1:-1:-1;13478:20:33;13501:78;13365:67;13501:54;13540:14;13501:32;13540:14;13520:12;13501:18;:32::i;:78::-;13478:101;;13634:28;13665:148;13728:3;13745:8;13767:12;13793:10;13665:49;:148::i;:::-;13634:179;;13823:26;13852:46;13877:8;13886:10;13877:20;;;;;;;;;;;;;;13852;:24;;:46;;;;:::i;:::-;13823:75;;14043:19;14081:9;14076:113;14100:8;:15;14096:1;:19;14076:113;;;14150:28;14166:8;14175:1;14166:11;;;;;;;14150:28;14136:42;-1:-1:-1;14117:3:33;;14076:113;;;;14343:21;14367:41;14396:11;14367:8;14376:10;14367:20;;;;;;;:41;14343:65;;14418:25;14446:26;:13;:24;:26::i;:::-;14418:54;-1:-1:-1;14482:21:33;14506:43;:18;14418:54;14506:24;:43::i;:::-;14482:67;-1:-1:-1;14559:24:33;14586:37;:18;14482:67;14586:22;:37::i;:::-;14559:64;-1:-1:-1;14742:77:33;14763:55;:13;863:4:14;14783:34:33;;;14763:19;:55::i;4782:112:14:-;4836:7;863:4;4863:1;:7;4862:25;;4886:1;4862:25;;;-1:-1:-1;863:4:14;4875:7;;4782:112::o;5:130:-1:-;72:20;;97:33;72:20;97:33;:::i;1102:707::-;;1219:3;1212:4;1204:6;1200:17;1196:27;1186:2;;-1:-1;;1227:12;1186:2;1274:6;1261:20;1296:80;1311:64;1368:6;1311:64;:::i;:::-;1296:80;:::i;:::-;1404:21;;;1287:89;-1:-1;1448:4;1461:14;;;;1436:17;;;1550;;;1541:27;;;;1538:36;-1:-1;1535:2;;;1587:1;;1577:12;1535:2;1612:1;1597:206;1622:6;1619:1;1616:13;1597:206;;;6336:20;;1690:50;;1754:14;;;;1782;;;;1644:1;1637:9;1597:206;;;1601:14;;;;;1179:630;;;;:::o;1835:722::-;;1963:3;1956:4;1948:6;1944:17;1940:27;1930:2;;-1:-1;;1971:12;1930:2;2011:6;2005:13;2033:80;2048:64;2105:6;2048:64;:::i;2033:80::-;2141:21;;;2024:89;-1:-1;2185:4;2198:14;;;;2173:17;;;2287;;;2278:27;;;;2275:36;-1:-1;2272:2;;;2324:1;;2314:12;2272:2;2349:1;2334:217;2359:6;2356:1;2353:13;2334:217;;;6484:13;;2427:61;;2502:14;;;;2530;;;;2381:1;2374:9;2334:217;;3104:440;;3205:3;3198:4;3190:6;3186:17;3182:27;3172:2;;-1:-1;;3213:12;3172:2;3260:6;3247:20;33841:18;33833:6;33830:30;33827:2;;;-1:-1;;33863:12;33827:2;3282:64;34004:4;-1:-1;;3198:4;33921:6;33917:17;33913:33;33994:15;3282:64;:::i;:::-;3273:73;;3366:6;3359:5;3352:21;3470:3;34004:4;3461:6;3394;3452:16;;3449:25;3446:2;;;3487:1;;3477:12;3446:2;37444:6;34004:4;3394:6;3390:17;34004:4;3428:5;3424:16;37421:30;37500:1;37482:16;;;34004:4;37482:16;37475:27;3428:5;3165:379;-1:-1;;3165:379::o;4405:156::-;4485:20;;39175:1;39165:12;;39155:2;;39191:1;;39181:12;4610:1652;;4728:6;;4716:9;4711:3;4707:19;4703:32;4700:2;;;-1:-1;;4738:12;4700:2;4766:22;4728:6;4766:22;:::i;:::-;4757:31;;;4870:62;4928:3;4904:22;4870:62;:::i;:::-;4852:16;4845:88;5030:64;5090:3;4997:2;5070:9;5066:22;5030:64;:::i;:::-;4997:2;5016:5;5012:16;5005:90;5193:64;5253:3;5160:2;5233:9;5229:22;5193:64;:::i;:::-;5160:2;5179:5;5175:16;5168:90;5321:2;5379:9;5375:22;6336:20;5321:2;5340:5;5336:16;5329:75;5467:3;5526:9;5522:22;2898:20;5467:3;5487:5;5483:16;5476:75;5623:3;5682:9;5678:22;6336:20;5623:3;5643:5;5639:16;5632:75;5802:49;5847:3;5768;5827:9;5823:22;5802:49;:::i;:::-;5768:3;5788:5;5784:16;5777:75;5945:49;5990:3;5911;5970:9;5966:22;5945:49;:::i;:::-;5911:3;5931:5;5927:16;5920:75;6088:3;;6077:9;6073:19;6060:33;6113:18;6105:6;6102:30;6099:2;;;4838:1;;6135:12;6099:2;6182:58;6236:3;6227:6;6216:9;6212:22;6182:58;:::i;:::-;6088:3;6166:5;6162:18;6155:86;;;4694:1568;;;;:::o;6680:241::-;;6784:2;6772:9;6763:7;6759:23;6755:32;6752:2;;;-1:-1;;6790:12;6752:2;85:6;72:20;97:33;124:5;97:33;:::i;6928:366::-;;;7049:2;7037:9;7028:7;7024:23;7020:32;7017:2;;;-1:-1;;7055:12;7017:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7107:63;-1:-1;7207:2;7246:22;;72:20;97:33;72:20;97:33;:::i;:::-;7215:63;;;;7011:283;;;;;:::o;7301:491::-;;;;7439:2;7427:9;7418:7;7414:23;7410:32;7407:2;;;-1:-1;;7445:12;7407:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7497:63;-1:-1;7597:2;7636:22;;72:20;97:33;72:20;97:33;:::i;:::-;7401:391;;7605:63;;-1:-1;;;7705:2;7744:22;;;;6336:20;;7401:391::o;7799:991::-;;;;;;;;8003:3;7991:9;7982:7;7978:23;7974:33;7971:2;;;-1:-1;;8010:12;7971:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8062:63;-1:-1;8162:2;8201:22;;72:20;97:33;72:20;97:33;:::i;:::-;8170:63;-1:-1;8270:2;8309:22;;6336:20;;-1:-1;8378:2;8417:22;;6336:20;;-1:-1;8486:3;8524:22;;6612:20;36466:4;36455:16;;39388:33;;39378:2;;-1:-1;;39425:12;39378:2;7965:825;;;;-1:-1;7965:825;;;;8495:61;8593:3;8633:22;;2898:20;;-1:-1;8702:3;8742:22;;;2898:20;;7965:825;-1:-1;;7965:825::o;8797:366::-;;;8918:2;8906:9;8897:7;8893:23;8889:32;8886:2;;;-1:-1;;8924:12;8886:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8976:63;9076:2;9115:22;;;;6336:20;;-1:-1;;;8880:283::o;9170:823::-;;;;9384:2;9372:9;9363:7;9359:23;9355:32;9352:2;;;-1:-1;;9390:12;9352:2;9441:17;9435:24;9479:18;;9471:6;9468:30;9465:2;;;-1:-1;;9501:12;9465:2;9618:6;9607:9;9603:22;;;452:3;445:4;437:6;433:17;429:27;419:2;;-1:-1;;460:12;419:2;500:6;494:13;522:95;537:79;609:6;537:79;:::i;522:95::-;623:16;659:6;652:5;645:21;689:4;;706:3;702:14;695:21;;689:4;681:6;677:17;811:3;689:4;;795:6;791:17;681:6;782:27;;779:36;776:2;;;-1:-1;;818:12;776:2;-1:-1;844:10;;838:232;863:6;860:1;857:13;838:232;;;3999:6;3993:13;4011:48;4053:5;4011:48;:::i;:::-;931:76;;885:1;878:9;;;;;1021:14;;;;1049;;838:232;;;-1:-1;9678:18;;9672:25;9521:114;;-1:-1;9672:25;-1:-1;;;9706:30;;;9703:2;;;-1:-1;;9739:12;9703:2;;9769:89;9850:7;9841:6;9830:9;9826:22;9769:89;:::i;:::-;9759:99;;;9895:2;9949:9;9945:22;6484:13;9903:74;;9346:647;;;;;:::o;10000:235::-;;10101:2;10089:9;10080:7;10076:23;10072:32;10069:2;;;-1:-1;;10107:12;10069:2;2642:6;2629:20;2654:30;2678:5;2654:30;:::i;10242:257::-;;10354:2;10342:9;10333:7;10329:23;10325:32;10322:2;;;-1:-1;;10360:12;10322:2;2777:6;2771:13;2789:30;2813:5;2789:30;:::i;10506:1235::-;;;;;;;;10746:3;10734:9;10725:7;10721:23;10717:33;10714:2;;;-1:-1;;10753:12;10714:2;2911:6;2898:20;10805:63;;10905:2;10948:9;10944:22;72:20;97:33;124:5;97:33;:::i;:::-;10913:63;-1:-1;11013:2;11052:22;;72:20;97:33;72:20;97:33;:::i;:::-;11021:63;-1:-1;11149:2;11134:18;;11121:32;11173:18;11162:30;;;11159:2;;;-1:-1;;11195:12;11159:2;11225:78;11295:7;11286:6;11275:9;11271:22;11225:78;:::i;:::-;11215:88;;11340:3;11384:9;11380:22;6336:20;11349:63;;11449:3;11493:9;11489:22;6336:20;11458:63;;11586:3;11575:9;11571:19;11558:33;11544:47;;11173:18;11603:6;11600:30;11597:2;;;-1:-1;;11633:12;11597:2;;11663:62;11717:7;11708:6;11697:9;11693:22;11663:62;:::i;:::-;11653:72;;;10708:1033;;;;;;;;;;:::o;11748:239::-;;11851:2;11839:9;11830:7;11826:23;11822:32;11819:2;;;-1:-1;;11857:12;11819:2;3047:6;3034:20;35878:66;38510:5;35867:78;38486:5;38483:34;38473:2;;-1:-1;;38521:12;11994:303;;12129:2;12117:9;12108:7;12104:23;12100:32;12097:2;;;-1:-1;;12135:12;12097:2;3656:6;3650:13;3668:53;3715:5;3668:53;:::i;12304:500::-;;;12449:2;12437:9;12428:7;12424:23;12420:32;12417:2;;;-1:-1;;12455:12;12417:2;3828:6;3815:20;3840:48;3882:5;3840:48;:::i;:::-;12507:78;-1:-1;12650:2;12635:18;;12622:32;12674:18;12663:30;;12660:2;;;-1:-1;;12696:12;12660:2;12726:62;12780:7;12771:6;12760:9;12756:22;12726:62;:::i;:::-;12716:72;;;12411:393;;;;;:::o;12811:289::-;;12939:2;12927:9;12918:7;12914:23;12910:32;12907:2;;;-1:-1;;12945:12;12907:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;13107:690::-;;;;13294:2;13282:9;13273:7;13269:23;13265:32;13262:2;;;-1:-1;;13300:12;13262:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;13497:2;13482:18;;13476:25;13352:87;;-1:-1;13521:18;13510:30;;13507:2;;;-1:-1;;13543:12;13507:2;13573:89;13654:7;13645:6;13634:9;13630:22;13573:89;:::i;13804:425::-;;;13949:2;13937:9;13928:7;13924:23;13920:32;13917:2;;;-1:-1;;13955:12;13917:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;14131:2;14181:22;;;;6484:13;14007:87;;6484:13;;-1:-1;;;13911:318::o;14236:561::-;;;;14398:2;14386:9;14377:7;14373:23;14369:32;14366:2;;;-1:-1;;14404:12;14366:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;14580:2;14630:22;;6484:13;14699:2;14749:22;;;6484:13;14456:87;;6484:13;;-1:-1;6484:13;14360:437;-1:-1;;;14360:437::o;15100:554::-;;;15270:2;15258:9;15249:7;15245:23;15241:32;15238:2;;;-1:-1;;15276:12;15238:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;15473:2;15458:18;;15452:25;15328:87;;-1:-1;15497:18;15486:30;;15483:2;;;-1:-1;;15519:12;15483:2;15549:89;15630:7;15621:6;15610:9;15606:22;15549:89;:::i;16926:897::-;;;;;17135:3;17123:9;17114:7;17110:23;17106:33;17103:2;;;-1:-1;;17142:12;17103:2;17200:17;17187:31;17238:18;;17230:6;17227:30;17224:2;;;-1:-1;;17260:12;17224:2;17290:82;17364:7;17355:6;17344:9;17340:22;17290:82;:::i;:::-;17280:92;;17437:2;17426:9;17422:18;17409:32;17395:46;;17238:18;17453:6;17450:30;17447:2;;;-1:-1;;17483:12;17447:2;;17513:78;17583:7;17574:6;17563:9;17559:22;17513:78;:::i;:::-;17097:726;;17503:88;;-1:-1;;;;17628:2;17667:22;;6336:20;;17736:2;17775:22;6336:20;;17097:726;-1:-1;17097:726::o;17830:635::-;;;;17997:2;17985:9;17976:7;17972:23;17968:32;17965:2;;;-1:-1;;18003:12;17965:2;18061:17;18048:31;18099:18;18091:6;18088:30;18085:2;;;-1:-1;;18121:12;18085:2;18151:82;18225:7;18216:6;18205:9;18201:22;18151:82;:::i;:::-;18141:92;18270:2;18309:22;;6336:20;;-1:-1;18378:2;18417:22;;;6336:20;;17959:506;-1:-1;;;;17959:506::o;18472:241::-;;18576:2;18564:9;18555:7;18551:23;18547:32;18544:2;;;-1:-1;;18582:12;18544:2;-1:-1;6336:20;;18538:175;-1:-1;18538:175::o;18720:366::-;;;18841:2;18829:9;18820:7;18816:23;18812:32;18809:2;;;-1:-1;;18847:12;18809:2;-1:-1;;6336:20;;;18999:2;19038:22;;;6336:20;;-1:-1;18803:283::o;19093:672::-;;;;;19259:3;19247:9;19238:7;19234:23;19230:33;19227:2;;;-1:-1;;19266:12;19227:2;6490:6;6484:13;19318:74;;19429:2;19483:9;19479:22;6484:13;19437:74;;19548:2;19602:9;19598:22;6484:13;19556:74;;19667:2;19721:9;19717:22;220:13;238:33;265:5;238:33;:::i;:::-;19221:544;;;;-1:-1;19221:544;;-1:-1;;19221:544::o;20105:690::-;;20298:5;34287:12;34831:6;34826:3;34819:19;34868:4;;34863:3;34859:14;20310:93;;34868:4;20474:5;34141:14;-1:-1;20513:260;20538:6;20535:1;20532:13;20513:260;;;20599:13;;20985:37;;19926:14;;;;34674;;;;20560:1;20553:9;20513:260;;;-1:-1;20779:10;;20229:566;-1:-1;;;;;20229:566::o;21689:343::-;;21831:5;34287:12;34831:6;34826:3;34819:19;-1:-1;37589:101;37603:6;37600:1;37597:13;37589:101;;;34868:4;37670:11;;;;;37664:18;37651:11;;;;;37644:39;37618:10;37589:101;;;37705:6;37702:1;37699:13;37696:2;;;-1:-1;34868:4;37761:6;34863:3;37752:16;;37745:27;37696:2;-1:-1;38042:2;38022:14;-1:-1;;38018:28;21988:39;;;;34868:4;21988:39;;21779:253;-1:-1;;21779:253::o;23643:387::-;20985:37;;;35878:66;35867:78;23894:2;23885:12;;21280:56;23994:11;;;23785:245::o;24037:291::-;;37444:6;37439:3;37434;37421:30;37482:16;;37475:27;;;37482:16;24181:147;-1:-1;24181:147::o;24335:659::-;23188:66;23168:87;;23153:1;23274:11;;20985:37;;;;24846:12;;;20985:37;24957:12;;;24580:414::o;25001:222::-;-1:-1;;;;;36250:54;;;;20025:37;;25128:2;25113:18;;25099:124::o;25230:629::-;;25485:2;25506:17;25499:47;25560:108;25485:2;25474:9;25470:18;25654:6;25560:108;:::i;:::-;25716:9;25710:4;25706:20;25701:2;25690:9;25686:18;25679:48;25741:108;25844:4;25835:6;25741:108;:::i;25866:210::-;35701:13;;35694:21;20868:34;;25987:2;25972:18;;25958:118::o;26083:432::-;35701:13;;35694:21;20868:34;;26418:2;26403:18;;20985:37;;;;26501:2;26486:18;;20985:37;26260:2;26245:18;;26231:284::o;26522:222::-;20985:37;;;26649:2;26634:18;;26620:124::o;26751:444::-;20985:37;;;-1:-1;;;;;36250:54;;;27098:2;27083:18;;20025:37;36250:54;27181:2;27166:18;;20025:37;26934:2;26919:18;;26905:290::o;27202:780::-;20985:37;;;-1:-1;;;;;36250:54;;;27634:2;27619:18;;20025:37;36250:54;;;;27717:2;27702:18;;20025:37;27800:2;27785:18;;20985:37;27883:3;27868:19;;20985:37;;;;27967:3;27952:19;;20985:37;27469:3;27454:19;;27440:542::o;27989:668::-;20985:37;;;28393:2;28378:18;;20985:37;;;;28476:2;28461:18;;20985:37;;;;28559:2;28544:18;;20985:37;-1:-1;;;;;36250:54;28642:3;28627:19;;20025:37;28228:3;28213:19;;28199:458::o;28664:417::-;;21015:5;20992:3;20985:37;28837:2;28955;28944:9;28940:18;28933:48;28995:76;28837:2;28826:9;28822:18;29057:6;28995:76;:::i;29088:363::-;20985:37;;;-1:-1;;;;;36250:54;29437:2;29422:18;;22130:70;29258:2;29243:18;;29229:222::o;29458:548::-;20985:37;;;36466:4;36455:16;;;;29826:2;29811:18;;23596:35;29909:2;29894:18;;20985:37;29992:2;29977:18;;20985:37;29665:3;29650:19;;29636:370::o;30541:310::-;;30688:2;30709:17;30702:47;30763:78;30688:2;30677:9;30673:18;30827:6;30763:78;:::i;31087:481::-;;21015:5;20992:3;20985:37;31292:2;31410;31399:9;31395:18;31388:48;31450:108;31292:2;31281:9;31277:18;31544:6;31450:108;:::i;31575:432::-;20985:37;;;35701:13;;35694:21;31910:2;31895:18;;20868:34;31993:2;31978:18;;20985:37;31752:2;31737:18;;31723:284::o;32014:556::-;20985:37;;;32390:2;32375:18;;20985:37;;;;32473:2;32458:18;;20985:37;32556:2;32541:18;;20985:37;32225:3;32210:19;;32196:374::o;32577:214::-;36466:4;36455:16;;;;23596:35;;32700:2;32685:18;;32671:120::o;32798:256::-;32860:2;32854:9;32886:17;;;32961:18;32946:34;;32982:22;;;32943:62;32940:2;;;33018:1;;33008:12;32940:2;32860;33027:22;32838:216;;-1:-1;32838:216::o;33061:319::-;;33235:18;33227:6;33224:30;33221:2;;;-1:-1;;33257:12;33221:2;-1:-1;33302:4;33290:17;;;33355:15;;33158:222::o;38059:117::-;-1:-1;;;;;38146:5;36250:54;38121:5;38118:35;38108:2;;38167:1;;38157:12;38183:111;38264:5;35701:13;35694:21;38242:5;38239:32;38229:2;;38285:1;;38275:12;38865:107;38947:1;38940:5;38937:12;38927:2;;38963:1;;38953:12
Swarm Source
ipfs://74699730ea8aa4fa00d2702d985bebe2cf30c6abf09e7ee52a1750d232c882ff
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.