ERC-20
Overview
Max Total Supply
5,192,296,858,534,827.628530496329220095 bb-yv-DAI
Holders
14
Total Transfers
-
Market
Price
$0.00 @ 0.000000 FTM
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Name:
YearnLinearPool
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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BalancerErrors.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ERC20Helpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-pool-utils/contracts/BasePool.sol"; import "@balancer-labs/v2-pool-utils/contracts/interfaces/IRateProvider.sol"; import "@balancer-labs/v2-pool-utils/contracts/rates/PriceRateCache.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IGeneralPool.sol"; import "./LinearMath.sol"; import "./LinearPoolUserData.sol"; /** * @dev Linear Pools are designed to hold two assets: "main" and "wrapped" tokens that have an equal value underlying * token (e.g., DAI and waDAI). There must be an external feed available to provide an exact, non-manipulable exchange * rate between the tokens. In particular, any reversible manipulation (e.g. causing the rate to increase and then * decrease) can lead to severe issues and loss of funds. * * The Pool will register three tokens in the Vault however: the two assets and the BPT itself, * so that BPT can be exchanged (effectively joining and exiting) via swaps. * * Despite inheriting from BasePool, much of the basic behavior changes. This Pool does not support regular joins and * exits, as the entire BPT supply is 'preminted' during initialization. * * Unlike most other Pools, this one does not attempt to create revenue by charging fees: value is derived by holding * the wrapped, yield-bearing asset. However, the 'swap fee percentage' value is still used, albeit with a different * meaning. This Pool attempts to hold a certain amount of "main" tokens, between a lower and upper target value. * The pool charges fees on trades that move the balance outside that range, which are then paid back as incentives to * traders whose swaps return the balance to the desired region. * The net revenue via fees is expected to be zero: all collected fees are used to pay for this 'rebalancing'. */ abstract contract LinearPool is BasePool, IGeneralPool, IRateProvider { using WordCodec for bytes32; using FixedPoint for uint256; using PriceRateCache for bytes32; using LinearPoolUserData for bytes; uint256 private constant _TOTAL_TOKENS = 3; // Main token, wrapped token, BPT // This is the maximum token amount the Vault can hold. In regular operation, the total BPT supply remains constant // and equal to _INITIAL_BPT_SUPPLY, but most of it remains in the Pool, waiting to be exchanged for tokens. The // actual amount of BPT in circulation is the total supply minus the amount held by the Pool, and is known as the // 'virtual supply'. // The total supply can only change if the emergency pause is activated by governance, enabling an // alternative proportional exit that burns BPT. As this is not expected to happen, we optimize for // success by using _INITIAL_BPT_SUPPLY instead of totalSupply(), saving a storage read. This optimization is only // valid if the Pool is never paused: in case of an emergency that leads to burned tokens, the Pool should not // be used after the buffer period expires and it automatically 'unpauses'. uint256 private constant _INITIAL_BPT_SUPPLY = 2**(112) - 1; IERC20 private immutable _mainToken; IERC20 private immutable _wrappedToken; // The indices of each token when registered, which can then be used to access the balances array. uint256 private immutable _bptIndex; uint256 private immutable _mainIndex; uint256 private immutable _wrappedIndex; // Both BPT and the main token have a regular, constant scaling factor (equal to FixedPoint.ONE for BPT, and // dependent on the number of decimals for the main token). However, the wrapped token's scaling factor has two // components: the usual token decimal scaling factor, and an externally provided rate used to convert wrapped // tokens to an equivalent main token amount. This external rate is expected to be ever increasing, reflecting the // fact that the wrapped token appreciates in value over time (e.g. because it is accruing interest). uint256 private immutable _scalingFactorMainToken; uint256 private immutable _scalingFactorWrappedToken; // The lower and upper target are in BasePool's misc data field, which has 192 bits available (as it shares the same // storage slot as the swap fee percentage, which is 64 bits). These are already scaled by the main token's scaling // factor, which means that the maximum upper target is ~80 billion in the main token units if the token were to // have 18 decimals (2^(192/2) / 10^18), which is more than enough. // [ 64 bits | 96 bits | 96 bits ] // [ reserved | upper target | lower target ] // [ base pool swap fee | misc data ] // [ MSB LSB ] uint256 private constant _LOWER_TARGET_OFFSET = 0; uint256 private constant _UPPER_TARGET_OFFSET = 96; uint256 private constant _MAX_UPPER_TARGET = 2**(96) - 1; event TargetsSet(IERC20 indexed token, uint256 lowerTarget, uint256 upperTarget); constructor( IVault vault, string memory name, string memory symbol, IERC20 mainToken, IERC20 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BasePool( vault, IVault.PoolSpecialization.GENERAL, name, symbol, _sortTokens(mainToken, wrappedToken, this), new address[](_TOTAL_TOKENS), swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // Set tokens _mainToken = mainToken; _wrappedToken = wrappedToken; // Set token indexes (uint256 mainIndex, uint256 wrappedIndex, uint256 bptIndex) = _getSortedTokenIndexes( mainToken, wrappedToken, this ); _bptIndex = bptIndex; _mainIndex = mainIndex; _wrappedIndex = wrappedIndex; // Set scaling factors _scalingFactorMainToken = _computeScalingFactor(mainToken); _scalingFactorWrappedToken = _computeScalingFactor(wrappedToken); // Set initial targets. Lower target must be set to zero because initially there are no fees accumulated. // Otherwise the pool will owe fees at start which results in a manipulable rate. uint256 lowerTarget = 0; _setTargets(mainToken, lowerTarget, upperTarget); } function getMainToken() public view returns (address) { return address(_mainToken); } function getWrappedToken() external view returns (address) { return address(_wrappedToken); } function getBptIndex() external view returns (uint256) { return _bptIndex; } function getMainIndex() external view returns (uint256) { return _mainIndex; } function getWrappedIndex() external view returns (uint256) { return _wrappedIndex; } /** * @dev Finishes initialization of the Linear Pool: it is unusable before calling this function as no BPT will have * been minted. * * Since Linear Pools have preminted BPT stored in the Vault, they require an initial join to deposit said BPT as * their balance. Unfortunately, this cannot be performed during construction, as a join involves calling the * `onJoinPool` function on the Pool, and the Pool will not have any code until construction finishes. Therefore, * this must happen in a separate call. * * It is highly recommended to create Linear pools using the LinearPoolFactory, which calls `initialize` * automatically. */ function initialize() external { bytes32 poolId = getPoolId(); (IERC20[] memory tokens, , ) = getVault().getPoolTokens(poolId); // Joins typically involve the Pool receiving tokens in exchange for newly-minted BPT. In this case however, the // Pool will mint the entire BPT supply to itself, and join itself with it. uint256[] memory maxAmountsIn = new uint256[](_TOTAL_TOKENS); maxAmountsIn[_bptIndex] = _INITIAL_BPT_SUPPLY; // The first time this executes, it will call `_onInitializePool` (as the BPT supply will be zero). Future calls // will be routed to `_onJoinPool`, which always reverts, meaning `initialize` will only execute once. IVault.JoinPoolRequest memory request = IVault.JoinPoolRequest({ assets: _asIAsset(tokens), maxAmountsIn: maxAmountsIn, userData: "", fromInternalBalance: false }); getVault().joinPool(poolId, address(this), address(this), request); } /** * @dev Implementation of onSwap, from IGeneralPool. */ function onSwap( SwapRequest memory request, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) public view override onlyVault(request.poolId) whenNotPaused returns (uint256) { // In most Pools, swaps involve exchanging one token held by the Pool for another. In this case however, since // one of the three tokens is the BPT itself, a swap might also be a join (main/wrapped for BPT) or an exit // (BPT for main/wrapped). // All three swap types (swaps, joins and exits) are fully disabled if the emergency pause is enabled. Under // these circumstances, the Pool should be exited using the regular Vault.exitPool function. // Sanity check: this is not entirely necessary as the Vault's interface enforces the indices to be valid, but // the check is cheap to perform. _require(indexIn < _TOTAL_TOKENS && indexOut < _TOTAL_TOKENS, Errors.OUT_OF_BOUNDS); // Note that we already know the indices of the main token, wrapped token and BPT, so there is no need to pass // these indices to the inner functions. // Upscale balances by the scaling factors (taking into account the wrapped token rate) uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 lowerTarget, uint256 upperTarget) = getTargets(); LinearMath.Params memory params = LinearMath.Params({ fee: getSwapFeePercentage(), lowerTarget: lowerTarget, upperTarget: upperTarget }); if (request.kind == IVault.SwapKind.GIVEN_IN) { // The amount given is for token in, the amount calculated is for token out request.amount = _upscale(request.amount, scalingFactors[indexIn]); uint256 amountOut = _onSwapGivenIn(request, balances, params); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactors[indexOut]); } else { // The amount given is for token out, the amount calculated is for token in request.amount = _upscale(request.amount, scalingFactors[indexOut]); uint256 amountIn = _onSwapGivenOut(request, balances, params); // amountIn tokens are entering the Pool, so we round up. return _downscaleUp(amountIn, scalingFactors[indexIn]); } } function _onSwapGivenIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { if (request.tokenIn == this) { return _swapGivenBptIn(request, balances, params); } else if (request.tokenIn == _mainToken) { return _swapGivenMainIn(request, balances, params); } else if (request.tokenIn == _wrappedToken) { return _swapGivenWrappedIn(request, balances, params); } else { _revert(Errors.INVALID_TOKEN); } } function _swapGivenBptIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _mainToken || request.tokenOut == _wrappedToken, Errors.INVALID_TOKEN); return (request.tokenOut == _mainToken ? LinearMath._calcMainOutPerBptIn : LinearMath._calcWrappedOutPerBptIn)( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ); } function _swapGivenMainIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _wrappedToken || request.tokenOut == this, Errors.INVALID_TOKEN); return request.tokenOut == this ? LinearMath._calcBptOutPerMainIn( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcWrappedOutPerMainIn(request.amount, balances[_mainIndex], params); } function _swapGivenWrappedIn( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenOut == _mainToken || request.tokenOut == this, Errors.INVALID_TOKEN); return request.tokenOut == this ? LinearMath._calcBptOutPerWrappedIn( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcMainOutPerWrappedIn(request.amount, balances[_mainIndex], params); } function _onSwapGivenOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { if (request.tokenOut == this) { return _swapGivenBptOut(request, balances, params); } else if (request.tokenOut == _mainToken) { return _swapGivenMainOut(request, balances, params); } else if (request.tokenOut == _wrappedToken) { return _swapGivenWrappedOut(request, balances, params); } else { _revert(Errors.INVALID_TOKEN); } } function _swapGivenBptOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _mainToken || request.tokenIn == _wrappedToken, Errors.INVALID_TOKEN); return (request.tokenIn == _mainToken ? LinearMath._calcMainInPerBptOut : LinearMath._calcWrappedInPerBptOut)( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ); } function _swapGivenMainOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _wrappedToken || request.tokenIn == this, Errors.INVALID_TOKEN); return request.tokenIn == this ? LinearMath._calcBptInPerMainOut( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcWrappedInPerMainOut(request.amount, balances[_mainIndex], params); } function _swapGivenWrappedOut( SwapRequest memory request, uint256[] memory balances, LinearMath.Params memory params ) internal view returns (uint256) { _require(request.tokenIn == _mainToken || request.tokenIn == this, Errors.INVALID_TOKEN); return request.tokenIn == this ? LinearMath._calcBptInPerWrappedOut( request.amount, balances[_mainIndex], balances[_wrappedIndex], _getApproximateVirtualSupply(balances[_bptIndex]), params ) : LinearMath._calcMainInPerWrappedOut(request.amount, balances[_mainIndex], params); } function _onInitializePool( bytes32, address sender, address recipient, uint256[] memory, bytes memory ) internal view override whenNotPaused returns (uint256, uint256[] memory) { // Linear Pools can only be initialized by the Pool performing the initial join via the `initialize` function. _require(sender == address(this), Errors.INVALID_INITIALIZATION); _require(recipient == address(this), Errors.INVALID_INITIALIZATION); // The full BPT supply will be minted and deposited in the Pool. Note that there is no need to approve the Vault // as it already has infinite BPT allowance. uint256 bptAmountOut = _INITIAL_BPT_SUPPLY; uint256[] memory amountsIn = new uint256[](_TOTAL_TOKENS); amountsIn[_bptIndex] = _INITIAL_BPT_SUPPLY; return (bptAmountOut, amountsIn); } function _onJoinPool( bytes32, address, address, uint256[] memory, uint256, uint256, uint256[] memory, bytes memory ) internal pure override returns ( uint256, uint256[] memory, uint256[] memory ) { _revert(Errors.UNHANDLED_BY_LINEAR_POOL); } function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256, uint256, uint256[] memory, bytes memory userData ) internal view override returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits typically revert, except for the proportional exit when the emergency pause mechanism has been // triggered. This allows for a simple and safe way to exit the Pool. // Note that the rate cache will not be automatically updated in such a scenario (though this can be still done // manually). This however should not lead to any issues as the rate is not important during the emergency exit. // On the contrary, decoupling the rate provider from the emergency exit might be useful under these // circumstances. LinearPoolUserData.ExitKind kind = userData.exitKind(); if (kind != LinearPoolUserData.ExitKind.EMERGENCY_EXACT_BPT_IN_FOR_TOKENS_OUT) { _revert(Errors.UNHANDLED_BY_LINEAR_POOL); } else { _ensurePaused(); // Note that this will cause the user's BPT to be burned, which is not something that happens during // regular operation of this Pool, and may lead to accounting errors. Because of this, it is highly // advisable to stop using a Pool after it is paused and the pause window expires. (bptAmountIn, amountsOut) = _emergencyProportionalExit(balances, userData); // Due protocol fees are set to zero as this Pool accrues no fees and pays no protocol fees. dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); } } function _emergencyProportionalExit(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This proportional exit function is only enabled if the contract is paused, to provide users a way to // retrieve their tokens in case of an emergency. // // This particular exit function is the only one available because it is the simplest, and therefore least // likely to be incorrect, or revert and lock funds. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. // This process burns BPT, rendering `_getApproximateVirtualSupply` inaccurate, so we use the real method here uint256[] memory amountsOut = LinearMath._calcTokensOutGivenExactBptIn( balances, bptAmountIn, _getVirtualSupply(balances[_bptIndex]), _bptIndex ); return (bptAmountIn, amountsOut); } function _getMaxTokens() internal pure override returns (uint256) { return _TOTAL_TOKENS; } function _getMinimumBpt() internal pure override returns (uint256) { // Linear Pools don't lock any BPT, as the total supply will already be forever non-zero due to the preminting // mechanism, ensuring initialization only occurs once. return 0; } function _getTotalTokens() internal view virtual override returns (uint256) { return _TOTAL_TOKENS; } function _scalingFactor(IERC20 token) internal view virtual override returns (uint256) { if (token == _mainToken) { return _scalingFactorMainToken; } else if (token == _wrappedToken) { // The wrapped token's scaling factor is not constant, but increases over time as the wrapped token // increases in value. return _scalingFactorWrappedToken.mulDown(_getWrappedTokenRate()); } else if (token == this) { return FixedPoint.ONE; } else { _revert(Errors.INVALID_TOKEN); } } function _scalingFactors() internal view virtual override returns (uint256[] memory) { uint256[] memory scalingFactors = new uint256[](_TOTAL_TOKENS); // The wrapped token's scaling factor is not constant, but increases over time as the wrapped token increases in // value. scalingFactors[_mainIndex] = _scalingFactorMainToken; scalingFactors[_wrappedIndex] = _scalingFactorWrappedToken.mulDown(_getWrappedTokenRate()); scalingFactors[_bptIndex] = FixedPoint.ONE; return scalingFactors; } // Price rates /** * @dev For a Linear Pool, the rate represents the appreciation of BPT with respect to the underlying tokens. This * rate increases slowly as the wrapped token appreciates in value. */ function getRate() external view override returns (uint256) { bytes32 poolId = getPoolId(); (, uint256[] memory balances, ) = getVault().getPoolTokens(poolId); _upscaleArray(balances, _scalingFactors()); (uint256 lowerTarget, uint256 upperTarget) = getTargets(); LinearMath.Params memory params = LinearMath.Params({ fee: getSwapFeePercentage(), lowerTarget: lowerTarget, upperTarget: upperTarget }); uint256 totalBalance = LinearMath._calcInvariant( LinearMath._toNominal(balances[_mainIndex], params), balances[_wrappedIndex] ); // Note that we're dividing by the virtual supply, which may be zero (causing this call to revert). However, the // only way for that to happen would be for all LPs to exit the Pool, and nothing prevents new LPs from // joining it later on. return totalBalance.divUp(_getApproximateVirtualSupply(balances[_bptIndex])); } function getWrappedTokenRate() external view returns (uint256) { return _getWrappedTokenRate(); } function _getWrappedTokenRate() internal view virtual returns (uint256); function getTargets() public view returns (uint256 lowerTarget, uint256 upperTarget) { bytes32 miscData = _getMiscData(); lowerTarget = miscData.decodeUint96(_LOWER_TARGET_OFFSET); upperTarget = miscData.decodeUint96(_UPPER_TARGET_OFFSET); } function _setTargets( IERC20 mainToken, uint256 lowerTarget, uint256 upperTarget ) private { _require(lowerTarget <= upperTarget, Errors.LOWER_GREATER_THAN_UPPER_TARGET); _require(upperTarget <= _MAX_UPPER_TARGET, Errors.UPPER_TARGET_TOO_HIGH); // Pack targets as two uint96 values into a single storage slot. This results in targets being capped to 96 // bits, but that should be more than enough. _setMiscData( WordCodec.encodeUint(lowerTarget, _LOWER_TARGET_OFFSET) | WordCodec.encodeUint(upperTarget, _UPPER_TARGET_OFFSET) ); emit TargetsSet(mainToken, lowerTarget, upperTarget); } function setTargets(uint256 newLowerTarget, uint256 newUpperTarget) external authenticate { // For a new target range to be valid: // - the pool must currently be between the current targets (meaning no fees are currently pending) // - the pool must currently be between the new targets (meaning setting them does not cause for fees to be // pending) // // The first requirement could be relaxed, as the LPs actually benefit from the pending fees not being paid out, // but being stricter makes analysis easier at little expense. (uint256 currentLowerTarget, uint256 currentUpperTarget) = getTargets(); _require(_isMainBalanceWithinTargets(currentLowerTarget, currentUpperTarget), Errors.OUT_OF_TARGET_RANGE); _require(_isMainBalanceWithinTargets(newLowerTarget, newUpperTarget), Errors.OUT_OF_NEW_TARGET_RANGE); _setTargets(_mainToken, newLowerTarget, newUpperTarget); } function setSwapFeePercentage(uint256 swapFeePercentage) public override { // For the swap fee percentage to be changeable: // - the pool must currently be between the current targets (meaning no fees are currently pending) // // As the amount of accrued fees is not explicitly stored but rather derived from the main token balance and the // current swap fee percentage, requiring for no fees to be pending prevents the fee setter from changing the // amount of pending fees, which they could use to e.g. drain Pool funds in the form of inflated fees. (uint256 lowerTarget, uint256 upperTarget) = getTargets(); _require(_isMainBalanceWithinTargets(lowerTarget, upperTarget), Errors.OUT_OF_TARGET_RANGE); super.setSwapFeePercentage(swapFeePercentage); } function _isMainBalanceWithinTargets(uint256 lowerTarget, uint256 upperTarget) private view returns (bool) { bytes32 poolId = getPoolId(); (, uint256[] memory balances, ) = getVault().getPoolTokens(poolId); uint256 mainTokenBalance = _upscale(balances[_mainIndex], _scalingFactor(_mainToken)); return mainTokenBalance >= lowerTarget && mainTokenBalance <= upperTarget; } function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) { return actionId == getActionId(this.setTargets.selector) || super._isOwnerOnlyAction(actionId); } /** * @dev Returns the number of tokens in circulation. * * In other pools, this would be the same as `totalSupply`, but since this pool pre-mints all BPT, `totalSupply` * remains constant, whereas `virtualSupply` increases as users join the pool and decreases as they exit it. */ function getVirtualSupply() external view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // We technically don't need to upscale the BPT balance as its scaling factor is equal to one (since BPT has // 18 decimals), but we do it for completeness. uint256 bptBalance = _upscale(balances[_bptIndex], _scalingFactor(this)); return _getVirtualSupply(bptBalance); } function _getVirtualSupply(uint256 bptBalance) internal view returns (uint256) { return totalSupply().sub(bptBalance); } /** * @dev Computes an approximation of virtual supply, which costs less gas than `_getVirtualSupply` and returns the * same value in all cases except when the emergency pause has been enabled and BPT burned as part of the emergency * exit process. */ function _getApproximateVirtualSupply(uint256 bptBalance) internal pure returns (uint256) { // No need for checked arithmetic as _INITIAL_BPT_SUPPLY is always greater than any valid Vault BPT balance. return _INITIAL_BPT_SUPPLY - bptBalance; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.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; uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326; uint256 internal constant SWAPS_DISABLED = 327; uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328; uint256 internal constant PRICE_RATE_OVERFLOW = 329; uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330; uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331; uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332; uint256 internal constant UPPER_TARGET_TOO_HIGH = 333; uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334; uint256 internal constant OUT_OF_TARGET_RANGE = 335; uint256 internal constant UNHANDLED_EXIT_KIND = 336; uint256 internal constant UNAUTHORIZED_EXIT = 337; uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338; uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339; uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340; uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341; uint256 internal constant INVALID_INITIALIZATION = 342; uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343; uint256 internal constant UNAUTHORIZED_OPERATION = 344; uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345; // 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; uint256 internal constant CALL_TO_NON_CONTRACT = 429; uint256 internal constant LOW_LEVEL_CALL_FAILED = 430; uint256 internal constant NOT_PAUSED = 431; uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432; uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433; // 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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-vault/contracts/interfaces/IAsset.sol"; import "../openzeppelin/IERC20.sol"; // solhint-disable function _asIAsset(IERC20[] memory tokens) pure returns (IAsset[] memory assets) { // solhint-disable-next-line no-inline-assembly assembly { assets := tokens } } function _sortTokens( IERC20 tokenA, IERC20 tokenB, IERC20 tokenC ) pure returns (IERC20[] memory tokens) { (uint256 indexTokenA, uint256 indexTokenB, uint256 indexTokenC) = _getSortedTokenIndexes(tokenA, tokenB, tokenC); tokens = new IERC20[](3); tokens[indexTokenA] = tokenA; tokens[indexTokenB] = tokenB; tokens[indexTokenC] = tokenC; } function _insertSorted(IERC20[] memory tokens, IERC20 token) pure returns (IERC20[] memory sorted) { sorted = new IERC20[](tokens.length + 1); if (tokens.length == 0) { sorted[0] = token; return sorted; } uint256 i; for (i = tokens.length; i > 0 && tokens[i - 1] > token; i--) sorted[i] = tokens[i - 1]; for (uint256 j = 0; j < i; j++) sorted[j] = tokens[j]; sorted[i] = token; } function _getSortedTokenIndexes( IERC20 tokenA, IERC20 tokenB, IERC20 tokenC ) pure returns ( uint256 indexTokenA, uint256 indexTokenB, uint256 indexTokenC ) { if (tokenA < tokenB) { if (tokenB < tokenC) { // (tokenA, tokenB, tokenC) return (0, 1, 2); } else if (tokenA < tokenC) { // (tokenA, tokenC, tokenB) return (0, 2, 1); } else { // (tokenC, tokenA, tokenB) return (1, 2, 0); } } else { // tokenB < tokenA if (tokenC < tokenB) { // (tokenC, tokenB, tokenA) return (2, 1, 0); } else if (tokenC < tokenA) { // (tokenB, tokenC, tokenA) return (2, 0, 1); } else { // (tokenB, tokenA, tokenC) return (1, 0, 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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/helpers/WordCodec.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 "@balancer-labs/v2-asset-manager-utils/contracts/IAssetManager.sol"; import "./BalancerPoolToken.sol"; import "./BasePoolAuthorization.sol"; // solhint-disable max-states-count /** * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with optional * 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 WordCodec for bytes32; using FixedPoint for uint256; uint256 private constant _MIN_TOKENS = 2; uint256 private constant _DEFAULT_MINIMUM_BPT = 1e6; // 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% - this fits in 64 bits // Storage slot that can be used to store unrelated pieces of information. In particular, by default is used // to store only the swap fee percentage of a pool. But it can be extended to store some more pieces of information. // The swap fee percentage is stored in the most-significant 64 bits, therefore the remaining 192 bits can be // used to store any other piece of information. bytes32 private _miscData; uint256 private constant _SWAP_FEE_PERCENTAGE_OFFSET = 192; bytes32 private immutable _poolId; 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, vault) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration) { _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS); _require(tokens.length <= _getMaxTokens(), 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 _poolId = poolId; } // Getters / Setters function getPoolId() public view override returns (bytes32) { return _poolId; } function _getTotalTokens() internal view virtual returns (uint256); function _getMaxTokens() internal pure virtual returns (uint256); /** * @dev Returns the minimum BPT supply. This amount is minted to the zero address during initialization, effectively * locking it. * * This is useful to make sure Pool initialization happens only once, but derived Pools can change this value (even * to zero) by overriding this function. */ function _getMinimumBpt() internal pure virtual returns (uint256) { return _DEFAULT_MINIMUM_BPT; } function getSwapFeePercentage() public view returns (uint256) { return _miscData.decodeUint64(_SWAP_FEE_PERCENTAGE_OFFSET); } 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); _miscData = _miscData.insertUint64(swapFeePercentage, _SWAP_FEE_PERCENTAGE_OFFSET); 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)); } function _getMiscData() internal view returns (bytes32) { return _miscData; } /** * Inserts data into the least-significant 192 bits of the misc data storage slot. * Note that the remaining 64 bits are used for the swap fee percentage and cannot be overloaded. */ function _setMiscData(bytes32 newData) internal { _miscData = _miscData.insertBits192(newData, 0); } // 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 _getMinimumBpt() 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 >= _getMinimumBpt(), Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _getMinimumBpt()); _mintPoolTokens(recipient, bptAmountOut - _getMinimumBpt()); // 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 _getMinimumBpt(), 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(getSwapFeePercentage())); } /** * @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(getSwapFeePercentage()); 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) internal view returns (uint256) { if (address(token) == address(this)) { return FixedPoint.ONE; } // 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); /** * @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); function getScalingFactors() external view returns (uint256[] memory) { 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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IRateProvider { /** * @dev Returns an 18 decimal fixed point number that is the exchange rate of the token to some other underlying * token. The meaning of this rate depends on the context. */ function getRate() 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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BalancerErrors.sol"; /** * Price rate caches are used to avoid querying the price rate for a token every time we need to work with it. It is * useful for slow changing rates, such as those that arise from interest-bearing tokens (e.g. waDAI into DAI). * * The cache data is packed into a single bytes32 value with the following structure: * [ expires | duration | price rate value ] * [ uint64 | uint64 | uint128 ] * [ MSB LSB ] * * * 'rate' is an 18 decimal fixed point number, supporting rates of up to ~3e20. 'expires' is a Unix timestamp, and * 'duration' is expressed in seconds. */ library PriceRateCache { using WordCodec for bytes32; uint256 private constant _PRICE_RATE_CACHE_VALUE_OFFSET = 0; uint256 private constant _PRICE_RATE_CACHE_DURATION_OFFSET = 128; uint256 private constant _PRICE_RATE_CACHE_EXPIRES_OFFSET = 128 + 64; /** * @dev Returns the rate of a price rate cache. */ function getRate(bytes32 cache) internal pure returns (uint256) { return cache.decodeUint128(_PRICE_RATE_CACHE_VALUE_OFFSET); } /** * @dev Returns the duration of a price rate cache. */ function getDuration(bytes32 cache) internal pure returns (uint256) { return cache.decodeUint64(_PRICE_RATE_CACHE_DURATION_OFFSET); } /** * @dev Returns the duration and expiration time of a price rate cache. */ function getTimestamps(bytes32 cache) internal pure returns (uint256 duration, uint256 expires) { duration = getDuration(cache); expires = cache.decodeUint64(_PRICE_RATE_CACHE_EXPIRES_OFFSET); } /** * @dev Encodes rate and duration into a price rate cache. The expiration time is computed automatically, counting * from the current time. */ function encode(uint256 rate, uint256 duration) internal view returns (bytes32) { _require(rate < 2**128, Errors.PRICE_RATE_OVERFLOW); // solhint-disable not-rely-on-time return WordCodec.encodeUint(uint128(rate), _PRICE_RATE_CACHE_VALUE_OFFSET) | WordCodec.encodeUint(uint64(duration), _PRICE_RATE_CACHE_DURATION_OFFSET) | WordCodec.encodeUint(uint64(block.timestamp + duration), _PRICE_RATE_CACHE_EXPIRES_OFFSET); } /** * @dev Returns rate, duration and expiration time of a price rate cache. */ function decode(bytes32 cache) internal pure returns ( uint256 rate, uint256 duration, uint256 expires ) { rate = getRate(cache); (duration, expires) = getTimestamps(cache); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; // These functions start with an underscore, as if they were part of a contract and not a library. At some point this // should be fixed. // solhint-disable private-vars-leading-underscore library LinearMath { using FixedPoint for uint256; // A thorough derivation of the formulas and derivations found here exceeds the scope of this file, so only // introductory notions will be presented. // A Linear Pool holds three tokens: the main token, the wrapped token, and the Pool share token (BPT). It is // possible to exchange any of these tokens for any of the other two (so we have three trading pairs) in both // directions (the first token of each pair can be bought or sold for the second) and by specifying either the input // or output amount (typically referred to as 'given in' or 'given out'). A full description thus requires // 3*2*2 = 12 functions. // Wrapped tokens have a known, trusted exchange rate to main tokens. All functions here assume such a rate has // already been applied, meaning main and wrapped balances can be compared as they are both expressed in the same // units (those of main token). // Additionally, Linear Pools feature a lower and upper target that represent the desired range of values for the // main token balance. Any action that moves the main balance away from this range is charged a proportional fee, // and any action that moves it towards this range is incentivized by paying the actor using these collected fees. // The collected fees are not stored in a separate data structure: they are a function of the current main balance, // targets and fee percentage. The main balance sans fees is known as the 'nominal balance', which is always smaller // than the real balance except when the real balance is within the targets. // The rule under which Linear Pools conduct trades between main and wrapped tokens is by keeping the sum of nominal // main balance and wrapped balance constant: this value is known as the 'invariant'. BPT is backed by nominal // reserves, meaning its supply is proportional to the invariant. As the wrapped token appreciates in value and its // exchange rate to the main token increases, so does the invariant and thus the value of BPT (in main token units). struct Params { uint256 fee; uint256 lowerTarget; uint256 upperTarget; } function _calcBptOutPerMainIn( uint256 mainIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as // there is no wrapped balance). return _toNominal(mainIn, params); } uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params); uint256 deltaNominalMain = afterNominalMain.sub(previousNominalMain); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); return Math.divDown(Math.mul(bptSupply, deltaNominalMain), invariant); } function _calcBptInPerMainOut( uint256 mainOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params); uint256 deltaNominalMain = previousNominalMain.sub(afterNominalMain); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); return Math.divUp(Math.mul(bptSupply, deltaNominalMain), invariant); } function _calcWrappedOutPerMainIn( uint256 mainIn, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.add(mainIn), params); return afterNominalMain.sub(previousNominalMain); } function _calcWrappedInPerMainOut( uint256 mainOut, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = _toNominal(mainBalance.sub(mainOut), params); return previousNominalMain.sub(afterNominalMain); } function _calcMainInPerBptOut( uint256 bptOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the nominal main balance as // there is no wrapped balance). return _fromNominal(bptOut, params); } uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); uint256 deltaNominalMain = Math.divUp(Math.mul(invariant, bptOut), bptSupply); uint256 afterNominalMain = previousNominalMain.add(deltaNominalMain); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return newMainBalance.sub(mainBalance); } function _calcMainOutPerBptIn( uint256 bptIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 invariant = _calcInvariant(previousNominalMain, wrappedBalance); uint256 deltaNominalMain = Math.divDown(Math.mul(invariant, bptIn), bptSupply); uint256 afterNominalMain = previousNominalMain.sub(deltaNominalMain); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return mainBalance.sub(newMainBalance); } function _calcMainOutPerWrappedIn( uint256 wrappedIn, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = previousNominalMain.sub(wrappedIn); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return mainBalance.sub(newMainBalance); } function _calcMainInPerWrappedOut( uint256 wrappedOut, uint256 mainBalance, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 previousNominalMain = _toNominal(mainBalance, params); uint256 afterNominalMain = previousNominalMain.add(wrappedOut); uint256 newMainBalance = _fromNominal(afterNominalMain, params); return newMainBalance.sub(mainBalance); } function _calcBptOutPerWrappedIn( uint256 wrappedIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as // there is no main balance). return wrappedIn; } uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newWrappedBalance = wrappedBalance.add(wrappedIn); uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance); uint256 newBptBalance = Math.divDown(Math.mul(bptSupply, newInvariant), previousInvariant); return newBptBalance.sub(bptSupply); } function _calcBptInPerWrappedOut( uint256 wrappedOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newWrappedBalance = wrappedBalance.sub(wrappedOut); uint256 newInvariant = _calcInvariant(nominalMain, newWrappedBalance); uint256 newBptBalance = Math.divDown(Math.mul(bptSupply, newInvariant), previousInvariant); return bptSupply.sub(newBptBalance); } function _calcWrappedInPerBptOut( uint256 bptOut, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount in, so we round up overall. if (bptSupply == 0) { // BPT typically grows in the same ratio the invariant does. The first time liquidity is added however, the // BPT supply is initialized to equal the invariant (which in this case is just the wrapped balance as // there is no main balance). return bptOut; } uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newBptBalance = bptSupply.add(bptOut); uint256 newWrappedBalance = Math.divUp(Math.mul(newBptBalance, previousInvariant), bptSupply).sub(nominalMain); return newWrappedBalance.sub(wrappedBalance); } function _calcWrappedOutPerBptIn( uint256 bptIn, uint256 mainBalance, uint256 wrappedBalance, uint256 bptSupply, Params memory params ) internal pure returns (uint256) { // Amount out, so we round down overall. uint256 nominalMain = _toNominal(mainBalance, params); uint256 previousInvariant = _calcInvariant(nominalMain, wrappedBalance); uint256 newBptBalance = bptSupply.sub(bptIn); uint256 newWrappedBalance = Math.divUp(Math.mul(newBptBalance, previousInvariant), bptSupply).sub(nominalMain); return wrappedBalance.sub(newWrappedBalance); } function _calcInvariant(uint256 nominalMainBalance, uint256 wrappedBalance) internal pure returns (uint256) { return nominalMainBalance.add(wrappedBalance); } function _toNominal(uint256 real, Params memory params) internal pure returns (uint256) { // Fees are always rounded down: either direction would work but we need to be consistent, and rounding down // uses less gas. if (real < params.lowerTarget) { uint256 fees = (params.lowerTarget - real).mulDown(params.fee); return real.sub(fees); } else if (real <= params.upperTarget) { return real; } else { uint256 fees = (real - params.upperTarget).mulDown(params.fee); return real.sub(fees); } } function _fromNominal(uint256 nominal, Params memory params) internal pure returns (uint256) { // Since real = nominal + fees, rounding down fees is equivalent to rounding down real. if (nominal < params.lowerTarget) { return (nominal.add(params.fee.mulDown(params.lowerTarget))).divDown(FixedPoint.ONE.add(params.fee)); } else if (nominal <= params.upperTarget) { return nominal; } else { return (nominal.sub(params.fee.mulDown(params.upperTarget)).divDown(FixedPoint.ONE.sub(params.fee))); } } function _calcTokensOutGivenExactBptIn( uint256[] memory balances, uint256 bptAmountIn, uint256 bptTotalSupply, uint256 bptIndex ) 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++) { // BPT is skipped as those tokens are not the LPs, but rather the preminted and undistributed amount. if (i != bptIndex) { amountsOut[i] = balances[i].mulDown(bptRatio); } } return amountsOut; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./LinearPool.sol"; library LinearPoolUserData { enum ExitKind { EMERGENCY_EXACT_BPT_IN_FOR_TOKENS_OUT } function exitKind(bytes memory self) internal pure returns (ExitKind) { return abi.decode(self, (ExitKind)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (ExitKind, 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 <http://www.gnu.org/licenses/>. 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: 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: 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: 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 absolute value of a signed integer. */ function abs(int256 a) internal pure returns (uint256) { return a > 0 ? uint256(a) : uint256(-a); } /** * @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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 Reverts if the contract is not paused. */ function _ensurePaused() internal view { _require(!_isNotPaused(), Errors.NOT_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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.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. * * We could use Solidity structs to pack values together in a single storage slot instead of relying on a custom and * error-prone library, but unfortunately Solidity only allows for structs to live in either storage, calldata or * memory. Because a memory struct uses not just memory but also a slot in the stack (to store its memory location), * using memory for word-sized values (i.e. of 256 bits or less) is strictly less gas performant, and doesn't even * prevent stack-too-deep issues. This is compounded by the fact that Balancer contracts typically are memory-intensive, * and the cost of accesing memory increases quadratically with the number of allocated words. Manual packing and * unpacking is therefore the preferred approach. */ 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_5 = 2**(5) - 1; uint256 private constant _MASK_7 = 2**(7) - 1; uint256 private constant _MASK_10 = 2**(10) - 1; uint256 private constant _MASK_16 = 2**(16) - 1; uint256 private constant _MASK_22 = 2**(22) - 1; uint256 private constant _MASK_31 = 2**(31) - 1; uint256 private constant _MASK_32 = 2**(32) - 1; uint256 private constant _MASK_53 = 2**(53) - 1; uint256 private constant _MASK_64 = 2**(64) - 1; uint256 private constant _MASK_96 = 2**(96) - 1; uint256 private constant _MASK_128 = 2**(128) - 1; uint256 private constant _MASK_192 = 2**(192) - 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 insertBool( 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 5 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 5 bits, otherwise it may overwrite sibling bytes. */ function insertUint5( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_5 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 7 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 7 bits, otherwise it may overwrite sibling bytes. */ function insertUint7( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_7 << offset)); return clearedWord | bytes32(value << offset); } /** * @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` only uses its least significant 10 bits, otherwise it may overwrite sibling bytes. */ 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 16 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. * Returns the new word. * * Assumes `value` only uses its least significant 16 bits, otherwise it may overwrite sibling bytes. */ function insertUint16( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_16 << 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 32 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` only uses its least significant 32 bits, otherwise it may overwrite sibling bytes. */ function insertUint32( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_32 << 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` only uses its least significant 64 bits, otherwise it may overwrite sibling bytes. */ 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); } // Bytes /** * @dev Inserts 192 bit shifted by an offset into a 256 bit word, replacing the old value. Returns the new word. * * Assumes `value` can be represented using 192 bits. */ function insertBits192( bytes32 word, bytes32 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_192 << offset)); return clearedWord | bytes32((uint256(value) & _MASK_192) << 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 5 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint5(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_5; } /** * @dev Decodes and returns a 7 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint7(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_7; } /** * @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 16 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint16(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_16; } /** * @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 32 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint32(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_32; } /** * @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; } /** * @dev Decodes and returns a 96 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint96(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_96; } /** * @dev Decodes and returns a 128 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint128(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_128; } // 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: 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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). `balances` 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. `balances` 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 <http://www.gnu.org/licenses/>. 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; /** * Note: No function to read the asset manager config is included in IAssetManager * as the signature is expected to vary between asset manager implementations */ /** * @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; /** * @notice allows an authorized rebalancer to remove capital to facilitate large withdrawals * @param poolId - the poolId of the pool to withdraw funds back to * @param amount - the amount of tokens to withdraw back to the pool */ function capitalOut(bytes32 poolId, 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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20Permit.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.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` * - Assigns infinite allowance for all token holders to the Vault */ contract BalancerPoolToken is ERC20Permit { IVault private immutable _vault; constructor( string memory tokenName, string memory tokenSymbol, IVault vault ) ERC20(tokenName, tokenSymbol) ERC20Permit(tokenName) { _vault = vault; } function getVault() public view returns (IVault) { return _vault; } // Overrides /** * @dev Override to grant the Vault infinite allowance, causing for Pool Tokens to not require approval. * * This is sound as the Vault already provides authorization mechanisms when initiation token transfers, which this * contract inherits. */ function allowance(address owner, address spender) public view override returns (uint256) { if (spender == address(getVault())) { return uint256(-1); } else { return super.allowance(owner, spender); } } /** * @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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/helpers/BaseSplitCodeFactory.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; /** * @dev Same as `BasePoolFactory`, for Pools whose creation code is so large that the factory cannot hold it. */ abstract contract BasePoolSplitCodeFactory is BaseSplitCodeFactory { IVault private immutable _vault; mapping(address => bool) private _isPoolFromFactory; event PoolCreated(address indexed pool); constructor(IVault vault, bytes memory creationCode) BaseSplitCodeFactory(creationCode) { _vault = vault; } /** * @dev Returns the Vault's address. */ function getVault() public view returns (IVault) { return _vault; } /** * @dev Returns true if `pool` was created by this factory. */ function isPoolFromFactory(address pool) external view returns (bool) { return _isPoolFromFactory[pool]; } function _create(bytes memory constructorArgs) internal override returns (address) { address pool = super._create(constructorArgs); _isPoolFromFactory[pool] = true; emit PoolCreated(pool); return pool; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; /** * @dev Utility to create Pool factories for Pools that use the `TemporarilyPausable` contract. * * By calling `TemporarilyPausable`'s constructor with the result of `getPauseConfiguration`, all Pools created by this * factory will share the same Pause Window end time, after which both old and new Pools will not be pausable. */ contract FactoryWidePauseWindow { // This contract relies on timestamps in a similar way as `TemporarilyPausable` does - the same caveats apply. // solhint-disable not-rely-on-time uint256 private constant _INITIAL_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _BUFFER_PERIOD_DURATION = 30 days; // Time when the pause window for all created Pools expires, and the pause window duration of new Pools becomes // zero. uint256 private immutable _poolsPauseWindowEndTime; constructor() { _poolsPauseWindowEndTime = block.timestamp + _INITIAL_PAUSE_WINDOW_DURATION; } /** * @dev Returns the current `TemporarilyPausable` configuration that will be applied to Pools created by this * factory. * * `pauseWindowDuration` will decrease over time until it reaches zero, at which point both it and * `bufferPeriodDuration` will be zero forever, meaning deployed Pools will not be pausable. */ function getPauseConfiguration() public view returns (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { uint256 currentTime = block.timestamp; if (currentTime < _poolsPauseWindowEndTime) { // The buffer period is always the same since its duration is related to how much time is needed to respond // to a potential emergency. The Pause Window duration however decreases as the end time approaches. pauseWindowDuration = _poolsPauseWindowEndTime - currentTime; // No need for checked arithmetic. bufferPeriodDuration = _BUFFER_PERIOD_DURATION; } else { // After the end time, newly created Pools have no Pause Window, nor Buffer Period (since they are not // pausable in the first place). pauseWindowDuration = 0; bufferPeriodDuration = 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 <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./BalancerErrors.sol"; import "./CodeDeployer.sol"; /** * @dev Base factory for contracts whose creation code is so large that the factory cannot hold it. This happens when * the contract's creation code grows close to 24kB. * * Note that this factory cannot help with contracts that have a *runtime* (deployed) bytecode larger than 24kB. */ abstract contract BaseSplitCodeFactory { // The contract's creation code is stored as code in two separate addresses, and retrieved via `extcodecopy`. This // means this factory supports contracts with creation code of up to 48kB. // We rely on inline-assembly to achieve this, both to make the entire operation highly gas efficient, and because // `extcodecopy` is not available in Solidity. // solhint-disable no-inline-assembly address private immutable _creationCodeContractA; uint256 private immutable _creationCodeSizeA; address private immutable _creationCodeContractB; uint256 private immutable _creationCodeSizeB; /** * @dev The creation code of a contract Foo can be obtained inside Solidity with `type(Foo).creationCode`. */ constructor(bytes memory creationCode) { uint256 creationCodeSize = creationCode.length; // We are going to deploy two contracts: one with approximately the first half of `creationCode`'s contents // (A), and another with the remaining half (B). // We store the lengths in both immutable and stack variables, since immutable variables cannot be read during // construction. uint256 creationCodeSizeA = creationCodeSize / 2; _creationCodeSizeA = creationCodeSizeA; uint256 creationCodeSizeB = creationCodeSize - creationCodeSizeA; _creationCodeSizeB = creationCodeSizeB; // To deploy the contracts, we're going to use `CodeDeployer.deploy()`, which expects a memory array with // the code to deploy. Note that we cannot simply create arrays for A and B's code by copying or moving // `creationCode`'s contents as they are expected to be very large (> 24kB), so we must operate in-place. // Memory: [ code length ] [ A.data ] [ B.data ] // Creating A's array is simple: we simply replace `creationCode`'s length with A's length. We'll later restore // the original length. bytes memory creationCodeA; assembly { creationCodeA := creationCode mstore(creationCodeA, creationCodeSizeA) } // Memory: [ A.length ] [ A.data ] [ B.data ] // ^ creationCodeA _creationCodeContractA = CodeDeployer.deploy(creationCodeA); // Creating B's array is a bit more involved: since we cannot move B's contents, we are going to create a 'new' // memory array starting at A's last 32 bytes, which will be replaced with B's length. We'll back-up this last // byte to later restore it. bytes memory creationCodeB; bytes32 lastByteA; assembly { // `creationCode` points to the array's length, not data, so by adding A's length to it we arrive at A's // last 32 bytes. creationCodeB := add(creationCode, creationCodeSizeA) lastByteA := mload(creationCodeB) mstore(creationCodeB, creationCodeSizeB) } // Memory: [ A.length ] [ A.data[ : -1] ] [ B.length ][ B.data ] // ^ creationCodeA ^ creationCodeB _creationCodeContractB = CodeDeployer.deploy(creationCodeB); // We now restore the original contents of `creationCode` by writing back the original length and A's last byte. assembly { mstore(creationCodeA, creationCodeSize) mstore(creationCodeB, lastByteA) } } /** * @dev Returns the two addresses where the creation code of the contract crated by this factory is stored. */ function getCreationCodeContracts() public view returns (address contractA, address contractB) { return (_creationCodeContractA, _creationCodeContractB); } /** * @dev Returns the creation code of the contract this factory creates. */ function getCreationCode() public view returns (bytes memory) { return _getCreationCodeWithArgs(""); } /** * @dev Returns the creation code that will result in a contract being deployed with `constructorArgs`. */ function _getCreationCodeWithArgs(bytes memory constructorArgs) private view returns (bytes memory code) { // This function exists because `abi.encode()` cannot be instructed to place its result at a specific address. // We need for the ABI-encoded constructor arguments to be located immediately after the creation code, but // cannot rely on `abi.encodePacked()` to perform concatenation as that would involve copying the creation code, // which would be prohibitively expensive. // Instead, we compute the creation code in a pre-allocated array that is large enough to hold *both* the // creation code and the constructor arguments, and then copy the ABI-encoded arguments (which should not be // overly long) right after the end of the creation code. // Immutable variables cannot be used in assembly, so we store them in the stack first. address creationCodeContractA = _creationCodeContractA; uint256 creationCodeSizeA = _creationCodeSizeA; address creationCodeContractB = _creationCodeContractB; uint256 creationCodeSizeB = _creationCodeSizeB; uint256 creationCodeSize = creationCodeSizeA + creationCodeSizeB; uint256 constructorArgsSize = constructorArgs.length; uint256 codeSize = creationCodeSize + constructorArgsSize; assembly { // First, we allocate memory for `code` by retrieving the free memory pointer and then moving it ahead of // `code` by the size of the creation code plus constructor arguments, and 32 bytes for the array length. code := mload(0x40) mstore(0x40, add(code, add(codeSize, 32))) // We now store the length of the code plus constructor arguments. mstore(code, codeSize) // Next, we concatenate the creation code stored in A and B. let dataStart := add(code, 32) extcodecopy(creationCodeContractA, dataStart, 0, creationCodeSizeA) extcodecopy(creationCodeContractB, add(dataStart, creationCodeSizeA), 0, creationCodeSizeB) } // Finally, we copy the constructorArgs to the end of the array. Unfortunately there is no way to avoid this // copy, as it is not possible to tell Solidity where to store the result of `abi.encode()`. uint256 constructorArgsDataPtr; uint256 constructorArgsCodeDataPtr; assembly { constructorArgsDataPtr := add(constructorArgs, 32) constructorArgsCodeDataPtr := add(add(code, 32), creationCodeSize) } _memcpy(constructorArgsCodeDataPtr, constructorArgsDataPtr, constructorArgsSize); } /** * @dev Deploys a contract with constructor arguments. To create `constructorArgs`, call `abi.encode()` with the * contract's constructor arguments, in order. */ function _create(bytes memory constructorArgs) internal virtual returns (address) { bytes memory creationCode = _getCreationCodeWithArgs(constructorArgs); address destination; assembly { destination := create(0, add(creationCode, 32), mload(creationCode)) } if (destination == address(0)) { // Bubble up inner revert reason // solhint-disable-next-line no-inline-assembly assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } return destination; } // From // https://github.com/Arachnid/solidity-stringutils/blob/b9a6f6615cf18a87a823cbc461ce9e140a61c305/src/strings.sol function _memcpy( uint256 dest, uint256 src, uint256 len ) private pure { // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint256 mask = 256**(32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; /** * @dev Library used to deploy contracts with specific code. This can be used for long-term storage of immutable data as * contract code, which can be retrieved via the `extcodecopy` opcode. */ library CodeDeployer { // During contract construction, the full code supplied exists as code, and can be accessed via `codesize` and // `codecopy`. This is not the contract's final code however: whatever the constructor returns is what will be // stored as its code. // // We use this mechanism to have a simple constructor that stores whatever is appended to it. The following opcode // sequence corresponds to the creation code of the following equivalent Solidity contract, plus padding to make the // full code 32 bytes long: // // contract CodeDeployer { // constructor() payable { // uint256 size; // assembly { // size := sub(codesize(), 32) // size of appended data, as constructor is 32 bytes long // codecopy(0, 32, size) // copy all appended data to memory at position 0 // return(0, size) // return appended data for it to be stored as code // } // } // } // // More specifically, it is composed of the following opcodes (plus padding): // // [1] PUSH1 0x20 // [2] CODESIZE // [3] SUB // [4] DUP1 // [6] PUSH1 0x20 // [8] PUSH1 0x00 // [9] CODECOPY // [11] PUSH1 0x00 // [12] RETURN // // The padding is just the 0xfe sequence (invalid opcode). bytes32 private constant _DEPLOYER_CREATION_CODE = 0x602038038060206000396000f3fefefefefefefefefefefefefefefefefefefe; /** * @dev Deploys a contract with `code` as its code, returning the destination address. * * Reverts if deployment fails. */ function deploy(bytes memory code) internal returns (address destination) { bytes32 deployerCreationCode = _DEPLOYER_CREATION_CODE; // solhint-disable-next-line no-inline-assembly assembly { let codeLength := mload(code) // `code` is composed of length and data. We've already stored its length in `codeLength`, so we simply // replace it with the deployer creation code (which is exactly 32 bytes long). mstore(code, deployerCreationCode) // At this point, `code` now points to the deployer creation code immediately followed by `code`'s data // contents. This is exactly what the deployer expects to receive when created. destination := create(0, code, add(codeLength, 32)) // Finally, we restore the original length in order to not mutate `code`. mstore(code, codeLength) } // The create opcode returns the zero address when contract creation fails, so we revert if this happens. _require(destination != address(0), Errors.CODE_DEPLOYMENT_FAILED); } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolSplitCodeFactory.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol"; import "./YearnLinearPool.sol"; contract YearnLinearPoolFactory is BasePoolSplitCodeFactory, FactoryWidePauseWindow { constructor(IVault vault) BasePoolSplitCodeFactory(vault, type(YearnLinearPool).creationCode) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Deploys a new `YearnLinearPool`. */ function create( string memory name, string memory symbol, IERC20 mainToken, IERC20 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, address owner ) external returns (LinearPool) { (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) = getPauseConfiguration(); LinearPool pool = YearnLinearPool( _create( abi.encode( getVault(), name, symbol, mainToken, wrappedToken, upperTarget, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) ) ); // LinearPools have a separate post-construction initialization step: we perform it here to // ensure deployment and initialization are atomic. pool.initialize(); return pool; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../interfaces/IYearnTokenVault.sol"; import "../LinearPool.sol"; contract YearnLinearPool is LinearPool { IYearnTokenVault private immutable _tokenVault; constructor( IVault vault, string memory name, string memory symbol, IERC20 mainToken, IERC20 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) LinearPool( vault, name, symbol, mainToken, wrappedToken, upperTarget, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { _tokenVault = IYearnTokenVault(address(wrappedToken)); _require(address(mainToken) == IYearnTokenVault(address(wrappedToken)).token(), Errors.TOKENS_MISMATCH); } //_getWrappedTokenRate is expected to return the rate scaled to 18 decimal points, regardless of underlying decimals function _getWrappedTokenRate() internal view override returns (uint256) { //the decimals of the vault token reflect that of the mainToken. So a USDC token vault has decimals = 6 uint8 decimals = _tokenVault.decimals(); uint256 pps = _tokenVault.pricePerShare(); if (decimals > 18) { //scale down to 18 return pps / 10**(decimals - 18); }else if (decimals < 18) { //scale up to 18 return pps * 10**(18 - decimals); } return pps; } }
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IYearnTokenVault { /** * @dev returns the address of the vault's underlying asset (mainToken) */ function token() external view returns (address); /** * @dev returns the price for a single Vault share (ie yvDAI). The pricePerShare is represented in the same decimals as the underlying asset (ie: 6 decimals for USDC) */ function pricePerShare() external view returns (uint256); /** * @dev returns the number of decimals for this vault token */ function decimals() external view returns (uint8); }
{ "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":"mainToken","type":"address"},{"internalType":"contract IERC20","name":"wrappedToken","type":"address"},{"internalType":"uint256","name":"upperTarget","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":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":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"lowerTarget","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"upperTarget","type":"uint256"}],"name":"TargetsSet","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":"getAuthorizer","outputs":[{"internalType":"contract IAuthorizer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBptIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMainIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMainToken","outputs":[{"internalType":"address","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":"getScalingFactors","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":"getTargets","outputs":[{"internalType":"uint256","name":"lowerTarget","type":"uint256"},{"internalType":"uint256","name":"upperTarget","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVirtualSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWrappedIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWrappedToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWrappedTokenRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"initialize","outputs":[],"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":"request","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":[{"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":"newLowerTarget","type":"uint256"},{"internalType":"uint256","name":"newUpperTarget","type":"uint256"}],"name":"setTargets","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
6102c06040527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9610120523480156200003757600080fd5b506040516200543a3803806200543a8339810160408190526200005a9162000b4b565b898989898989898989898960008a8a620000768b8b306200046d565b6040805160038082526080820190925290602082016060803683370190505089898989828289898d8280604051806040016040528060018152602001603160f81b81525085858a336001600160a01b031660001b806080818152505050806001600160a01b031660a0816001600160a01b031660601b8152505050816003908051906020019062000109929190620009bc565b5080516200011f906004906020840190620009bc565b505060058054601260ff1990911617905550815160209283012060c052805191012060e052507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6101005260601b6001600160601b03191661014052506200019290506276a7008311156101946200053c565b620001a662278d008211156101956200053c565b4290910161016081905201610180528551620001c8906002111560c86200053c565b620001e2620001d662000551565b8751111560c96200053c565b620001f8866200055660201b620014891760201c565b620002038462000562565b6040516309b2760f60e01b81526000906001600160a01b038c16906309b2760f9062000234908d9060040162000ce9565b602060405180830381600087803b1580156200024f57600080fd5b505af115801562000264573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200028a919062000b32565b604051633354e3e960e11b81529091506001600160a01b038c16906366a9c7d290620002bf9084908b908b9060040162000c4d565b600060405180830381600087803b158015620002da57600080fd5b505af1158015620002ef573d6000803e3d6000fd5b50505050806101a081815250505050505050505050505050866001600160a01b03166101c0816001600160a01b031660601b81525050856001600160a01b03166101e0816001600160a01b031660601b8152505060008060006200035b8a8a30620005ee60201b60201c565b610200819052610220839052610240829052919450925090506200037f8a620006e4565b610260526200038e89620006e4565b610280526000620003a18b828b620007b8565b5050505050505050505050505050856001600160a01b03166102a0816001600160a01b031660601b815250506200045d866001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200040b57600080fd5b505afa15801562000420573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000446919062000b0c565b6001600160a01b038981169116146102086200053c565b5050505050505050505062000d37565b60606000808062000480878787620005ee565b6040805160038082526080820190925293965091945092506020820160608036833701905050935086848481518110620004b657fe5b60200260200101906001600160a01b031690816001600160a01b03168152505085848381518110620004e457fe5b60200260200101906001600160a01b031690816001600160a01b031681525050848482815181106200051257fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505050509392505050565b816200054d576200054d8162000866565b5050565b600390565b806200054d81620008b9565b6200057764e8d4a5100082101560cb6200053c565b6200058f67016345785d8a000082111560ca6200053c565b620005ae8160c06008546200094660201b62001493179092919060201c565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc90620005e390839062000cfe565b60405180910390a150565b6000806000846001600160a01b0316866001600160a01b031610156200067757836001600160a01b0316856001600160a01b031610156200063a575060009150600190506002620006db565b836001600160a01b0316866001600160a01b0316101562000666575060009150600290506001620006db565b5060019150600290506000620006db565b846001600160a01b0316846001600160a01b03161015620006a3575060029150600190506000620006db565b856001600160a01b0316846001600160a01b03161015620006cf575060029150600090506001620006db565b50600191506000905060025b93509350939050565b60006001600160a01b038216301415620007085750670de0b6b3a7640000620007b3565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200074457600080fd5b505afa15801562000759573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200077f919062000c2a565b60ff16905060006200079e6012836200095b60201b620014a91760201c565b905080600a0a670de0b6b3a764000002925050505b919050565b620007c98183111561014c6200053c565b620007e16001600160601b0382111561014d6200053c565b6200081c620007fd8260606200097860201b620014bf1760201c565b620008158460006200097860201b620014bf1760201c565b176200097c565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d128083836040516200085992919062000d07565b60405180910390a2505050565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600281511015620008ca5762000943565b600081600081518110620008da57fe5b602002602001015190506000600190505b8251811015620009405760008382815181106200090457fe5b6020026020010151905062000935816001600160a01b0316846001600160a01b03161060656200053c60201b60201c565b9150600101620008eb565b50505b50565b6001600160401b03811b1992909216911b1790565b60006200096d8383111560016200053c565b508082035b92915050565b1b90565b6200099b816000600854620009a160201b620014c3179092919060201c565b60085550565b6001600160c01b03828116821b90821b198416179392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620009ff57805160ff191683800117855562000a2f565b8280016001018555821562000a2f579182015b8281111562000a2f57825182559160200191906001019062000a12565b5062000a3d92915062000a41565b5090565b5b8082111562000a3d576000815560010162000a42565b8051620009728162000d21565b600082601f83011262000a76578081fd5b81516001600160401b038082111562000a8d578283fd5b6040516020601f8401601f191682018101838111838210171562000aaf578586fd5b8060405250819450838252868185880101111562000acc57600080fd5b600092505b8383101562000af0578583018101518284018201529182019162000ad1565b8383111562000b025760008185840101525b5050505092915050565b60006020828403121562000b1e578081fd5b815162000b2b8162000d21565b9392505050565b60006020828403121562000b44578081fd5b5051919050565b6000806000806000806000806000806101408b8d03121562000b6b578586fd5b62000b778c8c62000a58565b60208c0151909a506001600160401b038082111562000b94578788fd5b62000ba28e838f0162000a65565b9a5060408d015191508082111562000bb8578788fd5b5062000bc78d828e0162000a65565b98505062000bd98c60608d0162000a58565b965062000bea8c60808d0162000a58565b955060a08b0151945060c08b0151935060e08b015192506101008b0151915062000c198c6101208d0162000a58565b90509295989b9194979a5092959850565b60006020828403121562000c3c578081fd5b815160ff8116811462000b2b578182fd5b60006060820185835260206060818501528186518084526080860191508288019350845b8181101562000c995762000c86855162000d15565b8352938301939183019160010162000c71565b505084810360408601528551808252908201925081860190845b8181101562000cdb5762000cc8835162000d15565b8552938301939183019160010162000cb3565b509298975050505050505050565b602081016003831062000cf857fe5b91905290565b90815260200190565b918252602082015260400190565b6001600160a01b031690565b6001600160a01b03811681146200094357600080fd5b60805160a05160601c60c05160e05161010051610120516101405160601c61016051610180516101a0516101c05160601c6101e05160601c61020051610220516102405161026051610280516102a05160601c61452462000f16600039806124d1528061256652508061159d525080611539528061241d5250806107c75280610b7a52806115c5528061282752806129d75280612b2e5280612ca05280612e3c5280612f935250806109755280610b40528061155b5280611c0e52806127f3528061295c52806129a35280612ab85280612afa5280612c6c5280612dc65280612e085280612f1d5280612f5f525080610bbb5280610d8a5280610e77528061140a52806116065280612362528061285e5280612a0e5280612b655280612cd75280612e735280612fca52806131af52806131e752508061145d528061172152806117ed528061244352806127a852806128e85280612c225280612d52525080610999528061101652806116d852806117a45280611c4452806123e25280612769528061288a5280612a445280612be35280612d035280612ea95250806109165250806119cd5250806119a9525080610f375250806110cc525080611ad3525080611b15525080611af4525080610f13525080610e9d52506145246000f3fe608060405234801561001057600080fd5b50600436106102d35760003560e01c8063679aefce1161018657806395d89b41116100e3578063d505accf11610097578063de82cd3411610071578063de82cd341461056b578063f174e24114610573578063f5431aa81461057b576102d3565b8063d505accf14610532578063d5c096c414610545578063dd62ed3e14610558576102d3565b8063a457c2d7116100c8578063a457c2d714610504578063a9059cbb14610517578063aaabadc51461052a576102d3565b806395d89b41146104e95780639f11080e146104f1576102d3565b806382687a561161013a57806387ec68171161011f57806387ec6817146104c6578063893d20e8146104d95780638d928af8146104e1576102d3565b806382687a56146104ab578063851c1bb3146104b3576102d3565b806374f3b0091161016b57806374f3b0091461046f5780637ecebe00146104905780638129fc1c146104a3576102d3565b8063679aefce1461045457806370a082311461045c576102d3565b80633644e515116102345780634de046d5116101e857806355c67628116101cd57806355c67628146104155780636028bfd41461041d57806363fe3b561461043e576102d3565b80634de046d5146103ed57806350dd6ed914610402576102d3565b806338fff2d01161021957806338fff2d0146103ca57806339509351146103d25780634d64cd74146103e5576102d3565b80633644e515146103af57806338e9922e146103b7576102d3565b806318160ddd1161028b5780631dd746ea116102705780631dd746ea1461037257806323b872dd14610387578063313ce5671461039a576102d3565b806318160ddd146103535780631c0de0511461035b576102d3565b8063095ea7b3116102bc578063095ea7b31461031657806316b8d6ff1461033657806316c38b3c1461033e576102d3565b806301ec954a146102d857806306fdde0314610301575b600080fd5b6102eb6102e6366004613f2d565b610583565b6040516102f89190614269565b60405180910390f35b6103096106f9565b6040516102f89190614421565b610329610324366004613c6a565b6107ae565b6040516102f89190614246565b6102eb6107c5565b61035161034c366004613d61565b6107e9565b005b6102eb6107fd565b610363610803565b6040516102f893929190614251565b61037a61082c565b6040516102f8919061420e565b610329610395366004613bba565b61083b565b6103a26108cf565b6040516102f8919061445b565b6102eb6108d8565b6103516103c536600461404c565b6108e2565b6102eb610914565b6103296103e0366004613c6a565b610938565b6102eb610973565b6103f5610997565b6040516102f891906141fa565b610351610410366004613e98565b6109bb565b6102eb6109d9565b61043061042b366004613d99565b6109ea565b6040516102f8929190614434565b610446610a21565b6040516102f892919061444d565b6102eb610a4f565b6102eb61046a366004613b66565b610c03565b61048261047d366004613d99565b610c22565b6040516102f8929190614221565b6102eb61049e366004613b66565b610ca0565b610351610cbb565b6102eb610e75565b6102eb6104c1366004613e3c565b610e99565b6104306104d4366004613d99565b610eeb565b6103f5610f11565b6103f5610f35565b610309610f59565b6103516104ff36600461407c565b610fd8565b610329610512366004613c6a565b611042565b610329610525366004613c6a565b611080565b6103f561108d565b610351610540366004613bfa565b611097565b610482610553366004613d99565b6111e0565b6102eb610566366004613b82565b611311565b6102eb61136c565b6103f561145b565b6102eb61147f565b600084608001516105b0610595610f35565b6001600160a01b0316336001600160a01b03161460cd6114ef565b6105c56105bb610914565b82146101f46114ef565b6105cd6114fd565b6105e76003851080156105e05750600384105b60646114ef565b60606105f1611512565b90506105fd868261163f565b600080610608610a21565b915091506106146139bd565b60405180606001604052806106276109d9565b815260208101859052604001839052905060008a51600181111561064757fe5b14156106ab5761066e8a60600151858a8151811061066157fe5b60200260200101516116a0565b60608b015260006106808b8b846116ac565b905061069f81868a8151811061069257fe5b6020026020010151611773565b965050505050506106f0565b6106bf8a6060015185898151811061066157fe5b60608b015260006106d18b8b8461177f565b905061069f81868b815181106106e357fe5b6020026020010151611834565b50949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b820191906000526020600020905b81548152906001019060200180831161078657829003601f168201915b505050505090505b90565b60006107bb338484611840565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000090565b6107f16118a8565b6107fa816118ee565b50565b60025490565b600080600061081061198a565b15925061081b6119a7565b91506108256119cb565b9050909192565b6060610836611512565b905090565b6000806108488533611311565b905061086c336001600160a01b03871614806108645750838210155b61019e6114ef565b6108778585856119ef565b336001600160a01b038616148015906108b057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b156108c2576108c28533858403611840565b60019150505b9392505050565b60055460ff1690565b6000610836611acf565b6000806108ed610a21565b915091506109066108fe8383611b6c565b61014f6114ef565b61090f83611c84565b505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916107bb91859061096e9086611c9d565b611840565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b6109c36118a8565b6109cb6114fd565b6109d58282611caf565b5050565b6008546000906108369060c0611d8f565b60006060610a0086516109fb611d9d565b611da2565b610a1589898989898989611daf611e53611eb4565b97509795505050505050565b6000806000610a2e612044565b9050610a3b81600061204a565b9250610a4881606061204a565b9150509091565b600080610a5a610914565b90506060610a66610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610a919190614269565b60006040518083038186803b158015610aa957600080fd5b505afa158015610abd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae59190810190613c95565b50915050610afa81610af5611512565b61163f565b600080610b05610a21565b91509150610b116139bd565b6040518060600160405280610b246109d9565b81526020018481526020018381525090506000610bb0610b77867f000000000000000000000000000000000000000000000000000000000000000081518110610b6957fe5b60200260200101518461205c565b867f000000000000000000000000000000000000000000000000000000000000000081518110610ba357fe5b60200260200101516120bd565b9050610bf8610bf1867f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b60200260200101516120c9565b82906120dc565b965050505050505090565b6001600160a01b0381166000908152602081905260409020545b919050565b60608088610c31610595610f35565b610c3c6105bb610914565b6060610c46611512565b9050610c52888261163f565b6000606080610c678e8e8e8e8e8e8a8f611daf565b925092509250610c778d84612133565b610c818285611e53565b610c8b8185611e53565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b6000610cc5610914565b90506060610cd1610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610cfc9190614269565b60006040518083038186803b158015610d1457600080fd5b505afa158015610d28573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d509190810190613c95565b505060408051600380825260808201909252919250606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f000000000000000000000000000000000000000000000000000000000000000081518110610db357fe5b602002602001018181525050610dc76139de565b6040518060800160405280610ddb856107ab565b8152602001838152602001604051806020016040528060008152508152602001600015158152509050610e0c610f35565b6001600160a01b031663b95cac28853030856040518563ffffffff1660e01b8152600401610e3d9493929190614291565b600060405180830381600087803b158015610e5757600080fd5b505af1158015610e6b573d6000803e3d6000fd5b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b60007f000000000000000000000000000000000000000000000000000000000000000082604051602001610ece929190614184565b604051602081830303815290604052805190602001209050919050565b60006060610efc86516109fb611d9d565b610a158989898989898961213d61215b611eb4565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b610fe06118a8565b600080610feb610a21565b91509150610ffc6108fe8383611b6c565b6110116110098585611b6c565b6101576114ef565b61103c7f000000000000000000000000000000000000000000000000000000000000000085856121bc565b50505050565b60008061104f3385611311565b90508083106110695761106433856000611840565b611076565b6110763385858403611840565b5060019392505050565b60006107bb3384846119ef565b600061083661224d565b6110a58442111560d16114ef565b6001600160a01b03871660009081526006602090815260408083205490519092916110fc917f0000000000000000000000000000000000000000000000000000000000000000918c918c918c9188918d9101614373565b604051602081830303815290604052805190602001209050600061111f826122c7565b90506000600182888888604051600081526020016040526040516111469493929190614403565b6020604051602081039080840390855afa158015611168573d6000803e3d6000fd5b5050604051601f19015191506111aa90506001600160a01b038216158015906111a257508b6001600160a01b0316826001600160a01b0316145b6101f86114ef565b6001600160a01b038b1660009081526006602052604090206001850190556111d38b8b8b611840565b5050505050505050505050565b606080886111ef610595610f35565b6111fa6105bb610914565b6060611204611512565b905061120e6107fd565b6112c157600060606112238d8d8d868b6122e3565b9150915061123c6112326123a4565b83101560cc6114ef565b61124e60006112496123a4565b6123a9565b6112618b61125a6123a4565b84036123a9565b61126b818461215b565b80611274611d9d565b67ffffffffffffffff8111801561128a57600080fd5b506040519080825280602002602001820160405280156112b4578160200160208202803683370190505b5095509550505050610c93565b6112cb888261163f565b60006060806112e08e8e8e8e8e8e8a8f61213d565b9250925092506112f08c846123a9565b6112fa828561215b565b6113048185611e53565b9095509350610c93915050565b600061131b610f35565b6001600160a01b0316826001600160a01b0316141561135b57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6107bf565b61136583836123b3565b90506107bf565b60006060611378610f35565b6001600160a01b031663f94d466861138e610914565b6040518263ffffffff1660e01b81526004016113aa9190614269565b60006040518083038186803b1580156113c257600080fd5b505afa1580156113d6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fe9190810190613c95565b509150506000611449827f00000000000000000000000000000000000000000000000000000000000000008151811061143357fe5b6020026020010151611444306123de565b6116a0565b9050611454816124b8565b9250505090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60006108366124cc565b806109d581612646565b67ffffffffffffffff811b1992909216911b1790565b60006114b98383111560016114ef565b50900390565b1b90565b77ffffffffffffffffffffffffffffffffffffffffffffffff828116821b90821b198416179392505050565b816109d5576109d5816126bf565b61151061150861198a565b6101926114ef565b565b604080516003808252608082019092526060918291906020820183803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000817f00000000000000000000000000000000000000000000000000000000000000008151811061158457fe5b6020026020010181815250506115c261159b6124cc565b7f00000000000000000000000000000000000000000000000000000000000000009061272c565b817f0000000000000000000000000000000000000000000000000000000000000000815181106115ee57fe5b602002602001018181525050670de0b6b3a7640000817f00000000000000000000000000000000000000000000000000000000000000008151811061162f57fe5b6020908102919091010152905090565b60005b61164a611d9d565b81101561090f5761168183828151811061166057fe5b602002602001015183838151811061167457fe5b602002602001015161272c565b83828151811061168d57fe5b6020908102919091010152600101611642565b60006108c8838361272c565b60208301516000906001600160a01b03163014156116d6576116cf848484612762565b90506108c8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684602001516001600160a01b0316141561171f576116cf8484846128e1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684602001516001600160a01b03161415611768576116cf848484612a3d565b6108c86101356126bf565b60006108c88383612b94565b60408301516000906001600160a01b03163014156117a2576116cf848484612bdc565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684604001516001600160a01b031614156117eb576116cf848484612d4b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684604001516001600160a01b03161415611768576116cf848484612ea2565b60006108c883836120dc565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061189b908590614269565b60405180910390a3505050565b60006118d76000357fffffffff0000000000000000000000000000000000000000000000000000000016610e99565b90506107fa6118e68233612ff9565b6101916114ef565b801561190e576119096118ff6119a7565b42106101936114ef565b611923565b6119236119196119cb565b42106101a96114ef565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be649061197f908390614246565b60405180910390a150565b60006119946119cb565b42118061083657505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b611a066001600160a01b03841615156101986114ef565b611a1d6001600160a01b03831615156101996114ef565b611a2883838361090f565b6001600160a01b038316600090815260208190526040902054611a4e90826101a06130e2565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611a7d9082611c9d565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590614269565b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611b3c6130f8565b30604051602001611b519594939291906143a7565b60405160208183030381529060405280519060200120905090565b600080611b77610914565b90506060611b83610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401611bae9190614269565b60006040518083038186803b158015611bc657600080fd5b505afa158015611bda573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c029190810190613c95565b509150506000611c68827f000000000000000000000000000000000000000000000000000000000000000081518110611c3757fe5b60200260200101516114447f00000000000000000000000000000000000000000000000000000000000000006123de565b9050858110158015611c7a5750848111155b9695505050505050565b611c8c6118a8565b611c946114fd565b6107fa816130fc565b60008282016108c884821015836114ef565b6000611cb9610914565b90506000611cc5610f35565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b8152600401611cf29291906143ec565b60806040518083038186803b158015611d0a57600080fd5b505afa158015611d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d42919061409d565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d49250610e3d9150859087906004016143d3565b1c67ffffffffffffffff1690565b600390565b6109d581831460676114ef565b60006060806000611dbf85613167565b90506000818015611dcc57fe5b14611de157611ddc61014e6126bf565b611e44565b611de961317d565b611df38986613191565b9094509250611e00611d9d565b67ffffffffffffffff81118015611e1657600080fd5b50604051908082528060200260200182016040528015611e40578160200160208202803683370190505b5091505b50985098509895505050505050565b60005b611e5e611d9d565b81101561090f57611e95838281518110611e7457fe5b6020026020010151838381518110611e8857fe5b6020026020010151612b94565b838281518110611ea157fe5b6020908102919091010152600101611e56565b333014611fa3576000306001600160a01b0316600036604051611ed89291906141b4565b6000604051808303816000865af19150503d8060008114611f15576040519150601f19603f3d011682016040523d82523d6000602084013e611f1a565b606091505b505090508060008114611f2957fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611f85573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611fad611512565b9050611fb9878261163f565b60006060611fd18c8c8c8c8c8c898d8d63ffffffff16565b5091509150611fe481848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60085490565b1c6bffffffffffffffffffffffff1690565b600081602001518310156120955781516020830151600091612081918690039061272c565b905061208d84826114a9565b9150506107bf565b816040015183116120a75750816107bf565b815160408301516000916120819186039061272c565b60006108c88383611c9d565b6dffffffffffffffffffffffffffff0390565b60006120eb82151560046114ef565b826120f8575060006107bf565b670de0b6b3a76400008381029061211b9085838161211257fe5b041460056114ef565b82600182038161212757fe5b046001019150506107bf565b6109d58282613218565b600060608061214d61014e6126bf565b985098509895505050505050565b60005b612166611d9d565b81101561090f5761219d83828151811061217c57fe5b602002602001015183838151811061219057fe5b60200260200101516120dc565b8382815181106121a957fe5b602090810291909101015260010161215e565b6121cb8183111561014c6114ef565b6121e66bffffffffffffffffffffffff82111561014d6114ef565b6122056121f48260606114bf565b6121ff8460006114bf565b176132d4565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d1280838360405161224092919061444d565b60405180910390a2505050565b6000612257610f35565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561228f57600080fd5b505afa1580156122a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108369190613e7c565b60006122d1611acf565b82604051602001610ece9291906141c4565b600060606122ef6114fd565b6123066001600160a01b03871630146101566114ef565b61231d6001600160a01b03861630146101566114ef565b604080516003808252608082019092526dffffffffffffffffffffffffffff91606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f00000000000000000000000000000000000000000000000000000000000000008151811061238b57fe5b6020908102919091010152909890975095505050505050565b600090565b6109d582826132e9565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561244157507f0000000000000000000000000000000000000000000000000000000000000000610c1d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561248d5761248661159b6124cc565b9050610c1d565b6001600160a01b0382163014156124ad5750670de0b6b3a7640000610c1d565b610c1d6101356126bf565b60006107bf826124c66107fd565b906114a9565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561252857600080fd5b505afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256091906140dd565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b1580156125bd57600080fd5b505afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f59190614064565b905060128260ff16111561261f576012820360ff16600a0a818161261557fe5b04925050506107ab565b60128260ff161015612640578160120360ff16600a0a8102925050506107ab565b91505090565b600281511015612655576107fa565b60008160008151811061266457fe5b602002602001015190506000600190505b825181101561090f57600083828151811061268c57fe5b602002602001015190506126b5816001600160a01b0316846001600160a01b03161060656114ef565b9150600101612675565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600082820261275084158061274957508385838161274657fe5b04145b60036114ef565b670de0b6b3a764000090049392505050565b60006127e87f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b031614806127e057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b0316145b6101356114ef565b6128d98460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061281c57fe5b6020026020010151857f00000000000000000000000000000000000000000000000000000000000000008151811061285057fe5b6020026020010151612887877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b867f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a604001516001600160a01b0316146128cd576133776128d1565b6133d75b63ffffffff16565b949350505050565b600061293d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b031614806127e0575060408501516001600160a01b031630146101356114ef565b60408401516001600160a01b03163014612998576129938460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061298557fe5b602002602001015184613440565b6128d9565b6128d98460600151847f0000000000000000000000000000000000000000000000000000000000000000815181106129cc57fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612a0057fe5b6020026020010151612a37877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613470565b6000612a997f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b031614806127e0575060408501516001600160a01b031630146101356114ef565b60408401516001600160a01b03163014612aef576129938460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612ae157fe5b6020026020010151846134d6565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612b2357fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612b5757fe5b6020026020010151612b8e877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613516565b6000612ba382151560046114ef565b82612bb0575060006107bf565b670de0b6b3a764000083810290612bca9085838161211257fe5b828181612bd357fe5b049150506107bf565b6000612c617f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b031614806127e057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b0316146101356114ef565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612c9557fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612cc957fe5b6020026020010151612d00877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b867f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a602001516001600160a01b031614612d465761357d6128d1565b6135d4565b6000612da77f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b031614806127e0575060208501516001600160a01b031630146101356114ef565b60208401516001600160a01b03163014612dfd576129938460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612def57fe5b60200260200101518461363e565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612e3157fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612e6557fe5b6020026020010151612e9c877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613668565b6000612efe7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b031614806127e0575060208501516001600160a01b031630146101356114ef565b60208401516001600160a01b03163014612f54576129938460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612f4657fe5b6020026020010151846136b7565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612f8857fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612fbc57fe5b6020026020010151612ff3877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b866136ec565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b613018610f11565b6001600160a01b031614158015613033575061303383613740565b1561305b57613040610f11565b6001600160a01b0316336001600160a01b03161490506107bf565b61306361224d565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b815260040161309293929190614272565b60206040518083038186803b1580156130aa57600080fd5b505afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113659190613d7d565b60006130f184841115836114ef565b5050900390565b4690565b61310f64e8d4a5100082101560cb6114ef565b61312567016345785d8a000082111560ca6114ef565b600854613134908260c0611493565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc9061197f908390614269565b6000818060200190518101906107bf9190613ee6565b61151061318861198a565b156101af6114ef565b6000606060006131a08461377c565b9050606061320b86836131e5897f0000000000000000000000000000000000000000000000000000000000000000815181106131d857fe5b60200260200101516124b8565b7f0000000000000000000000000000000000000000000000000000000000000000613792565b9196919550909350505050565b61322f6001600160a01b038316151561019b6114ef565b61323b8260008361090f565b6001600160a01b03821660009081526020819052604090205461326190826101a16130e2565b6001600160a01b038316600090815260208190526040902055600254613287908261384e565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132c8908590614269565b60405180910390a35050565b6008546132e3908260006114c3565b60085550565b6132f56000838361090f565b6002546133029082611c9d565b6002556001600160a01b0382166000908152602081905260409020546133289082611c9d565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132c8908590614269565b600080613384868461205c565b9050600061339282876120bd565b905060006133a0868a6114a9565b905060006133bb846124c66133b5858761385c565b8a613876565b90506133c788826114a9565b9450505050505b95945050505050565b6000806133e4868461205c565b905060006133f282876120bd565b90506000613409613403838b61385c565b876138a9565b9050600061341784836114a9565b9050600061342582886138c9565b90506134318a826114a9565b9b9a5050505050505050505050565b60008061344d848461205c565b9050600061346461345e8688611c9d565b8561205c565b9050611c7a81836114a9565b60008261348857613481868361205c565b90506133ce565b6000613494868461205c565b905060006134a561345e888a611c9d565b905060006134b382846114a9565b905060006134c184896120bd565b90506133c76134d0888461385c565b826138a9565b6000806134e3848461205c565b905060006134f182876114a9565b905060006134ff82866138c9565b905061350b86826114a9565b979650505050505050565b6000826135245750846133ce565b6000613530868461205c565b9050600061353e82876120bd565b9050600061354c878a611c9d565b9050600061355a84836120bd565b9050600061357161356b898461385c565b856138a9565b905061343181896114a9565b60008261358b5750846133ce565b6000613597868461205c565b905060006135a582876120bd565b905060006135b3868a611c9d565b905060006135c8846124c66133b5858761385c565b90506133c781896114a9565b6000826135e55761348186836138c9565b60006135f1868461205c565b905060006135ff82876120bd565b90506000613616613610838b61385c565b87613876565b905060006136248483611c9d565b9050600061363282886138c9565b9050613431818b6114a9565b60008061364b848461205c565b9050600061365c61345e86886114a9565b9050611c7a82826114a9565b600080613675868461205c565b9050600061368661345e888a6114a9565b9050600061369483836114a9565b905060006136a284896120bd565b90506133c76136b1888461385c565b82613876565b6000806136c4848461205c565b905060006136d28287611c9d565b905060006136e082866138c9565b905061350b81876114a9565b6000806136f9868461205c565b9050600061370782876120bd565b90506000613715878a6114a9565b9050600061372384836120bd565b9050600061373461356b898461385c565b905061343188826114a9565b600061376b7f9f11080e00000000000000000000000000000000000000000000000000000000610e99565b8214806107bf57506107bf82613959565b6000818060200190518101906108c89190613f01565b606060006137a08585612b94565b90506060865167ffffffffffffffff811180156137bc57600080fd5b506040519080825280602002602001820160405280156137e6578160200160208202803683370190505b50905060005b87518110156138435784811461383b576138228389838151811061380c57fe5b602002602001015161272c90919063ffffffff16565b82828151811061382e57fe5b6020026020010181815250505b6001016137ec565b509695505050505050565b60006108c8838360016130e2565b60008282026108c884158061274957508385838161274657fe5b600061388582151560046114ef565b82613892575060006107bf565b81600184038161389e57fe5b0460010190506107bf565b60006138b882151560046114ef565b8183816138c157fe5b049392505050565b60008160200151831015613912578151611365906138f090670de0b6b3a764000090611c9d565b6020840151845161390c91613905919061272c565b8690611c9d565b90612b94565b816040015183116139245750816107bf565b81516113659061393d90670de0b6b3a7640000906114a9565b6040840151845161390c91613952919061272c565b86906114a9565b60006139847f38e9922e00000000000000000000000000000000000000000000000000000000610e99565b8214806107bf57506139b57f50dd6ed900000000000000000000000000000000000000000000000000000000610e99565b909114919050565b60405180606001604052806000815260200160008152602001600081525090565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b80356107bf816144bc565b600082601f830112613a23578081fd5b8135613a36613a3182614490565b614469565b818152915060208083019084810181840286018201871015613a5757600080fd5b60005b84811015613a7657813584529282019290820190600101613a5a565b505050505092915050565b600082601f830112613a91578081fd5b8151613a9f613a3182614490565b818152915060208083019084810181840286018201871015613ac057600080fd5b60005b84811015613a7657815184529282019290820190600101613ac3565b600082601f830112613aef578081fd5b813567ffffffffffffffff811115613b05578182fd5b613b186020601f19601f84011601614469565b9150808252836020828501011115613b2f57600080fd5b8060208401602084013760009082016020015292915050565b8051600181106107bf57600080fd5b8035600281106107bf57600080fd5b600060208284031215613b77578081fd5b81356108c8816144bc565b60008060408385031215613b94578081fd5b8235613b9f816144bc565b91506020830135613baf816144bc565b809150509250929050565b600080600060608486031215613bce578081fd5b8335613bd9816144bc565b92506020840135613be9816144bc565b929592945050506040919091013590565b600080600080600080600060e0888a031215613c14578283fd5b8735613c1f816144bc565b96506020880135613c2f816144bc565b955060408801359450606088013593506080880135613c4d816144df565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613c7c578182fd5b8235613c87816144bc565b946020939093013593505050565b600080600060608486031215613ca9578081fd5b835167ffffffffffffffff80821115613cc0578283fd5b818601915086601f830112613cd3578283fd5b8151613ce1613a3182614490565b80828252602080830192508086018b828387028901011115613d01578788fd5b8796505b84871015613d2c578051613d18816144bc565b845260019690960195928101928101613d05565b508901519097509350505080821115613d43578283fd5b50613d5086828701613a81565b925050604084015190509250925092565b600060208284031215613d72578081fd5b81356108c8816144d1565b600060208284031215613d8e578081fd5b81516108c8816144d1565b600080600080600080600060e0888a031215613db3578081fd5b873596506020880135613dc5816144bc565b95506040880135613dd5816144bc565b9450606088013567ffffffffffffffff80821115613df1578283fd5b613dfd8b838c01613a13565b955060808a0135945060a08a0135935060c08a0135915080821115613e20578283fd5b50613e2d8a828b01613adf565b91505092959891949750929550565b600060208284031215613e4d578081fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c8578182fd5b600060208284031215613e8d578081fd5b81516108c8816144bc565b60008060408385031215613eaa578182fd5b8235613eb5816144bc565b9150602083013567ffffffffffffffff811115613ed0578182fd5b613edc85828601613adf565b9150509250929050565b600060208284031215613ef7578081fd5b6108c88383613b48565b60008060408385031215613f13578182fd5b613f1d8484613b48565b9150602083015190509250929050565b60008060008060808587031215613f42578182fd5b843567ffffffffffffffff80821115613f59578384fd5b818701915061012080838a031215613f6f578485fd5b613f7881614469565b9050613f848984613b57565b8152613f938960208501613a08565b6020820152613fa58960408501613a08565b6040820152606083013560608201526080830135608082015260a083013560a0820152613fd58960c08501613a08565b60c0820152613fe78960e08501613a08565b60e08201526101008084013583811115613fff578687fd5b61400b8b828701613adf565b828401525050809650506020870135915080821115614028578384fd5b5061403587828801613a13565b949794965050505060408301359260600135919050565b60006020828403121561405d578081fd5b5035919050565b600060208284031215614075578081fd5b5051919050565b6000806040838503121561408e578182fd5b50508035926020909101359150565b600080600080608085870312156140b2578182fd5b84519350602085015192506040850151915060608501516140d2816144bc565b939692955090935050565b6000602082840312156140ee578081fd5b81516108c8816144df565b6000815180845260208085019450808401835b838110156141285781518752958201959082019060010161410c565b509495945050505050565b15159052565b60008151808452815b8181101561415e57602081850181015186830182015201614142565b8181111561416f5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6000602082526108c860208301846140f9565b60006040825261423460408301856140f9565b82810360208401526133ce81856140f9565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b600085825260206001600160a01b038087168285015280861660408501525060806060840152610100830184516080808601528181518084526101208701915084830193508592505b80831015614302576142ec84516144b0565b82529284019260019290920191908401906142da565b508387015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809250828682030160a087015261434081856140f9565b935050506040850151818584030160c086015261435d8382614139565b92505050606084015161384360e0850182614133565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6000838252604060208301526128d96040830184614139565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526108c86020830184614139565b6000838252604060208301526128d960408301846140f9565b918252602082015260400190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561448857600080fd5b604052919050565b600067ffffffffffffffff8211156144a6578081fd5b5060209081020190565b6001600160a01b031690565b6001600160a01b03811681146107fa57600080fd5b80151581146107fa57600080fd5b60ff811681146107fa57600080fdfea26469706673582212208cee796c69d779f4ecdac48d0ee5699c0c37b947a653bfd7e783081a6338bb7464736f6c6343000701003300000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e000000000000000000000000637ec617c86d24e421328e6caea1d9211489243900000000000000000000000000000000000000000000e8ef1e96ae38978000000000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000007330450000000000000000000000000000000000000000000000000000000000278d00000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776000000000000000000000000000000000000000000000000000000000000001e426565747320596561726e20426f6f7374656420506f6f6c2028444149290000000000000000000000000000000000000000000000000000000000000000000962622d79762d4441490000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102d35760003560e01c8063679aefce1161018657806395d89b41116100e3578063d505accf11610097578063de82cd3411610071578063de82cd341461056b578063f174e24114610573578063f5431aa81461057b576102d3565b8063d505accf14610532578063d5c096c414610545578063dd62ed3e14610558576102d3565b8063a457c2d7116100c8578063a457c2d714610504578063a9059cbb14610517578063aaabadc51461052a576102d3565b806395d89b41146104e95780639f11080e146104f1576102d3565b806382687a561161013a57806387ec68171161011f57806387ec6817146104c6578063893d20e8146104d95780638d928af8146104e1576102d3565b806382687a56146104ab578063851c1bb3146104b3576102d3565b806374f3b0091161016b57806374f3b0091461046f5780637ecebe00146104905780638129fc1c146104a3576102d3565b8063679aefce1461045457806370a082311461045c576102d3565b80633644e515116102345780634de046d5116101e857806355c67628116101cd57806355c67628146104155780636028bfd41461041d57806363fe3b561461043e576102d3565b80634de046d5146103ed57806350dd6ed914610402576102d3565b806338fff2d01161021957806338fff2d0146103ca57806339509351146103d25780634d64cd74146103e5576102d3565b80633644e515146103af57806338e9922e146103b7576102d3565b806318160ddd1161028b5780631dd746ea116102705780631dd746ea1461037257806323b872dd14610387578063313ce5671461039a576102d3565b806318160ddd146103535780631c0de0511461035b576102d3565b8063095ea7b3116102bc578063095ea7b31461031657806316b8d6ff1461033657806316c38b3c1461033e576102d3565b806301ec954a146102d857806306fdde0314610301575b600080fd5b6102eb6102e6366004613f2d565b610583565b6040516102f89190614269565b60405180910390f35b6103096106f9565b6040516102f89190614421565b610329610324366004613c6a565b6107ae565b6040516102f89190614246565b6102eb6107c5565b61035161034c366004613d61565b6107e9565b005b6102eb6107fd565b610363610803565b6040516102f893929190614251565b61037a61082c565b6040516102f8919061420e565b610329610395366004613bba565b61083b565b6103a26108cf565b6040516102f8919061445b565b6102eb6108d8565b6103516103c536600461404c565b6108e2565b6102eb610914565b6103296103e0366004613c6a565b610938565b6102eb610973565b6103f5610997565b6040516102f891906141fa565b610351610410366004613e98565b6109bb565b6102eb6109d9565b61043061042b366004613d99565b6109ea565b6040516102f8929190614434565b610446610a21565b6040516102f892919061444d565b6102eb610a4f565b6102eb61046a366004613b66565b610c03565b61048261047d366004613d99565b610c22565b6040516102f8929190614221565b6102eb61049e366004613b66565b610ca0565b610351610cbb565b6102eb610e75565b6102eb6104c1366004613e3c565b610e99565b6104306104d4366004613d99565b610eeb565b6103f5610f11565b6103f5610f35565b610309610f59565b6103516104ff36600461407c565b610fd8565b610329610512366004613c6a565b611042565b610329610525366004613c6a565b611080565b6103f561108d565b610351610540366004613bfa565b611097565b610482610553366004613d99565b6111e0565b6102eb610566366004613b82565b611311565b6102eb61136c565b6103f561145b565b6102eb61147f565b600084608001516105b0610595610f35565b6001600160a01b0316336001600160a01b03161460cd6114ef565b6105c56105bb610914565b82146101f46114ef565b6105cd6114fd565b6105e76003851080156105e05750600384105b60646114ef565b60606105f1611512565b90506105fd868261163f565b600080610608610a21565b915091506106146139bd565b60405180606001604052806106276109d9565b815260208101859052604001839052905060008a51600181111561064757fe5b14156106ab5761066e8a60600151858a8151811061066157fe5b60200260200101516116a0565b60608b015260006106808b8b846116ac565b905061069f81868a8151811061069257fe5b6020026020010151611773565b965050505050506106f0565b6106bf8a6060015185898151811061066157fe5b60608b015260006106d18b8b8461177f565b905061069f81868b815181106106e357fe5b6020026020010151611834565b50949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b820191906000526020600020905b81548152906001019060200180831161078657829003601f168201915b505050505090505b90565b60006107bb338484611840565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000190565b6107f16118a8565b6107fa816118ee565b50565b60025490565b600080600061081061198a565b15925061081b6119a7565b91506108256119cb565b9050909192565b6060610836611512565b905090565b6000806108488533611311565b905061086c336001600160a01b03871614806108645750838210155b61019e6114ef565b6108778585856119ef565b336001600160a01b038616148015906108b057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b156108c2576108c28533858403611840565b60019150505b9392505050565b60055460ff1690565b6000610836611acf565b6000806108ed610a21565b915091506109066108fe8383611b6c565b61014f6114ef565b61090f83611c84565b505050565b7f2ff1552dd09f87d6774229ee5eca60cf570ae29100000000000000000000018690565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916107bb91859061096e9086611c9d565b611840565b7f000000000000000000000000000000000000000000000000000000000000000290565b7f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e90565b6109c36118a8565b6109cb6114fd565b6109d58282611caf565b5050565b6008546000906108369060c0611d8f565b60006060610a0086516109fb611d9d565b611da2565b610a1589898989898989611daf611e53611eb4565b97509795505050505050565b6000806000610a2e612044565b9050610a3b81600061204a565b9250610a4881606061204a565b9150509091565b600080610a5a610914565b90506060610a66610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610a919190614269565b60006040518083038186803b158015610aa957600080fd5b505afa158015610abd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae59190810190613c95565b50915050610afa81610af5611512565b61163f565b600080610b05610a21565b91509150610b116139bd565b6040518060600160405280610b246109d9565b81526020018481526020018381525090506000610bb0610b77867f000000000000000000000000000000000000000000000000000000000000000281518110610b6957fe5b60200260200101518461205c565b867f000000000000000000000000000000000000000000000000000000000000000181518110610ba357fe5b60200260200101516120bd565b9050610bf8610bf1867f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b60200260200101516120c9565b82906120dc565b965050505050505090565b6001600160a01b0381166000908152602081905260409020545b919050565b60608088610c31610595610f35565b610c3c6105bb610914565b6060610c46611512565b9050610c52888261163f565b6000606080610c678e8e8e8e8e8e8a8f611daf565b925092509250610c778d84612133565b610c818285611e53565b610c8b8185611e53565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b6000610cc5610914565b90506060610cd1610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610cfc9190614269565b60006040518083038186803b158015610d1457600080fd5b505afa158015610d28573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d509190810190613c95565b505060408051600380825260808201909252919250606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f000000000000000000000000000000000000000000000000000000000000000081518110610db357fe5b602002602001018181525050610dc76139de565b6040518060800160405280610ddb856107ab565b8152602001838152602001604051806020016040528060008152508152602001600015158152509050610e0c610f35565b6001600160a01b031663b95cac28853030856040518563ffffffff1660e01b8152600401610e3d9493929190614291565b600060405180830381600087803b158015610e5757600080fd5b505af1158015610e6b573d6000803e3d6000fd5b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b60007f0000000000000000000000001f73ae6ed391a2b1e84ff988a1bb5394b78a4a7182604051602001610ece929190614184565b604051602081830303815290604052805190602001209050919050565b60006060610efc86516109fb611d9d565b610a158989898989898961213d61215b611eb4565b7f000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a77690565b7f00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce90565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b610fe06118a8565b600080610feb610a21565b91509150610ffc6108fe8383611b6c565b6110116110098585611b6c565b6101576114ef565b61103c7f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e85856121bc565b50505050565b60008061104f3385611311565b90508083106110695761106433856000611840565b611076565b6110763385858403611840565b5060019392505050565b60006107bb3384846119ef565b600061083661224d565b6110a58442111560d16114ef565b6001600160a01b03871660009081526006602090815260408083205490519092916110fc917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918c918c918c9188918d9101614373565b604051602081830303815290604052805190602001209050600061111f826122c7565b90506000600182888888604051600081526020016040526040516111469493929190614403565b6020604051602081039080840390855afa158015611168573d6000803e3d6000fd5b5050604051601f19015191506111aa90506001600160a01b038216158015906111a257508b6001600160a01b0316826001600160a01b0316145b6101f86114ef565b6001600160a01b038b1660009081526006602052604090206001850190556111d38b8b8b611840565b5050505050505050505050565b606080886111ef610595610f35565b6111fa6105bb610914565b6060611204611512565b905061120e6107fd565b6112c157600060606112238d8d8d868b6122e3565b9150915061123c6112326123a4565b83101560cc6114ef565b61124e60006112496123a4565b6123a9565b6112618b61125a6123a4565b84036123a9565b61126b818461215b565b80611274611d9d565b67ffffffffffffffff8111801561128a57600080fd5b506040519080825280602002602001820160405280156112b4578160200160208202803683370190505b5095509550505050610c93565b6112cb888261163f565b60006060806112e08e8e8e8e8e8e8a8f61213d565b9250925092506112f08c846123a9565b6112fa828561215b565b6113048185611e53565b9095509350610c93915050565b600061131b610f35565b6001600160a01b0316826001600160a01b0316141561135b57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6107bf565b61136583836123b3565b90506107bf565b60006060611378610f35565b6001600160a01b031663f94d466861138e610914565b6040518263ffffffff1660e01b81526004016113aa9190614269565b60006040518083038186803b1580156113c257600080fd5b505afa1580156113d6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fe9190810190613c95565b509150506000611449827f00000000000000000000000000000000000000000000000000000000000000008151811061143357fe5b6020026020010151611444306123de565b6116a0565b9050611454816124b8565b9250505090565b7f000000000000000000000000637ec617c86d24e421328e6caea1d9211489243990565b60006108366124cc565b806109d581612646565b67ffffffffffffffff811b1992909216911b1790565b60006114b98383111560016114ef565b50900390565b1b90565b77ffffffffffffffffffffffffffffffffffffffffffffffff828116821b90821b198416179392505050565b816109d5576109d5816126bf565b61151061150861198a565b6101926114ef565b565b604080516003808252608082019092526060918291906020820183803683370190505090507f0000000000000000000000000000000000000000000000000de0b6b3a7640000817f00000000000000000000000000000000000000000000000000000000000000028151811061158457fe5b6020026020010181815250506115c261159b6124cc565b7f0000000000000000000000000000000000000000000000000de0b6b3a76400009061272c565b817f0000000000000000000000000000000000000000000000000000000000000001815181106115ee57fe5b602002602001018181525050670de0b6b3a7640000817f00000000000000000000000000000000000000000000000000000000000000008151811061162f57fe5b6020908102919091010152905090565b60005b61164a611d9d565b81101561090f5761168183828151811061166057fe5b602002602001015183838151811061167457fe5b602002602001015161272c565b83828151811061168d57fe5b6020908102919091010152600101611642565b60006108c8838361272c565b60208301516000906001600160a01b03163014156116d6576116cf848484612762565b90506108c8565b7f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031684602001516001600160a01b0316141561171f576116cf8484846128e1565b7f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031684602001516001600160a01b03161415611768576116cf848484612a3d565b6108c86101356126bf565b60006108c88383612b94565b60408301516000906001600160a01b03163014156117a2576116cf848484612bdc565b7f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031684604001516001600160a01b031614156117eb576116cf848484612d4b565b7f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031684604001516001600160a01b03161415611768576116cf848484612ea2565b60006108c883836120dc565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061189b908590614269565b60405180910390a3505050565b60006118d76000357fffffffff0000000000000000000000000000000000000000000000000000000016610e99565b90506107fa6118e68233612ff9565b6101916114ef565b801561190e576119096118ff6119a7565b42106101936114ef565b611923565b6119236119196119cb565b42106101a96114ef565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be649061197f908390614246565b60405180910390a150565b60006119946119cb565b42118061083657505060075460ff161590565b7f0000000000000000000000000000000000000000000000000000000062618dfe90565b7f0000000000000000000000000000000000000000000000000000000062891afe90565b611a066001600160a01b03841615156101986114ef565b611a1d6001600160a01b03831615156101996114ef565b611a2883838361090f565b6001600160a01b038316600090815260208190526040902054611a4e90826101a06130e2565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611a7d9082611c9d565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061189b908590614269565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f2d7620a870929c71d13c853a90e075b882bb2450edd3a0e7c5bad0862059dbe47fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6611b3c6130f8565b30604051602001611b519594939291906143a7565b60405160208183030381529060405280519060200120905090565b600080611b77610914565b90506060611b83610f35565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401611bae9190614269565b60006040518083038186803b158015611bc657600080fd5b505afa158015611bda573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c029190810190613c95565b509150506000611c68827f000000000000000000000000000000000000000000000000000000000000000281518110611c3757fe5b60200260200101516114447f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6123de565b9050858110158015611c7a5750848111155b9695505050505050565b611c8c6118a8565b611c946114fd565b6107fa816130fc565b60008282016108c884821015836114ef565b6000611cb9610914565b90506000611cc5610f35565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b8152600401611cf29291906143ec565b60806040518083038186803b158015611d0a57600080fd5b505afa158015611d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d42919061409d565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d49250610e3d9150859087906004016143d3565b1c67ffffffffffffffff1690565b600390565b6109d581831460676114ef565b60006060806000611dbf85613167565b90506000818015611dcc57fe5b14611de157611ddc61014e6126bf565b611e44565b611de961317d565b611df38986613191565b9094509250611e00611d9d565b67ffffffffffffffff81118015611e1657600080fd5b50604051908082528060200260200182016040528015611e40578160200160208202803683370190505b5091505b50985098509895505050505050565b60005b611e5e611d9d565b81101561090f57611e95838281518110611e7457fe5b6020026020010151838381518110611e8857fe5b6020026020010151612b94565b838281518110611ea157fe5b6020908102919091010152600101611e56565b333014611fa3576000306001600160a01b0316600036604051611ed89291906141b4565b6000604051808303816000865af19150503d8060008114611f15576040519150601f19603f3d011682016040523d82523d6000602084013e611f1a565b606091505b505090508060008114611f2957fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611f85573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611fad611512565b9050611fb9878261163f565b60006060611fd18c8c8c8c8c8c898d8d63ffffffff16565b5091509150611fe481848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60085490565b1c6bffffffffffffffffffffffff1690565b600081602001518310156120955781516020830151600091612081918690039061272c565b905061208d84826114a9565b9150506107bf565b816040015183116120a75750816107bf565b815160408301516000916120819186039061272c565b60006108c88383611c9d565b6dffffffffffffffffffffffffffff0390565b60006120eb82151560046114ef565b826120f8575060006107bf565b670de0b6b3a76400008381029061211b9085838161211257fe5b041460056114ef565b82600182038161212757fe5b046001019150506107bf565b6109d58282613218565b600060608061214d61014e6126bf565b985098509895505050505050565b60005b612166611d9d565b81101561090f5761219d83828151811061217c57fe5b602002602001015183838151811061219057fe5b60200260200101516120dc565b8382815181106121a957fe5b602090810291909101015260010161215e565b6121cb8183111561014c6114ef565b6121e66bffffffffffffffffffffffff82111561014d6114ef565b6122056121f48260606114bf565b6121ff8460006114bf565b176132d4565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d1280838360405161224092919061444d565b60405180910390a2505050565b6000612257610f35565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561228f57600080fd5b505afa1580156122a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108369190613e7c565b60006122d1611acf565b82604051602001610ece9291906141c4565b600060606122ef6114fd565b6123066001600160a01b03871630146101566114ef565b61231d6001600160a01b03861630146101566114ef565b604080516003808252608082019092526dffffffffffffffffffffffffffff91606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f00000000000000000000000000000000000000000000000000000000000000008151811061238b57fe5b6020908102919091010152909890975095505050505050565b600090565b6109d582826132e9565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60007f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b0316826001600160a01b0316141561244157507f0000000000000000000000000000000000000000000000000de0b6b3a7640000610c1d565b7f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b0316826001600160a01b0316141561248d5761248661159b6124cc565b9050610c1d565b6001600160a01b0382163014156124ad5750670de0b6b3a7640000610c1d565b610c1d6101356126bf565b60006107bf826124c66107fd565b906114a9565b6000807f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561252857600080fd5b505afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256091906140dd565b905060007f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b03166399530b066040518163ffffffff1660e01b815260040160206040518083038186803b1580156125bd57600080fd5b505afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f59190614064565b905060128260ff16111561261f576012820360ff16600a0a818161261557fe5b04925050506107ab565b60128260ff161015612640578160120360ff16600a0a8102925050506107ab565b91505090565b600281511015612655576107fa565b60008160008151811061266457fe5b602002602001015190506000600190505b825181101561090f57600083828151811061268c57fe5b602002602001015190506126b5816001600160a01b0316846001600160a01b03161060656114ef565b9150600101612675565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600082820261275084158061274957508385838161274657fe5b04145b60036114ef565b670de0b6b3a764000090049392505050565b60006127e87f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031685604001516001600160a01b031614806127e057507f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031685604001516001600160a01b0316145b6101356114ef565b6128d98460600151847f00000000000000000000000000000000000000000000000000000000000000028151811061281c57fe5b6020026020010151857f00000000000000000000000000000000000000000000000000000000000000018151811061285057fe5b6020026020010151612887877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b867f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b03168a604001516001600160a01b0316146128cd576133776128d1565b6133d75b63ffffffff16565b949350505050565b600061293d7f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031685604001516001600160a01b031614806127e0575060408501516001600160a01b031630146101356114ef565b60408401516001600160a01b03163014612998576129938460600151847f00000000000000000000000000000000000000000000000000000000000000028151811061298557fe5b602002602001015184613440565b6128d9565b6128d98460600151847f0000000000000000000000000000000000000000000000000000000000000002815181106129cc57fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000181518110612a0057fe5b6020026020010151612a37877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613470565b6000612a997f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031685604001516001600160a01b031614806127e0575060408501516001600160a01b031630146101356114ef565b60408401516001600160a01b03163014612aef576129938460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612ae157fe5b6020026020010151846134d6565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612b2357fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000181518110612b5757fe5b6020026020010151612b8e877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613516565b6000612ba382151560046114ef565b82612bb0575060006107bf565b670de0b6b3a764000083810290612bca9085838161211257fe5b828181612bd357fe5b049150506107bf565b6000612c617f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031685602001516001600160a01b031614806127e057507f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031685602001516001600160a01b0316146101356114ef565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612c9557fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000181518110612cc957fe5b6020026020010151612d00877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b867f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b03168a602001516001600160a01b031614612d465761357d6128d1565b6135d4565b6000612da77f000000000000000000000000637ec617c86d24e421328e6caea1d921148924396001600160a01b031685602001516001600160a01b031614806127e0575060208501516001600160a01b031630146101356114ef565b60208401516001600160a01b03163014612dfd576129938460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612def57fe5b60200260200101518461363e565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612e3157fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000181518110612e6557fe5b6020026020010151612e9c877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b86613668565b6000612efe7f0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e6001600160a01b031685602001516001600160a01b031614806127e0575060208501516001600160a01b031630146101356114ef565b60208401516001600160a01b03163014612f54576129938460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612f4657fe5b6020026020010151846136b7565b6128d98460600151847f000000000000000000000000000000000000000000000000000000000000000281518110612f8857fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000181518110612fbc57fe5b6020026020010151612ff3877f000000000000000000000000000000000000000000000000000000000000000081518110610be457fe5b866136ec565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b613018610f11565b6001600160a01b031614158015613033575061303383613740565b1561305b57613040610f11565b6001600160a01b0316336001600160a01b03161490506107bf565b61306361224d565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b815260040161309293929190614272565b60206040518083038186803b1580156130aa57600080fd5b505afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113659190613d7d565b60006130f184841115836114ef565b5050900390565b4690565b61310f64e8d4a5100082101560cb6114ef565b61312567016345785d8a000082111560ca6114ef565b600854613134908260c0611493565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc9061197f908390614269565b6000818060200190518101906107bf9190613ee6565b61151061318861198a565b156101af6114ef565b6000606060006131a08461377c565b9050606061320b86836131e5897f0000000000000000000000000000000000000000000000000000000000000000815181106131d857fe5b60200260200101516124b8565b7f0000000000000000000000000000000000000000000000000000000000000000613792565b9196919550909350505050565b61322f6001600160a01b038316151561019b6114ef565b61323b8260008361090f565b6001600160a01b03821660009081526020819052604090205461326190826101a16130e2565b6001600160a01b038316600090815260208190526040902055600254613287908261384e565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132c8908590614269565b60405180910390a35050565b6008546132e3908260006114c3565b60085550565b6132f56000838361090f565b6002546133029082611c9d565b6002556001600160a01b0382166000908152602081905260409020546133289082611c9d565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132c8908590614269565b600080613384868461205c565b9050600061339282876120bd565b905060006133a0868a6114a9565b905060006133bb846124c66133b5858761385c565b8a613876565b90506133c788826114a9565b9450505050505b95945050505050565b6000806133e4868461205c565b905060006133f282876120bd565b90506000613409613403838b61385c565b876138a9565b9050600061341784836114a9565b9050600061342582886138c9565b90506134318a826114a9565b9b9a5050505050505050505050565b60008061344d848461205c565b9050600061346461345e8688611c9d565b8561205c565b9050611c7a81836114a9565b60008261348857613481868361205c565b90506133ce565b6000613494868461205c565b905060006134a561345e888a611c9d565b905060006134b382846114a9565b905060006134c184896120bd565b90506133c76134d0888461385c565b826138a9565b6000806134e3848461205c565b905060006134f182876114a9565b905060006134ff82866138c9565b905061350b86826114a9565b979650505050505050565b6000826135245750846133ce565b6000613530868461205c565b9050600061353e82876120bd565b9050600061354c878a611c9d565b9050600061355a84836120bd565b9050600061357161356b898461385c565b856138a9565b905061343181896114a9565b60008261358b5750846133ce565b6000613597868461205c565b905060006135a582876120bd565b905060006135b3868a611c9d565b905060006135c8846124c66133b5858761385c565b90506133c781896114a9565b6000826135e55761348186836138c9565b60006135f1868461205c565b905060006135ff82876120bd565b90506000613616613610838b61385c565b87613876565b905060006136248483611c9d565b9050600061363282886138c9565b9050613431818b6114a9565b60008061364b848461205c565b9050600061365c61345e86886114a9565b9050611c7a82826114a9565b600080613675868461205c565b9050600061368661345e888a6114a9565b9050600061369483836114a9565b905060006136a284896120bd565b90506133c76136b1888461385c565b82613876565b6000806136c4848461205c565b905060006136d28287611c9d565b905060006136e082866138c9565b905061350b81876114a9565b6000806136f9868461205c565b9050600061370782876120bd565b90506000613715878a6114a9565b9050600061372384836120bd565b9050600061373461356b898461385c565b905061343188826114a9565b600061376b7f9f11080e00000000000000000000000000000000000000000000000000000000610e99565b8214806107bf57506107bf82613959565b6000818060200190518101906108c89190613f01565b606060006137a08585612b94565b90506060865167ffffffffffffffff811180156137bc57600080fd5b506040519080825280602002602001820160405280156137e6578160200160208202803683370190505b50905060005b87518110156138435784811461383b576138228389838151811061380c57fe5b602002602001015161272c90919063ffffffff16565b82828151811061382e57fe5b6020026020010181815250505b6001016137ec565b509695505050505050565b60006108c8838360016130e2565b60008282026108c884158061274957508385838161274657fe5b600061388582151560046114ef565b82613892575060006107bf565b81600184038161389e57fe5b0460010190506107bf565b60006138b882151560046114ef565b8183816138c157fe5b049392505050565b60008160200151831015613912578151611365906138f090670de0b6b3a764000090611c9d565b6020840151845161390c91613905919061272c565b8690611c9d565b90612b94565b816040015183116139245750816107bf565b81516113659061393d90670de0b6b3a7640000906114a9565b6040840151845161390c91613952919061272c565b86906114a9565b60006139847f38e9922e00000000000000000000000000000000000000000000000000000000610e99565b8214806107bf57506139b57f50dd6ed900000000000000000000000000000000000000000000000000000000610e99565b909114919050565b60405180606001604052806000815260200160008152602001600081525090565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b80356107bf816144bc565b600082601f830112613a23578081fd5b8135613a36613a3182614490565b614469565b818152915060208083019084810181840286018201871015613a5757600080fd5b60005b84811015613a7657813584529282019290820190600101613a5a565b505050505092915050565b600082601f830112613a91578081fd5b8151613a9f613a3182614490565b818152915060208083019084810181840286018201871015613ac057600080fd5b60005b84811015613a7657815184529282019290820190600101613ac3565b600082601f830112613aef578081fd5b813567ffffffffffffffff811115613b05578182fd5b613b186020601f19601f84011601614469565b9150808252836020828501011115613b2f57600080fd5b8060208401602084013760009082016020015292915050565b8051600181106107bf57600080fd5b8035600281106107bf57600080fd5b600060208284031215613b77578081fd5b81356108c8816144bc565b60008060408385031215613b94578081fd5b8235613b9f816144bc565b91506020830135613baf816144bc565b809150509250929050565b600080600060608486031215613bce578081fd5b8335613bd9816144bc565b92506020840135613be9816144bc565b929592945050506040919091013590565b600080600080600080600060e0888a031215613c14578283fd5b8735613c1f816144bc565b96506020880135613c2f816144bc565b955060408801359450606088013593506080880135613c4d816144df565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613c7c578182fd5b8235613c87816144bc565b946020939093013593505050565b600080600060608486031215613ca9578081fd5b835167ffffffffffffffff80821115613cc0578283fd5b818601915086601f830112613cd3578283fd5b8151613ce1613a3182614490565b80828252602080830192508086018b828387028901011115613d01578788fd5b8796505b84871015613d2c578051613d18816144bc565b845260019690960195928101928101613d05565b508901519097509350505080821115613d43578283fd5b50613d5086828701613a81565b925050604084015190509250925092565b600060208284031215613d72578081fd5b81356108c8816144d1565b600060208284031215613d8e578081fd5b81516108c8816144d1565b600080600080600080600060e0888a031215613db3578081fd5b873596506020880135613dc5816144bc565b95506040880135613dd5816144bc565b9450606088013567ffffffffffffffff80821115613df1578283fd5b613dfd8b838c01613a13565b955060808a0135945060a08a0135935060c08a0135915080821115613e20578283fd5b50613e2d8a828b01613adf565b91505092959891949750929550565b600060208284031215613e4d578081fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c8578182fd5b600060208284031215613e8d578081fd5b81516108c8816144bc565b60008060408385031215613eaa578182fd5b8235613eb5816144bc565b9150602083013567ffffffffffffffff811115613ed0578182fd5b613edc85828601613adf565b9150509250929050565b600060208284031215613ef7578081fd5b6108c88383613b48565b60008060408385031215613f13578182fd5b613f1d8484613b48565b9150602083015190509250929050565b60008060008060808587031215613f42578182fd5b843567ffffffffffffffff80821115613f59578384fd5b818701915061012080838a031215613f6f578485fd5b613f7881614469565b9050613f848984613b57565b8152613f938960208501613a08565b6020820152613fa58960408501613a08565b6040820152606083013560608201526080830135608082015260a083013560a0820152613fd58960c08501613a08565b60c0820152613fe78960e08501613a08565b60e08201526101008084013583811115613fff578687fd5b61400b8b828701613adf565b828401525050809650506020870135915080821115614028578384fd5b5061403587828801613a13565b949794965050505060408301359260600135919050565b60006020828403121561405d578081fd5b5035919050565b600060208284031215614075578081fd5b5051919050565b6000806040838503121561408e578182fd5b50508035926020909101359150565b600080600080608085870312156140b2578182fd5b84519350602085015192506040850151915060608501516140d2816144bc565b939692955090935050565b6000602082840312156140ee578081fd5b81516108c8816144df565b6000815180845260208085019450808401835b838110156141285781518752958201959082019060010161410c565b509495945050505050565b15159052565b60008151808452815b8181101561415e57602081850181015186830182015201614142565b8181111561416f5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6000602082526108c860208301846140f9565b60006040825261423460408301856140f9565b82810360208401526133ce81856140f9565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b600085825260206001600160a01b038087168285015280861660408501525060806060840152610100830184516080808601528181518084526101208701915084830193508592505b80831015614302576142ec84516144b0565b82529284019260019290920191908401906142da565b508387015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809250828682030160a087015261434081856140f9565b935050506040850151818584030160c086015261435d8382614139565b92505050606084015161384360e0850182614133565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6000838252604060208301526128d96040830184614139565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526108c86020830184614139565b6000838252604060208301526128d960408301846140f9565b918252602082015260400190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561448857600080fd5b604052919050565b600067ffffffffffffffff8211156144a6578081fd5b5060209081020190565b6001600160a01b031690565b6001600160a01b03811681146107fa57600080fd5b80151581146107fa57600080fd5b60ff811681146107fa57600080fdfea26469706673582212208cee796c69d779f4ecdac48d0ee5699c0c37b947a653bfd7e783081a6338bb7464736f6c63430007010033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e000000000000000000000000637ec617c86d24e421328e6caea1d9211489243900000000000000000000000000000000000000000000e8ef1e96ae38978000000000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000007330450000000000000000000000000000000000000000000000000000000000278d00000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776000000000000000000000000000000000000000000000000000000000000001e426565747320596561726e20426f6f7374656420506f6f6c2028444149290000000000000000000000000000000000000000000000000000000000000000000962622d79762d4441490000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : vault (address): 0x20dd72Ed959b6147912C2e529F0a0C651c33c9ce
Arg [1] : name (string): Beets Yearn Boosted Pool (DAI)
Arg [2] : symbol (string): bb-yv-DAI
Arg [3] : mainToken (address): 0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E
Arg [4] : wrappedToken (address): 0x637eC617c86D24E421328e6CAEa1d92114892439
Arg [5] : upperTarget (uint256): 1100000000000000000000000
Arg [6] : swapFeePercentage (uint256): 200000000000000
Arg [7] : pauseWindowDuration (uint256): 7548997
Arg [8] : bufferPeriodDuration (uint256): 2592000
Arg [9] : owner (address): 0xCd983793ADb846dcE4830c22F30C7Ef0C864a776
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [3] : 0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e
Arg [4] : 000000000000000000000000637ec617c86d24e421328e6caea1d92114892439
Arg [5] : 00000000000000000000000000000000000000000000e8ef1e96ae3897800000
Arg [6] : 0000000000000000000000000000000000000000000000000000b5e620f48000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000733045
Arg [8] : 0000000000000000000000000000000000000000000000000000000000278d00
Arg [9] : 000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776
Arg [10] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [11] : 426565747320596561726e20426f6f7374656420506f6f6c2028444149290000
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [13] : 62622d79762d4441490000000000000000000000000000000000000000000000
Deployed Bytecode Sourcemap
822:1546:41:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9823:2462:38;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2138:81:24;;;:::i;:::-;;;;;;;:::i;4172:164::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;7928:96:38:-;;;:::i;7548:89:2:-;;;;;;:::i;:::-;;:::i;:::-;;3181:98:24;;;:::i;3154:363:17:-;;;:::i;:::-;;;;;;;;;:::i;21849:111:2:-;;;:::i;:::-;;;;;;;:::i;2574:655:1:-;;;;;;:::i;:::-;;:::i;3040:81:24:-;;;:::i;:::-;;;;;;;:::i;2359:113:25:-;;;:::i;26992:832:38:-;;;;;;:::i;:::-;;:::i;5629:91:2:-;;;:::i;5584:211:24:-;;;;;;:::i;:::-;;:::i;7832:90:38:-;;;:::i;7524:97::-;;;:::i;:::-;;;;;;;:::i;7043:214:2:-;;;;;;:::i;:::-;;:::i;6314:137::-;;;:::i;14247:904::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;25032:269:38:-;;;:::i;:::-;;;;;;;;:::i;23819:1014::-;;;:::i;3337:117:24:-;;;;;;:::i;:::-;;:::i;10872:1197:2:-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;2127:108:25:-;;;;;;:::i;:::-;;:::i;8725:1019:38:-;;;:::i;7738:88::-;;;:::i;2487:430:8:-;;;;;;:::i;:::-;;:::i;12722:902:2:-;;;;;;:::i;:::-;;:::i;1776:80:3:-;;;:::i;1796:79:1:-;;;:::i;2332:85:24:-;;;:::i;26016:970:38:-;;;;;;:::i;:::-;;:::i;3355:429:1:-;;;;;;:::i;:::-;;:::i;3657:170:24:-;;;;;;:::i;:::-;;:::i;1862:101:3:-;;;:::i;1313:753:25:-;;;;;;:::i;:::-;;:::i;8566:2300:2:-;;;;;;:::i;:::-;;:::i;2177:254:1:-;;;;;;:::i;:::-;;:::i;28762:450:38:-;;;:::i;7627:105::-;;;:::i;24839:109::-;;;:::i;9823:2462::-;10037:7;9998;:14;;;8409:68:2;8440:10;:8;:10::i;:::-;-1:-1:-1;;;;;8418:33:2;:10;:33;5392:3:9;8409:8:2;:68::i;:::-;8487:55;8506:11;:9;:11::i;:::-;8496:6;:21;10600:3:9;8487:8:2;:55::i;:::-;2970:18:17::1;:16;:18::i;:::-;10706:83:38::2;3028:1;10715:7;:23;:51;;;;;3028:1;10742:8;:24;10715:51;4838:3:9;10706:8:38;:83::i;:::-;11065:31;11099:17;:15;:17::i;:::-;11065:51;;11126:39;11140:8;11150:14;11126:13;:39::i;:::-;11177:19;11198::::0;11221:12:::2;:10;:12::i;:::-;11176:57;;;;11243:31;;:::i;:::-;11277:146;;;;;;;;11314:22;:20;:22::i;:::-;11277:146:::0;;::::2;::::0;::::2;::::0;;;;;;;;11243:180;-1:-1:-1;;11438:12:38;;:40:::2;::::0;::::2;;;;;;;11434:845;;;11599:49;11608:7;:14;;;11624;11639:7;11624:23;;;;;;;;;;;;;;11599:8;:49::i;:::-;11582:14;::::0;::::2;:66:::0;11662:17:::2;11682:41;11582:7:::0;11706:8;11716:6;11682:14:::2;:41::i;:::-;11662:61;;11817:51;11832:9;11843:14;11858:8;11843:24;;;;;;;;;;;;;;11817:14;:51::i;:::-;11810:58;;;;;;;;;11434:845;12004:50;12013:7;:14;;;12029;12044:8;12029:24;;;;;;;12004:50;11987:14;::::0;::::2;:67:::0;12068:16:::2;12087:42;11987:7:::0;12112:8;12122:6;12087:15:::2;:42::i;:::-;12068:61;;12221:47;12234:8;12244:14;12259:7;12244:23;;;;;;;;;;;;;;12221:12;:47::i;2998:1:17:-;9823:2462:38::0;;;;;;;:::o;2138:81:24:-;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:24;4172:164;;;;;:::o;7928:96:38:-;8004:13;7928:96;:::o;7548:89:2:-;2156:21:8;:19;:21::i;:::-;7612:18:2::1;7623:6;7612:10;:18::i;:::-;7548:89:::0;:::o;3181:98:24:-;3260:12;;3181:98;:::o;3154:363:17:-;3257:11;3282:26;3322:27;3384:14;:12;:14::i;:::-;3383:15;3374:24;;3429;:22;:24::i;:::-;3408:45;;3485:25;:23;:25::i;:::-;3463:47;;3154:363;;;:::o;21849:111:2:-;21901:16;21936:17;:15;:17::i;:::-;21929:24;;21849:111;:::o;2574:655:1:-;2702:4;2718:24;2745:29;2755:6;2763:10;2745:9;:29::i;:::-;2718:56;-1:-1:-1;2784:101:1;-1:-1:-1;;;;;2793:20:1;;:10;:20;;:50;;;2837:6;2817:16;:26;;2793:50;9359:3:9;2784:8:1;:101::i;:::-;2896:36;2906:6;2914:9;2925:6;2896:9;:36::i;:::-;-1:-1:-1;;;;;2947:20:1;;:10;:20;;;;:55;;;2999:2;2971:16;:31;;2947:55;2943:258;;;3135:55;3144:6;3152:10;3183:6;3164:16;:25;3135:8;:55::i;:::-;3218:4;3211:11;;;2574:655;;;;;;:::o;3040:81:24:-;3105:9;;;;3040:81;:::o;2359:113:25:-;2419:7;2445:20;:18;:20::i;26992:832:38:-;27604:19;27625;27648:12;:10;:12::i;:::-;27603:57;;;;27670:91;27679:53;27707:11;27720;27679:27;:53::i;:::-;7793:3:9;27670:8:38;:91::i;:::-;27772:45;27799:17;27772:26;:45::i;:::-;26992:832;;;:::o;5629:91:2:-;5706:7;5629:91;:::o;5584:211:24:-;5697:10;5672:4;5718:23;;;:11;:23;;;;;;;;-1:-1:-1;;;;;5718:32:24;;;;;;;;;;5672:4;;5688:79;;5718:32;;:48;;5755:10;5718:36;:48::i;:::-;5688:8;:79::i;7832:90:38:-;7905:10;7832:90;:::o;7524:97::-;7603:10;7524:97;:::o;7043:214:2:-;2156:21:8;:19;:21::i;:::-;2970:18:17::1;:16;:18::i;:::-;7205:45:2::2;7232:5;7239:10;7205:26;:45::i;:::-;7043:214:::0;;:::o;6314:137::-;6393:9;;6367:7;;6393:51;;3364:3;6393:22;:51::i;14247:904::-;14507:13;14522:27;14561:71;14597:8;:15;14614:17;:15;:17::i;:::-;14561:35;:71::i;:::-;14643:255;14669:6;14689;14709:9;14732:8;14754:15;14783:25;14822:8;14844:11;14869:19;14643:12;:255::i;:::-;14247:904;;;;;;;;;;:::o;25032:269:38:-;25075:19;25096;25127:16;25146:14;:12;:14::i;:::-;25127:33;-1:-1:-1;25184:43:38;25127:33;5769:1;25184:21;:43::i;:::-;25170:57;-1:-1:-1;25251:43:38;:8;5824:2;25251:21;:43::i;:::-;25237:57;;25032:269;;;:::o;23819:1014::-;23870:7;23889:14;23906:11;:9;:11::i;:::-;23889:28;;23930:25;23961:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;23961:24:38;;;;;;;:32;;23986:6;;23961:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;23961:32:38;;;;;;;;;;;;:::i;:::-;23927:66;;;;24003:42;24017:8;24027:17;:15;:17::i;:::-;24003:13;:42::i;:::-;24057:19;24078;24101:12;:10;:12::i;:::-;24056:57;;;;24123:31;;:::i;:::-;24157:146;;;;;;;;24194:22;:20;:22::i;:::-;24157:146;;;;24243:11;24157:146;;;;24281:11;24157:146;;;24123:180;;24314:20;24337:137;24376:51;24398:8;24407:10;24398:20;;;;;;;;;;;;;;24420:6;24376:21;:51::i;:::-;24441:8;24450:13;24441:23;;;;;;;;;;;;;;24337:25;:137::i;:::-;24314:160;;24757:69;24776:49;24805:8;24814:9;24805:19;;;;;;;;;;;;;;24776:28;:49::i;:::-;24757:12;;:18;:69::i;:::-;24750:76;;;;;;;;23819:1014;:::o;3337:117:24:-;-1:-1:-1;;;;;3429:18:24;;3403:7;3429:18;;;;;;;;;;;3337:117;;;;:::o;10872:1197:2:-;11166:16;11184;11149:6;8409:68;8440:10;:8;:10::i;8409:68::-;8487:55;8506:11;:9;:11::i;8487:55::-;11212:31:::1;11246:17;:15;:17::i;:::-;11212:51;;11273:39;11287:8;11297:14;11273:13;:39::i;:::-;11324:19;11345:27;11374:38:::0;11416:224:::1;11441:6;11461;11481:9;11504:8;11526:15;11555:25;11594:14;11622:8;11416:11;:224::i;:::-;11323:317;;;;;;11746:36;11762:6;11770:11;11746:15;:36::i;:::-;11894:47;11914:10;11926:14;11894:19;:47::i;:::-;11951:58;11971:21;11994:14;11951:19;:58::i;:::-;12028:10:::0;;-1:-1:-1;12040:21:2;-1:-1:-1;;;8552:1:2::1;10872:1197:::0;;;;;;;;;;;:::o;2127:108:25:-;-1:-1:-1;;;;;2214:14:25;2188:7;2214:14;;;:7;:14;;;;;;;2127:108::o;8725:1019:38:-;8766:14;8783:11;:9;:11::i;:::-;8766:28;;8805:22;8835:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;8835:24:38;;;;;;;:32;;8860:6;;8835:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8835:32:38;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;9115:28:38;;;3028:1;9115:28;;;;;;;;;8804:63;;-1:-1:-1;9083:29:38;;9115:28;;;;9083:29;;9115:28;;;;;-1:-1:-1;9115:28:38;9083:60;;4018:12;9153;9166:9;9153:23;;;;;;;;;;;;;:45;;;;;9441:37;;:::i;:::-;9481:179;;;;;;;;9526:17;9536:6;9526:9;:17::i;:::-;9481:179;;;;9571:12;9481:179;;;;;;;;;;;;;;;;;;;;9644:5;9481:179;;;;;9441:219;;9671:10;:8;:10::i;:::-;:66;;;;;-1:-1:-1;;;;;9671:19:38;;;;;;;:66;;9691:6;;9707:4;;;;9729:7;;9671:66;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8725:1019;;;;:::o;7738:88::-;7810:9;7738:88;:::o;2487:430:8:-;2555:7;2876:22;2900:8;2859:50;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2849:61;;;;;;2842:68;;2487:430;;;:::o;12722:902:2:-;12982:14;12998:26;13036:71;13072:8;:15;13089:17;:15;:17::i;13036:71::-;13118:253;13144:6;13164;13184:9;13207:8;13229:15;13258:25;13297:8;13319:11;13344:17;13118:12;:253::i;1776:80:3:-;1843:6;1776:80;:::o;1796:79:1:-;1862:6;1796:79;:::o;2332:85:24:-;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2371:13;;2396:14;;2403:7;;2396:14;;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;26016:970:38;2156:21:8;:19;:21::i;:::-;26617:26:38::1;26645::::0;26675:12:::1;:10;:12::i;:::-;26616:71;;;;26697:105;26706:67;26734:18;26754;26706:27;:67::i;26697:105::-;26812:101;26821:59;26849:14;26865;26821:27;:59::i;:::-;8295:3:9;26812:8:38;:101::i;:::-;26924:55;26936:10;26948:14;26964;26924:11;:55::i;:::-;2187:1:8;;26016:970:38::0;;:::o;3355:429:1:-;3440:4;3456:24;3483:30;3493:10;3505:7;3483:9;:30::i;:::-;3456:57;;3538:16;3528:6;:26;3524:232;;3570:32;3579:10;3591:7;3600:1;3570:8;:32::i;:::-;3524:232;;;3689:56;3698:10;3710:7;3738:6;3719:16;:25;3689:8;:56::i;:::-;-1:-1:-1;3773:4:1;;3355:429;-1:-1:-1;;;3355:429:1:o;3657:170:24:-;3743:4;3759:40;3769:10;3781:9;3792:6;3759:9;:40::i;1862:101:3:-;1910:11;1940:16;:14;:16::i;1313:753:25:-;1575:60;1603:8;1584:15;:27;;5606:3:9;1575:8:25;:60::i;:::-;-1:-1:-1;;;;;1662:14:25;;1646:13;1662:14;;;:7;:14;;;;;;;;;1717:68;;1662:14;;1646:13;1717:68;;1728:16;;1662:14;;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:25;;-1:-1:-1;1868:24:25;;;-1:-1:-1;1902:79:25;;-1:-1:-1;;;;;;1912:20:25;;;;;;1911:43;;-1:-1:-1;;;;;;1938:15:25;;;;;;;1911:43;10833:3:9;1902:8:25;:79::i;:::-;-1:-1:-1;;;;;1992:14:25;;;;;;:7;:14;;;;;-1:-1:-1;2009:9:25;;1992:26;;2028:31;1992:14;2044:7;2053:5;2028:8;:31::i;:::-;1313:753;;;;;;;;;;;:::o;8566:2300:2:-;8860:16;8878;8843:6;8409:68;8440:10;:8;:10::i;8409:68::-;8487:55;8506:11;:9;:11::i;8487:55::-;8906:31:::1;8940:17;:15;:17::i;:::-;8906:51;;8972:13;:11;:13::i;:::-;8968:1892;;9007:20;9029:26;9059:164;9094:6;9118;9142:9;9169:14;9201:8;9059:17;:164::i;:::-;9006:217;;;;9522:62;9547:16;:14;:16::i;:::-;9531:12;:32;;5338:3:9;9522:8:2;:62::i;:::-;9598:45;9622:1;9626:16;:14;:16::i;:::-;9598:15;:45::i;:::-;9657:59;9673:9;9699:16;:14;:16::i;:::-;9684:12;:31;9657:15;:59::i;:::-;9803:44;9821:9;9832:14;9803:17;:44::i;:::-;9870:9;9895:17;:15;:17::i;:::-;9881:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;9881:32:2::1;;9862:52;;;;;;;;;8968:1892;9945:39;9959:8;9969:14;9945:13;:39::i;:::-;9999:20;10021:26;10049:38:::0;10091:260:::1;10120:6;10144;10168:9;10195:8;10221:15;10254:25;10297:14;10329:8;10091:11;:260::i;:::-;9998:353;;;;;;10465:40;10481:9;10492:12;10465:15;:40::i;:::-;10592:44;10610:9;10621:14;10592:17;:44::i;:::-;10735:58;10755:21;10778:14;10735:19;:58::i;:::-;10816:9:::0;;-1:-1:-1;10827:21:2;-1:-1:-1;10808:41:2::1;::::0;-1:-1:-1;;10808:41:2::1;2177:254:1::0;2258:7;2300:10;:8;:10::i;:::-;-1:-1:-1;;;;;2281:30:1;;;;;;2277:148;;;-1:-1:-1;2342:2:1;2327:18;;2277:148;2383:31;2399:5;2406:7;2383:15;:31::i;:::-;2376:38;;;;28762:450:38;28813:7;28835:25;28866:10;:8;:10::i;:::-;-1:-1:-1;;;;;28866:24:38;;28891:11;:9;:11::i;:::-;28866:37;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;28866:37:38;;;;;;;;;;;;:::i;:::-;28832:71;;;;29086:18;29107:51;29116:8;29125:9;29116:19;;;;;;;;;;;;;;29137:20;29152:4;29137:14;:20::i;:::-;29107:8;:51::i;:::-;29086:72;;29176:29;29194:10;29176:17;:29::i;:::-;29169:36;;;;28762:450;:::o;7627:105::-;7711:13;7627:105;:::o;24839:109::-;24893:7;24919:22;:20;:22::i;1135:274:16:-;1345:5;1369:33;1345:5;1369:19;:33::i;6940:269:18:-;2598:11;7127:18;;7125:21;7109:37;;;;7186:15;;7164:38;;6940:269::o;1142:166:21:-;1200:7;1219:37;1233:1;1228;:6;;4370:1:9;1219:8:21;:37::i;:::-;-1:-1:-1;1278:5:21;;;1142:166::o;8656:131:18:-;8764:15;;8656:131::o;8042:294::-;2760:12;8291:26;;;8290:38;;8230:19;;;8228:22;8212:38;;8268:61;8042:294;;;;;:::o;866:101:9:-;935:9;930:34;;946:18;954:9;946:7;:18::i;4220:98:17:-;4272:39;4281:14;:12;:14::i;:::-;8582:3:9;4272:8:17;:39::i;:::-;4220:98::o;23036:550:38:-;23165:28;;;3028:1;23165:28;;;;;;;;;23103:16;;;;23165:28;;;;23103:16;;23165:28;;;;;-1:-1:-1;23165:28:38;23131:62;;23372:23;23343:14;23358:10;23343:26;;;;;;;;;;;;;:52;;;;;23437:58;23472:22;:20;:22::i;:::-;23437:26;;:34;:58::i;:::-;23405:14;23420:13;23405:29;;;;;;;;;;;;;:90;;;;;893:4:19;23505:14:38;23520:9;23505:25;;;;;;;;;;;;;;;;;:42;23565:14;-1:-1:-1;23036:550:38;:::o;22870:247:2:-;22981:9;22976:135;23000:17;:15;:17::i;:::-;22996:1;:21;22976:135;;;23051:49;23070:7;23078:1;23070:10;;;;;;;;;;;;;;23082:14;23097:1;23082:17;;;;;;;;;;;;;;23051:18;:49::i;:::-;23038:7;23046:1;23038:10;;;;;;;;;;;;;;;;;:62;23019:3;;22976:135;;22122:579;22202:7;22653:41;22672:6;22680:13;22653:18;:41::i;12291:591:38:-;12479:15;;;;12456:7;;-1:-1:-1;;;;;12479:23:38;12498:4;12479:23;12475:401;;;12525:42;12541:7;12550:8;12560:6;12525:15;:42::i;:::-;12518:49;;;;12475:401;12588:15;;;;12607:10;-1:-1:-1;;;;;12588:29:38;;;;;;12584:292;;;12640:43;12657:7;12666:8;12676:6;12640:16;:43::i;12584:292::-;12704:15;;;;12723:13;-1:-1:-1;;;;;12704:32:38;;;;;;12700:176;;;12759:46;12779:7;12788:8;12798:6;12759:19;:46::i;12700:176::-;12836:29;6206:3:9;12836:7:38;:29::i;23321:160:2:-;23407:7;23433:41;23452:6;23460:13;23433:18;:41::i;15006:598:38:-;15195:16;;;;15172:7;;-1:-1:-1;;;;;15195:24:38;15215:4;15195:24;15191:407;;;15242:43;15259:7;15268:8;15278:6;15242:16;:43::i;15191:407::-;15306:16;;;;15326:10;-1:-1:-1;;;;;15306:30:38;;;;;;15302:296;;;15359:44;15377:7;15386:8;15396:6;15359:17;:44::i;15302:296::-;15424:16;;;;15444:13;-1:-1:-1;;;;;15424:33:38;;;;;;15420:178;;;15480:47;15501:7;15510:8;15520:6;15480:20;:47::i;24111:156:2:-;24195:7;24221:39;24238:6;24246:13;24221:16;:39::i;9345:213:24:-;-1:-1:-1;;;;;9468:18:24;;;;;;;-1:-1:-1;9468:18:24;;;;;;;;:27;;;;;;;;;;;;;;:36;;;9519:32;;;;;9468:36;;9519:32;:::i;:::-;;;;;;;;9345:213;;;:::o;2300:181:8:-;2355:16;2374:20;2386:7;;;;2374:11;:20::i;:::-;2355:39;;2404:70;2413:33;2425:8;2435:10;2413:11;:33::i;:::-;8538:3:9;2404:8:8;:70::i;3793:358:17:-;3849:6;3845:232;;;3871:81;3898:24;:22;:24::i;:::-;3880:15;:42;8640:3:9;3871:8:17;:81::i;:::-;3845:232;;;3983:83;4010:25;:23;:25::i;:::-;3992:15;:43;10070:3:9;3983:8:17;:83::i;:::-;4087:7;:16;;;;;;;;;;4118:26;;;;;;4087:16;;4118:26;:::i;:::-;;;;;;;;3793:358;:::o;4717:237::-;4764:4;4910:25;:23;:25::i;:::-;4892:15;:43;:55;;;-1:-1:-1;;4940:7:17;;;;4939:8;;4717:237::o;5067:108::-;5149:19;5067:108;:::o;5181:110::-;5264:20;5181:110;:::o;7068:559:24:-;7195:71;-1:-1:-1;;;;;7204:20:24;;;;8955:3:9;7195:8:24;:71::i;:::-;7276:72;-1:-1:-1;;;;;7285:23:24;;;;9023:3:9;7276:8:24;:72::i;:::-;7359:47;7380:6;7388:9;7399:6;7359:20;:47::i;:::-;-1:-1:-1;;;;;7437:17:24;;:9;:17;;;;;;;;;;;:68;;7459:6;9501:3:9;7437:21:24;:68::i;:::-;-1:-1:-1;;;;;7417:17:24;;;:9;:17;;;;;;;;;;;:88;;;;7538:20;;;;;;;:32;;7563:6;7538:24;:32::i;:::-;-1:-1:-1;;;;;7515:20:24;;;:9;:20;;;;;;;;;;;;:55;;;;7585:35;;;;;;;;;;7613:6;;7585:35;:::i;2386:188:23:-;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;27830:407:38:-;27931:4;27947:14;27964:11;:9;:11::i;:::-;27947:28;;27988:25;28019:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;28019:24:38;;;;;;;:32;;28044:6;;28019:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;28019:32:38;;;;;;;;;;;;:::i;:::-;27985:66;;;;28061:24;28088:58;28097:8;28106:10;28097:20;;;;;;;;;;;;;;28119:26;28134:10;28119:14;:26::i;28088:58::-;28061:85;;28184:11;28164:16;:31;;:66;;;;;28219:11;28199:16;:31;;28164:66;28157:73;27830:407;-1:-1:-1;;;;;;27830:407:38:o;6457:156:2:-;2156:21:8;:19;:21::i;:::-;2970:18:17::1;:16;:18::i;:::-;6566:40:2::2;6588:17;6566:21;:40::i;915:167:28:-:0;973:7;1004:5;;;1019:37;1028:6;;;;973:7;1019:8;:37::i;7263:279:2:-;7356:14;7373:11;:9;:11::i;:::-;7356:28;;7401:20;7425:10;:8;:10::i;:::-;:42;;;;;-1:-1:-1;;;;;7425:27:2;;;;;;;:42;;7453:6;;7461:5;;7425:42;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7478:57;;;;;7394:73;;-1:-1:-1;;;;;;7478:37:2;;;-1:-1:-1;7478:37:2;;-1:-1:-1;7478:57:2;;-1:-1:-1;7516:6:2;;7524:10;;7478:57;;;:::i;11643:142:18:-;11752:14;2598:11;11744:34;;11643:142::o;22326:113:38:-;3028:1;22326:113;:::o;810:131:16:-;888:46;902:1;897;:6;5002:3:9;888:8:16;:46::i;19025:1831:38:-;19306:19;19339:27;19380:38;20011:32;20046:19;:8;:17;:19::i;:::-;20011:54;-1:-1:-1;20087:65:38;20079:4;:73;;;;;;;20075:775;;20168:40;7736:3:9;20168:7:38;:40::i;:::-;20075:775;;;20239:15;:13;:15::i;:::-;20617:46;20644:8;20654;20617:26;:46::i;:::-;20589:74;;-1:-1:-1;20589:74:38;-1:-1:-1;20821:17:38;:15;:17::i;:::-;20807:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20807:32:38;;20783:56;;20075:775;19025:1831;;;;;;;;;;;;;:::o;23656:253:2:-;23773:9;23768:135;23792:17;:15;:17::i;:::-;23788:1;:21;23768:135;;;23843:49;23862:7;23870:1;23862:10;;;;;;;;;;;;;;23874:14;23889:1;23874:17;;;;;;;;;;;;;;23843:18;:49::i;:::-;23830:7;23838:1;23830:10;;;;;;;;;;;;;;;;;:62;23811:3;;23768:135;;25189:6885;25888:10;25910:4;25888:27;25884:6184;;26202:28;;26184:12;;26210:4;;26202:28;;26184:12;;26221:8;;26202:28;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26183:47;;;26448:7;26481:1;26476:3336;;;;29972:9;26476:3336;26952:4;26949:1;26946;26931:26;27005:1;26999:8;27009:66;26995:81;27237:66;27227:77;;27221:2;;27360:16;27357:1;27354;27339:38;27416:16;27413:1;27406:27;27221:2;;28827;28821:4;28818:1;28803:27;29024:2;29018:4;29011:16;29448:2;29430:16;29426:25;29420:4;29414;29399:53;29786:2;29768:16;29764:25;29761:1;29754:36;26314:3703;30047:31;30081:17;:15;:17::i;:::-;30047:51;;30112:39;30126:8;30136:14;30112:13;:39::i;:::-;30167:17;30186:29;30221:256;30246:6;30270;30294:9;30321:8;30347:15;30380:25;30423:14;30455:8;30221:7;:256;;:::i;:::-;30166:311;;;;;30492:45;30508:12;30522:14;30492:15;:45;;:::i;:::-;31018:19;;-1:-1:-1;31405:23:2;;31445:24;;;31691:66;31673:16;;;31666:92;-1:-1:-1;31014:28:2;31784:16;;;32040:2;32030:13;;31784:16;32016:28;7920:89;7993:9;;7920:89;:::o;11907:142:18:-;12016:14;2651:11;12008:34;;11907:142::o;12191:603:37:-;12270:7;12444:6;:18;;;12437:4;:25;12433:355;;;12529:10;;12494:18;;;;12478:12;;12493:47;;12494:25;;;;12493:35;:47::i;:::-;12478:62;-1:-1:-1;12561:14:37;:4;12478:62;12561:8;:14::i;:::-;12554:21;;;;;12433:355;12604:6;:18;;;12596:4;:26;12592:196;;-1:-1:-1;12645:4:37;12638:11;;12592:196;12731:10;;12703:18;;;;12680:12;;12695:47;;12696:25;;;12695:35;:47::i;12015:170::-;12114:7;12140:38;:18;12163:14;12140:22;:38::i;29632:263:38:-;4018:12;29856:32;;29632:263::o;2846:682:19:-;2906:7;2925:38;2934:6;;;4516:1:9;2925:8:19;:38::i;:::-;2978:6;2974:548;;-1:-1:-1;3007:1:19;3000:8;;2974:548;893:4;3059:7;;;;3080:51;;3059:1;:7;:1;3089:13;;;;;:20;4564:1:9;3080:8:19;:51::i;:::-;3505:1;3500;3488:9;:13;3487:19;;;;;;3510:1;3486:25;3479:32;;;;;3933:104:1;4009:21;4015:6;4023;4009:5;:21::i;18617:402:38:-;18880:7;18901:16;18931;18972:40;7736:3:9;18972:7:38;:40::i;:::-;18617:402;;;;;;;;;;;;:::o;24440:249:2:-;24555:9;24550:133;24574:17;:15;:17::i;:::-;24570:1;:21;24550:133;;;24625:47;24642:7;24650:1;24642:10;;;;;;;;;;;;;;24654:14;24669:1;24654:17;;;;;;;;;;;;;;24625:16;:47::i;:::-;24612:7;24620:1;24612:10;;;;;;;;;;;;;;;;;:60;24593:3;;24550:133;;25307:703:38;25436:76;25460:11;25445;:26;;7615:3:9;25436:8:38;:76::i;:::-;25522:72;5878:11;25531;:32;;7674:3:9;25522:8:38;:72::i;:::-;25775:165;25875:55;25896:11;5824:2;25875:20;:55::i;:::-;25801;25822:11;5769:1;25801:20;:55::i;:::-;:129;25775:12;:165::i;:::-;25956:47;;-1:-1:-1;;;;;25956:47:38;;;;;;;25978:11;;25991;;25956:47;:::i;:::-;;;;;;;;25307:703;;;:::o;24695:488:2:-;24753:11;25150:10;:8;:10::i;:::-;-1:-1:-1;;;;;25150:24:2;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;3199:183:23:-;3276:7;3341:20;:18;:20::i;:::-;3363:10;3312:62;;;;;;;;;:::i;17722:889:38:-;17917:7;17926:16;2970:18:17;:16;:18::i;:::-;18073:64:38::1;18100:4;-1:-1:-1::0;;;;;18082:23:38;::::1;;8234:3:9;18073:8:38;:64::i;:::-;18147:67;18177:4;-1:-1:-1::0;;;;;18156:26:38;::::1;;8234:3:9;18147:8:38;:67::i;:::-;18481:28;::::0;;3028:1:::1;18481:28:::0;;;;;::::1;::::0;;;4018:12:::1;::::0;18452:26:::1;::::0;18481:28;::::1;::::0;::::1;18452:26:::0;;18481:28:::1;::::0;::::1;;::::0;-1:-1:-1;18481:28:38::1;18452:57;;4018:12;18519:9;18529;18519:20;;;;;;;;;::::0;;::::1;::::0;;;;;:42;18580:12;;;;-1:-1:-1;17722:889:38;-1:-1:-1;;;;;;17722:889:38:o;22045:275::-;22103:7;22045:275;:::o;3817:110:1:-;3896:24;3902:9;3913:6;3896:5;:24::i;3885:149:24:-;-1:-1:-1;;;;;4000:18:24;;;3974:7;4000:18;;;-1:-1:-1;4000:18:24;;;;;;;;:27;;;;;;;;;;;;;3885:149::o;22445:585:38:-;22523:7;22555:10;-1:-1:-1;;;;;22546:19:38;;;;;;;22542:482;;;-1:-1:-1;22588:23:38;22581:30;;22542:482;22641:13;-1:-1:-1;;;;;22632:22:38;;;;;;;22628:396;;;22824:58;22859:22;:20;:22::i;22824:58::-;22817:65;;;;22628:396;22912:4;-1:-1:-1;;;;;22903:13:38;;;22899:125;;;-1:-1:-1;893:4:19;22932:21:38;;22899:125;22984:29;6206:3:9;22984:7:38;:29::i;29218:132::-;29288:7;29314:29;29332:10;29314:13;:11;:13::i;:::-;:17;;:29::i;1826:540:41:-;1890:7;2021:14;2038:11;-1:-1:-1;;;;;2038:20:41;;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2021:39;;2070:11;2084;-1:-1:-1;;;;;2084:25:41;;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2070:41;;2137:2;2126:8;:13;;;2122:217;;;2215:2;2204:8;:13;2199:19;;:2;:19;2193:3;:25;;;;;;2186:32;;;;;;2122:217;2249:2;2238:8;:13;;;2234:105;;;2319:8;2314:2;:13;2309:19;;:2;:19;2303:3;:25;2296:32;;;;;;2234:105;2356:3;-1:-1:-1;;1826:540:41;:::o;1415:374:16:-;1511:1;1496:5;:12;:16;1492:53;;;1528:7;;1492:53;1555:16;1574:5;1580:1;1574:8;;;;;;;;;;;;;;1555:27;;1597:9;1609:1;1597:13;;1592:191;1616:5;:12;1612:1;:16;1592:191;;;1649:15;1667:5;1673:1;1667:8;;;;;;;;;;;;;;;;;;;-1:-1:-1;1689:51:16;-1:-1:-1;;;;;1698:18:16;;;;;;;4890:3:9;1689:8:16;:51::i;:::-;1765:7;-1:-1:-1;1630:3:16;;1592:191;;1074:3172:9;3593:66;3588:3;3581:79;;;3799:66;3793:4;3786:80;3941:1;3935:4;3928:15;2999:73;2210:2;2243:18;;;2288;;;2215:4;2284:29;;;3040:1;3036:14;2195:18;;;;3025:26;;;;2336:18;;;;2383;;;2379:29;;;3057:2;3053:17;3021:50;;;;2999:73;2994:3;2990:83;4008:4;4001:26;4234:3;;4224:14;1647:209:19;1709:7;1746:5;;;1761:57;1770:6;;;:26;;;1795:1;1790;1780:7;:11;;;;;;:16;1770:26;4467:1:9;1761:8:19;:57::i;:::-;893:4;1836:13;;;;-1:-1:-1;;;1647:209:19:o;12888:639:38:-;13082:16;;;;13054:7;;13073:99;;13102:10;-1:-1:-1;;;;;13082:30:38;;;;;;;:67;;-1:-1:-1;13116:16:38;;;;13136:13;-1:-1:-1;;;;;13116:33:38;;;;;;13082:67;6206:3:9;13073:8:38;:99::i;:::-;13201:319;13322:7;:14;;;13354:8;13363:10;13354:20;;;;;;;;;;;;;;13392:8;13401:13;13392:23;;;;;;;;;;;;;;13433:49;13462:8;13471:9;13462:19;;;;;;;13433:49;13202:16;;;;13500:6;;13222:10;-1:-1:-1;;;;;13202:30:38;;;;;;:101;;13269:34;13202:101;;;13235:31;13202:101;13201:319;;:::i;:::-;13182:338;12888:639;-1:-1:-1;;;;12888:639:38:o;13533:729::-;13728:16;;;;13700:7;;13719:93;;13748:13;-1:-1:-1;;;;;13728:33:38;;;;;;;:61;;-1:-1:-1;13765:16:38;;;;-1:-1:-1;;;;;13765:24:38;13785:4;13765:24;6206:3:9;13719:8:38;:93::i;:::-;13841:16;;;;-1:-1:-1;;;;;13841:24:38;13861:4;13841:24;:414;;14174:81;14210:7;:14;;;14226:8;14235:10;14226:20;;;;;;;;;;;;;;14248:6;14174:35;:81::i;:::-;13841:414;;;13884:271;13937:7;:14;;;13973:8;13982:10;13973:20;;;;;;;;;;;;;;14015:8;14024:13;14015:23;;;;;;;;;;;;;;14060:49;14089:8;14098:9;14089:19;;;;;;;14060:49;14131:6;13884:31;:271::i;14268:732::-;14466:16;;;;14438:7;;14457:90;;14486:10;-1:-1:-1;;;;;14466:30:38;;;;;;;:58;;-1:-1:-1;14500:16:38;;;;-1:-1:-1;;;;;14500:24:38;14520:4;14500:24;6206:3:9;14457:8:38;:90::i;:::-;14576:16;;;;-1:-1:-1;;;;;14576:24:38;14596:4;14576:24;:417;;14912:81;14948:7;:14;;;14964:8;14973:10;14964:20;;;;;;;;;;;;;;14986:6;14912:35;:81::i;14576:417::-;14619:274;14675:7;:14;;;14711:8;14720:10;14711:20;;;;;;;;;;;;;;14753:8;14762:13;14753:23;;;;;;;;;;;;;;14798:49;14827:8;14836:9;14827:19;;;;;;;14798:49;14869:6;14619:34;:274::i;2485:355:19:-;2547:7;2566:38;2575:6;;;4516:1:9;2566:8:19;:38::i;:::-;2619:6;2615:219;;-1:-1:-1;2648:1:19;2641:8;;2615:219;893:4;2700:7;;;;2721:51;;2700:1;:7;:1;2730:13;;;2721:51;2822:1;2810:9;:13;;;;;;2803:20;;;;;15610:637:38;15805:15;;;;15777:7;;15796:97;;15824:10;-1:-1:-1;;;;;15805:29:38;;;;;;;:65;;-1:-1:-1;15838:15:38;;;;15857:13;-1:-1:-1;;;;;15838:32:38;;;;;;6206:3:9;15796:8:38;:97::i;:::-;15922:318;16042:7;:14;;;16074:8;16083:10;16074:20;;;;;;;;;;;;;;16112:8;16121:13;16112:23;;;;;;;;;;;;;;16153:49;16182:8;16191:9;16182:19;;;;;;;16153:49;15923:15;;;;16220:6;;15942:10;-1:-1:-1;;;;;15923:29:38;;;;;;:100;;15989:34;15923:100;;;15955:31;15922:318::i;16253:727::-;16449:15;;;;16421:7;;16440:91;;16468:13;-1:-1:-1;;;;;16449:32:38;;;;;;;:59;;-1:-1:-1;16485:15:38;;;;-1:-1:-1;;;;;16485:23:38;16504:4;16485:23;6206:3:9;16440:8:38;:91::i;:::-;16560:15;;;;-1:-1:-1;;;;;16560:23:38;16579:4;16560:23;:413;;16892:81;16928:7;:14;;;16944:8;16953:10;16944:20;;;;;;;;;;;;;;16966:6;16892:35;:81::i;16560:413::-;16602:271;16655:7;:14;;;16691:8;16700:10;16691:20;;;;;;;;;;;;;;16733:8;16742:13;16733:23;;;;;;;;;;;;;;16778:49;16807:8;16816:9;16807:19;;;;;;;16778:49;16849:6;16602:31;:271::i;16986:730::-;17185:15;;;;17157:7;;17176:88;;17204:10;-1:-1:-1;;;;;17185:29:38;;;;;;;:56;;-1:-1:-1;17218:15:38;;;;-1:-1:-1;;;;;17218:23:38;17237:4;17218:23;6206:3:9;17176:8:38;:88::i;:::-;17293:15;;;;-1:-1:-1;;;;;17293:23:38;17312:4;17293:23;:416;;17628:81;17664:7;:14;;;17680:8;17689:10;17680:20;;;;;;;;;;;;;;17702:6;17628:35;:81::i;17293:416::-;17335:274;17391:7;:14;;;17427:8;17436:10;17427:20;;;;;;;;;;;;;;17469:8;17478:13;17469:23;;;;;;;;;;;;;;17514:49;17543:8;17552:9;17543:19;;;;;;;17514:49;17585:6;17335:34;:274::i;1969:544:3:-;2057:4;1663:42;2078:10;:8;:10::i;:::-;-1:-1:-1;;;;;2078:29:3;;;;;2077:63;;;2112:28;2131:8;2112:18;:28::i;:::-;2073:434;;;2272:10;:8;:10::i;:::-;-1:-1:-1;;;;;2258:24:3;:10;:24;;-1:-1:-1;2251:31:3;;2073:434;2435:16;:14;:16::i;:::-;:61;;;;;-1:-1:-1;;;;;2435:27:3;;;;;;;:61;;2463:8;;2473:7;;2490:4;;2435:61;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;1765:176:28:-;1842:7;1861:27;1875:1;1870;:6;;1878:9;1861:8;:27::i;:::-;-1:-1:-1;;1910:5:28;;;1765:176::o;3388:427:23:-;3790:9;;3765:44::o;6619:418:2:-;6695:87;2763:4;6704:17;:45;;5289:3:9;6695:8:2;:87::i;:::-;6792;2836:4;6801:17;:45;;5228:3:9;6792:8:2;:87::i;:::-;6902:9;;:70;;6925:17;3364:3;6902:22;:70::i;:::-;6890:9;:82;6987:43;;;;;;7012:17;;6987:43;:::i;835:122:39:-;895:8;933:4;922:28;;;;;;;;;;;;:::i;4391:100:17:-;4440:44;4450:14;:12;:14::i;:::-;4449:15;10407:3:9;4440:8:17;:44::i;20862:1068:38:-;20994:7;21003:16;21393:19;21415:33;:8;:31;:33::i;:::-;21393:55;;21678:27;21708:172;21762:8;21784:11;21809:38;21827:8;21836:9;21827:19;;;;;;;;;;;;;;21809:17;:38::i;:::-;21861:9;21708:40;:172::i;:::-;21899:11;;;;-1:-1:-1;20862:1068:38;;-1:-1:-1;;;;20862:1068:38:o;8512:410:24:-;8587:68;-1:-1:-1;;;;;8596:21:24;;;;9153:3:9;8587:8:24;:68::i;:::-;8666:49;8687:7;8704:1;8708:6;8666:20;:49::i;:::-;-1:-1:-1;;;;;8747:18:24;;:9;:18;;;;;;;;;;;:67;;8770:6;9567:3:9;8747:22:24;:67::i;:::-;-1:-1:-1;;;;;8726:18:24;;:9;:18;;;;;;;;;;:88;8839:12;;:24;;8856:6;8839:16;:24::i;:::-;8824:12;:39;8878:37;;8904:1;;-1:-1:-1;;;;;8878:37:24;;;;;;;8908:6;;8878:37;:::i;:::-;;;;;;;;8512:410;;:::o;8220:112:2:-;8290:9;;:35;;8314:7;8323:1;8290:23;:35::i;:::-;8278:9;:47;-1:-1:-1;8220:112:2:o;7898:294:24:-;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:24;;:9;:18;;;;;;;;;;;:30;;8126:6;8103:22;:30::i;:::-;-1:-1:-1;;;;;8082:18:24;;:9;:18;;;;;;;;;;;:51;;;;8148:37;;8082:18;;:9;8148:37;;;;8178:6;;8148:37;:::i;11366:643:37:-;11569:7;11638:19;11660:31;11671:11;11684:6;11660:10;:31::i;:::-;11638:53;;11701:25;11729:43;11744:11;11757:14;11729;:43::i;:::-;11701:71;-1:-1:-1;11783:21:37;11807:20;:9;11821:5;11807:13;:20::i;:::-;11783:44;;11837:25;11865:82;11935:11;11865:65;11876:42;11885:13;11900:17;11876:8;:42::i;:::-;11920:9;11865:10;:65::i;:82::-;11837:110;-1:-1:-1;11965:37:37;:14;11837:110;11965:18;:37::i;:::-;11958:44;;;;;;11366:643;;;;;;;;:::o;6914:705::-;7114:7;7183:27;7213:31;7224:11;7237:6;7213:10;:31::i;:::-;7183:61;;7254:17;7274:51;7289:19;7310:14;7274;:51::i;:::-;7254:71;;7335:24;7362:51;7375:26;7384:9;7395:5;7375:8;:26::i;:::-;7403:9;7362:12;:51::i;:::-;7335:78;-1:-1:-1;7423:24:37;7450:41;:19;7335:78;7450:23;:41::i;:::-;7423:68;;7501:22;7526:38;7539:16;7557:6;7526:12;:38::i;:::-;7501:63;-1:-1:-1;7581:31:37;:11;7501:63;7581:15;:31::i;:::-;7574:38;6914:705;-1:-1:-1;;;;;;;;;;;6914:705:37:o;4978:421::-;5124:7;5193:27;5223:31;5234:11;5247:6;5223:10;:31::i;:::-;5193:61;-1:-1:-1;5264:24:37;5291:43;5302:23;:11;5318:6;5302:15;:23::i;:::-;5327:6;5291:10;:43::i;:::-;5264:70;-1:-1:-1;5351:41:37;5264:70;5372:19;5351:20;:41::i;3284:1029::-;3485:7;3558:14;3554:363;;3880:26;3891:6;3899;3880:10;:26::i;:::-;3873:33;;;;3554:363;3927:27;3957:31;3968:11;3981:6;3957:10;:31::i;:::-;3927:61;-1:-1:-1;3998:24:37;4025:43;4036:23;:11;4052:6;4036:15;:23::i;4025:43::-;3998:70;-1:-1:-1;4078:24:37;4105:41;3998:70;4126:19;4105:20;:41::i;:::-;4078:68;;4156:17;4176:51;4191:19;4212:14;4176;:51::i;:::-;4156:71;;4244:62;4257:37;4266:9;4277:16;4257:8;:37::i;:::-;4296:9;4244:12;:62::i;7625:478::-;7774:7;7843:27;7873:31;7884:11;7897:6;7873:10;:31::i;:::-;7843:61;-1:-1:-1;7914:24:37;7941:34;7843:61;7965:9;7941:23;:34::i;:::-;7914:61;;7985:22;8010:38;8023:16;8041:6;8010:12;:38::i;:::-;7985:63;-1:-1:-1;8065:31:37;:11;7985:63;8065:15;:31::i;:::-;8058:38;7625:478;-1:-1:-1;;;;;;;7625:478:37:o;8592:1059::-;8799:7;8872:14;8868:338;;-1:-1:-1;9186:9:37;9179:16;;8868:338;9216:19;9238:31;9249:11;9262:6;9238:10;:31::i;:::-;9216:53;;9279:25;9307:43;9322:11;9335:14;9307;:43::i;:::-;9279:71;-1:-1:-1;9361:25:37;9389:29;:14;9408:9;9389:18;:29::i;:::-;9361:57;;9428:20;9451:46;9466:11;9479:17;9451:14;:46::i;:::-;9428:69;;9508:21;9532:66;9545:33;9554:9;9565:12;9545:8;:33::i;:::-;9580:17;9532:12;:66::i;:::-;9508:90;-1:-1:-1;9616:28:37;9508:90;9634:9;9616:17;:28::i;10373:987::-;10577:7;10647:14;10643:335;;-1:-1:-1;10961:6:37;10954:13;;10643:335;10988:19;11010:31;11021:11;11034:6;11010:10;:31::i;:::-;10988:53;;11051:25;11079:43;11094:11;11107:14;11079;:43::i;:::-;11051:71;-1:-1:-1;11133:21:37;11157;:9;11171:6;11157:13;:21::i;:::-;11133:45;;11188:25;11216:82;11286:11;11216:65;11227:42;11236:13;11251:17;11227:8;:42::i;11216:82::-;11188:110;-1:-1:-1;11316:37:37;11188:110;11338:14;11316:21;:37::i;5831:1077::-;6032:7;6102:14;6098:365;;6424:28;6437:6;6445;6424:12;:28::i;6098:365::-;6473:27;6503:31;6514:11;6527:6;6503:10;:31::i;:::-;6473:61;;6544:17;6564:51;6579:19;6600:14;6564;:51::i;:::-;6544:71;;6625:24;6652:50;6663:27;6672:9;6683:6;6663:8;:27::i;:::-;6692:9;6652:10;:50::i;:::-;6625:77;-1:-1:-1;6712:24:37;6739:41;:19;6625:77;6739:23;:41::i;:::-;6712:68;;6790:22;6815:38;6828:16;6846:6;6815:12;:38::i;:::-;6790:63;-1:-1:-1;6870:31:37;6790:63;6889:11;6870:18;:31::i;5405:420::-;5552:7;5618:27;5648:31;5659:11;5672:6;5648:10;:31::i;:::-;5618:61;-1:-1:-1;5689:24:37;5716:44;5727:24;:11;5743:7;5727:15;:24::i;5716:44::-;5689:71;-1:-1:-1;5777:41:37;:19;5689:71;5777:23;:41::i;4319:653::-;4521:7;4587:27;4617:31;4628:11;4641:6;4617:10;:31::i;:::-;4587:61;-1:-1:-1;4658:24:37;4685:44;4696:24;:11;4712:7;4696:15;:24::i;4685:44::-;4658:71;-1:-1:-1;4739:24:37;4766:41;:19;4658:71;4766:23;:41::i;:::-;4739:68;;4817:17;4837:51;4852:19;4873:14;4837;:51::i;:::-;4817:71;;4905:60;4916:37;4925:9;4936:16;4916:8;:37::i;:::-;4955:9;4905:10;:60::i;8109:477::-;8259:7;8325:27;8355:31;8366:11;8379:6;8355:10;:31::i;:::-;8325:61;-1:-1:-1;8396:24:37;8423:35;8325:61;8447:10;8423:23;:35::i;:::-;8396:62;;8468:22;8493:38;8506:16;8524:6;8493:12;:38::i;:::-;8468:63;-1:-1:-1;8548:31:37;8468:63;8567:11;8548:18;:31::i;9657:710::-;9865:7;9931:19;9953:31;9964:11;9977:6;9953:10;:31::i;:::-;9931:53;;9994:25;10022:43;10037:11;10050:14;10022;:43::i;:::-;9994:71;-1:-1:-1;10076:25:37;10104:30;:14;10123:10;10104:18;:30::i;:::-;10076:58;;10144:20;10167:46;10182:11;10195:17;10167:14;:46::i;:::-;10144:69;;10224:21;10248:66;10261:33;10270:9;10281:12;10261:8;:33::i;10248:66::-;10224:90;-1:-1:-1;10332:28:37;:9;10224:90;10332:13;:28::i;28243:203:38:-;28329:4;28364:37;28376:24;28364:11;:37::i;:::-;28352:8;:49;:87;;;;28405:34;28430:8;28405:24;:34::i;963:167:39:-;1037:19;1097:4;1086:37;;;;;;;;;;;;:::i;13382:1650:37:-;13572:16;14582;14601:35;:11;14621:14;14601:19;:35::i;:::-;14582:54;;14647:27;14691:8;:15;14677:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;14677:30:37;;14647:60;;14722:9;14717:281;14741:8;:15;14737:1;:19;14717:281;;;14900:8;14895:1;:13;14891:97;;14944:29;14964:8;14944;14953:1;14944:11;;;;;;;;;;;;;;:19;;:29;;;;:::i;:::-;14928:10;14939:1;14928:13;;;;;;;;;;;;;:45;;;;;14891:97;14758:3;;14717:281;;;-1:-1:-1;15015:10:37;13382:1650;-1:-1:-1;;;;;;13382:1650:37:o;1353:121:28:-;1411:7;1437:30;1441:1;1444;4370::9;1437:3:28;:30::i;1987:180:21:-;2045:7;2076:5;;;2091:51;2100:6;;;:20;;;2119:1;2114;2110;:5;;;;2505:232;2565:7;2584:38;2593:6;;;4516:1:9;2584:8:21;:38::i;:::-;2637:6;2633:98;;-1:-1:-1;2666:1:21;2659:8;;2633:98;2719:1;2714;2710;:5;2709:11;;;;;;2705:1;:15;2698:22;;;;2351:148;2413:7;2432:38;2441:6;;;4516:1:9;2432:8:21;:38::i;:::-;2491:1;2487;:5;;;;;;;2351:148;-1:-1:-1;;;2351:148:21:o;12800:576:37:-;12884:7;13014:6;:18;;;13004:7;:28;13000:370;;;13136:10;;13055:93;;13117:30;;893:4:19;;13117:18:37;:30::i;:::-;13087:18;;;;13068:10;;13056:51;;13068:38;;:10;:18;:38::i;:::-;13056:7;;:11;:51::i;:::-;13055:61;;:93::i;13000:370::-;13180:6;:18;;;13169:7;:29;13165:205;;-1:-1:-1;13221:7:37;13214:14;;13165:205;13346:10;;13267:91;;13327:30;;893:4:19;;13327:18:37;:30::i;:::-;13298:18;;;;13279:10;;13267:51;;13279:38;;:10;:18;:38::i;:::-;13267:7;;:11;:51::i;7643:271:2:-;7729:4;7777:47;7789:34;7777:11;:47::i;:::-;7765:8;:59;7764:143;;;-1:-1:-1;7854:52:2;7866:39;7854:11;:52::i;:::-;7842:64;;;;7643:271;-1:-1:-1;7643:271:2:o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;5:130::-;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;;;6171: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;;;6319: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;34298:18;34290:6;34287:30;34284:2;;;-1:-1;;34320:12;34284:2;3282:64;-1:-1;34374:17;;-1:-1;34370:33;34461:4;34451:15;3282:64;:::i;:::-;3273:73;;3366:6;3359:5;3352:21;3470:3;34461:4;3461:6;3394;3452:16;;3449:25;3446:2;;;3487:1;;3477:12;3446:2;39166:6;34461:4;3394:6;3390:17;34461:4;3428:5;3424:16;39143:30;39222:1;39204:16;;;34461:4;39204:16;39197:27;3428:5;3165:379;-1:-1;;3165:379::o;4071:162::-;4163:13;;40670:1;40660:12;;40650:2;;40686:1;;40676:12;4240:156;4320:20;;40784:1;40774:12;;40764:2;;40800:1;;40790:12;6652:241;;6756:2;6744:9;6735:7;6731:23;6727:32;6724:2;;;-1:-1;;6762:12;6724:2;85:6;72:20;97:33;124:5;97:33;:::i;6900:366::-;;;7021:2;7009:9;7000:7;6996:23;6992:32;6989:2;;;-1:-1;;7027:12;6989:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7079:63;-1:-1;7179:2;7218:22;;72:20;97:33;72:20;97:33;:::i;:::-;7187:63;;;;6983:283;;;;;:::o;7273:491::-;;;;7411:2;7399:9;7390:7;7386:23;7382:32;7379:2;;;-1:-1;;7417:12;7379:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7469:63;-1:-1;7569:2;7608:22;;72:20;97:33;72:20;97:33;:::i;:::-;7373:391;;7577:63;;-1:-1;;;7677:2;7716:22;;;;6171:20;;7373:391::o;7771:991::-;;;;;;;;7975:3;7963:9;7954:7;7950:23;7946:33;7943:2;;;-1:-1;;7982:12;7943:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8034:63;-1:-1;8134:2;8173:22;;72:20;97:33;72:20;97:33;:::i;:::-;8142:63;-1:-1;8242:2;8281:22;;6171:20;;-1:-1;8350:2;8389:22;;6171:20;;-1:-1;8458:3;8496:22;;6447:20;6472:31;6447:20;6472:31;:::i;:::-;7937:825;;;;-1:-1;7937:825;;;;8467:61;8565:3;8605:22;;2898:20;;-1:-1;8674:3;8714:22;;;2898:20;;7937:825;-1:-1;;7937:825::o;8769:366::-;;;8890:2;8878:9;8869:7;8865:23;8861:32;8858:2;;;-1:-1;;8896:12;8858:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8948:63;9048:2;9087:22;;;;6171:20;;-1:-1;;;8852:283::o;9142:823::-;;;;9356:2;9344:9;9335:7;9331:23;9327:32;9324:2;;;-1:-1;;9362:12;9324:2;9413:17;9407:24;9451:18;;9443:6;9440:30;9437:2;;;-1:-1;;9473:12;9437:2;9590:6;9579:9;9575: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;9650:18;;9644:25;9493:114;;-1:-1;9644:25;-1:-1;;;9678:30;;;9675:2;;;-1:-1;;9711:12;9675:2;;9741:89;9822:7;9813:6;9802:9;9798:22;9741:89;:::i;:::-;9731:99;;;9867:2;9921:9;9917:22;6319:13;9875:74;;9318:647;;;;;:::o;9972:235::-;;10073:2;10061:9;10052:7;10048:23;10044:32;10041:2;;;-1:-1;;10079:12;10041:2;2642:6;2629:20;2654:30;2678:5;2654:30;:::i;10214:257::-;;10326:2;10314:9;10305:7;10301:23;10297:32;10294:2;;;-1:-1;;10332:12;10294:2;2777:6;2771:13;2789:30;2813:5;2789:30;:::i;10478:1235::-;;;;;;;;10718:3;10706:9;10697:7;10693:23;10689:33;10686:2;;;-1:-1;;10725:12;10686:2;2911:6;2898:20;10777:63;;10877:2;10920:9;10916:22;72:20;97:33;124:5;97:33;:::i;:::-;10885:63;-1:-1;10985:2;11024:22;;72:20;97:33;72:20;97:33;:::i;:::-;10993:63;-1:-1;11121:2;11106:18;;11093:32;11145:18;11134:30;;;11131:2;;;-1:-1;;11167:12;11131:2;11197:78;11267:7;11258:6;11247:9;11243:22;11197:78;:::i;:::-;11187:88;;11312:3;11356:9;11352:22;6171:20;11321:63;;11421:3;11465:9;11461:22;6171:20;11430:63;;11558:3;11547:9;11543:19;11530:33;11516:47;;11145:18;11575:6;11572:30;11569:2;;;-1:-1;;11605:12;11569:2;;11635:62;11689:7;11680:6;11669:9;11665:22;11635:62;:::i;:::-;11625:72;;;10680:1033;;;;;;;;;;:::o;11720:239::-;;11823:2;11811:9;11802:7;11798:23;11794:32;11791:2;;;-1:-1;;11829:12;11791:2;3047:6;3034:20;37312:66;40232:5;37301:78;40208:5;40205:34;40195:2;;-1:-1;;40243:12;11966:303;;12101:2;12089:9;12080:7;12076:23;12072:32;12069:2;;;-1:-1;;12107:12;12069:2;3656:6;3650:13;3668:53;3715:5;3668:53;:::i;12276:500::-;;;12421:2;12409:9;12400:7;12396:23;12392:32;12389:2;;;-1:-1;;12427:12;12389:2;3828:6;3815:20;3840:48;3882:5;3840:48;:::i;:::-;12479:78;-1:-1;12622:2;12607:18;;12594:32;12646:18;12635:30;;12632:2;;;-1:-1;;12668:12;12632:2;12698:62;12752:7;12743:6;12732:9;12728:22;12698:62;:::i;:::-;12688:72;;;12383:393;;;;;:::o;12783:291::-;;12912:2;12900:9;12891:7;12887:23;12883:32;12880:2;;;-1:-1;;12918:12;12880:2;12980:78;13050:7;13026:22;12980:78;:::i;13081:427::-;;;13227:2;13215:9;13206:7;13202:23;13198:32;13195:2;;;-1:-1;;13233:12;13195:2;13295:78;13365:7;13341:22;13295:78;:::i;:::-;13285:88;;13410:2;13464:9;13460:22;6319:13;13418:74;;13189:319;;;;;:::o;13515:897::-;;;;;13724:3;13712:9;13703:7;13699:23;13695:33;13692:2;;;-1:-1;;13731:12;13692:2;13789:17;13776:31;13827:18;;13819:6;13816:30;13813:2;;;-1:-1;;13849:12;13813:2;13944:6;13933:9;13929:22;;;4563:6;;4551:9;4546:3;4542:19;4538:32;4535:2;;;-1:-1;;4573:12;4535:2;4601:22;4563:6;4601:22;:::i;:::-;4592:31;;4705:62;4763:3;4739:22;4705:62;:::i;:::-;4687:16;4680:88;4865:64;4925:3;4832:2;4905:9;4901:22;4865:64;:::i;:::-;4832:2;4851:5;4847:16;4840:90;5028:64;5088:3;4995:2;5068:9;5064:22;5028:64;:::i;:::-;4995:2;5014:5;5010:16;5003:90;5156:2;5214:9;5210:22;6171:20;5156:2;5175:5;5171:16;5164:75;13724:3;5361:9;5357:22;2898:20;13724:3;5322:5;5318:16;5311:75;5458:3;5517:9;5513:22;6171:20;5458:3;5478:5;5474:16;5467:75;5637:49;5682:3;5603;5662:9;5658:22;5637:49;:::i;:::-;5603:3;5623:5;5619:16;5612:75;5780:49;5825:3;5746;5805:9;5801:22;5780:49;:::i;:::-;5746:3;5766:5;5762:16;5755:75;5923:3;;5912:9;5908:19;5895:33;13827:18;5940:6;5937:30;5934:2;;;-1:-1;;5970:12;5934:2;6017:58;6071:3;6062:6;6051:9;6047:22;6017:58;:::i;:::-;5923:3;6001:5;5997:18;5990:86;;;13869:92;;;;4832:2;14015:9;14011:18;13998:32;13984:46;;13827:18;14042:6;14039:30;14036:2;;;-1:-1;;14072:12;14036:2;;14102:78;14172:7;14163:6;14152:9;14148:22;14102:78;:::i;:::-;13686:726;;14092:88;;-1:-1;;;;4995:2;14256:22;;6171:20;;5156:2;14364:22;6171:20;;13686:726;-1:-1;13686:726::o;14419:241::-;;14523:2;14511:9;14502:7;14498:23;14494:32;14491:2;;;-1:-1;;14529:12;14491:2;-1:-1;6171:20;;14485:175;-1:-1;14485:175::o;14667:263::-;;14782:2;14770:9;14761:7;14757:23;14753:32;14750:2;;;-1:-1;;14788:12;14750:2;-1:-1;6319:13;;14744:186;-1:-1;14744:186::o;14937:366::-;;;15058:2;15046:9;15037:7;15033:23;15029:32;15026:2;;;-1:-1;;15064:12;15026:2;-1:-1;;6171:20;;;15216:2;15255:22;;;6171:20;;-1:-1;15020:283::o;15310:672::-;;;;;15476:3;15464:9;15455:7;15451:23;15447:33;15444:2;;;-1:-1;;15483:12;15444:2;6325:6;6319:13;15535:74;;15646:2;15700:9;15696:22;6319:13;15654:74;;15765:2;15819:9;15815:22;6319:13;15773:74;;15884:2;15938:9;15934:22;220:13;238:33;265:5;238:33;:::i;:::-;15438:544;;;;-1:-1;15438:544;;-1:-1;;15438:544::o;15989:259::-;;16102:2;16090:9;16081:7;16077:23;16073:32;16070:2;;;-1:-1;;16108:12;16070:2;6597:6;6591:13;6609:31;6634:5;6609:31;:::i;17592:670::-;;17775:5;34932:12;35740:6;35735:3;35728:19;35777:4;;35772:3;35768:14;17787:83;;35777:4;17941:5;34613:14;-1:-1;17980:260;18005:6;18002:1;17999:13;17980:260;;;18066:13;;19282:37;;16621:14;;;;35478;;;;18027:1;18020:9;17980:260;;;-1:-1;18246:10;;17706:556;-1:-1;;;;;17706:556::o;18999:94::-;37135:13;37128:21;19054:34;;19048:45::o;19986:323::-;;20118:5;34932:12;35740:6;35735:3;35728:19;-1:-1;39311:101;39325:6;39322:1;39319:13;39311:101;;;35777:4;39392:11;;;;;39386:18;39373:11;;;;;39366:39;39340:10;39311:101;;;39427:6;39424:1;39421:13;39418:2;;;-1:-1;35777:4;39483:6;35772:3;39474:16;;39467:27;39418:2;-1:-1;39764:2;39744:14;-1:-1;;39740:28;20265:39;;;;35777:4;20265:39;;20066:243;-1:-1;;20066:243::o;23642:387::-;19282:37;;;37312:66;37301:78;23893:2;23884:12;;19577:56;23993:11;;;23784:245::o;24036:291::-;;39166:6;39161:3;39156;39143:30;39204:16;;39197:27;;;39204:16;24180:147;-1:-1;24180:147::o;24334:659::-;21968:66;21948:87;;21933:1;22054:11;;19282:37;;;;24845:12;;;19282:37;24956:12;;;24579:414::o;25000:222::-;-1:-1;;;;;37684:54;;;;16720:37;;25127:2;25112:18;;25098:124::o;25229:370::-;;25406:2;25427:17;25420:47;25481:108;25406:2;25395:9;25391:18;25575:6;25481:108;:::i;25606:629::-;;25861:2;25882:17;25875:47;25936:108;25861:2;25850:9;25846:18;26030:6;25936:108;:::i;:::-;26092:9;26086:4;26082:20;26077:2;26066:9;26062:18;26055:48;26117:108;26220:4;26211:6;26117:108;:::i;26242:210::-;37135:13;;37128:21;19054:34;;26363:2;26348:18;;26334:118::o;26459:432::-;37135:13;;37128:21;19054:34;;26794:2;26779:18;;19282:37;;;;26877:2;26862:18;;19282:37;26636:2;26621:18;;26607:284::o;26898:222::-;19282:37;;;27025:2;27010:18;;26996:124::o;27127:444::-;19282:37;;;-1:-1;;;;;37684:54;;;27474:2;27459:18;;16720:37;37684:54;27557:2;27542:18;;16720:37;27310:2;27295:18;;27281:290::o;27578:736::-;19282:37;;;-1:-1;;;;;37684:54;;;28020:2;28005:18;;;16720:37;;;;37684:54;;;28103:2;28088:18;;16720:37;27855:3;28140:2;28125:18;;28118:48;;;22383:23;;27840:19;;;22419:38;;;;34932:12;;22306:14;;;35728:19;;;27578:736;;28020:2;34613:14;;;27578:736;;35768:14;;;;17241:290;17266:6;17263:1;17260:13;17241:290;;;38011:52;17333:6;17327:13;38011:52;:::i;:::-;20742:65;;35478:14;;;;17288:1;17281:9;;;;;16439:14;;;;17241:290;;;17245:14;28020:2;22676:5;22672:16;22666:23;22646:43;;22725:14;;;;27844:9;22729:4;22725:14;;22709;27844:9;22709:14;22702:38;22755:103;22853:4;22839:12;22755:103;:::i;:::-;22747:111;;;;28103:2;22940:5;22936:16;22930:23;22725:14;27844:9;22993:4;22989:14;;22973;27844:9;22973:14;22966:38;23019:71;23085:4;23071:12;23019:71;:::i;:::-;23011:79;;;;28140:2;23183:5;23179:16;23173:23;23202:57;23244:14;27844:9;23244:14;23230:12;23202:57;:::i;28321:780::-;19282:37;;;-1:-1;;;;;37684:54;;;28753:2;28738:18;;16720:37;37684:54;;;;28836:2;28821:18;;16720:37;28919:2;28904:18;;19282:37;29002:3;28987:19;;19282:37;;;;-1:-1;29071:19;;19282:37;28588:3;28573:19;;28559:542::o;29108:668::-;19282:37;;;29512:2;29497:18;;19282:37;;;;29595:2;29580:18;;19282:37;;;;29678:2;29663:18;;19282:37;-1:-1;;;;;37684:54;29761:3;29746:19;;16720:37;-1:-1;29332:19;;29318:458::o;29783:417::-;;19312:5;19289:3;19282:37;29956:2;30074;30063:9;30059:18;30052:48;30114:76;29956:2;29945:9;29941:18;30176:6;30114:76;:::i;30207:363::-;19282:37;;;-1:-1;;;;;37684:54;30556:2;30541:18;;20742:65;30377:2;30362:18;;30348:222::o;30577:548::-;19282:37;;;37900:4;37889:16;;;;30945:2;30930:18;;23595:35;31028:2;31013:18;;19282:37;31111:2;31096:18;;19282:37;30784:3;30769:19;;30755:370::o;31660:310::-;;31807:2;31828:17;31821:47;31882:78;31807:2;31796:9;31792:18;31946:6;31882:78;:::i;32206:481::-;;19312:5;19289:3;19282:37;32411:2;32529;32518:9;32514:18;32507:48;32569:108;32411:2;32400:9;32396:18;32663:6;32569:108;:::i;32694:333::-;19282:37;;;33013:2;32998:18;;19282:37;32849:2;32834:18;;32820:207::o;33034:214::-;37900:4;37889:16;;;;23595:35;;33157:2;33142:18;;33128:120::o;33255:256::-;33317:2;33311:9;33343:17;;;33418:18;33403:34;;33439:22;;;33400:62;33397:2;;;33475:1;;33465:12;33397:2;33317;33484:22;33295:216;;-1:-1;33295:216::o;33518:319::-;;33692:18;33684:6;33681:30;33678:2;;;-1:-1;;33714:12;33678:2;-1:-1;33759:4;33747:17;;;33812:15;;33615:222::o;36971:91::-;-1:-1;;;;;37684:54;;37016:46::o;39781:117::-;-1:-1;;;;;37684:54;;39840:35;;39830:2;;39889:1;;39879:12;39905:111;39986:5;37135:13;37128:21;39964:5;39961:32;39951:2;;40007:1;;39997:12;40940:113;37900:4;41023:5;37889:16;41000:5;40997:33;40987:2;;41044:1;;41034:12
Swarm Source
ipfs://8cee796c69d779f4ecdac48d0ee5699c0c37b947a653bfd7e783081a6338bb74
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.