Token Beets Boosted USD+
Overview [ERC-20]
Price
$0.00 @ 0.000000 Eth
Fully Diluted Market Cap
Max Total Supply:
5,192,296,858,534,827.628530496329220095 bb-USD+
Holders:
9
Transfers:
-
Contract:
Decimals:
18
[ Download CSV Export ]
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
ERC4626LinearPool
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/LegacyBasePool.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 LegacyBasePool, 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 ) LegacyBasePool( 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() public 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(); } /** * @dev Should be 1e18 for the subsequent calculation of the wrapper token scaling factor. */ 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; uint256 internal constant DISABLED = 211; // 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; uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434; // 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 TWO = 2 * ONE; uint256 internal constant FOUR = 4 * ONE; 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) { // Optimize for when y equals 1.0, 2.0 or 4.0, as those are very simple to implement and occur often in 50/50 // and 80/20 Weighted Pools if (y == ONE) { return x; } else if (y == TWO) { return mulDown(x, x); } else if (y == FOUR) { uint256 square = mulDown(x, x); return mulDown(square, square); } else { 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) { // Optimize for when y equals 1.0, 2.0 or 4.0, as those are very simple to implement and occur often in 50/50 // and 80/20 Weighted Pools if (y == ONE) { return x; } else if (y == TWO) { return mulUp(x, x); } else if (y == FOUR) { uint256 square = mulUp(x, x); return mulUp(square, square); } else { 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 LegacyBasePool 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_BALANCE); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { _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"; /** * @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). It is important as it lets us work in-place, avoiding // memory allocation and copying. 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; // We need to concatenate the deployer creation code and `code` in memory, but want to avoid copying all of // `code` (which could be quite long) into a new memory location. Therefore, we operate in-place using // assembly. // 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 "./ERC4626LinearPool.sol"; contract ERC4626LinearPoolFactory is BasePoolSplitCodeFactory, FactoryWidePauseWindow { constructor(IVault vault) BasePoolSplitCodeFactory(vault, type(ERC4626LinearPool).creationCode) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Deploys a new `ERC4626LinearPool`. */ function create( string memory name, string memory symbol, IERC20 mainToken, IERC4626 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, address owner ) external returns (LinearPool) { (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) = getPauseConfiguration(); LinearPool pool = ERC4626LinearPool( _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 "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IERC4626.sol"; import "../LinearPool.sol"; contract ERC4626LinearPool is LinearPool { using Math for uint256; uint256 private immutable _rateScaleFactor; constructor( IVault vault, string memory name, string memory symbol, IERC20 mainToken, IERC4626 wrappedToken, uint256 upperTarget, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) LinearPool( vault, name, symbol, mainToken, wrappedToken, upperTarget, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // We do NOT enforce mainToken == wrappedToken.asset() even // though this is the expected behavior in most cases. Instead, // we assume a 1:1 relationship between mainToken and // wrappedToken.asset(), but they do not have to be the same // token. It is vitally important that this 1:1 relationship is // respected, or the pool will not function as intended. // // This allows for use cases where the wrappedToken is // double-wrapped into an ERC-4626 token. For example, consider // a linear pool whose goal is to pair DAI with aDAI. Because // aDAI is a rebasing token, it needs to be wrapped, and let's // say an ERC-4626 wrapper is chosen for compatibility with this // linear pool. Then wrappedToken.asset() will return aDAI, // whereas mainToken is DAI. But the 1:1 relationship holds, and // the pool is still valid. // _getWrappedTokenRate is scaled e18, so we may need to scale IERC4626.convertToAssets() uint256 wrappedTokenDecimals = ERC20(address(wrappedToken)).decimals(); uint256 mainTokenDecimals = ERC20(address(mainToken)).decimals(); // This is always positive because we only accept tokens with <= 18 decimals uint256 digitsDifference = Math.add(18, wrappedTokenDecimals).sub(mainTokenDecimals); _rateScaleFactor = 10**digitsDifference; } function _getWrappedTokenRate() internal view override returns (uint256) { IERC4626 wrappedToken = IERC4626(getWrappedToken()); // Main tokens per 1e18 wrapped token wei // decimals: main + (18 - wrapped) uint256 assetsPerShare = wrappedToken.convertToAssets(FixedPoint.ONE); // This function returns a 18 decimal fixed point number // assetsPerShare decimals: 18 + main - wrapped // _rateScaleFactor decimals: 18 - main + wrapped uint256 rate = assetsPerShare.mul(_rateScaleFactor).divDown(FixedPoint.ONE); return rate; } }
// 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"; interface IERC4626 is IERC20 { /** * @dev `caller` has exchanged `assets` for `shares`, and transferred those `shares` to `owner`. */ event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); /** * @dev `caller` has exchanged `shares`, owned by `owner`, for `assets`, * and transferred those `assets` to `receiver`. */ event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Mints `shares` Vault shares to `receiver` by depositing exactly `amount` of underlying tokens. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Burns exactly `shares` from `owner` and sends `assets` of underlying tokens to `receiver`. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); /** * @dev The address of the underlying token that the Vault uses for accounting, depositing, and withdrawing. */ function asset() external view returns (address); /** * @dev Total amount of the underlying asset that is “managed” by Vault. */ function totalAssets() external view returns (uint256); /** * @dev The amount of `assets` that the Vault would exchange for the amount * of `shares` provided, in an ideal scenario where all the conditions are met. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev The amount of `shares` that the Vault would exchange for the amount * of `assets` provided, in an ideal scenario where all the conditions are met. */ function convertToShares(uint256 assets) external view returns (uint256 shares); }
{ "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 IERC4626","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
6102c06040527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9610120523480156200003757600080fd5b50604051620053de380380620053de8339810160408190526200005a9162000bd0565b898989898989898989898960008a8a620000768b8b30620004f5565b6040805160038082526080820190925290602082016060803683370190505089898989828289898d8280604051806040016040528060018152602001603160f81b81525085858a336001600160a01b031660001b806080818152505050806001600160a01b031660a0816001600160a01b031660601b815250505081600390805190602001906200010992919062000a5c565b5080516200011f90600490602084019062000a5c565b505060058054601260ff1990911617905550815160209283012060c052805191012060e052507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6101005260601b6001600160601b03191661014052506200019290506276a700831115610194620005c4565b620001a662278d00821115610195620005c4565b4290910161016081905201610180528551620001c8906002111560c8620005c4565b620001e2620001d6620005d9565b8751111560c9620005c4565b620001f886620005de60201b620014881760201c565b6200020384620005ea565b6040516309b2760f60e01b81526000906001600160a01b038c16906309b2760f9062000234908d9060040162000d6e565b602060405180830381600087803b1580156200024f57600080fd5b505af115801562000264573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200028a919062000bb7565b604051633354e3e960e11b81529091506001600160a01b038c16906366a9c7d290620002bf9084908b908b9060040162000cd2565b600060405180830381600087803b158015620002da57600080fd5b505af1158015620002ef573d6000803e3d6000fd5b50505050806101a081815250505050505050505050505050866001600160a01b03166101c0816001600160a01b031660601b81525050856001600160a01b03166101e0816001600160a01b031660601b8152505060008060006200035b8a8a306200067660201b60201c565b610200819052610220839052610240829052919450925090506200037f8a6200076c565b610260526200038e896200076c565b610280526000620003a18b828b62000840565b50505050505050505050505050506000866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015620003eb57600080fd5b505afa15801562000400573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000426919062000caf565b60ff1690506000886001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200046757600080fd5b505afa1580156200047c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004a2919062000caf565b60ff1690506000620004da82620004c6601286620008ee60201b620014921760201c565b6200090b60201b620014a41790919060201c565b600a0a6102a0525062000da69b505050505050505050505050565b6060600080806200050887878762000676565b60408051600380825260808201909252939650919450925060208201606080368337019050509350868484815181106200053e57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858483815181106200056c57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050848482815181106200059a57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505050509392505050565b81620005d557620005d58162000923565b5050565b600390565b80620005d58162000976565b620005ff64e8d4a5100082101560cb620005c4565b6200061767016345785d8a000082111560ca620005c4565b620006368160c060085462000a0360201b620014ba179092919060201c565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906200066b90839062000d83565b60405180910390a150565b6000806000846001600160a01b0316866001600160a01b03161015620006ff57836001600160a01b0316856001600160a01b03161015620006c257506000915060019050600262000763565b836001600160a01b0316866001600160a01b03161015620006ee57506000915060029050600162000763565b506001915060029050600062000763565b846001600160a01b0316846001600160a01b031610156200072b57506002915060019050600062000763565b856001600160a01b0316846001600160a01b031610156200075757506002915060009050600162000763565b50600191506000905060025b93509350939050565b60006001600160a01b038216301415620007905750670de0b6b3a76400006200083b565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015620007cc57600080fd5b505afa158015620007e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000807919062000caf565b60ff1690506000620008266012836200090b60201b620014a41760201c565b905080600a0a670de0b6b3a764000002925050505b919050565b620008518183111561014c620005c4565b620008696001600160601b0382111561014d620005c4565b620008a46200088582606062000a1860201b620014d01760201c565b6200089d84600062000a1860201b620014d01760201c565b1762000a1c565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d12808383604051620008e192919062000d8c565b60405180910390a2505050565b6000828201620009028482101583620005c4565b90505b92915050565b60006200091d838311156001620005c4565b50900390565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600281511015620009875762000a00565b6000816000815181106200099757fe5b602002602001015190506000600190505b8251811015620009fd576000838281518110620009c157fe5b60200260200101519050620009f2816001600160a01b0316846001600160a01b0316106065620005c460201b60201c565b9150600101620009a8565b50505b50565b6001600160401b03811b1992909216911b1790565b1b90565b62000a3b81600060085462000a4160201b620014d4179092919060201c565b60085550565b6001600160c01b03828116821b90821b198416179392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1062000a9f57805160ff191683800117855562000acf565b8280016001018555821562000acf579182015b8281111562000acf57825182559160200191906001019062000ab2565b5062000add92915062000ae1565b5090565b5b8082111562000add576000815560010162000ae2565b80516001600160a01b03811681146200090557600080fd5b600082601f83011262000b21578081fd5b81516001600160401b038082111562000b38578283fd5b6040516020601f8401601f191682018101838111838210171562000b5a578586fd5b8060405250819450838252868185880101111562000b7757600080fd5b600092505b8383101562000b9b578583018101518284018201529182019162000b7c565b8383111562000bad5760008185840101525b5050505092915050565b60006020828403121562000bc9578081fd5b5051919050565b6000806000806000806000806000806101408b8d03121562000bf0578586fd5b62000bfc8c8c62000af8565b60208c0151909a506001600160401b038082111562000c19578788fd5b62000c278e838f0162000b10565b9a5060408d015191508082111562000c3d578788fd5b5062000c4c8d828e0162000b10565b98505062000c5e8c60608d0162000af8565b965062000c6f8c60808d0162000af8565b955060a08b0151945060c08b0151935060e08b015192506101008b0151915062000c9e8c6101208d0162000af8565b90509295989b9194979a5092959850565b60006020828403121562000cc1578081fd5b815160ff8116811462000902578182fd5b60006060820185835260206060818501528186518084526080860191508288019350845b8181101562000d1e5762000d0b855162000d9a565b8352938301939183019160010162000cf6565b505084810360408601528551808252908201925081860190845b8181101562000d605762000d4d835162000d9a565b8552938301939183019160010162000d38565b509298975050505050505050565b602081016003831062000d7d57fe5b91905290565b90815260200190565b918252602082015260400190565b6001600160a01b031690565b60805160a05160601c60c05160e05161010051610120516101405160601c61016051610180516101a0516101c05160601c6101e05160601c61020051610220516102405161026051610280516102a05161446162000f7d600039806125775250806115ae52508061154a528061241f5250806107c65280610b7952806115d6528061278a528061293a5280612a915280612c035280612d9f5280612ef65250806109745280610b3f528061156c5280611c1f528061275652806128bf52806129065280612a1b5280612a5d5280612bcf5280612d295280612d6b5280612e805280612ec2525080610bba5280610d895280610e7652806114095280611617528061236452806127c152806129715280612ac85280612c3a5280612dd65280612f2d5280613112528061314a52508061145c528061173252806117fe5280612445528061270b528061284b5280612b855280612cb5525080610998528061101552806116e952806117b55280611c5552806123e452806126cc52806127ed52806129a75280612b465280612c665280612e0c5250806109155250806119de5250806119ba525080610f365250806110cb525080611ae4525080611b26525080611b05525080610f12525080610e9c52506144616000f3fe608060405234801561001057600080fd5b50600436106102d35760003560e01c8063679aefce1161018657806395d89b41116100e3578063d505accf11610097578063de82cd3411610071578063de82cd341461056b578063f174e24114610573578063f5431aa81461057b576102d3565b8063d505accf14610532578063d5c096c414610545578063dd62ed3e14610558576102d3565b8063a457c2d7116100c8578063a457c2d714610504578063a9059cbb14610517578063aaabadc51461052a576102d3565b806395d89b41146104e95780639f11080e146104f1576102d3565b806382687a561161013a57806387ec68171161011f57806387ec6817146104c6578063893d20e8146104d95780638d928af8146104e1576102d3565b806382687a56146104ab578063851c1bb3146104b3576102d3565b806374f3b0091161016b57806374f3b0091461046f5780637ecebe00146104905780638129fc1c146104a3576102d3565b8063679aefce1461045457806370a082311461045c576102d3565b80633644e515116102345780634de046d5116101e857806355c67628116101cd57806355c67628146104155780636028bfd41461041d57806363fe3b561461043e576102d3565b80634de046d5146103ed57806350dd6ed914610402576102d3565b806338fff2d01161021957806338fff2d0146103ca57806339509351146103d25780634d64cd74146103e5576102d3565b80633644e515146103af57806338e9922e146103b7576102d3565b806318160ddd1161028b5780631dd746ea116102705780631dd746ea1461037257806323b872dd14610387578063313ce5671461039a576102d3565b806318160ddd146103535780631c0de0511461035b576102d3565b8063095ea7b3116102bc578063095ea7b31461031657806316b8d6ff1461033657806316c38b3c1461033e576102d3565b806301ec954a146102d857806306fdde0314610301575b600080fd5b6102eb6102e6366004613e95565b610583565b6040516102f891906141b5565b60405180910390f35b6103096106f9565b6040516102f8919061436d565b610329610324366004613bd2565b6107ad565b6040516102f89190614192565b6102eb6107c4565b61035161034c366004613cc9565b6107e8565b005b6102eb6107fc565b610363610802565b6040516102f89392919061419d565b61037a61082b565b6040516102f8919061415a565b610329610395366004613b1d565b61083a565b6103a26108ce565b6040516102f891906143a7565b6102eb6108d7565b6103516103c5366004613fb4565b6108e1565b6102eb610913565b6103296103e0366004613bd2565b610937565b6102eb610972565b6103f5610996565b6040516102f89190614146565b610351610410366004613e00565b6109ba565b6102eb6109d8565b61043061042b366004613d01565b6109e9565b6040516102f8929190614380565b610446610a20565b6040516102f8929190614399565b6102eb610a4e565b6102eb61046a366004613ac9565b610c02565b61048261047d366004613d01565b610c21565b6040516102f892919061416d565b6102eb61049e366004613ac9565b610c9f565b610351610cba565b6102eb610e74565b6102eb6104c1366004613da4565b610e98565b6104306104d4366004613d01565b610eea565b6103f5610f10565b6103f5610f34565b610309610f58565b6103516104ff366004613fe4565b610fd7565b610329610512366004613bd2565b611041565b610329610525366004613bd2565b61107f565b6103f561108c565b610351610540366004613b5d565b611096565b610482610553366004613d01565b6111df565b6102eb610566366004613ae5565b611310565b6102eb61136b565b6103f561145a565b6102eb61147e565b600084608001516105b0610595610f34565b6001600160a01b0316336001600160a01b03161460cd611500565b6105c56105bb610913565b82146101f4611500565b6105cd61150e565b6105e76003851080156105e05750600384105b6064611500565b60606105f1611523565b90506105fd8682611650565b600080610608610a20565b91509150610614613920565b60405180606001604052806106276109d8565b815260208101859052604001839052905060008a51600181111561064757fe5b14156106ab5761066e8a60600151858a8151811061066157fe5b60200260200101516116b1565b60608b015260006106808b8b846116bd565b905061069f81868a8151811061069257fe5b6020026020010151611784565b965050505050506106f0565b6106bf8a6060015185898151811061066157fe5b60608b015260006106d18b8b84611790565b905061069f81868b815181106106e357fe5b6020026020010151611845565b50949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b820191906000526020600020905b81548152906001019060200180831161078657829003601f168201915b5050505050905090565b60006107ba338484611851565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000090565b6107f06118b9565b6107f9816118ff565b50565b60025490565b600080600061080f61199b565b15925061081a6119b8565b91506108246119dc565b9050909192565b6060610835611523565b905090565b6000806108478533611310565b905061086b336001600160a01b03871614806108635750838210155b61019e611500565b610876858585611a00565b336001600160a01b038616148015906108af57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b156108c1576108c18533858403611851565b60019150505b9392505050565b60055460ff1690565b6000610835611ae0565b6000806108ec610a20565b915091506109056108fd8383611b7d565b61014f611500565b61090e83611c95565b505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916107ba91859061096d9086611492565b611851565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b6109c26118b9565b6109ca61150e565b6109d48282611cae565b5050565b6008546000906108359060c0611d8e565b600060606109ff86516109fa611d9c565b611da1565b610a1489898989898989611dae611e52611eb3565b97509795505050505050565b6000806000610a2d612043565b9050610a3a816000612049565b9250610a47816060612049565b9150509091565b600080610a59610913565b90506060610a65610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610a9091906141b5565b60006040518083038186803b158015610aa857600080fd5b505afa158015610abc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae49190810190613bfd565b50915050610af981610af4611523565b611650565b600080610b04610a20565b91509150610b10613920565b6040518060600160405280610b236109d8565b81526020018481526020018381525090506000610baf610b76867f000000000000000000000000000000000000000000000000000000000000000081518110610b6857fe5b60200260200101518461205b565b867f000000000000000000000000000000000000000000000000000000000000000081518110610ba257fe5b60200260200101516120bc565b9050610bf7610bf0867f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b60200260200101516120c8565b82906120db565b965050505050505090565b6001600160a01b0381166000908152602081905260409020545b919050565b60608088610c30610595610f34565b610c3b6105bb610913565b6060610c45611523565b9050610c518882611650565b6000606080610c668e8e8e8e8e8e8a8f611dae565b925092509250610c768d84612132565b610c808285611e52565b610c8a8185611e52565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b6000610cc4610913565b90506060610cd0610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610cfb91906141b5565b60006040518083038186803b158015610d1357600080fd5b505afa158015610d27573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4f9190810190613bfd565b505060408051600380825260808201909252919250606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f000000000000000000000000000000000000000000000000000000000000000081518110610db257fe5b602002602001018181525050610dc6613941565b6040518060800160405280610dda8561213c565b8152602001838152602001604051806020016040528060008152508152602001600015158152509050610e0b610f34565b6001600160a01b031663b95cac28853030856040518563ffffffff1660e01b8152600401610e3c94939291906141dd565b600060405180830381600087803b158015610e5657600080fd5b505af1158015610e6a573d6000803e3d6000fd5b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b60007f000000000000000000000000000000000000000000000000000000000000000082604051602001610ecd9291906140d0565b604051602081830303815290604052805190602001209050919050565b60006060610efb86516109fa611d9c565b610a148989898989898961213f61215d611eb3565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b610fdf6118b9565b600080610fea610a20565b91509150610ffb6108fd8383611b7d565b6110106110088585611b7d565b610157611500565b61103b7f000000000000000000000000000000000000000000000000000000000000000085856121be565b50505050565b60008061104e3385611310565b90508083106110685761106333856000611851565b611075565b6110753385858403611851565b5060019392505050565b60006107ba338484611a00565b600061083561224f565b6110a48442111560d1611500565b6001600160a01b03871660009081526006602090815260408083205490519092916110fb917f0000000000000000000000000000000000000000000000000000000000000000918c918c918c9188918d91016142bf565b604051602081830303815290604052805190602001209050600061111e826122c9565b9050600060018288888860405160008152602001604052604051611145949392919061434f565b6020604051602081039080840390855afa158015611167573d6000803e3d6000fd5b5050604051601f19015191506111a990506001600160a01b038216158015906111a157508b6001600160a01b0316826001600160a01b0316145b6101f8611500565b6001600160a01b038b1660009081526006602052604090206001850190556111d28b8b8b611851565b5050505050505050505050565b606080886111ee610595610f34565b6111f96105bb610913565b6060611203611523565b905061120d6107fc565b6112c057600060606112228d8d8d868b6122e5565b9150915061123b6112316123a6565b83101560cc611500565b61124d60006112486123a6565b6123ab565b6112608b6112596123a6565b84036123ab565b61126a818461215d565b80611273611d9c565b67ffffffffffffffff8111801561128957600080fd5b506040519080825280602002602001820160405280156112b3578160200160208202803683370190505b5095509550505050610c92565b6112ca8882611650565b60006060806112df8e8e8e8e8e8e8a8f61213f565b9250925092506112ef8c846123ab565b6112f9828561215d565b6113038185611e52565b9095509350610c92915050565b600061131a610f34565b6001600160a01b0316826001600160a01b0316141561135a57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6107be565b61136483836123b5565b90506107be565b60006060611377610f34565b6001600160a01b031663f94d466861138d610913565b6040518263ffffffff1660e01b81526004016113a991906141b5565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd9190810190613bfd565b509150506000611448827f00000000000000000000000000000000000000000000000000000000000000008151811061143257fe5b6020026020010151611443306123e0565b6116b1565b9050611453816124ba565b9250505090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60006108356124ce565b806109d4816125a9565b60008282016108c78482101583611500565b60006114b4838311156001611500565b50900390565b67ffffffffffffffff811b1992909216911b1790565b1b90565b77ffffffffffffffffffffffffffffffffffffffffffffffff828116821b90821b198416179392505050565b816109d4576109d481612622565b61152161151961199b565b610192611500565b565b604080516003808252608082019092526060918291906020820183803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000817f00000000000000000000000000000000000000000000000000000000000000008151811061159557fe5b6020026020010181815250506115d36115ac6124ce565b7f00000000000000000000000000000000000000000000000000000000000000009061268f565b817f0000000000000000000000000000000000000000000000000000000000000000815181106115ff57fe5b602002602001018181525050670de0b6b3a7640000817f00000000000000000000000000000000000000000000000000000000000000008151811061164057fe5b6020908102919091010152905090565b60005b61165b611d9c565b81101561090e5761169283828151811061167157fe5b602002602001015183838151811061168557fe5b602002602001015161268f565b83828151811061169e57fe5b6020908102919091010152600101611653565b60006108c7838361268f565b60208301516000906001600160a01b03163014156116e7576116e08484846126c5565b90506108c7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684602001516001600160a01b03161415611730576116e0848484612844565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684602001516001600160a01b03161415611779576116e08484846129a0565b6108c7610135612622565b60006108c78383612af7565b60408301516000906001600160a01b03163014156117b3576116e0848484612b3f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684604001516001600160a01b031614156117fc576116e0848484612cae565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031684604001516001600160a01b03161415611779576116e0848484612e05565b60006108c783836120db565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906118ac9085906141b5565b60405180910390a3505050565b60006118e86000357fffffffff0000000000000000000000000000000000000000000000000000000016610e98565b90506107f96118f78233612f5c565b610191611500565b801561191f5761191a6119106119b8565b4210610193611500565b611934565b61193461192a6119dc565b42106101a9611500565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be6490611990908390614192565b60405180910390a150565b60006119a56119dc565b42118061083557505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b611a176001600160a01b0384161515610198611500565b611a2e6001600160a01b0383161515610199611500565b611a3983838361090e565b6001600160a01b038316600090815260208190526040902054611a5f90826101a0613045565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611a8e9082611492565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906118ac9085906141b5565b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611b4d61305b565b30604051602001611b629594939291906142f3565b60405160208183030381529060405280519060200120905090565b600080611b88610913565b90506060611b94610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401611bbf91906141b5565b60006040518083038186803b158015611bd757600080fd5b505afa158015611beb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c139190810190613bfd565b509150506000611c79827f000000000000000000000000000000000000000000000000000000000000000081518110611c4857fe5b60200260200101516114437f00000000000000000000000000000000000000000000000000000000000000006123e0565b9050858110158015611c8b5750848111155b9695505050505050565b611c9d6118b9565b611ca561150e565b6107f98161305f565b6000611cb8610913565b90506000611cc4610f34565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b8152600401611cf1929190614338565b60806040518083038186803b158015611d0957600080fd5b505afa158015611d1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d419190614005565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d49250610e3c91508590879060040161431f565b1c67ffffffffffffffff1690565b600390565b6109d48183146067611500565b60006060806000611dbe856130ca565b90506000818015611dcb57fe5b14611de057611ddb61014e612622565b611e43565b611de86130e0565b611df289866130f4565b9094509250611dff611d9c565b67ffffffffffffffff81118015611e1557600080fd5b50604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b5091505b50985098509895505050505050565b60005b611e5d611d9c565b81101561090e57611e94838281518110611e7357fe5b6020026020010151838381518110611e8757fe5b6020026020010151612af7565b838281518110611ea057fe5b6020908102919091010152600101611e55565b333014611fa2576000306001600160a01b0316600036604051611ed7929190614100565b6000604051808303816000865af19150503d8060008114611f14576040519150601f19603f3d011682016040523d82523d6000602084013e611f19565b606091505b505090508060008114611f2857fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611f84573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611fac611523565b9050611fb88782611650565b60006060611fd08c8c8c8c8c8c898d8d63ffffffff16565b5091509150611fe381848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60085490565b1c6bffffffffffffffffffffffff1690565b600081602001518310156120945781516020830151600091612080918690039061268f565b905061208c84826114a4565b9150506107be565b816040015183116120a65750816107be565b815160408301516000916120809186039061268f565b60006108c78383611492565b6dffffffffffffffffffffffffffff0390565b60006120ea8215156004611500565b826120f7575060006107be565b670de0b6b3a76400008381029061211a9085838161211157fe5b04146005611500565b82600182038161212657fe5b046001019150506107be565b6109d4828261317b565b90565b600060608061214f61014e612622565b985098509895505050505050565b60005b612168611d9c565b81101561090e5761219f83828151811061217e57fe5b602002602001015183838151811061219257fe5b60200260200101516120db565b8382815181106121ab57fe5b6020908102919091010152600101612160565b6121cd8183111561014c611500565b6121e86bffffffffffffffffffffffff82111561014d611500565b6122076121f68260606114d0565b6122018460006114d0565b17613237565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d12808383604051612242929190614399565b60405180910390a2505050565b6000612259610f34565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561229157600080fd5b505afa1580156122a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190613de4565b60006122d3611ae0565b82604051602001610ecd929190614110565b600060606122f161150e565b6123086001600160a01b0387163014610156611500565b61231f6001600160a01b0386163014610156611500565b604080516003808252608082019092526dffffffffffffffffffffffffffff91606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f00000000000000000000000000000000000000000000000000000000000000008151811061238d57fe5b6020908102919091010152909890975095505050505050565b600090565b6109d4828261324c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561244357507f0000000000000000000000000000000000000000000000000000000000000000610c1c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561248f576124886115ac6124ce565b9050610c1c565b6001600160a01b0382163014156124af5750670de0b6b3a7640000610c1c565b610c1c610135612622565b60006107be826124c86107fc565b906114a4565b6000806124d961145a565b90506000816001600160a01b03166307a2d13a670de0b6b3a76400006040518263ffffffff1660e01b815260040161251191906141b5565b60206040518083038186803b15801561252957600080fd5b505afa15801561253d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125619190613fcc565b905060006125a1670de0b6b3a764000061259b847f00000000000000000000000000000000000000000000000000000000000000006132da565b906132f4565b935050505090565b6002815110156125b8576107f9565b6000816000815181106125c757fe5b602002602001015190506000600190505b825181101561090e5760008382815181106125ef57fe5b60200260200101519050612618816001600160a01b0316846001600160a01b0316106065611500565b91506001016125d8565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60008282026126b38415806126ac5750838583816126a957fe5b04145b6003611500565b670de0b6b3a764000090049392505050565b600061274b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b0316148061274357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b0316145b610135611500565b61283c8460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061277f57fe5b6020026020010151857f0000000000000000000000000000000000000000000000000000000000000000815181106127b357fe5b60200260200101516127ea877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b867f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a604001516001600160a01b03161461283057613314612834565b6133745b63ffffffff16565b949350505050565b60006128a07f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b03161480612743575060408501516001600160a01b03163014610135611500565b60408401516001600160a01b031630146128fb576128f68460600151847f0000000000000000000000000000000000000000000000000000000000000000815181106128e857fe5b6020026020010151846133dd565b61283c565b61283c8460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061292f57fe5b6020026020010151857f00000000000000000000000000000000000000000000000000000000000000008151811061296357fe5b602002602001015161299a877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b8661340d565b60006129fc7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685604001516001600160a01b03161480612743575060408501516001600160a01b03163014610135611500565b60408401516001600160a01b03163014612a52576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612a4457fe5b602002602001015184613473565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612a8657fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612aba57fe5b6020026020010151612af1877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b866134b3565b6000612b068215156004611500565b82612b13575060006107be565b670de0b6b3a764000083810290612b2d9085838161211157fe5b828181612b3657fe5b049150506107be565b6000612bc47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b0316148061274357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b031614610135611500565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612bf857fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612c2c57fe5b6020026020010151612c63877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b867f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a602001516001600160a01b031614612ca95761351a612834565b613571565b6000612d0a7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b03161480612743575060208501516001600160a01b03163014610135611500565b60208401516001600160a01b03163014612d60576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612d5257fe5b6020026020010151846135db565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612d9457fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612dc857fe5b6020026020010151612dff877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b86613605565b6000612e617f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685602001516001600160a01b03161480612743575060208501516001600160a01b03163014610135611500565b60208401516001600160a01b03163014612eb7576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612ea957fe5b602002602001015184613654565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612eeb57fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000081518110612f1f57fe5b6020026020010151612f56877f000000000000000000000000000000000000000000000000000000000000000081518110610be357fe5b86613689565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b612f7b610f10565b6001600160a01b031614158015612f965750612f96836136dd565b15612fbe57612fa3610f10565b6001600160a01b0316336001600160a01b03161490506107be565b612fc661224f565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b8152600401612ff5939291906141be565b60206040518083038186803b15801561300d57600080fd5b505afa158015613021573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113649190613ce5565b60006130548484111583611500565b5050900390565b4690565b61307264e8d4a5100082101560cb611500565b61308867016345785d8a000082111560ca611500565b600854613097908260c06114ba565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906119909083906141b5565b6000818060200190518101906107be9190613e4e565b6115216130eb61199b565b156101af611500565b60006060600061310384613719565b9050606061316e8683613148897f00000000000000000000000000000000000000000000000000000000000000008151811061313b57fe5b60200260200101516124ba565b7f000000000000000000000000000000000000000000000000000000000000000061372f565b9196919550909350505050565b6131926001600160a01b038316151561019b611500565b61319e8260008361090e565b6001600160a01b0382166000908152602081905260409020546131c490826101b2613045565b6001600160a01b0383166000908152602081905260409020556002546131ea90826137eb565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061322b9085906141b5565b60405180910390a35050565b600854613246908260006114d4565b60085550565b6132586000838361090e565b6002546132659082611492565b6002556001600160a01b03821660009081526020819052604090205461328b9082611492565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061322b9085906141b5565b60008282026108c78415806126ac5750838583816126a957fe5b60006133038215156004611500565b81838161330c57fe5b049392505050565b600080613321868461205b565b9050600061332f82876120bc565b9050600061333d868a6114a4565b90506000613358846124c861335285876132da565b8a6137f9565b905061336488826114a4565b9450505050505b95945050505050565b600080613381868461205b565b9050600061338f82876120bc565b905060006133a66133a0838b6132da565b876132f4565b905060006133b484836114a4565b905060006133c2828861382c565b90506133ce8a826114a4565b9b9a5050505050505050505050565b6000806133ea848461205b565b905060006134016133fb8688611492565b8561205b565b9050611c8b81836114a4565b6000826134255761341e868361205b565b905061336b565b6000613431868461205b565b905060006134426133fb888a611492565b9050600061345082846114a4565b9050600061345e84896120bc565b905061336461346d88846132da565b826132f4565b600080613480848461205b565b9050600061348e82876114a4565b9050600061349c828661382c565b90506134a886826114a4565b979650505050505050565b6000826134c157508461336b565b60006134cd868461205b565b905060006134db82876120bc565b905060006134e9878a611492565b905060006134f784836120bc565b9050600061350e61350889846132da565b856132f4565b90506133ce81896114a4565b60008261352857508461336b565b6000613534868461205b565b9050600061354282876120bc565b90506000613550868a611492565b90506000613565846124c861335285876132da565b905061336481896114a4565b6000826135825761341e868361382c565b600061358e868461205b565b9050600061359c82876120bc565b905060006135b36135ad838b6132da565b876137f9565b905060006135c18483611492565b905060006135cf828861382c565b90506133ce818b6114a4565b6000806135e8848461205b565b905060006135f96133fb86886114a4565b9050611c8b82826114a4565b600080613612868461205b565b905060006136236133fb888a6114a4565b9050600061363183836114a4565b9050600061363f84896120bc565b905061336461364e88846132da565b826137f9565b600080613661848461205b565b9050600061366f8287611492565b9050600061367d828661382c565b90506134a881876114a4565b600080613696868461205b565b905060006136a482876120bc565b905060006136b2878a6114a4565b905060006136c084836120bc565b905060006136d161350889846132da565b90506133ce88826114a4565b60006137087f9f11080e00000000000000000000000000000000000000000000000000000000610e98565b8214806107be57506107be826138bc565b6000818060200190518101906108c79190613e69565b6060600061373d8585612af7565b90506060865167ffffffffffffffff8111801561375957600080fd5b50604051908082528060200260200182016040528015613783578160200160208202803683370190505b50905060005b87518110156137e0578481146137d8576137bf838983815181106137a957fe5b602002602001015161268f90919063ffffffff16565b8282815181106137cb57fe5b6020026020010181815250505b600101613789565b509695505050505050565b60006108c783836001613045565b60006138088215156004611500565b82613815575060006107be565b81600184038161382157fe5b0460010190506107be565b600081602001518310156138755781516113649061385390670de0b6b3a764000090611492565b6020840151845161386f91613868919061268f565b8690611492565b90612af7565b816040015183116138875750816107be565b8151611364906138a090670de0b6b3a7640000906114a4565b6040840151845161386f916138b5919061268f565b86906114a4565b60006138e77f38e9922e00000000000000000000000000000000000000000000000000000000610e98565b8214806107be57506139187f50dd6ed900000000000000000000000000000000000000000000000000000000610e98565b909114919050565b60405180606001604052806000815260200160008152602001600081525090565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b80356107be81614408565b600082601f830112613986578081fd5b8135613999613994826143dc565b6143b5565b8181529150602080830190848101818402860182018710156139ba57600080fd5b60005b848110156139d9578135845292820192908201906001016139bd565b505050505092915050565b600082601f8301126139f4578081fd5b8151613a02613994826143dc565b818152915060208083019084810181840286018201871015613a2357600080fd5b60005b848110156139d957815184529282019290820190600101613a26565b600082601f830112613a52578081fd5b813567ffffffffffffffff811115613a68578182fd5b613a7b6020601f19601f840116016143b5565b9150808252836020828501011115613a9257600080fd5b8060208401602084013760009082016020015292915050565b8051600181106107be57600080fd5b8035600281106107be57600080fd5b600060208284031215613ada578081fd5b81356108c781614408565b60008060408385031215613af7578081fd5b8235613b0281614408565b91506020830135613b1281614408565b809150509250929050565b600080600060608486031215613b31578081fd5b8335613b3c81614408565b92506020840135613b4c81614408565b929592945050506040919091013590565b600080600080600080600060e0888a031215613b77578283fd5b8735613b8281614408565b96506020880135613b9281614408565b95506040880135945060608801359350608088013560ff81168114613bb5578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613be4578182fd5b8235613bef81614408565b946020939093013593505050565b600080600060608486031215613c11578081fd5b835167ffffffffffffffff80821115613c28578283fd5b818601915086601f830112613c3b578283fd5b8151613c49613994826143dc565b80828252602080830192508086018b828387028901011115613c69578788fd5b8796505b84871015613c94578051613c8081614408565b845260019690960195928101928101613c6d565b508901519097509350505080821115613cab578283fd5b50613cb8868287016139e4565b925050604084015190509250925092565b600060208284031215613cda578081fd5b81356108c78161441d565b600060208284031215613cf6578081fd5b81516108c78161441d565b600080600080600080600060e0888a031215613d1b578081fd5b873596506020880135613d2d81614408565b95506040880135613d3d81614408565b9450606088013567ffffffffffffffff80821115613d59578283fd5b613d658b838c01613976565b955060808a0135945060a08a0135935060c08a0135915080821115613d88578283fd5b50613d958a828b01613a42565b91505092959891949750929550565b600060208284031215613db5578081fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c7578182fd5b600060208284031215613df5578081fd5b81516108c781614408565b60008060408385031215613e12578182fd5b8235613e1d81614408565b9150602083013567ffffffffffffffff811115613e38578182fd5b613e4485828601613a42565b9150509250929050565b600060208284031215613e5f578081fd5b6108c78383613aab565b60008060408385031215613e7b578182fd5b613e858484613aab565b9150602083015190509250929050565b60008060008060808587031215613eaa578182fd5b843567ffffffffffffffff80821115613ec1578384fd5b818701915061012080838a031215613ed7578485fd5b613ee0816143b5565b9050613eec8984613aba565b8152613efb896020850161396b565b6020820152613f0d896040850161396b565b6040820152606083013560608201526080830135608082015260a083013560a0820152613f3d8960c0850161396b565b60c0820152613f4f8960e0850161396b565b60e08201526101008084013583811115613f67578687fd5b613f738b828701613a42565b828401525050809650506020870135915080821115613f90578384fd5b50613f9d87828801613976565b949794965050505060408301359260600135919050565b600060208284031215613fc5578081fd5b5035919050565b600060208284031215613fdd578081fd5b5051919050565b60008060408385031215613ff6578182fd5b50508035926020909101359150565b6000806000806080858703121561401a578182fd5b845193506020850151925060408501519150606085015161403a81614408565b939692955090935050565b6000815180845260208085019450808401835b8381101561407457815187529582019590820190600101614058565b509495945050505050565b15159052565b60008151808452815b818110156140aa5760208185018101518683018201520161408e565b818111156140bb5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6000602082526108c76020830184614045565b6000604082526141806040830185614045565b828103602084015261336b8185614045565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b600085825260206001600160a01b038087168285015280861660408501525060806060840152610100830184516080808601528181518084526101208701915084830193508592505b8083101561424e5761423884516143fc565b8252928401926001929092019190840190614226565b508387015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809250828682030160a087015261428c8185614045565b935050506040850151818584030160c08601526142a98382614085565b9250505060608401516137e060e085018261407f565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b60008382526040602083015261283c6040830184614085565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526108c76020830184614085565b60008382526040602083015261283c6040830184614045565b918252602082015260400190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156143d457600080fd5b604052919050565b600067ffffffffffffffff8211156143f2578081fd5b5060209081020190565b6001600160a01b031690565b6001600160a01b03811681146107f957600080fd5b80151581146107f957600080fdfea26469706673582212200fbadc367b8879628dc7ed74c8e19d9c31dab509d2a82dea92ea8a0a495594d764736f6c63430007010033000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f82600000000000000000000000000000000000000000000054b40b1f852bda0000000000000000000000000000000000000000000000000000000d529ae9e86000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d9e2889ac8c6fff8e94c7c1beeade1352df1a5130000000000000000000000000000000000000000000000000000000000000012426565747320426f6f73746564205553442b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000762622d5553442b00000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102d35760003560e01c8063679aefce1161018657806395d89b41116100e3578063d505accf11610097578063de82cd3411610071578063de82cd341461056b578063f174e24114610573578063f5431aa81461057b576102d3565b8063d505accf14610532578063d5c096c414610545578063dd62ed3e14610558576102d3565b8063a457c2d7116100c8578063a457c2d714610504578063a9059cbb14610517578063aaabadc51461052a576102d3565b806395d89b41146104e95780639f11080e146104f1576102d3565b806382687a561161013a57806387ec68171161011f57806387ec6817146104c6578063893d20e8146104d95780638d928af8146104e1576102d3565b806382687a56146104ab578063851c1bb3146104b3576102d3565b806374f3b0091161016b57806374f3b0091461046f5780637ecebe00146104905780638129fc1c146104a3576102d3565b8063679aefce1461045457806370a082311461045c576102d3565b80633644e515116102345780634de046d5116101e857806355c67628116101cd57806355c67628146104155780636028bfd41461041d57806363fe3b561461043e576102d3565b80634de046d5146103ed57806350dd6ed914610402576102d3565b806338fff2d01161021957806338fff2d0146103ca57806339509351146103d25780634d64cd74146103e5576102d3565b80633644e515146103af57806338e9922e146103b7576102d3565b806318160ddd1161028b5780631dd746ea116102705780631dd746ea1461037257806323b872dd14610387578063313ce5671461039a576102d3565b806318160ddd146103535780631c0de0511461035b576102d3565b8063095ea7b3116102bc578063095ea7b31461031657806316b8d6ff1461033657806316c38b3c1461033e576102d3565b806301ec954a146102d857806306fdde0314610301575b600080fd5b6102eb6102e6366004613e95565b610583565b6040516102f891906141b5565b60405180910390f35b6103096106f9565b6040516102f8919061436d565b610329610324366004613bd2565b6107ad565b6040516102f89190614192565b6102eb6107c4565b61035161034c366004613cc9565b6107e8565b005b6102eb6107fc565b610363610802565b6040516102f89392919061419d565b61037a61082b565b6040516102f8919061415a565b610329610395366004613b1d565b61083a565b6103a26108ce565b6040516102f891906143a7565b6102eb6108d7565b6103516103c5366004613fb4565b6108e1565b6102eb610913565b6103296103e0366004613bd2565b610937565b6102eb610972565b6103f5610996565b6040516102f89190614146565b610351610410366004613e00565b6109ba565b6102eb6109d8565b61043061042b366004613d01565b6109e9565b6040516102f8929190614380565b610446610a20565b6040516102f8929190614399565b6102eb610a4e565b6102eb61046a366004613ac9565b610c02565b61048261047d366004613d01565b610c21565b6040516102f892919061416d565b6102eb61049e366004613ac9565b610c9f565b610351610cba565b6102eb610e74565b6102eb6104c1366004613da4565b610e98565b6104306104d4366004613d01565b610eea565b6103f5610f10565b6103f5610f34565b610309610f58565b6103516104ff366004613fe4565b610fd7565b610329610512366004613bd2565b611041565b610329610525366004613bd2565b61107f565b6103f561108c565b610351610540366004613b5d565b611096565b610482610553366004613d01565b6111df565b6102eb610566366004613ae5565b611310565b6102eb61136b565b6103f561145a565b6102eb61147e565b600084608001516105b0610595610f34565b6001600160a01b0316336001600160a01b03161460cd611500565b6105c56105bb610913565b82146101f4611500565b6105cd61150e565b6105e76003851080156105e05750600384105b6064611500565b60606105f1611523565b90506105fd8682611650565b600080610608610a20565b91509150610614613920565b60405180606001604052806106276109d8565b815260208101859052604001839052905060008a51600181111561064757fe5b14156106ab5761066e8a60600151858a8151811061066157fe5b60200260200101516116b1565b60608b015260006106808b8b846116bd565b905061069f81868a8151811061069257fe5b6020026020010151611784565b965050505050506106f0565b6106bf8a6060015185898151811061066157fe5b60608b015260006106d18b8b84611790565b905061069f81868b815181106106e357fe5b6020026020010151611845565b50949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b820191906000526020600020905b81548152906001019060200180831161078657829003601f168201915b5050505050905090565b60006107ba338484611851565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000290565b6107f06118b9565b6107f9816118ff565b50565b60025490565b600080600061080f61199b565b15925061081a6119b8565b91506108246119dc565b9050909192565b6060610835611523565b905090565b6000806108478533611310565b905061086b336001600160a01b03871614806108635750838210155b61019e611500565b610876858585611a00565b336001600160a01b038616148015906108af57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b156108c1576108c18533858403611851565b60019150505b9392505050565b60055460ff1690565b6000610835611ae0565b6000806108ec610a20565b915091506109056108fd8383611b7d565b61014f611500565b61090e83611c95565b505050565b7f88d07558470484c03d3bb44c3ecc36cafcf4325300000000000000000000005190565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916107ba91859061096d9086611492565b611851565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c3160790565b6109c26118b9565b6109ca61150e565b6109d48282611cae565b5050565b6008546000906108359060c0611d8e565b600060606109ff86516109fa611d9c565b611da1565b610a1489898989898989611dae611e52611eb3565b97509795505050505050565b6000806000610a2d612043565b9050610a3a816000612049565b9250610a47816060612049565b9150509091565b600080610a59610913565b90506060610a65610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610a9091906141b5565b60006040518083038186803b158015610aa857600080fd5b505afa158015610abc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ae49190810190613bfd565b50915050610af981610af4611523565b611650565b600080610b04610a20565b91509150610b10613920565b6040518060600160405280610b236109d8565b81526020018481526020018381525090506000610baf610b76867f000000000000000000000000000000000000000000000000000000000000000081518110610b6857fe5b60200260200101518461205b565b867f000000000000000000000000000000000000000000000000000000000000000281518110610ba257fe5b60200260200101516120bc565b9050610bf7610bf0867f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b60200260200101516120c8565b82906120db565b965050505050505090565b6001600160a01b0381166000908152602081905260409020545b919050565b60608088610c30610595610f34565b610c3b6105bb610913565b6060610c45611523565b9050610c518882611650565b6000606080610c668e8e8e8e8e8e8a8f611dae565b925092509250610c768d84612132565b610c808285611e52565b610c8a8185611e52565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b6000610cc4610913565b90506060610cd0610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401610cfb91906141b5565b60006040518083038186803b158015610d1357600080fd5b505afa158015610d27573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4f9190810190613bfd565b505060408051600380825260808201909252919250606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f000000000000000000000000000000000000000000000000000000000000000181518110610db257fe5b602002602001018181525050610dc6613941565b6040518060800160405280610dda8561213c565b8152602001838152602001604051806020016040528060008152508152602001600015158152509050610e0b610f34565b6001600160a01b031663b95cac28853030856040518563ffffffff1660e01b8152600401610e3c94939291906141dd565b600060405180830381600087803b158015610e5657600080fd5b505af1158015610e6a573d6000803e3d6000fd5b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000190565b60007f0000000000000000000000004c4287b07d293e361281bceee8715c8cdeb64e3482604051602001610ecd9291906140d0565b604051602081830303815290604052805190602001209050919050565b60006060610efb86516109fa611d9c565b610a148989898989898961213f61215d611eb3565b7f000000000000000000000000d9e2889ac8c6fff8e94c7c1beeade1352df1a51390565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107a35780601f10610778576101008083540402835291602001916107a3565b610fdf6118b9565b600080610fea610a20565b91509150610ffb6108fd8383611b7d565b6110106110088585611b7d565b610157611500565b61103b7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c3160785856121be565b50505050565b60008061104e3385611310565b90508083106110685761106333856000611851565b611075565b6110753385858403611851565b5060019392505050565b60006107ba338484611a00565b600061083561224f565b6110a48442111560d1611500565b6001600160a01b03871660009081526006602090815260408083205490519092916110fb917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918c918c918c9188918d91016142bf565b604051602081830303815290604052805190602001209050600061111e826122c9565b9050600060018288888860405160008152602001604052604051611145949392919061434f565b6020604051602081039080840390855afa158015611167573d6000803e3d6000fd5b5050604051601f19015191506111a990506001600160a01b038216158015906111a157508b6001600160a01b0316826001600160a01b0316145b6101f8611500565b6001600160a01b038b1660009081526006602052604090206001850190556111d28b8b8b611851565b5050505050505050505050565b606080886111ee610595610f34565b6111f96105bb610913565b6060611203611523565b905061120d6107fc565b6112c057600060606112228d8d8d868b6122e5565b9150915061123b6112316123a6565b83101560cc611500565b61124d60006112486123a6565b6123ab565b6112608b6112596123a6565b84036123ab565b61126a818461215d565b80611273611d9c565b67ffffffffffffffff8111801561128957600080fd5b506040519080825280602002602001820160405280156112b3578160200160208202803683370190505b5095509550505050610c92565b6112ca8882611650565b60006060806112df8e8e8e8e8e8e8a8f61213f565b9250925092506112ef8c846123ab565b6112f9828561215d565b6113038185611e52565b9095509350610c92915050565b600061131a610f34565b6001600160a01b0316826001600160a01b0316141561135a57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6107be565b61136483836123b5565b90506107be565b60006060611377610f34565b6001600160a01b031663f94d466861138d610913565b6040518263ffffffff1660e01b81526004016113a991906141b5565b60006040518083038186803b1580156113c157600080fd5b505afa1580156113d5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113fd9190810190613bfd565b509150506000611448827f00000000000000000000000000000000000000000000000000000000000000018151811061143257fe5b6020026020010151611443306123e0565b6116b1565b9050611453816124ba565b9250505090565b7f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f82690565b60006108356124ce565b806109d4816125a9565b60008282016108c78482101583611500565b60006114b4838311156001611500565b50900390565b67ffffffffffffffff811b1992909216911b1790565b1b90565b77ffffffffffffffffffffffffffffffffffffffffffffffff828116821b90821b198416179392505050565b816109d4576109d481612622565b61152161151961199b565b610192611500565b565b604080516003808252608082019092526060918291906020820183803683370190505090507f000000000000000000000000000000000000000c9f2c9cd04674edea40000000817f00000000000000000000000000000000000000000000000000000000000000008151811061159557fe5b6020026020010181815250506115d36115ac6124ce565b7f000000000000000000000000000000000000000c9f2c9cd04674edea400000009061268f565b817f0000000000000000000000000000000000000000000000000000000000000002815181106115ff57fe5b602002602001018181525050670de0b6b3a7640000817f00000000000000000000000000000000000000000000000000000000000000018151811061164057fe5b6020908102919091010152905090565b60005b61165b611d9c565b81101561090e5761169283828151811061167157fe5b602002602001015183838151811061168557fe5b602002602001015161268f565b83828151811061169e57fe5b6020908102919091010152600101611653565b60006108c7838361268f565b60208301516000906001600160a01b03163014156116e7576116e08484846126c5565b90506108c7565b7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031684602001516001600160a01b03161415611730576116e0848484612844565b7f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031684602001516001600160a01b03161415611779576116e08484846129a0565b6108c7610135612622565b60006108c78383612af7565b60408301516000906001600160a01b03163014156117b3576116e0848484612b3f565b7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031684604001516001600160a01b031614156117fc576116e0848484612cae565b7f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031684604001516001600160a01b03161415611779576116e0848484612e05565b60006108c783836120db565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906118ac9085906141b5565b60405180910390a3505050565b60006118e86000357fffffffff0000000000000000000000000000000000000000000000000000000016610e98565b90506107f96118f78233612f5c565b610191611500565b801561191f5761191a6119106119b8565b4210610193611500565b611934565b61193461192a6119dc565b42106101a9611500565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be6490611990908390614192565b60405180910390a150565b60006119a56119dc565b42118061083557505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000006336e54790565b7f000000000000000000000000000000000000000000000000000000006336e54790565b611a176001600160a01b0384161515610198611500565b611a2e6001600160a01b0383161515610199611500565b611a3983838361090e565b6001600160a01b038316600090815260208190526040902054611a5f90826101a0613045565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611a8e9082611492565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906118ac9085906141b5565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f3288b2d912e3b83af08158574ad3ee1f06e2d4fa5ffc4bcc4476a63ef0dd641a7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6611b4d61305b565b30604051602001611b629594939291906142f3565b60405160208183030381529060405280519060200120905090565b600080611b88610913565b90506060611b94610f34565b6001600160a01b031663f94d4668836040518263ffffffff1660e01b8152600401611bbf91906141b5565b60006040518083038186803b158015611bd757600080fd5b505afa158015611beb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c139190810190613bfd565b509150506000611c79827f000000000000000000000000000000000000000000000000000000000000000081518110611c4857fe5b60200260200101516114437f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076123e0565b9050858110158015611c8b5750848111155b9695505050505050565b611c9d6118b9565b611ca561150e565b6107f98161305f565b6000611cb8610913565b90506000611cc4610f34565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b8152600401611cf1929190614338565b60806040518083038186803b158015611d0957600080fd5b505afa158015611d1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d419190614005565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d49250610e3c91508590879060040161431f565b1c67ffffffffffffffff1690565b600390565b6109d48183146067611500565b60006060806000611dbe856130ca565b90506000818015611dcb57fe5b14611de057611ddb61014e612622565b611e43565b611de86130e0565b611df289866130f4565b9094509250611dff611d9c565b67ffffffffffffffff81118015611e1557600080fd5b50604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b5091505b50985098509895505050505050565b60005b611e5d611d9c565b81101561090e57611e94838281518110611e7357fe5b6020026020010151838381518110611e8757fe5b6020026020010151612af7565b838281518110611ea057fe5b6020908102919091010152600101611e55565b333014611fa2576000306001600160a01b0316600036604051611ed7929190614100565b6000604051808303816000865af19150503d8060008114611f14576040519150601f19603f3d011682016040523d82523d6000602084013e611f19565b606091505b505090508060008114611f2857fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611f84573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611fac611523565b9050611fb88782611650565b60006060611fd08c8c8c8c8c8c898d8d63ffffffff16565b5091509150611fe381848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60085490565b1c6bffffffffffffffffffffffff1690565b600081602001518310156120945781516020830151600091612080918690039061268f565b905061208c84826114a4565b9150506107be565b816040015183116120a65750816107be565b815160408301516000916120809186039061268f565b60006108c78383611492565b6dffffffffffffffffffffffffffff0390565b60006120ea8215156004611500565b826120f7575060006107be565b670de0b6b3a76400008381029061211a9085838161211157fe5b04146005611500565b82600182038161212657fe5b046001019150506107be565b6109d4828261317b565b90565b600060608061214f61014e612622565b985098509895505050505050565b60005b612168611d9c565b81101561090e5761219f83828151811061217e57fe5b602002602001015183838151811061219257fe5b60200260200101516120db565b8382815181106121ab57fe5b6020908102919091010152600101612160565b6121cd8183111561014c611500565b6121e86bffffffffffffffffffffffff82111561014d611500565b6122076121f68260606114d0565b6122018460006114d0565b17613237565b826001600160a01b03167fd0e27a0d0c2cb09280fa5e4487315455b32afcdcf012dc35b6ef2a0e3c4d12808383604051612242929190614399565b60405180910390a2505050565b6000612259610f34565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561229157600080fd5b505afa1580156122a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190613de4565b60006122d3611ae0565b82604051602001610ecd929190614110565b600060606122f161150e565b6123086001600160a01b0387163014610156611500565b61231f6001600160a01b0386163014610156611500565b604080516003808252608082019092526dffffffffffffffffffffffffffff91606091906020820183803683370190505090506dffffffffffffffffffffffffffff817f00000000000000000000000000000000000000000000000000000000000000018151811061238d57fe5b6020908102919091010152909890975095505050505050565b600090565b6109d4828261324c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60007f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b0316826001600160a01b0316141561244357507f000000000000000000000000000000000000000c9f2c9cd04674edea40000000610c1c565b7f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b0316826001600160a01b0316141561248f576124886115ac6124ce565b9050610c1c565b6001600160a01b0382163014156124af5750670de0b6b3a7640000610c1c565b610c1c610135612622565b60006107be826124c86107fc565b906114a4565b6000806124d961145a565b90506000816001600160a01b03166307a2d13a670de0b6b3a76400006040518263ffffffff1660e01b815260040161251191906141b5565b60206040518083038186803b15801561252957600080fd5b505afa15801561253d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125619190613fcc565b905060006125a1670de0b6b3a764000061259b847f0000000000000000000000000000000000000000000000000de0b6b3a76400006132da565b906132f4565b935050505090565b6002815110156125b8576107f9565b6000816000815181106125c757fe5b602002602001015190506000600190505b825181101561090e5760008382815181106125ef57fe5b60200260200101519050612618816001600160a01b0316846001600160a01b0316106065611500565b91506001016125d8565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60008282026126b38415806126ac5750838583816126a957fe5b04145b6003611500565b670de0b6b3a764000090049392505050565b600061274b7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031685604001516001600160a01b0316148061274357507f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031685604001516001600160a01b0316145b610135611500565b61283c8460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061277f57fe5b6020026020010151857f0000000000000000000000000000000000000000000000000000000000000002815181106127b357fe5b60200260200101516127ea877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b867f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b03168a604001516001600160a01b03161461283057613314612834565b6133745b63ffffffff16565b949350505050565b60006128a07f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031685604001516001600160a01b03161480612743575060408501516001600160a01b03163014610135611500565b60408401516001600160a01b031630146128fb576128f68460600151847f0000000000000000000000000000000000000000000000000000000000000000815181106128e857fe5b6020026020010151846133dd565b61283c565b61283c8460600151847f00000000000000000000000000000000000000000000000000000000000000008151811061292f57fe5b6020026020010151857f00000000000000000000000000000000000000000000000000000000000000028151811061296357fe5b602002602001015161299a877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b8661340d565b60006129fc7f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031685604001516001600160a01b03161480612743575060408501516001600160a01b03163014610135611500565b60408401516001600160a01b03163014612a52576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612a4457fe5b602002602001015184613473565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612a8657fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000281518110612aba57fe5b6020026020010151612af1877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b866134b3565b6000612b068215156004611500565b82612b13575060006107be565b670de0b6b3a764000083810290612b2d9085838161211157fe5b828181612b3657fe5b049150506107be565b6000612bc47f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031685602001516001600160a01b0316148061274357507f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031685602001516001600160a01b031614610135611500565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612bf857fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000281518110612c2c57fe5b6020026020010151612c63877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b867f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b03168a602001516001600160a01b031614612ca95761351a612834565b613571565b6000612d0a7f000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f8266001600160a01b031685602001516001600160a01b03161480612743575060208501516001600160a01b03163014610135611500565b60208401516001600160a01b03163014612d60576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612d5257fe5b6020026020010151846135db565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612d9457fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000281518110612dc857fe5b6020026020010151612dff877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b86613605565b6000612e617f0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316076001600160a01b031685602001516001600160a01b03161480612743575060208501516001600160a01b03163014610135611500565b60208401516001600160a01b03163014612eb7576128f68460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612ea957fe5b602002602001015184613654565b61283c8460600151847f000000000000000000000000000000000000000000000000000000000000000081518110612eeb57fe5b6020026020010151857f000000000000000000000000000000000000000000000000000000000000000281518110612f1f57fe5b6020026020010151612f56877f000000000000000000000000000000000000000000000000000000000000000181518110610be357fe5b86613689565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b612f7b610f10565b6001600160a01b031614158015612f965750612f96836136dd565b15612fbe57612fa3610f10565b6001600160a01b0316336001600160a01b03161490506107be565b612fc661224f565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b8152600401612ff5939291906141be565b60206040518083038186803b15801561300d57600080fd5b505afa158015613021573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113649190613ce5565b60006130548484111583611500565b5050900390565b4690565b61307264e8d4a5100082101560cb611500565b61308867016345785d8a000082111560ca611500565b600854613097908260c06114ba565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906119909083906141b5565b6000818060200190518101906107be9190613e4e565b6115216130eb61199b565b156101af611500565b60006060600061310384613719565b9050606061316e8683613148897f00000000000000000000000000000000000000000000000000000000000000018151811061313b57fe5b60200260200101516124ba565b7f000000000000000000000000000000000000000000000000000000000000000161372f565b9196919550909350505050565b6131926001600160a01b038316151561019b611500565b61319e8260008361090e565b6001600160a01b0382166000908152602081905260409020546131c490826101b2613045565b6001600160a01b0383166000908152602081905260409020556002546131ea90826137eb565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061322b9085906141b5565b60405180910390a35050565b600854613246908260006114d4565b60085550565b6132586000838361090e565b6002546132659082611492565b6002556001600160a01b03821660009081526020819052604090205461328b9082611492565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061322b9085906141b5565b60008282026108c78415806126ac5750838583816126a957fe5b60006133038215156004611500565b81838161330c57fe5b049392505050565b600080613321868461205b565b9050600061332f82876120bc565b9050600061333d868a6114a4565b90506000613358846124c861335285876132da565b8a6137f9565b905061336488826114a4565b9450505050505b95945050505050565b600080613381868461205b565b9050600061338f82876120bc565b905060006133a66133a0838b6132da565b876132f4565b905060006133b484836114a4565b905060006133c2828861382c565b90506133ce8a826114a4565b9b9a5050505050505050505050565b6000806133ea848461205b565b905060006134016133fb8688611492565b8561205b565b9050611c8b81836114a4565b6000826134255761341e868361205b565b905061336b565b6000613431868461205b565b905060006134426133fb888a611492565b9050600061345082846114a4565b9050600061345e84896120bc565b905061336461346d88846132da565b826132f4565b600080613480848461205b565b9050600061348e82876114a4565b9050600061349c828661382c565b90506134a886826114a4565b979650505050505050565b6000826134c157508461336b565b60006134cd868461205b565b905060006134db82876120bc565b905060006134e9878a611492565b905060006134f784836120bc565b9050600061350e61350889846132da565b856132f4565b90506133ce81896114a4565b60008261352857508461336b565b6000613534868461205b565b9050600061354282876120bc565b90506000613550868a611492565b90506000613565846124c861335285876132da565b905061336481896114a4565b6000826135825761341e868361382c565b600061358e868461205b565b9050600061359c82876120bc565b905060006135b36135ad838b6132da565b876137f9565b905060006135c18483611492565b905060006135cf828861382c565b90506133ce818b6114a4565b6000806135e8848461205b565b905060006135f96133fb86886114a4565b9050611c8b82826114a4565b600080613612868461205b565b905060006136236133fb888a6114a4565b9050600061363183836114a4565b9050600061363f84896120bc565b905061336461364e88846132da565b826137f9565b600080613661848461205b565b9050600061366f8287611492565b9050600061367d828661382c565b90506134a881876114a4565b600080613696868461205b565b905060006136a482876120bc565b905060006136b2878a6114a4565b905060006136c084836120bc565b905060006136d161350889846132da565b90506133ce88826114a4565b60006137087f9f11080e00000000000000000000000000000000000000000000000000000000610e98565b8214806107be57506107be826138bc565b6000818060200190518101906108c79190613e69565b6060600061373d8585612af7565b90506060865167ffffffffffffffff8111801561375957600080fd5b50604051908082528060200260200182016040528015613783578160200160208202803683370190505b50905060005b87518110156137e0578481146137d8576137bf838983815181106137a957fe5b602002602001015161268f90919063ffffffff16565b8282815181106137cb57fe5b6020026020010181815250505b600101613789565b509695505050505050565b60006108c783836001613045565b60006138088215156004611500565b82613815575060006107be565b81600184038161382157fe5b0460010190506107be565b600081602001518310156138755781516113649061385390670de0b6b3a764000090611492565b6020840151845161386f91613868919061268f565b8690611492565b90612af7565b816040015183116138875750816107be565b8151611364906138a090670de0b6b3a7640000906114a4565b6040840151845161386f916138b5919061268f565b86906114a4565b60006138e77f38e9922e00000000000000000000000000000000000000000000000000000000610e98565b8214806107be57506139187f50dd6ed900000000000000000000000000000000000000000000000000000000610e98565b909114919050565b60405180606001604052806000815260200160008152602001600081525090565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b80356107be81614408565b600082601f830112613986578081fd5b8135613999613994826143dc565b6143b5565b8181529150602080830190848101818402860182018710156139ba57600080fd5b60005b848110156139d9578135845292820192908201906001016139bd565b505050505092915050565b600082601f8301126139f4578081fd5b8151613a02613994826143dc565b818152915060208083019084810181840286018201871015613a2357600080fd5b60005b848110156139d957815184529282019290820190600101613a26565b600082601f830112613a52578081fd5b813567ffffffffffffffff811115613a68578182fd5b613a7b6020601f19601f840116016143b5565b9150808252836020828501011115613a9257600080fd5b8060208401602084013760009082016020015292915050565b8051600181106107be57600080fd5b8035600281106107be57600080fd5b600060208284031215613ada578081fd5b81356108c781614408565b60008060408385031215613af7578081fd5b8235613b0281614408565b91506020830135613b1281614408565b809150509250929050565b600080600060608486031215613b31578081fd5b8335613b3c81614408565b92506020840135613b4c81614408565b929592945050506040919091013590565b600080600080600080600060e0888a031215613b77578283fd5b8735613b8281614408565b96506020880135613b9281614408565b95506040880135945060608801359350608088013560ff81168114613bb5578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613be4578182fd5b8235613bef81614408565b946020939093013593505050565b600080600060608486031215613c11578081fd5b835167ffffffffffffffff80821115613c28578283fd5b818601915086601f830112613c3b578283fd5b8151613c49613994826143dc565b80828252602080830192508086018b828387028901011115613c69578788fd5b8796505b84871015613c94578051613c8081614408565b845260019690960195928101928101613c6d565b508901519097509350505080821115613cab578283fd5b50613cb8868287016139e4565b925050604084015190509250925092565b600060208284031215613cda578081fd5b81356108c78161441d565b600060208284031215613cf6578081fd5b81516108c78161441d565b600080600080600080600060e0888a031215613d1b578081fd5b873596506020880135613d2d81614408565b95506040880135613d3d81614408565b9450606088013567ffffffffffffffff80821115613d59578283fd5b613d658b838c01613976565b955060808a0135945060a08a0135935060c08a0135915080821115613d88578283fd5b50613d958a828b01613a42565b91505092959891949750929550565b600060208284031215613db5578081fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c7578182fd5b600060208284031215613df5578081fd5b81516108c781614408565b60008060408385031215613e12578182fd5b8235613e1d81614408565b9150602083013567ffffffffffffffff811115613e38578182fd5b613e4485828601613a42565b9150509250929050565b600060208284031215613e5f578081fd5b6108c78383613aab565b60008060408385031215613e7b578182fd5b613e858484613aab565b9150602083015190509250929050565b60008060008060808587031215613eaa578182fd5b843567ffffffffffffffff80821115613ec1578384fd5b818701915061012080838a031215613ed7578485fd5b613ee0816143b5565b9050613eec8984613aba565b8152613efb896020850161396b565b6020820152613f0d896040850161396b565b6040820152606083013560608201526080830135608082015260a083013560a0820152613f3d8960c0850161396b565b60c0820152613f4f8960e0850161396b565b60e08201526101008084013583811115613f67578687fd5b613f738b828701613a42565b828401525050809650506020870135915080821115613f90578384fd5b50613f9d87828801613976565b949794965050505060408301359260600135919050565b600060208284031215613fc5578081fd5b5035919050565b600060208284031215613fdd578081fd5b5051919050565b60008060408385031215613ff6578182fd5b50508035926020909101359150565b6000806000806080858703121561401a578182fd5b845193506020850151925060408501519150606085015161403a81614408565b939692955090935050565b6000815180845260208085019450808401835b8381101561407457815187529582019590820190600101614058565b509495945050505050565b15159052565b60008151808452815b818110156140aa5760208185018101518683018201520161408e565b818111156140bb5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6000602082526108c76020830184614045565b6000604082526141806040830185614045565b828103602084015261336b8185614045565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b600085825260206001600160a01b038087168285015280861660408501525060806060840152610100830184516080808601528181518084526101208701915084830193508592505b8083101561424e5761423884516143fc565b8252928401926001929092019190840190614226565b508387015193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809250828682030160a087015261428c8185614045565b935050506040850151818584030160c08601526142a98382614085565b9250505060608401516137e060e085018261407f565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b60008382526040602083015261283c6040830184614085565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526108c76020830184614085565b60008382526040602083015261283c6040830184614045565b918252602082015260400190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156143d457600080fd5b604052919050565b600067ffffffffffffffff8211156143f2578081fd5b5060209081020190565b6001600160a01b031690565b6001600160a01b03811681146107f957600080fd5b80151581146107f957600080fdfea26469706673582212200fbadc367b8879628dc7ed74c8e19d9c31dab509d2a82dea92ea8a0a495594d764736f6c63430007010033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f82600000000000000000000000000000000000000000000054b40b1f852bda0000000000000000000000000000000000000000000000000000000d529ae9e86000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d9e2889ac8c6fff8e94c7c1beeade1352df1a5130000000000000000000000000000000000000000000000000000000000000012426565747320426f6f73746564205553442b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000762622d5553442b00000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : vault (address): 0xBA12222222228d8Ba445958a75a0704d566BF2C8
Arg [1] : name (string): Beets Boosted USD+
Arg [2] : symbol (string): bb-USD+
Arg [3] : mainToken (address): 0x7F5c764cBc14f9669B88837ca1490cCa17c31607
Arg [4] : wrappedToken (address): 0xA348700745D249c3b49D2c2AcAC9A5AE8155F826
Arg [5] : upperTarget (uint256): 25000000000000000000000
Arg [6] : swapFeePercentage (uint256): 60000000000000000
Arg [7] : pauseWindowDuration (uint256): 0
Arg [8] : bufferPeriodDuration (uint256): 0
Arg [9] : owner (address): 0xd9e2889AC8C6fFF8e94c7c1bEEAde1352dF1A513
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [3] : 0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607
Arg [4] : 000000000000000000000000a348700745d249c3b49d2c2acac9a5ae8155f826
Arg [5] : 00000000000000000000000000000000000000000000054b40b1f852bda00000
Arg [6] : 00000000000000000000000000000000000000000000000000d529ae9e860000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [9] : 000000000000000000000000d9e2889ac8c6fff8e94c7c1beeade1352df1a513
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [11] : 426565747320426f6f73746564205553442b0000000000000000000000000000
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [13] : 62622d5553442b00000000000000000000000000000000000000000000000000
Deployed ByteCode Sourcemap
991:2779:41:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9839:2462:39;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2138:81:25;;;:::i;:::-;;;;;;;:::i;4172:164::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;7944:96:39:-;;;:::i;7554:89:3:-;;;;;;:::i;:::-;;:::i;:::-;;3181:98:25;;;:::i;3154:363:17:-;;;:::i;:::-;;;;;;;;;:::i;21855:111:3:-;;;:::i;:::-;;;;;;;:::i;2574:655:1:-;;;;;;:::i;:::-;;:::i;3040:81:25:-;;;:::i;:::-;;;;;;;:::i;2359:113:26:-;;;:::i;27119:832:39:-;;;;;;:::i;:::-;;:::i;5635:91:3:-;;;:::i;5584:211:25:-;;;;;;:::i;:::-;;:::i;7848:90:39:-;;;:::i;7542:97::-;;;:::i;:::-;;;;;;;:::i;7049:214:3:-;;;;;;:::i;:::-;;:::i;6320:137::-;;;:::i;14253:904::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;25159:269:39:-;;;:::i;:::-;;;;;;;;:::i;23835:1014::-;;;:::i;3337:117:25:-;;;;;;:::i;:::-;;:::i;10878:1197:3:-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;2127:108:26:-;;;;;;:::i;:::-;;:::i;8741:1019:39:-;;;:::i;7754:88::-;;;:::i;2487:430:8:-;;;;;;:::i;:::-;;:::i;12728:902:3:-;;;;;;:::i;:::-;;:::i;1750:80:2:-;;;:::i;1796:79:1:-;;;:::i;2332:85:25:-;;;:::i;26143:970:39:-;;;;;;:::i;:::-;;:::i;3355:429:1:-;;;;;;:::i;:::-;;:::i;3657:170:25:-;;;;;;:::i;:::-;;:::i;1836:101:2:-;;;:::i;1313:753:26:-;;;;;;:::i;:::-;;:::i;8572:2300:3:-;;;;;;:::i;:::-;;:::i;2177:254:1:-;;;;;;:::i;:::-;;:::i;28889:450:39:-;;;:::i;7645:103::-;;;:::i;24855:109::-;;;:::i;9839:2462::-;10053:7;10014;:14;;;8415:68:3;8446:10;:8;:10::i;:::-;-1:-1:-1;;;;;8424:33:3;:10;:33;5392:3:9;8415:8:3;:68::i;:::-;8493:55;8512:11;:9;:11::i;:::-;8502:6;:21;10710:3:9;8493:8:3;:55::i;:::-;2970:18:17::1;:16;:18::i;:::-;10722:83:39::2;3040:1;10731:7;:23;:51;;;;;3040:1;10758:8;:24;10731:51;4838:3:9;10722:8:39;:83::i;:::-;11081:31;11115:17;:15;:17::i;:::-;11081:51;;11142:39;11156:8;11166:14;11142:13;:39::i;:::-;11193:19;11214::::0;11237:12:::2;:10;:12::i;:::-;11192:57;;;;11259:31;;:::i;:::-;11293:146;;;;;;;;11330:22;:20;:22::i;:::-;11293:146:::0;;::::2;::::0;::::2;::::0;;;;;;;;11259:180;-1:-1:-1;;11454:12:39;;:40:::2;::::0;::::2;;;;;;;11450:845;;;11615:49;11624:7;:14;;;11640;11655:7;11640:23;;;;;;;;;;;;;;11615:8;:49::i;:::-;11598:14;::::0;::::2;:66:::0;11678:17:::2;11698:41;11598:7:::0;11722:8;11732:6;11698:14:::2;:41::i;:::-;11678:61;;11833:51;11848:9;11859:14;11874:8;11859:24;;;;;;;;;;;;;;11833:14;:51::i;:::-;11826:58;;;;;;;;;11450:845;12020:50;12029:7;:14;;;12045;12060:8;12045:24;;;;;;;12020:50;12003:14;::::0;::::2;:67:::0;12084:16:::2;12103:42;12003:7:::0;12128:8;12138:6;12103:15:::2;:42::i;:::-;12084:61;;12237:47;12250:8;12260:14;12275:7;12260:23;;;;;;;;;;;;;;12237:12;:47::i;2998:1:17:-;9839:2462:39::0;;;;;;;:::o;2138:81:25:-;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:25;4172:164;;;;;:::o;7944:96:39:-;8020:13;7944:96;:::o;7554:89:3:-;2156:21:8;:19;:21::i;:::-;7618:18:3::1;7629:6;7618:10;:18::i;:::-;7554:89:::0;:::o;3181:98:25:-;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;21855:111:3:-;21907:16;21942:17;:15;:17::i;:::-;21935:24;;21855: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;9405: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:25:-;3105:9;;;;3040:81;:::o;2359:113:26:-;2419:7;2445:20;:18;:20::i;27119:832:39:-;27731:19;27752;27775:12;:10;:12::i;:::-;27730:57;;;;27797:91;27806:53;27834:11;27847;27806:27;:53::i;:::-;7839:3:9;27797:8:39;:91::i;:::-;27899:45;27926:17;27899:26;:45::i;:::-;27119:832;;;:::o;5635:91:3:-;5712:7;5635:91;:::o;5584:211:25:-;5697:10;5672:4;5718:23;;;:11;:23;;;;;;;;-1:-1:-1;;;;;5718:32:25;;;;;;;;;;5672:4;;5688:79;;5718:32;;:48;;5755:10;5718:36;:48::i;:::-;5688:8;:79::i;7848:90:39:-;7921:10;7848:90;:::o;7542:97::-;7621:10;7542:97;:::o;7049:214:3:-;2156:21:8;:19;:21::i;:::-;2970:18:17::1;:16;:18::i;:::-;7211:45:3::2;7238:5;7245:10;7211:26;:45::i;:::-;7049:214:::0;;:::o;6320:137::-;6399:9;;6373:7;;6399:51;;3370:3;6399:22;:51::i;14253:904::-;14513:13;14528:27;14567:71;14603:8;:15;14620:17;:15;:17::i;:::-;14567:35;:71::i;:::-;14649:255;14675:6;14695;14715:9;14738:8;14760:15;14789:25;14828:8;14850:11;14875:19;14649:12;:255::i;:::-;14253:904;;;;;;;;;;:::o;25159:269:39:-;25202:19;25223;25254:16;25273:14;:12;:14::i;:::-;25254:33;-1:-1:-1;25311:43:39;25254:33;5781:1;25311:21;:43::i;:::-;25297:57;-1:-1:-1;25378:43:39;:8;5836:2;25378:21;:43::i;:::-;25364:57;;25159:269;;;:::o;23835:1014::-;23886:7;23905:14;23922:11;:9;:11::i;:::-;23905:28;;23946:25;23977:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;23977:24:39;;;;;;;:32;;24002:6;;23977:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;23977:32:39;;;;;;;;;;;;:::i;:::-;23943:66;;;;24019:42;24033:8;24043:17;:15;:17::i;:::-;24019:13;:42::i;:::-;24073:19;24094;24117:12;:10;:12::i;:::-;24072:57;;;;24139:31;;:::i;:::-;24173:146;;;;;;;;24210:22;:20;:22::i;:::-;24173:146;;;;24259:11;24173:146;;;;24297:11;24173:146;;;24139:180;;24330:20;24353:137;24392:51;24414:8;24423:10;24414:20;;;;;;;;;;;;;;24436:6;24392:21;:51::i;:::-;24457:8;24466:13;24457:23;;;;;;;;;;;;;;24353:25;:137::i;:::-;24330:160;;24773:69;24792:49;24821:8;24830:9;24821:19;;;;;;;;;;;;;;24792:28;:49::i;:::-;24773:12;;:18;:69::i;:::-;24766:76;;;;;;;;23835:1014;:::o;3337:117:25:-;-1:-1:-1;;;;;3429:18:25;;3403:7;3429:18;;;;;;;;;;;3337:117;;;;:::o;10878:1197:3:-;11172:16;11190;11155:6;8415:68;8446:10;:8;:10::i;8415:68::-;8493:55;8512:11;:9;:11::i;8493:55::-;11218:31:::1;11252:17;:15;:17::i;:::-;11218:51;;11279:39;11293:8;11303:14;11279:13;:39::i;:::-;11330:19;11351:27;11380:38:::0;11422:224:::1;11447:6;11467;11487:9;11510:8;11532:15;11561:25;11600:14;11628:8;11422:11;:224::i;:::-;11329:317;;;;;;11752:36;11768:6;11776:11;11752:15;:36::i;:::-;11900:47;11920:10;11932:14;11900:19;:47::i;:::-;11957:58;11977:21;12000:14;11957:19;:58::i;:::-;12034:10:::0;;-1:-1:-1;12046:21:3;-1:-1:-1;;;8558:1:3::1;10878:1197:::0;;;;;;;;;;;:::o;2127:108:26:-;-1:-1:-1;;;;;2214:14:26;2188:7;2214:14;;;:7;:14;;;;;;;2127:108::o;8741:1019:39:-;8782:14;8799:11;:9;:11::i;:::-;8782:28;;8821:22;8851:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;8851:24:39;;;;;;;:32;;8876:6;;8851:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8851:32:39;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;9131:28:39;;;3040:1;9131:28;;;;;;;;;8820:63;;-1:-1:-1;9099:29:39;;9131:28;;;;9099:29;;9131:28;;;;;-1:-1:-1;9131:28:39;9099:60;;4030:12;9169;9182:9;9169:23;;;;;;;;;;;;;:45;;;;;9457:37;;:::i;:::-;9497:179;;;;;;;;9542:17;9552:6;9542:9;:17::i;:::-;9497:179;;;;9587:12;9497:179;;;;;;;;;;;;;;;;;;;;9660:5;9497:179;;;;;9457:219;;9687:10;:8;:10::i;:::-;:66;;;;;-1:-1:-1;;;;;9687:19:39;;;;;;;:66;;9707:6;;9723:4;;;;9745:7;;9687:66;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8741:1019;;;;:::o;7754:88::-;7826:9;7754:88;:::o;2487:430:8:-;2555:7;2876:22;2900:8;2859:50;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2849:61;;;;;;2842:68;;2487:430;;;:::o;12728:902:3:-;12988:14;13004:26;13042:71;13078:8;:15;13095:17;:15;:17::i;13042:71::-;13124:253;13150:6;13170;13190:9;13213:8;13235:15;13264:25;13303:8;13325:11;13350:17;13124:12;:253::i;1750:80:2:-;1817:6;1750:80;:::o;1796:79:1:-;1862:6;1796:79;:::o;2332:85:25:-;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2371:13;;2396:14;;2403:7;;2396:14;;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;26143:970:39;2156:21:8;:19;:21::i;:::-;26744:26:39::1;26772::::0;26802:12:::1;:10;:12::i;:::-;26743:71;;;;26824:105;26833:67;26861:18;26881;26833:27;:67::i;26824:105::-;26939:101;26948:59;26976:14;26992;26948:27;:59::i;:::-;8341:3:9;26939:8:39;:101::i;:::-;27051:55;27063:10;27075:14;27091;27051:11;:55::i;:::-;2187:1:8;;26143:970:39::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:25:-;3743:4;3759:40;3769:10;3781:9;3792:6;3759:9;:40::i;1836:101:2:-;1884:11;1914:16;:14;:16::i;1313:753:26:-;1575:60;1603:8;1584:15;:27;;5606:3:9;1575:8:26;:60::i;:::-;-1:-1:-1;;;;;1662:14:26;;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:26;;-1:-1:-1;1868:24:26;;;-1:-1:-1;1902:79:26;;-1:-1:-1;;;;;;1912:20:26;;;;;;1911:43;;-1:-1:-1;;;;;;1938:15:26;;;;;;;1911:43;10943:3:9;1902:8:26;:79::i;:::-;-1:-1:-1;;;;;1992:14:26;;;;;;:7;:14;;;;;-1:-1:-1;2009:9:26;;1992:26;;2028:31;1992:14;2044:7;2053:5;2028:8;:31::i;:::-;1313:753;;;;;;;;;;;:::o;8572:2300:3:-;8866:16;8884;8849:6;8415:68;8446:10;:8;:10::i;8415:68::-;8493:55;8512:11;:9;:11::i;8493:55::-;8912:31:::1;8946:17;:15;:17::i;:::-;8912:51;;8978:13;:11;:13::i;:::-;8974:1892;;9013:20;9035:26;9065:164;9100:6;9124;9148:9;9175:14;9207:8;9065:17;:164::i;:::-;9012:217;;;;9528:62;9553:16;:14;:16::i;:::-;9537:12;:32;;5338:3:9;9528:8:3;:62::i;:::-;9604:45;9628:1;9632:16;:14;:16::i;:::-;9604:15;:45::i;:::-;9663:59;9679:9;9705:16;:14;:16::i;:::-;9690:12;:31;9663:15;:59::i;:::-;9809:44;9827:9;9838:14;9809:17;:44::i;:::-;9876:9;9901:17;:15;:17::i;:::-;9887:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;9887:32:3::1;;9868:52;;;;;;;;;8974:1892;9951:39;9965:8;9975:14;9951:13;:39::i;:::-;10005:20;10027:26;10055:38:::0;10097:260:::1;10126:6;10150;10174:9;10201:8;10227:15;10260:25;10303:14;10335:8;10097:11;:260::i;:::-;10004:353;;;;;;10471:40;10487:9;10498:12;10471:15;:40::i;:::-;10598:44;10616:9;10627:14;10598:17;:44::i;:::-;10741:58;10761:21;10784:14;10741:19;:58::i;:::-;10822:9:::0;;-1:-1:-1;10833:21:3;-1:-1:-1;10814:41:3::1;::::0;-1:-1:-1;;10814:41:3::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;;;;28889:450:39;28940:7;28962:25;28993:10;:8;:10::i;:::-;-1:-1:-1;;;;;28993:24:39;;29018:11;:9;:11::i;:::-;28993:37;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;28993:37:39;;;;;;;;;;;;:::i;:::-;28959:71;;;;29213:18;29234:51;29243:8;29252:9;29243:19;;;;;;;;;;;;;;29264:20;29279:4;29264:14;:20::i;:::-;29234:8;:51::i;:::-;29213:72;;29303:29;29321:10;29303:17;:29::i;:::-;29296:36;;;;28889:450;:::o;7645:103::-;7727:13;7645:103;:::o;24855:109::-;24909:7;24935:22;:20;:22::i;1135:274:16:-;1345:5;1369:33;1345:5;1369:19;:33::i;561:166:21:-;619:7;650:5;;;665:37;674:6;;;;619:7;665:8;:37::i;1142:166::-;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;6940:269:18:-;2598:11;7127:18;;7125:21;7109:37;;;;7186:15;;7164:38;;6940:269::o;8656:131::-;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;:::-;8628:3:9;4272:8:17;:39::i;:::-;4220:98::o;23052:550:39:-;23181:28;;;3040:1;23181:28;;;;;;;;;23119:16;;;;23181:28;;;;23119:16;;23181:28;;;;;-1:-1:-1;23181:28:39;23147:62;;23388:23;23359:14;23374:10;23359:26;;;;;;;;;;;;;:52;;;;;23453:58;23488:22;:20;:22::i;:::-;23453:26;;:34;:58::i;:::-;23421:14;23436:13;23421:29;;;;;;;;;;;;;:90;;;;;893:4:19;23521:14:39;23536:9;23521:25;;;;;;;;;;;;;;;;;:42;23581:14;-1:-1:-1;23052:550:39;:::o;22876:247:3:-;22987:9;22982:135;23006:17;:15;:17::i;:::-;23002:1;:21;22982:135;;;23057:49;23076:7;23084:1;23076:10;;;;;;;;;;;;;;23088:14;23103:1;23088:17;;;;;;;;;;;;;;23057:18;:49::i;:::-;23044:7;23052:1;23044:10;;;;;;;;;;;;;;;;;:62;23025:3;;22982:135;;22128:579;22208:7;22659:41;22678:6;22686:13;22659:18;:41::i;12307:591:39:-;12495:15;;;;12472:7;;-1:-1:-1;;;;;12495:23:39;12514:4;12495:23;12491:401;;;12541:42;12557:7;12566:8;12576:6;12541:15;:42::i;:::-;12534:49;;;;12491:401;12604:15;;;;12623:10;-1:-1:-1;;;;;12604:29:39;;;;;;12600:292;;;12656:43;12673:7;12682:8;12692:6;12656:16;:43::i;12600:292::-;12720:15;;;;12739:13;-1:-1:-1;;;;;12720:32:39;;;;;;12716:176;;;12775:46;12795:7;12804:8;12814:6;12775:19;:46::i;12716:176::-;12852:29;6252:3:9;12852:7:39;:29::i;23327:160:3:-;23413:7;23439:41;23458:6;23466:13;23439:18;:41::i;15022:598:39:-;15211:16;;;;15188:7;;-1:-1:-1;;;;;15211:24:39;15231:4;15211:24;15207:407;;;15258:43;15275:7;15284:8;15294:6;15258:16;:43::i;15207:407::-;15322:16;;;;15342:10;-1:-1:-1;;;;;15322:30:39;;;;;;15318:296;;;15375:44;15393:7;15402:8;15412:6;15375:17;:44::i;15318:296::-;15440:16;;;;15460:13;-1:-1:-1;;;;;15440:33:39;;;;;;15436:178;;;15496:47;15517:7;15526:8;15536:6;15496:20;:47::i;24117:156:3:-;24201:7;24227:39;24244:6;24252:13;24227:16;:39::i;9343:213:25:-;-1:-1:-1;;;;;9466:18:25;;;;;;;-1:-1:-1;9466:18:25;;;;;;;;:27;;;;;;;;;;;;;;:36;;;9517:32;;;;;9466:36;;9517:32;:::i;:::-;;;;;;;;9343: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;:::-;8584:3:9;2404:8:8;:70::i;3793:358:17:-;3849:6;3845:232;;;3871:81;3898:24;:22;:24::i;:::-;3880:15;:42;8686:3:9;3871:8:17;:81::i;:::-;3845:232;;;3983:83;4010:25;:23;:25::i;:::-;3992:15;:43;10116: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:25:-;7195:71;-1:-1:-1;;;;;7204:20:25;;;;9001:3:9;7195:8:25;:71::i;:::-;7276:72;-1:-1:-1;;;;;7285:23:25;;;;9069:3:9;7276:8:25;:72::i;:::-;7359:47;7380:6;7388:9;7399:6;7359:20;:47::i;:::-;-1:-1:-1;;;;;7437:17:25;;:9;:17;;;;;;;;;;;:68;;7459:6;9547:3:9;7437:21:25;:68::i;:::-;-1:-1:-1;;;;;7417:17:25;;;:9;:17;;;;;;;;;;;:88;;;;7538:20;;;;;;;:32;;7563:6;7538:24;:32::i;:::-;-1:-1:-1;;;;;7515:20:25;;;:9;:20;;;;;;;;;;;;:55;;;;7585:35;;;;;;;;;;7613:6;;7585:35;:::i;2386:188:24:-;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;27957:407:39:-;28058:4;28074:14;28091:11;:9;:11::i;:::-;28074:28;;28115:25;28146:10;:8;:10::i;:::-;:32;;;;;-1:-1:-1;;;;;28146:24:39;;;;;;;:32;;28171:6;;28146:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;28146:32:39;;;;;;;;;;;;:::i;:::-;28112:66;;;;28188:24;28215:58;28224:8;28233:10;28224:20;;;;;;;;;;;;;;28246:26;28261:10;28246:14;:26::i;28215:58::-;28188:85;;28311:11;28291:16;:31;;:66;;;;;28346:11;28326:16;:31;;28291:66;28284:73;27957:407;-1:-1:-1;;;;;;27957:407:39:o;6463:156:3:-;2156:21:8;:19;:21::i;:::-;2970:18:17::1;:16;:18::i;:::-;6572:40:3::2;6594:17;6572:21;:40::i;7269:279::-:0;7362:14;7379:11;:9;:11::i;:::-;7362:28;;7407:20;7431:10;:8;:10::i;:::-;:42;;;;;-1:-1:-1;;;;;7431:27:3;;;;;;;:42;;7459:6;;7467:5;;7431:42;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7484:57;;;;;7400:73;;-1:-1:-1;;;;;;7484:37:3;;;-1:-1:-1;7484:37:3;;-1:-1:-1;7484:57:3;;-1:-1:-1;7522:6:3;;7530:10;;7484:57;;;:::i;11643:142:18:-;11752:14;2598:11;11744:34;;11643:142::o;22342:113:39:-;3040:1;22342:113;:::o;810:131:16:-;888:46;902:1;897;:6;5002:3:9;888:8:16;:46::i;19041:1831:39:-;19322:19;19355:27;19396:38;20027:32;20062:19;:8;:17;:19::i;:::-;20027:54;-1:-1:-1;20103:65:39;20095:4;:73;;;;;;;20091:775;;20184:40;7782:3:9;20184:7:39;:40::i;:::-;20091:775;;;20255:15;:13;:15::i;:::-;20633:46;20660:8;20670;20633:26;:46::i;:::-;20605:74;;-1:-1:-1;20605:74:39;-1:-1:-1;20837:17:39;:15;:17::i;:::-;20823:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20823:32:39;;20799:56;;20091:775;19041:1831;;;;;;;;;;;;;:::o;23662:253:3:-;23779:9;23774:135;23798:17;:15;:17::i;:::-;23794:1;:21;23774:135;;;23849:49;23868:7;23876:1;23868:10;;;;;;;;;;;;;;23880:14;23895:1;23880:17;;;;;;;;;;;;;;23849:18;:49::i;:::-;23836:7;23844:1;23836:10;;;;;;;;;;;;;;;;;:62;23817:3;;23774:135;;25195:6885;25894:10;25916:4;25894:27;25890:6184;;26208:28;;26190:12;;26216:4;;26208:28;;26190:12;;26227:8;;26208:28;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26189:47;;;26454:7;26487:1;26482:3336;;;;29978:9;26482:3336;26958:4;26955:1;26952;26937:26;27011:1;27005:8;27015:66;27001:81;27243:66;27233:77;;27227:2;;27366:16;27363:1;27360;27345:38;27422:16;27419:1;27412:27;27227:2;;28833;28827:4;28824:1;28809:27;29030:2;29024:4;29017:16;29454:2;29436:16;29432:25;29426:4;29420;29405:53;29792:2;29774:16;29770:25;29767:1;29760:36;26320:3703;30053:31;30087:17;:15;:17::i;:::-;30053:51;;30118:39;30132:8;30142:14;30118:13;:39::i;:::-;30173:17;30192:29;30227:256;30252:6;30276;30300:9;30327:8;30353:15;30386:25;30429:14;30461:8;30227:7;:256;;:::i;:::-;30172:311;;;;;30498:45;30514:12;30528:14;30498:15;:45;;:::i;:::-;31024:19;;-1:-1:-1;31411:23:3;;31451:24;;;31697:66;31679:16;;;31672:92;-1:-1:-1;31020:28:3;31790:16;;;32046:2;32036:13;;31790:16;32022:28;7926:89;7999:9;;7926:89;:::o;11907:142:18:-;12016:14;2651:11;12008:34;;11907:142::o;12191:603:38:-;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:38;:4;12478:62;12561:8;:14::i;:::-;12554:21;;;;;12433:355;12604:6;:18;;;12596:4;:26;12592:196;;-1:-1:-1;12645:4:38;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;29759:263:39:-;4030:12;29983:32;;29759:263::o;2937:682:19:-;2997:7;3016:38;3025:6;;;4516:1:9;3016:8:19;:38::i;:::-;3069:6;3065:548;;-1:-1:-1;3098:1:19;3091:8;;3065:548;893:4;3150:7;;;;3171:51;;3150:1;:7;:1;3180:13;;;;;:20;4564:1:9;3171:8:19;:51::i;:::-;3596:1;3591;3579:9;:13;3578:19;;;;;;3601:1;3577:25;3570:32;;;;;3933:104:1;4009:21;4015:6;4023;4009:5;:21::i;838:182:12:-;1006:6;986:32::o;18633:402:39:-;18896:7;18917:16;18947;18988:40;7782:3:9;18988:7:39;:40::i;:::-;18633:402;;;;;;;;;;;;:::o;24446:249:3:-;24561:9;24556:133;24580:17;:15;:17::i;:::-;24576:1;:21;24556:133;;;24631:47;24648:7;24656:1;24648:10;;;;;;;;;;;;;;24660:14;24675:1;24660:17;;;;;;;;;;;;;;24631:16;:47::i;:::-;24618:7;24626:1;24618:10;;;;;;;;;;;;;;;;;:60;24599:3;;24556:133;;25434:703:39;25563:76;25587:11;25572;:26;;7661:3:9;25563:8:39;:76::i;:::-;25649:72;5890:11;25658;:32;;7720:3:9;25649:8:39;:72::i;:::-;25902:165;26002:55;26023:11;5836:2;26002:20;:55::i;:::-;25928;25949:11;5781:1;25928:20;:55::i;:::-;:129;25902:12;:165::i;:::-;26083:47;;-1:-1:-1;;;;;26083:47:39;;;;;;;26105:11;;26118;;26083:47;:::i;:::-;;;;;;;;25434:703;;;:::o;24701:488:3:-;24759:11;25156:10;:8;:10::i;:::-;-1:-1:-1;;;;;25156:24:3;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;3199:183:24:-;3276:7;3341:20;:18;:20::i;:::-;3363:10;3312:62;;;;;;;;;:::i;17738:889:39:-;17933:7;17942:16;2970:18:17;:16;:18::i;:::-;18089:64:39::1;18116:4;-1:-1:-1::0;;;;;18098:23:39;::::1;;8280:3:9;18089:8:39;:64::i;:::-;18163:67;18193:4;-1:-1:-1::0;;;;;18172:26:39;::::1;;8280:3:9;18163:8:39;:67::i;:::-;18497:28;::::0;;3040:1:::1;18497:28:::0;;;;;::::1;::::0;;;4030:12:::1;::::0;18468:26:::1;::::0;18497:28;::::1;::::0;::::1;18468:26:::0;;18497:28:::1;::::0;::::1;;::::0;-1:-1:-1;18497:28:39::1;18468:57;;4030:12;18535:9;18545;18535:20;;;;;;;;;::::0;;::::1;::::0;;;;;:42;18596:12;;;;-1:-1:-1;17738:889:39;-1:-1:-1;;;;;;17738:889:39:o;22061:275::-;22119:7;22061:275;:::o;3817:110:1:-;3896:24;3902:9;3913:6;3896:5;:24::i;3885:149:25:-;-1:-1:-1;;;;;4000:18:25;;;3974:7;4000:18;;;-1:-1:-1;4000:18:25;;;;;;;;:27;;;;;;;;;;;;;3885:149::o;22461:585:39:-;22539:7;22571:10;-1:-1:-1;;;;;22562:19:39;;;;;;;22558:482;;;-1:-1:-1;22604:23:39;22597:30;;22558:482;22657:13;-1:-1:-1;;;;;22648:22:39;;;;;;;22644:396;;;22840:58;22875:22;:20;:22::i;22840:58::-;22833:65;;;;22644:396;22928:4;-1:-1:-1;;;;;22919:13:39;;;22915:125;;;-1:-1:-1;893:4:19;22948:21:39;;22915:125;23000:29;6252:3:9;23000:7:39;:29::i;29345:132::-;29415:7;29441:29;29459:10;29441:13;:11;:13::i;:::-;:17;;:29::i;3154:614:41:-;3218:7;3237:21;3270:17;:15;:17::i;:::-;3421:44;;;;;3237:51;;-1:-1:-1;3396:22:41;;-1:-1:-1;;;;;3421:28:41;;;;;:44;;893:4:19;;3421:44:41;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3396:69;-1:-1:-1;3665:12:41;3680:60;893:4:19;3680:36:41;3396:69;3699:16;3680:18;:36::i;:::-;:44;;:60::i;:::-;3665:75;-1:-1:-1;;;;3154:614: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;1738:209:19;1800:7;1837:5;;;1852:57;1861:6;;;:26;;;1886:1;1881;1871:7;:11;;;;;;:16;1861:26;4467:1:9;1852:8:19;:57::i;:::-;893:4;1927:13;;;;-1:-1:-1;;;1738:209:19:o;12904:639:39:-;13098:16;;;;13070:7;;13089:99;;13118:10;-1:-1:-1;;;;;13098:30:39;;;;;;;:67;;-1:-1:-1;13132:16:39;;;;13152:13;-1:-1:-1;;;;;13132:33:39;;;;;;13098:67;6252:3:9;13089:8:39;:99::i;:::-;13217:319;13338:7;:14;;;13370:8;13379:10;13370:20;;;;;;;;;;;;;;13408:8;13417:13;13408:23;;;;;;;;;;;;;;13449:49;13478:8;13487:9;13478:19;;;;;;;13449:49;13218:16;;;;13516:6;;13238:10;-1:-1:-1;;;;;13218:30:39;;;;;;:101;;13285:34;13218:101;;;13251:31;13218:101;13217:319;;:::i;:::-;13198:338;12904:639;-1:-1:-1;;;;12904:639:39:o;13549:729::-;13744:16;;;;13716:7;;13735:93;;13764:13;-1:-1:-1;;;;;13744:33:39;;;;;;;:61;;-1:-1:-1;13781:16:39;;;;-1:-1:-1;;;;;13781:24:39;13801:4;13781:24;6252:3:9;13735:8:39;:93::i;:::-;13857:16;;;;-1:-1:-1;;;;;13857:24:39;13877:4;13857:24;:414;;14190:81;14226:7;:14;;;14242:8;14251:10;14242:20;;;;;;;;;;;;;;14264:6;14190:35;:81::i;:::-;13857:414;;;13900:271;13953:7;:14;;;13989:8;13998:10;13989:20;;;;;;;;;;;;;;14031:8;14040:13;14031:23;;;;;;;;;;;;;;14076:49;14105:8;14114:9;14105:19;;;;;;;14076:49;14147:6;13900:31;:271::i;14284:732::-;14482:16;;;;14454:7;;14473:90;;14502:10;-1:-1:-1;;;;;14482:30:39;;;;;;;:58;;-1:-1:-1;14516:16:39;;;;-1:-1:-1;;;;;14516:24:39;14536:4;14516:24;6252:3:9;14473:8:39;:90::i;:::-;14592:16;;;;-1:-1:-1;;;;;14592:24:39;14612:4;14592:24;:417;;14928:81;14964:7;:14;;;14980:8;14989:10;14980:20;;;;;;;;;;;;;;15002:6;14928:35;:81::i;14592:417::-;14635:274;14691:7;:14;;;14727:8;14736:10;14727:20;;;;;;;;;;;;;;14769:8;14778:13;14769:23;;;;;;;;;;;;;;14814:49;14843:8;14852:9;14843:19;;;;;;;14814:49;14885:6;14635:34;:274::i;2576:355:19:-;2638:7;2657:38;2666:6;;;4516:1:9;2657:8:19;:38::i;:::-;2710:6;2706:219;;-1:-1:-1;2739:1:19;2732:8;;2706:219;893:4;2791:7;;;;2812:51;;2791:1;:7;:1;2821:13;;;2812:51;2913:1;2901:9;:13;;;;;;2894:20;;;;;15626:637:39;15821:15;;;;15793:7;;15812:97;;15840:10;-1:-1:-1;;;;;15821:29:39;;;;;;;:65;;-1:-1:-1;15854:15:39;;;;15873:13;-1:-1:-1;;;;;15854:32:39;;;;;;6252:3:9;15812:8:39;:97::i;:::-;15938:318;16058:7;:14;;;16090:8;16099:10;16090:20;;;;;;;;;;;;;;16128:8;16137:13;16128:23;;;;;;;;;;;;;;16169:49;16198:8;16207:9;16198:19;;;;;;;16169:49;15939:15;;;;16236:6;;15958:10;-1:-1:-1;;;;;15939:29:39;;;;;;:100;;16005:34;15939:100;;;15971:31;15938:318::i;16269:727::-;16465:15;;;;16437:7;;16456:91;;16484:13;-1:-1:-1;;;;;16465:32:39;;;;;;;:59;;-1:-1:-1;16501:15:39;;;;-1:-1:-1;;;;;16501:23:39;16520:4;16501:23;6252:3:9;16456:8:39;:91::i;:::-;16576:15;;;;-1:-1:-1;;;;;16576:23:39;16595:4;16576:23;:413;;16908:81;16944:7;:14;;;16960:8;16969:10;16960:20;;;;;;;;;;;;;;16982:6;16908:35;:81::i;16576:413::-;16618:271;16671:7;:14;;;16707:8;16716:10;16707:20;;;;;;;;;;;;;;16749:8;16758:13;16749:23;;;;;;;;;;;;;;16794:49;16823:8;16832:9;16823:19;;;;;;;16794:49;16865:6;16618:31;:271::i;17002:730::-;17201:15;;;;17173:7;;17192:88;;17220:10;-1:-1:-1;;;;;17201:29:39;;;;;;;:56;;-1:-1:-1;17234:15:39;;;;-1:-1:-1;;;;;17234:23:39;17253:4;17234:23;6252:3:9;17192:8:39;:88::i;:::-;17309:15;;;;-1:-1:-1;;;;;17309:23:39;17328:4;17309:23;:416;;17644:81;17680:7;:14;;;17696:8;17705:10;17696:20;;;;;;;;;;;;;;17718:6;17644:35;:81::i;17309:416::-;17351:274;17407:7;:14;;;17443:8;17452:10;17443:20;;;;;;;;;;;;;;17485:8;17494:13;17485:23;;;;;;;;;;;;;;17530:49;17559:8;17568:9;17559:19;;;;;;;17530:49;17601:6;17351:34;:274::i;1943:544:2:-;2031:4;1637:42;2052:10;:8;:10::i;:::-;-1:-1:-1;;;;;2052:29:2;;;;;2051:63;;;2086:28;2105:8;2086:18;:28::i;:::-;2047:434;;;2246:10;:8;:10::i;:::-;-1:-1:-1;;;;;2232:24:2;:10;:24;;-1:-1:-1;2225:31:2;;2047:434;2409:16;:14;:16::i;:::-;:61;;;;;-1:-1:-1;;;;;2409:27:2;;;;;;;:61;;2437:8;;2447:7;;2464:4;;2409:61;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;1765:176:29:-;1842:7;1861:27;1875:1;1870;:6;;1878:9;1861:8;:27::i;:::-;-1:-1:-1;;1910:5:29;;;1765:176::o;3388:427:24:-;3790:9;;3765:44::o;6625:418:3:-;6701:87;2769:4;6710:17;:45;;5289:3:9;6701:8:3;:87::i;:::-;6798;2842:4;6807:17;:45;;5228:3:9;6798:8:3;:87::i;:::-;6908:9;;:70;;6931:17;3370:3;6908:22;:70::i;:::-;6896:9;:82;6993:43;;;;;;7018:17;;6993:43;:::i;835:122:40:-;895:8;933:4;922:28;;;;;;;;;;;;:::i;4391:100:17:-;4440:44;4450:14;:12;:14::i;:::-;4449:15;10453:3:9;4440:8:17;:44::i;20878:1068:39:-;21010:7;21019:16;21409:19;21431:33;:8;:31;:33::i;:::-;21409:55;;21694:27;21724:172;21778:8;21800:11;21825:38;21843:8;21852:9;21843:19;;;;;;;;;;;;;;21825:17;:38::i;:::-;21877:9;21724:40;:172::i;:::-;21915:11;;;;-1:-1:-1;20878:1068:39;;-1:-1:-1;;;;20878:1068:39:o;8512:408:25:-;8587:68;-1:-1:-1;;;;;8596:21:25;;;;9199:3:9;8587:8:25;:68::i;:::-;8666:49;8687:7;8704:1;8708:6;8666:20;:49::i;:::-;-1:-1:-1;;;;;8747:18:25;;:9;:18;;;;;;;;;;;:65;;8770:6;10643:3:9;8747:22:25;:65::i;:::-;-1:-1:-1;;;;;8726:18:25;;:9;:18;;;;;;;;;;:86;8837:12;;:24;;8854:6;8837:16;:24::i;:::-;8822:12;:39;8876:37;;8902:1;;-1:-1:-1;;;;;8876:37:25;;;;;;;8906:6;;8876:37;:::i;:::-;;;;;;;;8512:408;;:::o;8226:112:3:-;8296:9;;:35;;8320:7;8329:1;8296:23;:35::i;:::-;8284:9;:47;-1:-1:-1;8226:112:3:o;7898:294:25:-;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:25;;:9;:18;;;;;;;;;;;:30;;8126:6;8103:22;:30::i;:::-;-1:-1:-1;;;;;8082:18:25;;:9;:18;;;;;;;;;;;:51;;;;8148:37;;8082:18;;:9;8148:37;;;;8178:6;;8148:37;:::i;1987:180:21:-;2045:7;2076:5;;;2091:51;2100:6;;;:20;;;2119:1;2114;2110;:5;;;;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;11366:643:38:-;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:38;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:38;: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:38;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:38;:11;7501:63;7581:15;:31::i;:::-;7574:38;6914:705;-1:-1:-1;;;;;;;;;;;6914:705:38:o;4978:421::-;5124:7;5193:27;5223:31;5234:11;5247:6;5223:10;:31::i;:::-;5193:61;-1:-1:-1;5264:24:38;5291:43;5302:23;:11;5318:6;5302:15;:23::i;:::-;5327:6;5291:10;:43::i;:::-;5264:70;-1:-1:-1;5351:41:38;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:38;4025:43;4036:23;:11;4052:6;4036:15;:23::i;4025:43::-;3998:70;-1:-1:-1;4078:24:38;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:38;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:38;:11;7985:63;8065:15;:31::i;:::-;8058:38;7625:478;-1:-1:-1;;;;;;;7625:478:38:o;8592:1059::-;8799:7;8872:14;8868:338;;-1:-1:-1;9186:9:38;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:38;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:38;9508:90;9634:9;9616:17;:28::i;10373:987::-;10577:7;10647:14;10643:335;;-1:-1:-1;10961:6:38;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:38;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:38;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:38;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:38;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:38;5716:44;5727:24;:11;5743:7;5727:15;:24::i;5716:44::-;5689:71;-1:-1:-1;5777:41:38;: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:38;4685:44;4696:24;:11;4712:7;4696:15;:24::i;4685:44::-;4658:71;-1:-1:-1;4739:24:38;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:38;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:38;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:38;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:38;:9;10224:90;10332:13;:28::i;28370:203:39:-;28456:4;28491:37;28503:24;28491:11;:37::i;:::-;28479:8;:49;:87;;;;28532:34;28557:8;28532:24;:34::i;963:167:40:-;1037:19;1097:4;1086:37;;;;;;;;;;;;:::i;13382:1650:38:-;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:38;;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:38;13382:1650;-1:-1:-1;;;;;;13382:1650:38:o;1353:121:29:-;1411:7;1437:30;1441:1;1444;4370::9;1437:3:29;:30::i;2505:232:21:-;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;;;;12800:576:38;12884:7;13014:6;:18;;;13004:7;:28;13000:370;;;13136:10;;13055:93;;13117:30;;893:4:19;;13117:18:38;: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:38;13214:14;;13165:205;13346:10;;13267:91;;13327:30;;893:4:19;;13327:18:38;:30::i;:::-;13298:18;;;;13279:10;;13267:51;;13279:38;;:10;:18;:38::i;:::-;13267:7;;:11;:51::i;7649:271:3:-;7735:4;7783:47;7795:34;7783:11;:47::i;:::-;7771:8;:59;7770:143;;;-1:-1:-1;7860:52:3;7872:39;7860:11;:52::i;:::-;7848:64;;;;7649:271;-1:-1:-1;7649:271:3: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;33895:18;33887:6;33884:30;33881:2;;;-1:-1;;33917:12;33881:2;3282:64;-1:-1;33971:17;;-1:-1;33967:33;34058:4;34048:15;3282:64;:::i;:::-;3273:73;;3366:6;3359:5;3352:21;3470:3;34058:4;3461:6;3394;3452:16;;3449:25;3446:2;;;3487:1;;3477:12;3446:2;38763:6;34058:4;3394:6;3390:17;34058:4;3428:5;3424:16;38740:30;38819:1;38801:16;;;34058:4;38801:16;38794:27;3428:5;3165:379;-1:-1;;3165:379::o;4071:162::-;4163:13;;40267:1;40257:12;;40247:2;;40283:1;;40273:12;4240:156;4320:20;;40381:1;40371:12;;40361:2;;40397:1;;40387:12;6515:241;;6619:2;6607:9;6598:7;6594:23;6590:32;6587:2;;;-1:-1;;6625:12;6587:2;85:6;72:20;97:33;124:5;97:33;:::i;6763:366::-;;;6884:2;6872:9;6863:7;6859:23;6855:32;6852:2;;;-1:-1;;6890:12;6852:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;6942:63;-1:-1;7042:2;7081:22;;72:20;97:33;72:20;97:33;:::i;:::-;7050:63;;;;6846:283;;;;;:::o;7136:491::-;;;;7274:2;7262:9;7253:7;7249:23;7245:32;7242:2;;;-1:-1;;7280:12;7242:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7332:63;-1:-1;7432:2;7471:22;;72:20;97:33;72:20;97:33;:::i;:::-;7236:391;;7440:63;;-1:-1;;;7540:2;7579:22;;;;6171:20;;7236:391::o;7634:991::-;;;;;;;;7838:3;7826:9;7817:7;7813:23;7809:33;7806:2;;;-1:-1;;7845:12;7806:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7897:63;-1:-1;7997:2;8036:22;;72:20;97:33;72:20;97:33;:::i;:::-;8005:63;-1:-1;8105:2;8144:22;;6171:20;;-1:-1;8213:2;8252:22;;6171:20;;-1:-1;8321:3;8359:22;;6447:20;37497:4;37486:16;;40594:33;;40584:2;;-1:-1;;40631:12;40584:2;7800:825;;;;-1:-1;7800:825;;;;8330:61;8428:3;8468:22;;2898:20;;-1:-1;8537:3;8577:22;;;2898:20;;7800:825;-1:-1;;7800:825::o;8632:366::-;;;8753:2;8741:9;8732:7;8728:23;8724:32;8721:2;;;-1:-1;;8759:12;8721:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8811:63;8911:2;8950:22;;;;6171:20;;-1:-1;;;8715:283::o;9005:823::-;;;;9219:2;9207:9;9198:7;9194:23;9190:32;9187:2;;;-1:-1;;9225:12;9187:2;9276:17;9270:24;9314:18;;9306:6;9303:30;9300:2;;;-1:-1;;9336:12;9300:2;9453:6;9442:9;9438: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;9513:18;;9507:25;9356:114;;-1:-1;9507:25;-1:-1;;;9541:30;;;9538:2;;;-1:-1;;9574:12;9538:2;;9604:89;9685:7;9676:6;9665:9;9661:22;9604:89;:::i;:::-;9594:99;;;9730:2;9784:9;9780:22;6319:13;9738:74;;9181:647;;;;;:::o;9835:235::-;;9936:2;9924:9;9915:7;9911:23;9907:32;9904:2;;;-1:-1;;9942:12;9904:2;2642:6;2629:20;2654:30;2678:5;2654:30;:::i;10077:257::-;;10189:2;10177:9;10168:7;10164:23;10160:32;10157:2;;;-1:-1;;10195:12;10157:2;2777:6;2771:13;2789:30;2813:5;2789:30;:::i;10341:1235::-;;;;;;;;10581:3;10569:9;10560:7;10556:23;10552:33;10549:2;;;-1:-1;;10588:12;10549:2;2911:6;2898:20;10640:63;;10740:2;10783:9;10779:22;72:20;97:33;124:5;97:33;:::i;:::-;10748:63;-1:-1;10848:2;10887:22;;72:20;97:33;72:20;97:33;:::i;:::-;10856:63;-1:-1;10984:2;10969:18;;10956:32;11008:18;10997:30;;;10994:2;;;-1:-1;;11030:12;10994:2;11060:78;11130:7;11121:6;11110:9;11106:22;11060:78;:::i;:::-;11050:88;;11175:3;11219:9;11215:22;6171:20;11184:63;;11284:3;11328:9;11324:22;6171:20;11293:63;;11421:3;11410:9;11406:19;11393:33;11379:47;;11008:18;11438:6;11435:30;11432:2;;;-1:-1;;11468:12;11432:2;;11498:62;11552:7;11543:6;11532:9;11528:22;11498:62;:::i;:::-;11488:72;;;10543:1033;;;;;;;;;;:::o;11583:239::-;;11686:2;11674:9;11665:7;11661:23;11657:32;11654:2;;;-1:-1;;11692:12;11654:2;3047:6;3034:20;36909:66;39829:5;36898:78;39805:5;39802:34;39792:2;;-1:-1;;39840:12;11829:303;;11964:2;11952:9;11943:7;11939:23;11935:32;11932:2;;;-1:-1;;11970:12;11932:2;3656:6;3650:13;3668:53;3715:5;3668:53;:::i;12139:500::-;;;12284:2;12272:9;12263:7;12259:23;12255:32;12252:2;;;-1:-1;;12290:12;12252:2;3828:6;3815:20;3840:48;3882:5;3840:48;:::i;:::-;12342:78;-1:-1;12485:2;12470:18;;12457:32;12509:18;12498:30;;12495:2;;;-1:-1;;12531:12;12495:2;12561:62;12615:7;12606:6;12595:9;12591:22;12561:62;:::i;:::-;12551:72;;;12246:393;;;;;:::o;12646:291::-;;12775:2;12763:9;12754:7;12750:23;12746:32;12743:2;;;-1:-1;;12781:12;12743:2;12843:78;12913:7;12889:22;12843:78;:::i;12944:427::-;;;13090:2;13078:9;13069:7;13065:23;13061:32;13058:2;;;-1:-1;;13096:12;13058:2;13158:78;13228:7;13204:22;13158:78;:::i;:::-;13148:88;;13273:2;13327:9;13323:22;6319:13;13281:74;;13052:319;;;;;:::o;13378:897::-;;;;;13587:3;13575:9;13566:7;13562:23;13558:33;13555:2;;;-1:-1;;13594:12;13555:2;13652:17;13639:31;13690:18;;13682:6;13679:30;13676:2;;;-1:-1;;13712:12;13676:2;13807:6;13796:9;13792: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;13587:3;5361:9;5357:22;2898:20;13587: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;13690: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;;;13732:92;;;;4832:2;13878:9;13874:18;13861:32;13847:46;;13690:18;13905:6;13902:30;13899:2;;;-1:-1;;13935:12;13899:2;;13965:78;14035:7;14026:6;14015:9;14011:22;13965:78;:::i;:::-;13549:726;;13955:88;;-1:-1;;;;4995:2;14119:22;;6171:20;;5156:2;14227:22;6171:20;;13549:726;-1:-1;13549:726::o;14282:241::-;;14386:2;14374:9;14365:7;14361:23;14357:32;14354:2;;;-1:-1;;14392:12;14354:2;-1:-1;6171:20;;14348:175;-1:-1;14348:175::o;14530:263::-;;14645:2;14633:9;14624:7;14620:23;14616:32;14613:2;;;-1:-1;;14651:12;14613:2;-1:-1;6319:13;;14607:186;-1:-1;14607:186::o;14800:366::-;;;14921:2;14909:9;14900:7;14896:23;14892:32;14889:2;;;-1:-1;;14927:12;14889:2;-1:-1;;6171:20;;;15079:2;15118:22;;;6171:20;;-1:-1;14883:283::o;15173:672::-;;;;;15339:3;15327:9;15318:7;15314:23;15310:33;15307:2;;;-1:-1;;15346:12;15307:2;6325:6;6319:13;15398:74;;15509:2;15563:9;15559:22;6319:13;15517:74;;15628:2;15682:9;15678:22;6319:13;15636:74;;15747:2;15801:9;15797:22;220:13;238:33;265:5;238:33;:::i;:::-;15301:544;;;;-1:-1;15301:544;;-1:-1;;15301:544::o;17189:670::-;;17372:5;34529:12;35337:6;35332:3;35325:19;35374:4;;35369:3;35365:14;17384:83;;35374:4;17538:5;34210:14;-1:-1;17577:260;17602:6;17599:1;17596:13;17577:260;;;17663:13;;18879:37;;16218:14;;;;35075;;;;17624:1;17617:9;17577:260;;;-1:-1;17843:10;;17303:556;-1:-1;;;;;17303:556::o;18596:94::-;36732:13;36725:21;18651:34;;18645:45::o;19583:323::-;;19715:5;34529:12;35337:6;35332:3;35325:19;-1:-1;38908:101;38922:6;38919:1;38916:13;38908:101;;;35374:4;38989:11;;;;;38983:18;38970:11;;;;;38963:39;38937:10;38908:101;;;39024:6;39021:1;39018:13;39015:2;;;-1:-1;35374:4;39080:6;35369:3;39071:16;;39064:27;39015:2;-1:-1;39361:2;39341:14;-1:-1;;39337:28;19862:39;;;;35374:4;19862:39;;19663:243;-1:-1;;19663:243::o;23239:387::-;18879:37;;;36909:66;36898:78;23490:2;23481:12;;19174:56;23590:11;;;23381:245::o;23633:291::-;;38763:6;38758:3;38753;38740:30;38801:16;;38794:27;;;38801:16;23777:147;-1:-1;23777:147::o;23931:659::-;21565:66;21545:87;;21530:1;21651:11;;18879:37;;;;24442:12;;;18879:37;24553:12;;;24176:414::o;24597:222::-;-1:-1;;;;;37281:54;;;;16317:37;;24724:2;24709:18;;24695:124::o;24826:370::-;;25003:2;25024:17;25017:47;25078:108;25003:2;24992:9;24988:18;25172:6;25078:108;:::i;25203:629::-;;25458:2;25479:17;25472:47;25533:108;25458:2;25447:9;25443:18;25627:6;25533:108;:::i;:::-;25689:9;25683:4;25679:20;25674:2;25663:9;25659:18;25652:48;25714:108;25817:4;25808:6;25714:108;:::i;25839:210::-;36732:13;;36725:21;18651:34;;25960:2;25945:18;;25931:118::o;26056:432::-;36732:13;;36725:21;18651:34;;26391:2;26376:18;;18879:37;;;;26474:2;26459:18;;18879:37;26233:2;26218:18;;26204:284::o;26495:222::-;18879:37;;;26622:2;26607:18;;26593:124::o;26724:444::-;18879:37;;;-1:-1;;;;;37281:54;;;27071:2;27056:18;;16317:37;37281:54;27154:2;27139:18;;16317:37;26907:2;26892:18;;26878:290::o;27175:736::-;18879:37;;;-1:-1;;;;;37281:54;;;27617:2;27602:18;;;16317:37;;;;37281:54;;;27700:2;27685:18;;16317:37;27452:3;27737:2;27722:18;;27715:48;;;21980:23;;27437:19;;;22016:38;;;;34529:12;;21903:14;;;35325:19;;;27175:736;;27617:2;34210:14;;;27175:736;;35365:14;;;;16838:290;16863:6;16860:1;16857:13;16838:290;;;37608:52;16930:6;16924:13;37608:52;:::i;:::-;20339:65;;35075:14;;;;16885:1;16878:9;;;;;16036:14;;;;16838:290;;;16842:14;27617:2;22273:5;22269:16;22263:23;22243:43;;22322:14;;;;27441:9;22326:4;22322:14;;22306;27441:9;22306:14;22299:38;22352:103;22450:4;22436:12;22352:103;:::i;:::-;22344:111;;;;27700:2;22537:5;22533:16;22527:23;22322:14;27441:9;22590:4;22586:14;;22570;27441:9;22570:14;22563:38;22616:71;22682:4;22668:12;22616:71;:::i;:::-;22608:79;;;;27737:2;22780:5;22776:16;22770:23;22799:57;22841:14;27441:9;22841:14;22827:12;22799:57;:::i;27918:780::-;18879:37;;;-1:-1;;;;;37281:54;;;28350:2;28335:18;;16317:37;37281:54;;;;28433:2;28418:18;;16317:37;28516:2;28501:18;;18879:37;28599:3;28584:19;;18879:37;;;;-1:-1;28668:19;;18879:37;28185:3;28170:19;;28156:542::o;28705:668::-;18879:37;;;29109:2;29094:18;;18879:37;;;;29192:2;29177:18;;18879:37;;;;29275:2;29260:18;;18879:37;-1:-1;;;;;37281:54;29358:3;29343:19;;16317:37;-1:-1;28929:19;;28915:458::o;29380:417::-;;18909:5;18886:3;18879:37;29553:2;29671;29660:9;29656:18;29649:48;29711:76;29553:2;29542:9;29538:18;29773:6;29711:76;:::i;29804:363::-;18879:37;;;-1:-1;;;;;37281:54;30153:2;30138:18;;20339:65;29974:2;29959:18;;29945:222::o;30174:548::-;18879:37;;;37497:4;37486:16;;;;30542:2;30527:18;;23192:35;30625:2;30610:18;;18879:37;30708:2;30693:18;;18879:37;30381:3;30366:19;;30352:370::o;31257:310::-;;31404:2;31425:17;31418:47;31479:78;31404:2;31393:9;31389:18;31543:6;31479:78;:::i;31803:481::-;;18909:5;18886:3;18879:37;32008:2;32126;32115:9;32111:18;32104:48;32166:108;32008:2;31997:9;31993:18;32260:6;32166:108;:::i;32291:333::-;18879:37;;;32610:2;32595:18;;18879:37;32446:2;32431:18;;32417:207::o;32631:214::-;37497:4;37486:16;;;;23192:35;;32754:2;32739:18;;32725:120::o;32852:256::-;32914:2;32908:9;32940:17;;;33015:18;33000:34;;33036:22;;;32997:62;32994:2;;;33072:1;;33062:12;32994:2;32914;33081:22;32892:216;;-1:-1;32892:216::o;33115:319::-;;33289:18;33281:6;33278:30;33275:2;;;-1:-1;;33311:12;33275:2;-1:-1;33356:4;33344:17;;;33409:15;;33212:222::o;36568:91::-;-1:-1;;;;;37281:54;;36613:46::o;39378:117::-;-1:-1;;;;;37281:54;;39437:35;;39427:2;;39486:1;;39476:12;39502:111;39583:5;36732:13;36725:21;39561:5;39558:32;39548:2;;39604:1;;39594:12
Swarm Source
ipfs://0fbadc367b8879628dc7ed74c8e19d9c31dab509d2a82dea92ea8a0a495594d7