Token A Dai-abolical Balance

 

Overview ERC-20

Price
$0.00 @ 0.000000 FTM
Fully Diluted Market Cap
Total Supply:
201,537.657851 BPT_USDB-DAI

Holders:
11 addresses
Contract:
0xd5e946b5619fff054c40d38c976f1d06c1e2fa820xD5E946b5619fFf054c40D38c976f1d06C1e2fA82

Decimals:
18

Social Profiles:
Not Available, Update ?

Balance
0.000000000001 BPT_USDB-DAI

Value
$0.00
0x0000000000000000000000000000000000000000
Loading
[ Download CSV Export  ] 
Loading
[ Download CSV Export  ] 
Loading

Click here to update the token ICO / general information
# Exchange Pair Price  24H Volume % Volume
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StablePool

Compiler Version
v0.7.1+commit.f4a555be

Optimization Enabled:
Yes with 9999 runs

Other Settings:
default evmVersion, GNU GPLv3 license

Contract Source Code (Solidity Standard Json-Input format)

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol";

import "@balancer-labs/v2-pool-utils/contracts/BaseGeneralPool.sol";
import "@balancer-labs/v2-pool-utils/contracts/BaseMinimalSwapInfoPool.sol";

import "./StableMath.sol";
import "./StablePoolUserDataHelpers.sol";

contract StablePool is BaseGeneralPool, BaseMinimalSwapInfoPool, StableMath {
    using FixedPoint for uint256;
    using StablePoolUserDataHelpers for bytes;
    using WordCodec for bytes32;

    // This contract uses timestamps to slowly update its Amplification parameter over time. These changes must occur
    // over a minimum time period much larger than the blocktime, making timestamp manipulation a non-issue.
    // solhint-disable not-rely-on-time

    // Amplification factor changes must happen over a minimum period of one day, and can at most divide or multiple the
    // current value by 2 every day.
    // WARNING: this only limits *a single* amplification change to have a maximum rate of change of twice the original
    // value daily. It is possible to perform multiple amplification changes in sequence to increase this value more
    // rapidly: for example, by doubling the value every day it can increase by a factor of 8 over three days (2^3).
    uint256 private constant _MIN_UPDATE_TIME = 1 days;
    uint256 private constant _MAX_AMP_UPDATE_DAILY_RATE = 2;

    bytes32 private _packedAmplificationData;

    event AmpUpdateStarted(uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime);
    event AmpUpdateStopped(uint256 currentValue);

    // To track how many tokens are owed to the Vault as protocol fees, we measure and store the value of the invariant
    // after every join and exit. All invariant growth that happens between join and exit events is due to swap fees.
    uint256 private _lastInvariant;
    // Because the invariant depends on the amplification parameter, and this value may change over time, we should only
    // compare invariants that were computed using the same value. We therefore store it whenever we store
    // _lastInvariant.
    uint256 private _lastInvariantAmp;

    enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT }
    enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT }

    constructor(
        IVault vault,
        string memory name,
        string memory symbol,
        IERC20[] memory tokens,
        uint256 amplificationParameter,
        uint256 swapFeePercentage,
        uint256 pauseWindowDuration,
        uint256 bufferPeriodDuration,
        address owner
    )
        BasePool(
            vault,
            // Because we're inheriting from both BaseGeneralPool and BaseMinimalSwapInfoPool we can choose any
            // specialization setting. Since this Pool never registers or deregisters any tokens after construction,
            // picking Two Token when the Pool only has two tokens is free gas savings.
            tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.GENERAL,
            name,
            symbol,
            tokens,
            new address[](tokens.length),
            swapFeePercentage,
            pauseWindowDuration,
            bufferPeriodDuration,
            owner
        )
    {
        _require(tokens.length <= _MAX_STABLE_TOKENS, Errors.MAX_STABLE_TOKENS);

        _require(amplificationParameter >= _MIN_AMP, Errors.MIN_AMP);
        _require(amplificationParameter <= _MAX_AMP, Errors.MAX_AMP);

        uint256 initialAmp = Math.mul(amplificationParameter, _AMP_PRECISION);
        _setAmplificationData(initialAmp);
    }

    // Base Pool handlers

    // Swap - General Pool specialization (from BaseGeneralPool)

    function _onSwapGivenIn(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut
    ) internal view virtual override whenNotPaused returns (uint256) {
        (uint256 currentAmp, ) = _getAmplificationParameter();
        uint256 amountOut = StableMath._calcOutGivenIn(currentAmp, balances, indexIn, indexOut, swapRequest.amount);
        return amountOut;
    }

    function _onSwapGivenOut(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut
    ) internal view virtual override whenNotPaused returns (uint256) {
        (uint256 currentAmp, ) = _getAmplificationParameter();
        uint256 amountIn = StableMath._calcInGivenOut(currentAmp, balances, indexIn, indexOut, swapRequest.amount);
        return amountIn;
    }

    // Swap - Two Token Pool specialization (from BaseMinimalSwapInfoPool)

    function _onSwapGivenIn(
        SwapRequest memory swapRequest,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    ) internal view virtual override returns (uint256) {
        _require(_getTotalTokens() == 2, Errors.NOT_TWO_TOKENS);

        (uint256[] memory balances, uint256 indexIn, uint256 indexOut) = _getSwapBalanceArrays(
            swapRequest,
            balanceTokenIn,
            balanceTokenOut
        );

        return _onSwapGivenIn(swapRequest, balances, indexIn, indexOut);
    }

    function _onSwapGivenOut(
        SwapRequest memory swapRequest,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    ) internal view virtual override returns (uint256) {
        _require(_getTotalTokens() == 2, Errors.NOT_TWO_TOKENS);

        (uint256[] memory balances, uint256 indexIn, uint256 indexOut) = _getSwapBalanceArrays(
            swapRequest,
            balanceTokenIn,
            balanceTokenOut
        );
        return _onSwapGivenOut(swapRequest, balances, indexIn, indexOut);
    }

    function _getSwapBalanceArrays(
        SwapRequest memory swapRequest,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    )
        private
        view
        returns (
            uint256[] memory balances,
            uint256 indexIn,
            uint256 indexOut
        )
    {
        balances = new uint256[](2);

        if (_token0 == swapRequest.tokenIn) {
            indexIn = 0;
            indexOut = 1;

            balances[0] = balanceTokenIn;
            balances[1] = balanceTokenOut;
        } else {
            // _token0 == swapRequest.tokenOut
            indexOut = 0;
            indexIn = 1;

            balances[0] = balanceTokenOut;
            balances[1] = balanceTokenIn;
        }
    }

    // Initialize

    function _onInitializePool(
        bytes32,
        address,
        address,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) internal virtual override whenNotPaused returns (uint256, uint256[] memory) {
        // It would be strange for the Pool to be paused before it is initialized, but for consistency we prevent
        // initialization in this case.

        StablePool.JoinKind kind = userData.joinKind();
        _require(kind == StablePool.JoinKind.INIT, Errors.UNINITIALIZED);

        uint256[] memory amountsIn = userData.initialAmountsIn();
        InputHelpers.ensureInputLengthMatch(amountsIn.length, _getTotalTokens());
        _upscaleArray(amountsIn, scalingFactors);

        (uint256 currentAmp, ) = _getAmplificationParameter();
        uint256 invariantAfterJoin = StableMath._calculateInvariant(currentAmp, amountsIn, true);

        // Set the initial BPT to the value of the invariant.
        uint256 bptAmountOut = invariantAfterJoin;

        _updateLastInvariant(invariantAfterJoin, currentAmp);

        return (bptAmountOut, amountsIn);
    }

    // Join

    function _onJoinPool(
        bytes32,
        address,
        address,
        uint256[] memory balances,
        uint256,
        uint256 protocolSwapFeePercentage,
        uint256[] memory scalingFactors,
        bytes memory userData
    )
        internal
        virtual
        override
        whenNotPaused
        returns (
            uint256,
            uint256[] memory,
            uint256[] memory
        )
    {
        // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous join
        // or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids spending gas to
        // calculate the fee amounts during each individual swap.
        uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage);

        // Update current balances by subtracting the protocol fee amounts
        _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub);
        (uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, scalingFactors, userData);

        // Update the invariant with the balances the Pool will have after the join, in order to compute the
        // protocol swap fee amounts due in future joins and exits.
        _updateInvariantAfterJoin(balances, amountsIn);

        return (bptAmountOut, amountsIn, dueProtocolFeeAmounts);
    }

    function _doJoin(
        uint256[] memory balances,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) private view returns (uint256, uint256[] memory) {
        JoinKind kind = userData.joinKind();

        if (kind == JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) {
            return _joinExactTokensInForBPTOut(balances, scalingFactors, userData);
        } else if (kind == JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) {
            return _joinTokenInForExactBPTOut(balances, userData);
        } else {
            _revert(Errors.UNHANDLED_JOIN_KIND);
        }
    }

    function _joinExactTokensInForBPTOut(
        uint256[] memory balances,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) private view returns (uint256, uint256[] memory) {
        (uint256[] memory amountsIn, uint256 minBPTAmountOut) = userData.exactTokensInForBptOut();
        InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length);

        _upscaleArray(amountsIn, scalingFactors);

        (uint256 currentAmp, ) = _getAmplificationParameter();
        uint256 bptAmountOut = StableMath._calcBptOutGivenExactTokensIn(
            currentAmp,
            balances,
            amountsIn,
            totalSupply(),
            _swapFeePercentage
        );

        _require(bptAmountOut >= minBPTAmountOut, Errors.BPT_OUT_MIN_AMOUNT);

        return (bptAmountOut, amountsIn);
    }

    function _joinTokenInForExactBPTOut(uint256[] memory balances, bytes memory userData)
        private
        view
        returns (uint256, uint256[] memory)
    {
        (uint256 bptAmountOut, uint256 tokenIndex) = userData.tokenInForExactBptOut();
        // Note that there is no maximum amountIn parameter: this is handled by `IVault.joinPool`.

        _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS);

        uint256[] memory amountsIn = new uint256[](_getTotalTokens());
        (uint256 currentAmp, ) = _getAmplificationParameter();
        amountsIn[tokenIndex] = StableMath._calcTokenInGivenExactBptOut(
            currentAmp,
            balances,
            tokenIndex,
            bptAmountOut,
            totalSupply(),
            _swapFeePercentage
        );

        return (bptAmountOut, amountsIn);
    }

    // Exit

    function _onExitPool(
        bytes32,
        address,
        address,
        uint256[] memory balances,
        uint256,
        uint256 protocolSwapFeePercentage,
        uint256[] memory scalingFactors,
        bytes memory userData
    )
        internal
        virtual
        override
        returns (
            uint256 bptAmountIn,
            uint256[] memory amountsOut,
            uint256[] memory dueProtocolFeeAmounts
        )
    {
        // Exits are not completely disabled while the contract is paused: proportional exits (exact BPT in for tokens
        // out) remain functional.

        if (_isNotPaused()) {
            // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous
            // join or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids
            // spending gas calculating fee amounts during each individual swap
            dueProtocolFeeAmounts = _getDueProtocolFeeAmounts(balances, protocolSwapFeePercentage);

            // Update current balances by subtracting the protocol fee amounts
            _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub);
        } else {
            // If the contract is paused, swap protocol fee amounts are not charged to avoid extra calculations and
            // reduce the potential for errors.
            dueProtocolFeeAmounts = new uint256[](_getTotalTokens());
        }

        (bptAmountIn, amountsOut) = _doExit(balances, scalingFactors, userData);

        // Update the invariant with the balances the Pool will have after the exit, in order to compute the
        // protocol swap fee amounts due in future joins and exits.
        _updateInvariantAfterExit(balances, amountsOut);

        return (bptAmountIn, amountsOut, dueProtocolFeeAmounts);
    }

    function _doExit(
        uint256[] memory balances,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) private view returns (uint256, uint256[] memory) {
        ExitKind kind = userData.exitKind();

        if (kind == ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) {
            return _exitExactBPTInForTokenOut(balances, userData);
        } else if (kind == ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) {
            return _exitExactBPTInForTokensOut(balances, userData);
        } else {
            // ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT
            return _exitBPTInForExactTokensOut(balances, scalingFactors, userData);
        }
    }

    function _exitExactBPTInForTokenOut(uint256[] memory balances, bytes memory userData)
        private
        view
        whenNotPaused
        returns (uint256, uint256[] memory)
    {
        // This exit function is disabled if the contract is paused.

        (uint256 bptAmountIn, uint256 tokenIndex) = userData.exactBptInForTokenOut();
        // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`.

        _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS);

        // We exit in a single token, so initialize amountsOut with zeros
        uint256[] memory amountsOut = new uint256[](_getTotalTokens());

        // And then assign the result to the selected token
        (uint256 currentAmp, ) = _getAmplificationParameter();
        amountsOut[tokenIndex] = StableMath._calcTokenOutGivenExactBptIn(
            currentAmp,
            balances,
            tokenIndex,
            bptAmountIn,
            totalSupply(),
            _swapFeePercentage
        );

        return (bptAmountIn, amountsOut);
    }

    function _exitExactBPTInForTokensOut(uint256[] memory balances, bytes memory userData)
        private
        view
        returns (uint256, uint256[] memory)
    {
        // This exit function is the only one that is not disabled if the contract is paused: it remains unrestricted
        // in an attempt to provide users with a mechanism to retrieve their tokens in case of an emergency.
        // This particular exit function is the only one that remains available because it is the simplest one, and
        // therefore the one with the lowest likelihood of errors.

        uint256 bptAmountIn = userData.exactBptInForTokensOut();
        // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`.

        uint256[] memory amountsOut = StableMath._calcTokensOutGivenExactBptIn(balances, bptAmountIn, totalSupply());
        return (bptAmountIn, amountsOut);
    }

    function _exitBPTInForExactTokensOut(
        uint256[] memory balances,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) private view whenNotPaused returns (uint256, uint256[] memory) {
        // This exit function is disabled if the contract is paused.

        (uint256[] memory amountsOut, uint256 maxBPTAmountIn) = userData.bptInForExactTokensOut();
        InputHelpers.ensureInputLengthMatch(amountsOut.length, _getTotalTokens());
        _upscaleArray(amountsOut, scalingFactors);

        (uint256 currentAmp, ) = _getAmplificationParameter();
        uint256 bptAmountIn = StableMath._calcBptInGivenExactTokensOut(
            currentAmp,
            balances,
            amountsOut,
            totalSupply(),
            _swapFeePercentage
        );
        _require(bptAmountIn <= maxBPTAmountIn, Errors.BPT_IN_MAX_AMOUNT);

        return (bptAmountIn, amountsOut);
    }

    // Helpers

    /**
     * @dev Stores the last measured invariant, and the amplification parameter used to compute it.
     */
    function _updateLastInvariant(uint256 invariant, uint256 amplificationParameter) private {
        _lastInvariant = invariant;
        _lastInvariantAmp = amplificationParameter;
    }

    /**
     * @dev Returns the amount of protocol fees to pay, given the value of the last stored invariant and the current
     * balances.
     */
    function _getDueProtocolFeeAmounts(uint256[] memory balances, uint256 protocolSwapFeePercentage)
        private
        view
        returns (uint256[] memory)
    {
        // Initialize with zeros
        uint256[] memory dueProtocolFeeAmounts = new uint256[](_getTotalTokens());

        // Early return if the protocol swap fee percentage is zero, saving gas.
        if (protocolSwapFeePercentage == 0) {
            return dueProtocolFeeAmounts;
        }

        // Instead of paying the protocol swap fee in all tokens proportionally, we will pay it in a single one. This
        // will reduce gas costs for single asset joins and exits, as at most only two Pool balances will change (the
        // token joined/exited, and the token in which fees will be paid).

        // The protocol fee is charged using the token with the highest balance in the pool.
        uint256 chosenTokenIndex = 0;
        uint256 maxBalance = balances[0];
        for (uint256 i = 1; i < _getTotalTokens(); ++i) {
            uint256 currentBalance = balances[i];
            if (currentBalance > maxBalance) {
                chosenTokenIndex = i;
                maxBalance = currentBalance;
            }
        }

        // Set the fee amount to pay in the selected token
        dueProtocolFeeAmounts[chosenTokenIndex] = StableMath._calcDueTokenProtocolSwapFeeAmount(
            _lastInvariantAmp,
            balances,
            _lastInvariant,
            chosenTokenIndex,
            protocolSwapFeePercentage
        );

        return dueProtocolFeeAmounts;
    }

    /**
     * @dev Computes and stores the value of the invariant after a join, which is required to compute due protocol fees
     * in the future.
     */
    function _updateInvariantAfterJoin(uint256[] memory balances, uint256[] memory amountsIn) private {
        _mutateAmounts(balances, amountsIn, FixedPoint.add);

        (uint256 currentAmp, ) = _getAmplificationParameter();
        // This invariant is used only to compute the final balance when calculating the protocol fees. These are
        // rounded down, so we round the invariant up.
        _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp);
    }

    /**
     * @dev Computes and stores the value of the invariant after an exit, which is required to compute due protocol fees
     * in the future.
     */
    function _updateInvariantAfterExit(uint256[] memory balances, uint256[] memory amountsOut) private {
        _mutateAmounts(balances, amountsOut, FixedPoint.sub);

        (uint256 currentAmp, ) = _getAmplificationParameter();
        // This invariant is used only to compute the final balance when calculating the protocol fees. These are
        // rounded down, so we round the invariant up.
        _updateLastInvariant(StableMath._calculateInvariant(currentAmp, balances, true), currentAmp);
    }

    /**
     * @dev Mutates `amounts` by applying `mutation` with each entry in `arguments`.
     *
     * Equivalent to `amounts = amounts.map(mutation)`.
     */
    function _mutateAmounts(
        uint256[] memory toMutate,
        uint256[] memory arguments,
        function(uint256, uint256) pure returns (uint256) mutation
    ) private view {
        for (uint256 i = 0; i < _getTotalTokens(); ++i) {
            toMutate[i] = mutation(toMutate[i], arguments[i]);
        }
    }

    /**
     * @dev This function returns the appreciation of one BPT relative to the
     * underlying tokens. This starts at 1 when the pool is created and grows over time
     */
    function getRate() public view returns (uint256) {
        (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId());

        // When calculating the current BPT rate, we may not have paid the protocol fees, therefore
        // the invariant should be smaller than its current value. Then, we round down overall.
        (uint256 currentAmp, ) = _getAmplificationParameter();

        _upscaleArray(balances, _scalingFactors());

        uint256 invariant = StableMath._calculateInvariant(currentAmp, balances, false);
        return invariant.divDown(totalSupply());
    }

    // Amplification

    /**
     * @dev Begins changing the amplification parameter to `rawEndValue` over time. The value will change linearly until
     * `endTime` is reached, when it will be `rawEndValue`.
     *
     * NOTE: Internally, the amplification parameter is represented using higher precision. The values returned by
     * `getAmplificationParameter` have to be corrected to account for this when comparing to `rawEndValue`.
     */
    function startAmplificationParameterUpdate(uint256 rawEndValue, uint256 endTime) external authenticate {
        _require(rawEndValue >= _MIN_AMP, Errors.MIN_AMP);
        _require(rawEndValue <= _MAX_AMP, Errors.MAX_AMP);

        uint256 duration = Math.sub(endTime, block.timestamp);
        _require(duration >= _MIN_UPDATE_TIME, Errors.AMP_END_TIME_TOO_CLOSE);

        (uint256 currentValue, bool isUpdating) = _getAmplificationParameter();
        _require(!isUpdating, Errors.AMP_ONGOING_UPDATE);

        uint256 endValue = Math.mul(rawEndValue, _AMP_PRECISION);

        // daily rate = (endValue / currentValue) / duration * 1 day
        // We perform all multiplications first to not reduce precision, and round the division up as we want to avoid
        // large rates. Note that these are regular integer multiplications and divisions, not fixed point.
        uint256 dailyRate = endValue > currentValue
            ? Math.divUp(Math.mul(1 days, endValue), Math.mul(currentValue, duration))
            : Math.divUp(Math.mul(1 days, currentValue), Math.mul(endValue, duration));
        _require(dailyRate <= _MAX_AMP_UPDATE_DAILY_RATE, Errors.AMP_RATE_TOO_HIGH);

        _setAmplificationData(currentValue, endValue, block.timestamp, endTime);
    }

    /**
     * @dev Stops the amplification parameter change process, keeping the current value.
     */
    function stopAmplificationParameterUpdate() external authenticate {
        (uint256 currentValue, bool isUpdating) = _getAmplificationParameter();
        _require(isUpdating, Errors.AMP_NO_ONGOING_UPDATE);

        _setAmplificationData(currentValue);
    }

    function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) {
        return
            (actionId == getActionId(StablePool.startAmplificationParameterUpdate.selector)) ||
            (actionId == getActionId(StablePool.stopAmplificationParameterUpdate.selector)) ||
            super._isOwnerOnlyAction(actionId);
    }

    function getAmplificationParameter()
        external
        view
        returns (
            uint256 value,
            bool isUpdating,
            uint256 precision
        )
    {
        (value, isUpdating) = _getAmplificationParameter();
        precision = _AMP_PRECISION;
    }

    function _getAmplificationParameter() internal view returns (uint256 value, bool isUpdating) {
        (uint256 startValue, uint256 endValue, uint256 startTime, uint256 endTime) = _getAmplificationData();

        // Note that block.timestamp >= startTime, since startTime is set to the current time when an update starts

        if (block.timestamp < endTime) {
            isUpdating = true;

            // We can skip checked arithmetic as:
            //  - block.timestamp is always larger or equal to startTime
            //  - endTime is alawys larger than startTime
            //  - the value delta is bounded by the largest amplification paramater, which never causes the
            //    multiplication to overflow.
            // This also means that the following computation will never revert nor yield invalid results.
            if (endValue > startValue) {
                value = startValue + ((endValue - startValue) * (block.timestamp - startTime)) / (endTime - startTime);
            } else {
                value = startValue - ((startValue - endValue) * (block.timestamp - startTime)) / (endTime - startTime);
            }
        } else {
            isUpdating = false;
            value = endValue;
        }
    }

    function _setAmplificationData(uint256 value) private {
        _setAmplificationData(value, value, block.timestamp, block.timestamp);

        emit AmpUpdateStopped(value);
    }

    function _setAmplificationData(
        uint256 startValue,
        uint256 endValue,
        uint256 startTime,
        uint256 endTime
    ) private {
        _packedAmplificationData =
            WordCodec.encodeUint(uint64(startValue), 0) |
            WordCodec.encodeUint(uint64(endValue), 64) |
            WordCodec.encodeUint(uint64(startTime), 64 * 2) |
            WordCodec.encodeUint(uint64(endTime), 64 * 3);

        emit AmpUpdateStarted(startValue, endValue, startTime, endTime);
    }

    function _getAmplificationData()
        private
        view
        returns (
            uint256 startValue,
            uint256 endValue,
            uint256 startTime,
            uint256 endTime
        )
    {
        startValue = _packedAmplificationData.decodeUint64(0);
        endValue = _packedAmplificationData.decodeUint64(64);
        startTime = _packedAmplificationData.decodeUint64(64 * 2);
        endTime = _packedAmplificationData.decodeUint64(64 * 3);
    }
}

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

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

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

pragma solidity ^0.7.0;

import "./LogExpMath.sol";
import "../helpers/BalancerErrors.sol";

/* solhint-disable private-vars-leading-underscore */

library FixedPoint {
    uint256 internal constant ONE = 1e18; // 18 decimal places
    uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14)

    // Minimum base for the power function when the exponent is 'free' (larger than ONE).
    uint256 internal constant MIN_POW_BASE_FREE_EXPONENT = 0.7e18;

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        // Fixed Point addition is the same as regular checked addition

        uint256 c = a + b;
        _require(c >= a, Errors.ADD_OVERFLOW);
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        // Fixed Point addition is the same as regular checked addition

        _require(b <= a, Errors.SUB_OVERFLOW);
        uint256 c = a - b;
        return c;
    }

    function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 product = a * b;
        _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW);

        return product / ONE;
    }

    function mulUp(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 product = a * b;
        _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW);

        if (product == 0) {
            return 0;
        } else {
            // The traditional divUp formula is:
            // divUp(x, y) := (x + y - 1) / y
            // To avoid intermediate overflow in the addition, we distribute the division and get:
            // divUp(x, y) := (x - 1) / y + 1
            // Note that this requires x != 0, which we already tested for.

            return ((product - 1) / ONE) + 1;
        }
    }

    function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
        _require(b != 0, Errors.ZERO_DIVISION);

        if (a == 0) {
            return 0;
        } else {
            uint256 aInflated = a * ONE;
            _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow

            return aInflated / b;
        }
    }

    function divUp(uint256 a, uint256 b) internal pure returns (uint256) {
        _require(b != 0, Errors.ZERO_DIVISION);

        if (a == 0) {
            return 0;
        } else {
            uint256 aInflated = a * ONE;
            _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow

            // The traditional divUp formula is:
            // divUp(x, y) := (x + y - 1) / y
            // To avoid intermediate overflow in the addition, we distribute the division and get:
            // divUp(x, y) := (x - 1) / y + 1
            // Note that this requires x != 0, which we already tested for.

            return ((aInflated - 1) / b) + 1;
        }
    }

    /**
     * @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above
     * the true value (that is, the error function expected - actual is always positive).
     */
    function powDown(uint256 x, uint256 y) internal pure returns (uint256) {
        uint256 raw = LogExpMath.pow(x, y);
        uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1);

        if (raw < maxError) {
            return 0;
        } else {
            return sub(raw, maxError);
        }
    }

    /**
     * @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below
     * the true value (that is, the error function expected - actual is always negative).
     */
    function powUp(uint256 x, uint256 y) internal pure returns (uint256) {
        uint256 raw = LogExpMath.pow(x, y);
        uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1);

        return add(raw, maxError);
    }

    /**
     * @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1.
     *
     * Useful when computing the complement for values with some level of relative error, as it strips this error and
     * prevents intermediate negative values.
     */
    function complement(uint256 x) internal pure returns (uint256) {
        return (x < ONE) ? (ONE - x) : 0;
    }
}

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

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

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

pragma solidity ^0.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;
        }
    }
}

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

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

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

pragma solidity ^0.7.0;

/**
 * @dev Library for encoding and decoding values stored inside a 256 bit word. Typically used to pack multiple values in
 * a single storage slot, saving gas by performing less storage accesses.
 *
 * Each value is defined by its size and the least significant bit in the word, also known as offset. For example, two
 * 128 bit values may be encoded in a word by assigning one an offset of 0, and the other an offset of 128.
 */
library WordCodec {
    // Masks are values with the least significant N bits set. They can be used to extract an encoded value from a word,
    // or to insert a new one replacing the old.
    uint256 private constant _MASK_1 = 2**(1) - 1;
    uint256 private constant _MASK_10 = 2**(10) - 1;
    uint256 private constant _MASK_22 = 2**(22) - 1;
    uint256 private constant _MASK_31 = 2**(31) - 1;
    uint256 private constant _MASK_53 = 2**(53) - 1;
    uint256 private constant _MASK_64 = 2**(64) - 1;

    // Largest positive values that can be represented as N bits signed integers.
    int256 private constant _MAX_INT_22 = 2**(21) - 1;
    int256 private constant _MAX_INT_53 = 2**(52) - 1;

    // In-place insertion

    /**
     * @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new
     * word.
     */
    function insertBoolean(
        bytes32 word,
        bool value,
        uint256 offset
    ) internal pure returns (bytes32) {
        bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_1 << offset));
        return clearedWord | bytes32(uint256(value ? 1 : 0) << offset);
    }

    // Unsigned

    /**
     * @dev Inserts a 10 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns
     * the new word.
     *
     * Assumes `value` can be represented using 10 bits.
     */
    function insertUint10(
        bytes32 word,
        uint256 value,
        uint256 offset
    ) internal pure returns (bytes32) {
        bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_10 << offset));
        return clearedWord | bytes32(value << offset);
    }

    /**
     * @dev Inserts a 31 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns
     * the new word.
     *
     * Assumes `value` can be represented using 31 bits.
     */
    function insertUint31(
        bytes32 word,
        uint256 value,
        uint256 offset
    ) internal pure returns (bytes32) {
        bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_31 << offset));
        return clearedWord | bytes32(value << offset);
    }

    /**
     * @dev Inserts a 64 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns
     * the new word.
     *
     * Assumes `value` can be represented using 64 bits.
     */
    function insertUint64(
        bytes32 word,
        uint256 value,
        uint256 offset
    ) internal pure returns (bytes32) {
        bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_64 << offset));
        return clearedWord | bytes32(value << offset);
    }

    // Signed

    /**
     * @dev Inserts a 22 bits signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns
     * the new word.
     *
     * Assumes `value` can be represented using 22 bits.
     */
    function insertInt22(
        bytes32 word,
        int256 value,
        uint256 offset
    ) internal pure returns (bytes32) {
        bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_22 << offset));
        // Integer values need masking to remove the upper bits of negative values.
        return clearedWord | bytes32((uint256(value) & _MASK_22) << offset);
    }

    // Encoding

    // Unsigned

    /**
     * @dev Encodes an unsigned integer shifted by an offset. This performs no size checks: it is up to the caller to
     * ensure that the values are bounded.
     *
     * The return value can be logically ORed with other encoded values to form a 256 bit word.
     */
    function encodeUint(uint256 value, uint256 offset) internal pure returns (bytes32) {
        return bytes32(value << offset);
    }

    // Signed

    /**
     * @dev Encodes a 22 bits signed integer shifted by an offset.
     *
     * The return value can be logically ORed with other encoded values to form a 256 bit word.
     */
    function encodeInt22(int256 value, uint256 offset) internal pure returns (bytes32) {
        // Integer values need masking to remove the upper bits of negative values.
        return bytes32((uint256(value) & _MASK_22) << offset);
    }

    /**
     * @dev Encodes a 53 bits signed integer shifted by an offset.
     *
     * The return value can be logically ORed with other encoded values to form a 256 bit word.
     */
    function encodeInt53(int256 value, uint256 offset) internal pure returns (bytes32) {
        // Integer values need masking to remove the upper bits of negative values.
        return bytes32((uint256(value) & _MASK_53) << offset);
    }

    // Decoding

    /**
     * @dev Decodes and returns a boolean shifted by an offset from a 256 bit word.
     */
    function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool) {
        return (uint256(word >> offset) & _MASK_1) == 1;
    }

    // Unsigned

    /**
     * @dev Decodes and returns a 10 bit unsigned integer shifted by an offset from a 256 bit word.
     */
    function decodeUint10(bytes32 word, uint256 offset) internal pure returns (uint256) {
        return uint256(word >> offset) & _MASK_10;
    }

    /**
     * @dev Decodes and returns a 31 bit unsigned integer shifted by an offset from a 256 bit word.
     */
    function decodeUint31(bytes32 word, uint256 offset) internal pure returns (uint256) {
        return uint256(word >> offset) & _MASK_31;
    }

    /**
     * @dev Decodes and returns a 64 bit unsigned integer shifted by an offset from a 256 bit word.
     */
    function decodeUint64(bytes32 word, uint256 offset) internal pure returns (uint256) {
        return uint256(word >> offset) & _MASK_64;
    }

    // Signed

    /**
     * @dev Decodes and returns a 22 bits signed integer shifted by an offset from a 256 bit word.
     */
    function decodeInt22(bytes32 word, uint256 offset) internal pure returns (int256) {
        int256 value = int256(uint256(word >> offset) & _MASK_22);
        // In case the decoded value is greater than the max positive integer that can be represented with 22 bits,
        // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit
        // representation.
        return value > _MAX_INT_22 ? (value | int256(~_MASK_22)) : value;
    }

    /**
     * @dev Decodes and returns a 53 bits signed integer shifted by an offset from a 256 bit word.
     */
    function decodeInt53(bytes32 word, uint256 offset) internal pure returns (int256) {
        int256 value = int256(uint256(word >> offset) & _MASK_53);
        // In case the decoded value is greater than the max positive integer that can be represented with 53 bits,
        // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit
        // representation.

        return value > _MAX_INT_53 ? (value | int256(~_MASK_53)) : value;
    }
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./BasePool.sol";
import "@balancer-labs/v2-vault/contracts/interfaces/IGeneralPool.sol";

/**
 * @dev Extension of `BasePool`, adding a handler for `IGeneralPool.onSwap`.
 *
 * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with
 * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the General
 * specialization setting.
 */
abstract contract BaseGeneralPool is IGeneralPool, BasePool {
    // Swap Hooks

    function onSwap(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut
    ) external view virtual override returns (uint256) {
        _validateIndexes(indexIn, indexOut, _getTotalTokens());
        uint256[] memory scalingFactors = _scalingFactors();

        return
            swapRequest.kind == IVault.SwapKind.GIVEN_IN
                ? _swapGivenIn(swapRequest, balances, indexIn, indexOut, scalingFactors)
                : _swapGivenOut(swapRequest, balances, indexIn, indexOut, scalingFactors);
    }

    function _swapGivenIn(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut,
        uint256[] memory scalingFactors
    ) internal view returns (uint256) {
        // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis.
        swapRequest.amount = _subtractSwapFeeAmount(swapRequest.amount);

        _upscaleArray(balances, scalingFactors);
        swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexIn]);

        uint256 amountOut = _onSwapGivenIn(swapRequest, balances, indexIn, indexOut);

        // amountOut tokens are exiting the Pool, so we round down.
        return _downscaleDown(amountOut, scalingFactors[indexOut]);
    }

    function _swapGivenOut(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut,
        uint256[] memory scalingFactors
    ) internal view returns (uint256) {
        _upscaleArray(balances, scalingFactors);
        swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexOut]);

        uint256 amountIn = _onSwapGivenOut(swapRequest, balances, indexIn, indexOut);

        // amountIn tokens are entering the Pool, so we round up.
        amountIn = _downscaleUp(amountIn, scalingFactors[indexIn]);

        // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis.
        return _addSwapFeeAmount(amountIn);
    }

    /*
     * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known.
     *
     * Returns the amount of tokens that will be taken from the Pool in return.
     *
     * All amounts inside `swapRequest` and `balances` are upscaled. The swap fee has already been deducted from
     * `swapRequest.amount`.
     *
     * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the
     * Vault.
     */
    function _onSwapGivenIn(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut
    ) internal view virtual returns (uint256);

    /*
     * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known.
     *
     * Returns the amount of tokens that will be granted to the Pool in return.
     *
     * All amounts inside `swapRequest` and `balances` are upscaled.
     *
     * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee
     * and returning it to the Vault.
     */
    function _onSwapGivenOut(
        SwapRequest memory swapRequest,
        uint256[] memory balances,
        uint256 indexIn,
        uint256 indexOut
    ) internal view virtual returns (uint256);

    function _validateIndexes(
        uint256 indexIn,
        uint256 indexOut,
        uint256 limit
    ) private pure {
        _require(indexIn < limit && indexOut < limit, Errors.OUT_OF_BOUNDS);
    }
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./BasePool.sol";
import "@balancer-labs/v2-vault/contracts/interfaces/IMinimalSwapInfoPool.sol";

/**
 * @dev Extension of `BasePool`, adding a handler for `IMinimalSwapInfoPool.onSwap`.
 *
 * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with
 * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the Two Token or Minimal
 * Swap Info specialization settings.
 */
abstract contract BaseMinimalSwapInfoPool is IMinimalSwapInfoPool, BasePool {
    // Swap Hooks

    function onSwap(
        SwapRequest memory request,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    ) external view virtual override returns (uint256) {
        uint256 scalingFactorTokenIn = _scalingFactor(request.tokenIn);
        uint256 scalingFactorTokenOut = _scalingFactor(request.tokenOut);

        if (request.kind == IVault.SwapKind.GIVEN_IN) {
            // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis.
            request.amount = _subtractSwapFeeAmount(request.amount);

            // All token amounts are upscaled.
            balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn);
            balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut);
            request.amount = _upscale(request.amount, scalingFactorTokenIn);

            uint256 amountOut = _onSwapGivenIn(request, balanceTokenIn, balanceTokenOut);

            // amountOut tokens are exiting the Pool, so we round down.
            return _downscaleDown(amountOut, scalingFactorTokenOut);
        } else {
            // All token amounts are upscaled.
            balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn);
            balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut);
            request.amount = _upscale(request.amount, scalingFactorTokenOut);

            uint256 amountIn = _onSwapGivenOut(request, balanceTokenIn, balanceTokenOut);

            // amountIn tokens are entering the Pool, so we round up.
            amountIn = _downscaleUp(amountIn, scalingFactorTokenIn);

            // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis.
            return _addSwapFeeAmount(amountIn);
        }
    }

    /*
     * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known.
     *
     * Returns the amount of tokens that will be taken from the Pool in return.
     *
     * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. The swap fee has already
     * been deducted from `swapRequest.amount`.
     *
     * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the
     * Vault.
     */
    function _onSwapGivenIn(
        SwapRequest memory swapRequest,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    ) internal view virtual returns (uint256);

    /*
     * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known.
     *
     * Returns the amount of tokens that will be granted to the Pool in return.
     *
     * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled.
     *
     * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee
     * and returning it to the Vault.
     */
    function _onSwapGivenOut(
        SwapRequest memory swapRequest,
        uint256 balanceTokenIn,
        uint256 balanceTokenOut
    ) internal view virtual returns (uint256);
}

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

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

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

pragma solidity ^0.7.0;

import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol";

// This is a contract to emulate file-level functions. Convert to a library
// after the migration to solc v0.7.1.

// solhint-disable private-vars-leading-underscore
// solhint-disable var-name-mixedcase

contract StableMath {
    using FixedPoint for uint256;

    uint256 internal constant _MIN_AMP = 1;
    uint256 internal constant _MAX_AMP = 5000;
    uint256 internal constant _AMP_PRECISION = 1e3;

    uint256 internal constant _MAX_STABLE_TOKENS = 5;

    // Note on unchecked arithmetic:
    // This contract performs a large number of additions, subtractions, multiplications and divisions, often inside
    // loops. Since many of these operations are gas-sensitive (as they happen e.g. during a swap), it is important to
    // not make any unnecessary checks. We rely on a set of invariants to avoid having to use checked arithmetic (the
    // Math library), including:
    //  - the number of tokens is bounded by _MAX_STABLE_TOKENS
    //  - the amplification parameter is bounded by _MAX_AMP * _AMP_PRECISION, which fits in 23 bits
    //  - the token balances are bounded by 2^112 (guaranteed by the Vault) times 1e18 (the maximum scaling factor),
    //    which fits in 172 bits
    //
    // This means e.g. we can safely multiply a balance by the amplification parameter without worrying about overflow.

    // Computes the invariant given the current balances, using the Newton-Raphson approximation.
    // The amplification parameter equals: A n^(n-1)
    function _calculateInvariant(
        uint256 amplificationParameter,
        uint256[] memory balances,
        bool roundUp
    ) internal pure returns (uint256) {
        /**********************************************************************************************
        // invariant                                                                                 //
        // D = invariant                                                  D^(n+1)                    //
        // A = amplification coefficient      A  n^n S + D = A D n^n + -----------                   //
        // S = sum of balances                                             n^n P                     //
        // P = product of balances                                                                   //
        // n = number of tokens                                                                      //
        *********x************************************************************************************/

        // We support rounding up or down.

        uint256 sum = 0;
        uint256 numTokens = balances.length;
        for (uint256 i = 0; i < numTokens; i++) {
            sum = sum.add(balances[i]);
        }
        if (sum == 0) {
            return 0;
        }

        uint256 prevInvariant = 0;
        uint256 invariant = sum;
        uint256 ampTimesTotal = amplificationParameter * numTokens;

        for (uint256 i = 0; i < 255; i++) {
            uint256 P_D = balances[0] * numTokens;
            for (uint256 j = 1; j < numTokens; j++) {
                P_D = Math.div(Math.mul(Math.mul(P_D, balances[j]), numTokens), invariant, roundUp);
            }
            prevInvariant = invariant;
            invariant = Math.div(
                Math.mul(Math.mul(numTokens, invariant), invariant).add(
                    Math.div(Math.mul(Math.mul(ampTimesTotal, sum), P_D), _AMP_PRECISION, roundUp)
                ),
                Math.mul(numTokens + 1, invariant).add(
                    // No need to use checked arithmetic for the amp precision, the amp is guaranteed to be at least 1
                    Math.div(Math.mul(ampTimesTotal - _AMP_PRECISION, P_D), _AMP_PRECISION, !roundUp)
                ),
                roundUp
            );

            if (invariant > prevInvariant) {
                if (invariant - prevInvariant <= 1) {
                    return invariant;
                }
            } else if (prevInvariant - invariant <= 1) {
                return invariant;
            }
        }

        _revert(Errors.STABLE_GET_BALANCE_DIDNT_CONVERGE);
    }

    // Computes how many tokens can be taken out of a pool if `tokenAmountIn` are sent, given the current balances.
    // The amplification parameter equals: A n^(n-1)
    function _calcOutGivenIn(
        uint256 amplificationParameter,
        uint256[] memory balances,
        uint256 tokenIndexIn,
        uint256 tokenIndexOut,
        uint256 tokenAmountIn
    ) internal pure returns (uint256) {
        /**************************************************************************************************************
        // outGivenIn token x for y - polynomial equation to solve                                                   //
        // ay = amount out to calculate                                                                              //
        // by = balance token out                                                                                    //
        // y = by - ay (finalBalanceOut)                                                                             //
        // D = invariant                                               D                     D^(n+1)                 //
        // A = amplification coefficient               y^2 + ( S - ----------  - D) * y -  ------------- = 0         //
        // n = number of tokens                                    (A * n^n)               A * n^2n * P              //
        // S = sum of final balances but y                                                                           //
        // P = product of final balances but y                                                                       //
        **************************************************************************************************************/

        // Amount out, so we round down overall.

        // Given that we need to have a greater final balance out, the invariant needs to be rounded up
        uint256 invariant = _calculateInvariant(amplificationParameter, balances, true);

        balances[tokenIndexIn] = balances[tokenIndexIn].add(tokenAmountIn);

        uint256 finalBalanceOut = _getTokenBalanceGivenInvariantAndAllOtherBalances(
            amplificationParameter,
            balances,
            invariant,
            tokenIndexOut
        );

        // No need to use checked arithmetic since `tokenAmountIn` was actually added to the same balance right before
        // calling `_getTokenBalanceGivenInvariantAndAllOtherBalances` which doesn't alter the balances array.
        balances[tokenIndexIn] = balances[tokenIndexIn] - tokenAmountIn;

        return balances[tokenIndexOut].sub(finalBalanceOut).sub(1);
    }

    // Computes how many tokens must be sent to a pool if `tokenAmountOut` are sent given the
    // current balances, using the Newton-Raphson approximation.
    // The amplification parameter equals: A n^(n-1)
    function _calcInGivenOut(
        uint256 amplificationParameter,
        uint256[] memory balances,
        uint256 tokenIndexIn,
        uint256 tokenIndexOut,
        uint256 tokenAmountOut
    ) internal pure returns (uint256) {
        /**************************************************************************************************************
        // inGivenOut token x for y - polynomial equation to solve                                                   //
        // ax = amount in to calculate                                                                               //
        // bx = balance token in                                                                                     //
        // x = bx + ax (finalBalanceIn)                                                                              //
        // D = invariant                                                D                     D^(n+1)                //
        // A = amplification coefficient               x^2 + ( S - ----------  - D) * x -  ------------- = 0         //
        // n = number of tokens                                     (A * n^n)               A * n^2n * P             //
        // S = sum of final balances but x                                                                           //
        // P = product of final balances but x                                                                       //
        **************************************************************************************************************/

        // Amount in, so we round up overall.

        // Given that we need to have a greater final balance in, the invariant needs to be rounded up
        uint256 invariant = _calculateInvariant(amplificationParameter, balances, true);

        balances[tokenIndexOut] = balances[tokenIndexOut].sub(tokenAmountOut);

        uint256 finalBalanceIn = _getTokenBalanceGivenInvariantAndAllOtherBalances(
            amplificationParameter,
            balances,
            invariant,
            tokenIndexIn
        );

        // No need to use checked arithmetic since `tokenAmountOut` was actually subtracted from the same balance right
        // before calling `_getTokenBalanceGivenInvariantAndAllOtherBalances` which doesn't alter the balances array.
        balances[tokenIndexOut] = balances[tokenIndexOut] + tokenAmountOut;

        return finalBalanceIn.sub(balances[tokenIndexIn]).add(1);
    }

    function _calcBptOutGivenExactTokensIn(
        uint256 amp,
        uint256[] memory balances,
        uint256[] memory amountsIn,
        uint256 bptTotalSupply,
        uint256 swapFeePercentage
    ) internal pure returns (uint256) {
        // BPT out, so we round down overall.

        // First loop calculates the sum of all token balances, which will be used to calculate
        // the current weights of each token, relative to this sum
        uint256 sumBalances = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            sumBalances = sumBalances.add(balances[i]);
        }

        // Calculate the weighted balance ratio without considering fees
        uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length);
        // The weighted sum of token balance ratios without fee
        uint256 invariantRatioWithFees = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            uint256 currentWeight = balances[i].divDown(sumBalances);
            balanceRatiosWithFee[i] = balances[i].add(amountsIn[i]).divDown(balances[i]);
            invariantRatioWithFees = invariantRatioWithFees.add(balanceRatiosWithFee[i].mulDown(currentWeight));
        }

        // Second loop calculates new amounts in, taking into account the fee on the percentage excess
        uint256[] memory newBalances = new uint256[](balances.length);
        for (uint256 i = 0; i < balances.length; i++) {
            uint256 amountInWithoutFee;

            // Check if the balance ratio is greater than the ideal ratio to charge fees or not
            if (balanceRatiosWithFee[i] > invariantRatioWithFees) {
                uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithFees.sub(FixedPoint.ONE));
                uint256 taxableAmount = amountsIn[i].sub(nonTaxableAmount);
                // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50%
                amountInWithoutFee = nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE - swapFeePercentage));
            } else {
                amountInWithoutFee = amountsIn[i];
            }

            newBalances[i] = balances[i].add(amountInWithoutFee);
        }

        // Get current and new invariants, taking swap fees into account
        uint256 currentInvariant = _calculateInvariant(amp, balances, true);
        uint256 newInvariant = _calculateInvariant(amp, newBalances, false);
        uint256 invariantRatio = newInvariant.divDown(currentInvariant);

        // If the invariant didn't increase for any reason, we simply don't mint BPT
        if (invariantRatio > FixedPoint.ONE) {
            return bptTotalSupply.mulDown(invariantRatio - FixedPoint.ONE);
        } else {
            return 0;
        }
    }

    function _calcTokenInGivenExactBptOut(
        uint256 amp,
        uint256[] memory balances,
        uint256 tokenIndex,
        uint256 bptAmountOut,
        uint256 bptTotalSupply,
        uint256 swapFeePercentage
    ) internal pure returns (uint256) {
        // Token in, so we round up overall.

        // Get the current invariant
        uint256 currentInvariant = _calculateInvariant(amp, balances, true);

        // Calculate new invariant
        uint256 newInvariant = bptTotalSupply.add(bptAmountOut).divUp(bptTotalSupply).mulUp(currentInvariant);

        // Calculate amount in without fee.
        uint256 newBalanceTokenIndex = _getTokenBalanceGivenInvariantAndAllOtherBalances(
            amp,
            balances,
            newInvariant,
            tokenIndex
        );
        uint256 amountInWithoutFee = newBalanceTokenIndex.sub(balances[tokenIndex]);

        // First calculate the sum of all token balances, which will be used to calculate
        // the current weight of each token
        uint256 sumBalances = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            sumBalances = sumBalances.add(balances[i]);
        }

        // We can now compute how much extra balance is being deposited and used in virtual swaps, and charge swap fees
        // accordingly.
        uint256 currentWeight = balances[tokenIndex].divDown(sumBalances);
        uint256 taxablePercentage = currentWeight.complement();
        uint256 taxableAmount = amountInWithoutFee.mulUp(taxablePercentage);
        uint256 nonTaxableAmount = amountInWithoutFee.sub(taxableAmount);

        // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50%
        return nonTaxableAmount.add(taxableAmount.divUp(FixedPoint.ONE - swapFeePercentage));
    }

    /*
    Flow of calculations:
    amountsTokenOut -> amountsOutProportional ->
    amountOutPercentageExcess -> amountOutBeforeFee -> newInvariant -> amountBPTIn
    */
    function _calcBptInGivenExactTokensOut(
        uint256 amp,
        uint256[] memory balances,
        uint256[] memory amountsOut,
        uint256 bptTotalSupply,
        uint256 swapFeePercentage
    ) internal pure returns (uint256) {
        // BPT in, so we round up overall.

        // First loop calculates the sum of all token balances, which will be used to calculate
        // the current weights of each token relative to this sum
        uint256 sumBalances = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            sumBalances = sumBalances.add(balances[i]);
        }

        // Calculate the weighted balance ratio without considering fees
        uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length);
        uint256 invariantRatioWithoutFees = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            uint256 currentWeight = balances[i].divUp(sumBalances);
            balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]);
            invariantRatioWithoutFees = invariantRatioWithoutFees.add(balanceRatiosWithoutFee[i].mulUp(currentWeight));
        }

        // Second loop calculates new amounts in, taking into account the fee on the percentage excess
        uint256[] memory newBalances = new uint256[](balances.length);
        for (uint256 i = 0; i < balances.length; i++) {
            // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it to
            // 'token out'. This results in slightly larger price impact.

            uint256 amountOutWithFee;
            if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) {
                uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement());
                uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount);
                // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50%
                amountOutWithFee = nonTaxableAmount.add(taxableAmount.divUp(FixedPoint.ONE - swapFeePercentage));
            } else {
                amountOutWithFee = amountsOut[i];
            }

            newBalances[i] = balances[i].sub(amountOutWithFee);
        }

        // Get current and new invariants, taking into account swap fees
        uint256 currentInvariant = _calculateInvariant(amp, balances, true);
        uint256 newInvariant = _calculateInvariant(amp, newBalances, false);
        uint256 invariantRatio = newInvariant.divDown(currentInvariant);

        // return amountBPTIn
        return bptTotalSupply.mulUp(invariantRatio.complement());
    }

    function _calcTokenOutGivenExactBptIn(
        uint256 amp,
        uint256[] memory balances,
        uint256 tokenIndex,
        uint256 bptAmountIn,
        uint256 bptTotalSupply,
        uint256 swapFeePercentage
    ) internal pure returns (uint256) {
        // Token out, so we round down overall.

        // Get the current and new invariants. Since we need a bigger new invariant, we round the current one up.
        uint256 currentInvariant = _calculateInvariant(amp, balances, true);
        uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(currentInvariant);

        // Calculate amount out without fee
        uint256 newBalanceTokenIndex = _getTokenBalanceGivenInvariantAndAllOtherBalances(
            amp,
            balances,
            newInvariant,
            tokenIndex
        );
        uint256 amountOutWithoutFee = balances[tokenIndex].sub(newBalanceTokenIndex);

        // First calculate the sum of all token balances, which will be used to calculate
        // the current weight of each token
        uint256 sumBalances = 0;
        for (uint256 i = 0; i < balances.length; i++) {
            sumBalances = sumBalances.add(balances[i]);
        }

        // We can now compute how much excess balance is being withdrawn as a result of the virtual swaps, which result
        // in swap fees.
        uint256 currentWeight = balances[tokenIndex].divDown(sumBalances);
        uint256 taxablePercentage = currentWeight.complement();

        // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it
        // to 'token out'. This results in slightly larger price impact. Fees are rounded up.
        uint256 taxableAmount = amountOutWithoutFee.mulUp(taxablePercentage);
        uint256 nonTaxableAmount = amountOutWithoutFee.sub(taxableAmount);

        // No need to use checked arithmetic for the swap fee, it is guaranteed to be lower than 50%
        return nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE - swapFeePercentage));
    }

    function _calcTokensOutGivenExactBptIn(
        uint256[] memory balances,
        uint256 bptAmountIn,
        uint256 bptTotalSupply
    ) internal pure returns (uint256[] memory) {
        /**********************************************************************************************
        // exactBPTInForTokensOut                                                                    //
        // (per token)                                                                               //
        // aO = tokenAmountOut             /        bptIn         \                                  //
        // b = tokenBalance      a0 = b * | ---------------------  |                                 //
        // bptIn = bptAmountIn             \     bptTotalSupply    /                                 //
        // bpt = bptTotalSupply                                                                      //
        **********************************************************************************************/

        // Since we're computing an amount out, we round down overall. This means rounding down on both the
        // multiplication and division.

        uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply);

        uint256[] memory amountsOut = new uint256[](balances.length);
        for (uint256 i = 0; i < balances.length; i++) {
            amountsOut[i] = balances[i].mulDown(bptRatio);
        }

        return amountsOut;
    }

    // The amplification parameter equals: A n^(n-1)
    function _calcDueTokenProtocolSwapFeeAmount(
        uint256 amplificationParameter,
        uint256[] memory balances,
        uint256 lastInvariant,
        uint256 tokenIndex,
        uint256 protocolSwapFeePercentage
    ) internal pure returns (uint256) {
        /**************************************************************************************************************
        // oneTokenSwapFee - polynomial equation to solve                                                            //
        // af = fee amount to calculate in one token                                                                 //
        // bf = balance of fee token                                                                                 //
        // f = bf - af (finalBalanceFeeToken)                                                                        //
        // D = old invariant                                            D                     D^(n+1)                //
        // A = amplification coefficient               f^2 + ( S - ----------  - D) * f -  ------------- = 0         //
        // n = number of tokens                                    (A * n^n)               A * n^2n * P              //
        // S = sum of final balances but f                                                                           //
        // P = product of final balances but f                                                                       //
        **************************************************************************************************************/

        // Protocol swap fee amount, so we round down overall.

        uint256 finalBalanceFeeToken = _getTokenBalanceGivenInvariantAndAllOtherBalances(
            amplificationParameter,
            balances,
            lastInvariant,
            tokenIndex
        );

        if (balances[tokenIndex] <= finalBalanceFeeToken) {
            // This shouldn't happen outside of rounding errors, but have this safeguard nonetheless to prevent the Pool
            // from entering a locked state in which joins and exits revert while computing accumulated swap fees.
            return 0;
        }

        // Result is rounded down
        uint256 accumulatedTokenSwapFees = balances[tokenIndex] - finalBalanceFeeToken;
        return accumulatedTokenSwapFees.mulDown(protocolSwapFeePercentage).divDown(FixedPoint.ONE);
    }

    // Private functions

    // This function calculates the balance of a given token (tokenIndex)
    // given all the other balances and the invariant
    function _getTokenBalanceGivenInvariantAndAllOtherBalances(
        uint256 amplificationParameter,
        uint256[] memory balances,
        uint256 invariant,
        uint256 tokenIndex
    ) internal pure returns (uint256) {
        // Rounds result up overall

        uint256 ampTimesTotal = amplificationParameter * balances.length;
        uint256 sum = balances[0];
        uint256 P_D = balances[0] * balances.length;
        for (uint256 j = 1; j < balances.length; j++) {
            P_D = Math.divDown(Math.mul(Math.mul(P_D, balances[j]), balances.length), invariant);
            sum = sum.add(balances[j]);
        }
        // No need to use safe math, based on the loop above `sum` is greater than or equal to `balances[tokenIndex]`
        sum = sum - balances[tokenIndex];

        uint256 inv2 = Math.mul(invariant, invariant);
        // We remove the balance fromm c by multiplying it
        uint256 c = Math.mul(
            Math.mul(Math.divUp(inv2, Math.mul(ampTimesTotal, P_D)), _AMP_PRECISION),
            balances[tokenIndex]
        );
        uint256 b = sum.add(Math.mul(Math.divDown(invariant, ampTimesTotal), _AMP_PRECISION));

        // We iterate to find the balance
        uint256 prevTokenBalance = 0;
        // We multiply the first iteration outside the loop with the invariant to set the value of the
        // initial approximation.
        uint256 tokenBalance = Math.divUp(inv2.add(c), invariant.add(b));

        for (uint256 i = 0; i < 255; i++) {
            prevTokenBalance = tokenBalance;

            tokenBalance = Math.divUp(
                Math.mul(tokenBalance, tokenBalance).add(c),
                Math.mul(tokenBalance, 2).add(b).sub(invariant)
            );

            if (tokenBalance > prevTokenBalance) {
                if (tokenBalance - prevTokenBalance <= 1) {
                    return tokenBalance;
                }
            } else if (prevTokenBalance - tokenBalance <= 1) {
                return tokenBalance;
            }
        }

        _revert(Errors.STABLE_GET_BALANCE_DIDNT_CONVERGE);
    }
}

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

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

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

pragma solidity ^0.7.0;

import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol";

import "./StablePool.sol";

library StablePoolUserDataHelpers {
    function joinKind(bytes memory self) internal pure returns (StablePool.JoinKind) {
        return abi.decode(self, (StablePool.JoinKind));
    }

    function exitKind(bytes memory self) internal pure returns (StablePool.ExitKind) {
        return abi.decode(self, (StablePool.ExitKind));
    }

    // Joins

    function initialAmountsIn(bytes memory self) internal pure returns (uint256[] memory amountsIn) {
        (, amountsIn) = abi.decode(self, (StablePool.JoinKind, uint256[]));
    }

    function exactTokensInForBptOut(bytes memory self)
        internal
        pure
        returns (uint256[] memory amountsIn, uint256 minBPTAmountOut)
    {
        (, amountsIn, minBPTAmountOut) = abi.decode(self, (StablePool.JoinKind, uint256[], uint256));
    }

    function tokenInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut, uint256 tokenIndex) {
        (, bptAmountOut, tokenIndex) = abi.decode(self, (StablePool.JoinKind, uint256, uint256));
    }

    // Exits

    function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) {
        (, bptAmountIn, tokenIndex) = abi.decode(self, (StablePool.ExitKind, uint256, uint256));
    }

    function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) {
        (, bptAmountIn) = abi.decode(self, (StablePool.ExitKind, uint256));
    }

    function bptInForExactTokensOut(bytes memory self)
        internal
        pure
        returns (uint256[] memory amountsOut, uint256 maxBPTAmountIn)
    {
        (, amountsOut, maxBPTAmountIn) = abi.decode(self, (StablePool.ExitKind, uint256[], uint256));
    }
}

File 9 of 36 : LogExpMath.sol
// 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;
    }
}

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

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

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

pragma solidity ^0.7.0;

// solhint-disable

/**
 * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are
 * supported.
 */
function _require(bool condition, uint256 errorCode) pure {
    if (!condition) _revert(errorCode);
}

/**
 * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
 */
function _revert(uint256 errorCode) pure {
    // We're going to dynamically create a revert string based on the error code, with the following format:
    // 'BAL#{errorCode}'
    // where the code is left-padded with zeroes to three digits (so they range from 000 to 999).
    //
    // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a
    // number (8 to 16 bits) than the individual string characters.
    //
    // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a
    // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a
    // safe place to rely on it without worrying about how its usage might affect e.g. memory contents.
    assembly {
        // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999
        // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for
        // the '0' character.

        let units := add(mod(errorCode, 10), 0x30)

        errorCode := div(errorCode, 10)
        let tenths := add(mod(errorCode, 10), 0x30)

        errorCode := div(errorCode, 10)
        let hundreds := add(mod(errorCode, 10), 0x30)

        // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant
        // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the
        // characters to it, each shifted by a multiple of 8.
        // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits
        // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte
        // array).

        let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds))))

        // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded
        // message will have the following layout:
        // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ]

        // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We
        // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten.
        mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
        // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away).
        mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)
        // The string length is fixed: 7 characters.
        mstore(0x24, 7)
        // Finally, the string itself is stored.
        mstore(0x44, revertReason)

        // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of
        // the encoded message is therefore 4 + 32 + 32 + 32 = 100.
        revert(0, 100)
    }
}

library Errors {
    // Math
    uint256 internal constant ADD_OVERFLOW = 0;
    uint256 internal constant SUB_OVERFLOW = 1;
    uint256 internal constant SUB_UNDERFLOW = 2;
    uint256 internal constant MUL_OVERFLOW = 3;
    uint256 internal constant ZERO_DIVISION = 4;
    uint256 internal constant DIV_INTERNAL = 5;
    uint256 internal constant X_OUT_OF_BOUNDS = 6;
    uint256 internal constant Y_OUT_OF_BOUNDS = 7;
    uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8;
    uint256 internal constant INVALID_EXPONENT = 9;

    // Input
    uint256 internal constant OUT_OF_BOUNDS = 100;
    uint256 internal constant UNSORTED_ARRAY = 101;
    uint256 internal constant UNSORTED_TOKENS = 102;
    uint256 internal constant INPUT_LENGTH_MISMATCH = 103;
    uint256 internal constant ZERO_TOKEN = 104;

    // Shared pools
    uint256 internal constant MIN_TOKENS = 200;
    uint256 internal constant MAX_TOKENS = 201;
    uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202;
    uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203;
    uint256 internal constant MINIMUM_BPT = 204;
    uint256 internal constant CALLER_NOT_VAULT = 205;
    uint256 internal constant UNINITIALIZED = 206;
    uint256 internal constant BPT_IN_MAX_AMOUNT = 207;
    uint256 internal constant BPT_OUT_MIN_AMOUNT = 208;
    uint256 internal constant EXPIRED_PERMIT = 209;
    uint256 internal constant NOT_TWO_TOKENS = 210;

    // Pools
    uint256 internal constant MIN_AMP = 300;
    uint256 internal constant MAX_AMP = 301;
    uint256 internal constant MIN_WEIGHT = 302;
    uint256 internal constant MAX_STABLE_TOKENS = 303;
    uint256 internal constant MAX_IN_RATIO = 304;
    uint256 internal constant MAX_OUT_RATIO = 305;
    uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306;
    uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307;
    uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308;
    uint256 internal constant INVALID_TOKEN = 309;
    uint256 internal constant UNHANDLED_JOIN_KIND = 310;
    uint256 internal constant ZERO_INVARIANT = 311;
    uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312;
    uint256 internal constant ORACLE_NOT_INITIALIZED = 313;
    uint256 internal constant ORACLE_QUERY_TOO_OLD = 314;
    uint256 internal constant ORACLE_INVALID_INDEX = 315;
    uint256 internal constant ORACLE_BAD_SECS = 316;
    uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317;
    uint256 internal constant AMP_ONGOING_UPDATE = 318;
    uint256 internal constant AMP_RATE_TOO_HIGH = 319;
    uint256 internal constant AMP_NO_ONGOING_UPDATE = 320;
    uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321;
    uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322;
    uint256 internal constant RELAYER_NOT_CONTRACT = 323;
    uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324;
    uint256 internal constant REBALANCING_RELAYER_REENTERED = 325;

    // Lib
    uint256 internal constant REENTRANCY = 400;
    uint256 internal constant SENDER_NOT_ALLOWED = 401;
    uint256 internal constant PAUSED = 402;
    uint256 internal constant PAUSE_WINDOW_EXPIRED = 403;
    uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404;
    uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405;
    uint256 internal constant INSUFFICIENT_BALANCE = 406;
    uint256 internal constant INSUFFICIENT_ALLOWANCE = 407;
    uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408;
    uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409;
    uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410;
    uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411;
    uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412;
    uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413;
    uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414;
    uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415;
    uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416;
    uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417;
    uint256 internal constant SAFE_ERC20_CALL_FAILED = 418;
    uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419;
    uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420;
    uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421;
    uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422;
    uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423;
    uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424;
    uint256 internal constant BUFFER_PERIOD_EXPIRED = 425;
    uint256 internal constant CALLER_IS_NOT_OWNER = 426;
    uint256 internal constant NEW_OWNER_IS_ZERO = 427;
    uint256 internal constant CODE_DEPLOYMENT_FAILED = 428;

    // Vault
    uint256 internal constant INVALID_POOL_ID = 500;
    uint256 internal constant CALLER_NOT_POOL = 501;
    uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502;
    uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503;
    uint256 internal constant INVALID_SIGNATURE = 504;
    uint256 internal constant EXIT_BELOW_MIN = 505;
    uint256 internal constant JOIN_ABOVE_MAX = 506;
    uint256 internal constant SWAP_LIMIT = 507;
    uint256 internal constant SWAP_DEADLINE = 508;
    uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509;
    uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510;
    uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511;
    uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512;
    uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513;
    uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514;
    uint256 internal constant INVALID_POST_LOAN_BALANCE = 515;
    uint256 internal constant INSUFFICIENT_ETH = 516;
    uint256 internal constant UNALLOCATED_ETH = 517;
    uint256 internal constant ETH_TRANSFER = 518;
    uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519;
    uint256 internal constant TOKENS_MISMATCH = 520;
    uint256 internal constant TOKEN_NOT_REGISTERED = 521;
    uint256 internal constant TOKEN_ALREADY_REGISTERED = 522;
    uint256 internal constant TOKENS_ALREADY_SET = 523;
    uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524;
    uint256 internal constant NONZERO_TOKEN_BALANCE = 525;
    uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526;
    uint256 internal constant POOL_NO_TOKENS = 527;
    uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528;

    // Fees
    uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600;
    uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601;
    uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602;
}

File 11 of 36 : IERC20.sol
// 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);
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/TemporarilyPausable.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol";

import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol";
import "@balancer-labs/v2-vault/contracts/interfaces/IBasePool.sol";

import "./BalancerPoolToken.sol";
import "./BasePoolAuthorization.sol";

import "@balancer-labs/v2-asset-manager-utils/contracts/IAssetManager.sol";

// This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage
// reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus a total
// count, resulting in a large number of state variables.

// solhint-disable max-states-count

/**
 * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with an immutable set
 * of registered tokens, no Asset Managers, an admin-controlled swap fee percentage, and an emergency pause mechanism.
 *
 * Note that neither swap fees nor the pause mechanism are used by this contract. They are passed through so that
 * derived contracts can use them via the `_addSwapFeeAmount` and `_subtractSwapFeeAmount` functions, and the
 * `whenNotPaused` modifier.
 *
 * No admin permissions are checked here: instead, this contract delegates that to the Vault's own Authorizer.
 *
 * Because this contract doesn't implement the swap hooks, derived contracts should generally inherit from
 * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces
 * and implement the swap callbacks themselves.
 */
abstract contract BasePool is IBasePool, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable {
    using FixedPoint for uint256;

    uint256 private constant _MIN_TOKENS = 2;
    uint256 private constant _MAX_TOKENS = 8;

    // 1e18 corresponds to 1.0, or a 100% fee
    uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001%
    uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10%

    uint256 private constant _MINIMUM_BPT = 1e6;

    uint256 internal _swapFeePercentage;

    IVault private immutable _vault;
    bytes32 private immutable _poolId;
    uint256 private immutable _totalTokens;

    IERC20 internal immutable _token0;
    IERC20 internal immutable _token1;
    IERC20 internal immutable _token2;
    IERC20 internal immutable _token3;
    IERC20 internal immutable _token4;
    IERC20 internal immutable _token5;
    IERC20 internal immutable _token6;
    IERC20 internal immutable _token7;

    // All token balances are normalized to behave as if the token had 18 decimals. We assume a token's decimals will
    // not change throughout its lifetime, and store the corresponding scaling factor for each at construction time.
    // These factors are always greater than or equal to one: tokens with more than 18 decimals are not supported.

    uint256 private immutable _scalingFactor0;
    uint256 private immutable _scalingFactor1;
    uint256 private immutable _scalingFactor2;
    uint256 private immutable _scalingFactor3;
    uint256 private immutable _scalingFactor4;
    uint256 private immutable _scalingFactor5;
    uint256 private immutable _scalingFactor6;
    uint256 private immutable _scalingFactor7;

    event SwapFeePercentageChanged(uint256 swapFeePercentage);

    constructor(
        IVault vault,
        IVault.PoolSpecialization specialization,
        string memory name,
        string memory symbol,
        IERC20[] memory tokens,
        address[] memory assetManagers,
        uint256 swapFeePercentage,
        uint256 pauseWindowDuration,
        uint256 bufferPeriodDuration,
        address owner
    )
        // Base Pools are expected to be deployed using factories. By using the factory address as the action
        // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for
        // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in
        // any Pool created by the same factory), while still making action identifiers unique among different factories
        // if the selectors match, preventing accidental errors.
        Authentication(bytes32(uint256(msg.sender)))
        BalancerPoolToken(name, symbol)
        BasePoolAuthorization(owner)
        TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration)
    {
        _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS);
        _require(tokens.length <= _MAX_TOKENS, Errors.MAX_TOKENS);

        // The Vault only requires the token list to be ordered for the Two Token Pools specialization. However,
        // to make the developer experience consistent, we are requiring this condition for all the native pools.
        // Also, since these Pools will register tokens only once, we can ensure the Pool tokens will follow the same
        // order. We rely on this property to make Pools simpler to write, as it lets us assume that the
        // order of token-specific parameters (such as token weights) will not change.
        InputHelpers.ensureArrayIsSorted(tokens);

        _setSwapFeePercentage(swapFeePercentage);

        bytes32 poolId = vault.registerPool(specialization);

        vault.registerTokens(poolId, tokens, assetManagers);

        // Set immutable state variables - these cannot be read from during construction
        uint256 totalTokens = tokens.length;
        _vault = vault;
        _poolId = poolId;
        _totalTokens = totalTokens;

        // Immutable variables cannot be initialized inside an if statement, so we must do conditional assignments
        _token0 = totalTokens > 0 ? tokens[0] : IERC20(0);
        _token1 = totalTokens > 1 ? tokens[1] : IERC20(0);
        _token2 = totalTokens > 2 ? tokens[2] : IERC20(0);
        _token3 = totalTokens > 3 ? tokens[3] : IERC20(0);
        _token4 = totalTokens > 4 ? tokens[4] : IERC20(0);
        _token5 = totalTokens > 5 ? tokens[5] : IERC20(0);
        _token6 = totalTokens > 6 ? tokens[6] : IERC20(0);
        _token7 = totalTokens > 7 ? tokens[7] : IERC20(0);

        _scalingFactor0 = totalTokens > 0 ? _computeScalingFactor(tokens[0]) : 0;
        _scalingFactor1 = totalTokens > 1 ? _computeScalingFactor(tokens[1]) : 0;
        _scalingFactor2 = totalTokens > 2 ? _computeScalingFactor(tokens[2]) : 0;
        _scalingFactor3 = totalTokens > 3 ? _computeScalingFactor(tokens[3]) : 0;
        _scalingFactor4 = totalTokens > 4 ? _computeScalingFactor(tokens[4]) : 0;
        _scalingFactor5 = totalTokens > 5 ? _computeScalingFactor(tokens[5]) : 0;
        _scalingFactor6 = totalTokens > 6 ? _computeScalingFactor(tokens[6]) : 0;
        _scalingFactor7 = totalTokens > 7 ? _computeScalingFactor(tokens[7]) : 0;
    }

    // Getters / Setters

    function getVault() public view returns (IVault) {
        return _vault;
    }

    function getPoolId() public view override returns (bytes32) {
        return _poolId;
    }

    function _getTotalTokens() internal view returns (uint256) {
        return _totalTokens;
    }

    function getSwapFeePercentage() external view returns (uint256) {
        return _swapFeePercentage;
    }

    function setSwapFeePercentage(uint256 swapFeePercentage) public virtual authenticate whenNotPaused {
        _setSwapFeePercentage(swapFeePercentage);
    }

    function _setSwapFeePercentage(uint256 swapFeePercentage) private {
        _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE);
        _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE);

        _swapFeePercentage = swapFeePercentage;
        emit SwapFeePercentageChanged(swapFeePercentage);
    }

    function setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig)
        public
        virtual
        authenticate
        whenNotPaused
    {
        _setAssetManagerPoolConfig(token, poolConfig);
    }

    function _setAssetManagerPoolConfig(IERC20 token, bytes memory poolConfig) private {
        bytes32 poolId = getPoolId();
        (, , , address assetManager) = getVault().getPoolTokenInfo(poolId, token);

        IAssetManager(assetManager).setConfig(poolId, poolConfig);
    }

    function setPaused(bool paused) external authenticate {
        _setPaused(paused);
    }

    function _isOwnerOnlyAction(bytes32 actionId) internal view virtual override returns (bool) {
        return
            (actionId == getActionId(this.setSwapFeePercentage.selector)) ||
            (actionId == getActionId(this.setAssetManagerPoolConfig.selector));
    }

    // Join / Exit Hooks

    modifier onlyVault(bytes32 poolId) {
        _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT);
        _require(poolId == getPoolId(), Errors.INVALID_POOL_ID);
        _;
    }

    function onJoinPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) {
        uint256[] memory scalingFactors = _scalingFactors();

        if (totalSupply() == 0) {
            (uint256 bptAmountOut, uint256[] memory amountsIn) = _onInitializePool(
                poolId,
                sender,
                recipient,
                scalingFactors,
                userData
            );

            // On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum
            // as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from
            // ever being fully drained.
            _require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT);
            _mintPoolTokens(address(0), _MINIMUM_BPT);
            _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT);

            // amountsIn are amounts entering the Pool, so we round up.
            _downscaleUpArray(amountsIn, scalingFactors);

            return (amountsIn, new uint256[](_getTotalTokens()));
        } else {
            _upscaleArray(balances, scalingFactors);
            (uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) = _onJoinPool(
                poolId,
                sender,
                recipient,
                balances,
                lastChangeBlock,
                protocolSwapFeePercentage,
                scalingFactors,
                userData
            );

            // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it.

            _mintPoolTokens(recipient, bptAmountOut);

            // amountsIn are amounts entering the Pool, so we round up.
            _downscaleUpArray(amountsIn, scalingFactors);
            // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down.
            _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors);

            return (amountsIn, dueProtocolFeeAmounts);
        }
    }

    function onExitPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) public virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) {
        uint256[] memory scalingFactors = _scalingFactors();
        _upscaleArray(balances, scalingFactors);

        (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool(
            poolId,
            sender,
            recipient,
            balances,
            lastChangeBlock,
            protocolSwapFeePercentage,
            scalingFactors,
            userData
        );

        // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it.

        _burnPoolTokens(sender, bptAmountIn);

        // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down.
        _downscaleDownArray(amountsOut, scalingFactors);
        _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors);

        return (amountsOut, dueProtocolFeeAmounts);
    }

    // Query functions

    /**
     * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the
     * Vault with the same arguments, along with the number of tokens `sender` would have to supply.
     *
     * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault
     * data, such as the protocol swap fee percentage and Pool balances.
     *
     * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must
     * explicitly use eth_call instead of eth_sendTransaction.
     */
    function queryJoin(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) external returns (uint256 bptOut, uint256[] memory amountsIn) {
        InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens());

        _queryAction(
            poolId,
            sender,
            recipient,
            balances,
            lastChangeBlock,
            protocolSwapFeePercentage,
            userData,
            _onJoinPool,
            _downscaleUpArray
        );

        // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement,
        // and we don't need to return anything here - it just silences compiler warnings.
        return (bptOut, amountsIn);
    }

    /**
     * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the
     * Vault with the same arguments, along with the number of tokens `recipient` would receive.
     *
     * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault
     * data, such as the protocol swap fee percentage and Pool balances.
     *
     * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must
     * explicitly use eth_call instead of eth_sendTransaction.
     */
    function queryExit(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) external returns (uint256 bptIn, uint256[] memory amountsOut) {
        InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens());

        _queryAction(
            poolId,
            sender,
            recipient,
            balances,
            lastChangeBlock,
            protocolSwapFeePercentage,
            userData,
            _onExitPool,
            _downscaleDownArray
        );

        // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement,
        // and we don't need to return anything here - it just silences compiler warnings.
        return (bptIn, amountsOut);
    }

    // Internal hooks to be overridden by derived contracts - all token amounts (except BPT) in these interfaces are
    // upscaled.

    /**
     * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero.
     *
     * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return.
     *
     * Minted BPT will be sent to `recipient`, except for _MINIMUM_BPT, which will be deducted from this amount and sent
     * to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP from
     * ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire Pool's
     * lifetime.
     *
     * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will
     * be downscaled (rounding up) before being returned to the Vault.
     */
    function _onInitializePool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory scalingFactors,
        bytes memory userData
    ) internal virtual returns (uint256 bptAmountOut, uint256[] memory amountsIn);

    /**
     * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`).
     *
     * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of
     * tokens to pay in protocol swap fees.
     *
     * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when
     * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely.
     *
     * Minted BPT will be sent to `recipient`.
     *
     * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will
     * be downscaled (rounding up) before being returned to the Vault.
     *
     * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These
     * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault.
     */
    function _onJoinPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        uint256[] memory scalingFactors,
        bytes memory userData
    )
        internal
        virtual
        returns (
            uint256 bptAmountOut,
            uint256[] memory amountsIn,
            uint256[] memory dueProtocolFeeAmounts
        );

    /**
     * @dev Called whenever the Pool is exited.
     *
     * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and
     * the number of tokens to pay in protocol swap fees.
     *
     * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when
     * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely.
     *
     * BPT will be burnt from `sender`.
     *
     * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled
     * (rounding down) before being returned to the Vault.
     *
     * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These
     * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault.
     */
    function _onExitPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        uint256[] memory scalingFactors,
        bytes memory userData
    )
        internal
        virtual
        returns (
            uint256 bptAmountIn,
            uint256[] memory amountsOut,
            uint256[] memory dueProtocolFeeAmounts
        );

    // Internal functions

    /**
     * @dev Adds swap fee amount to `amount`, returning a higher value.
     */
    function _addSwapFeeAmount(uint256 amount) internal view returns (uint256) {
        // This returns amount + fee amount, so we round up (favoring a higher fee amount).
        return amount.divUp(FixedPoint.ONE.sub(_swapFeePercentage));
    }

    /**
     * @dev Subtracts swap fee amount from `amount`, returning a lower value.
     */
    function _subtractSwapFeeAmount(uint256 amount) internal view returns (uint256) {
        // This returns amount - fee amount, so we round up (favoring a higher fee amount).
        uint256 feeAmount = amount.mulUp(_swapFeePercentage);
        return amount.sub(feeAmount);
    }

    // Scaling

    /**
     * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if
     * it had 18 decimals.
     */
    function _computeScalingFactor(IERC20 token) private view returns (uint256) {
        // Tokens that don't implement the `decimals` method are not supported.
        uint256 tokenDecimals = ERC20(address(token)).decimals();

        // Tokens with more than 18 decimals are not supported.
        uint256 decimalsDifference = Math.sub(18, tokenDecimals);
        return FixedPoint.ONE * 10**decimalsDifference;
    }

    /**
     * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the
     * Pool.
     *
     * All scaling factors are fixed-point values with 18 decimals, to allow for this function to be overridden by
     * derived contracts that need to apply further scaling, making these factors potentially non-integer.
     *
     * The largest 'base' scaling factor (i.e. in tokens with less than 18 decimals) is 10**18, which in fixed-point is
     * 10**36. This value can be multiplied with a 112 bit Vault balance with no overflow by a factor of ~1e7, making
     * even relatively 'large' factors safe to use.
     *
     * The 1e7 figure is the result of 2**256 / (1e18 * 1e18 * 2**112).
     */
    function _scalingFactor(IERC20 token) internal view virtual returns (uint256) {
        // prettier-ignore
        if (token == _token0) { return _scalingFactor0; }
        else if (token == _token1) { return _scalingFactor1; }
        else if (token == _token2) { return _scalingFactor2; }
        else if (token == _token3) { return _scalingFactor3; }
        else if (token == _token4) { return _scalingFactor4; }
        else if (token == _token5) { return _scalingFactor5; }
        else if (token == _token6) { return _scalingFactor6; }
        else if (token == _token7) { return _scalingFactor7; }
        else {
            _revert(Errors.INVALID_TOKEN);
        }
    }

    /**
     * @dev Same as `_scalingFactor()`, except for all registered tokens (in the same order as registered). The Vault
     * will always pass balances in this order when calling any of the Pool hooks.
     */
    function _scalingFactors() internal view virtual returns (uint256[] memory) {
        uint256 totalTokens = _getTotalTokens();
        uint256[] memory scalingFactors = new uint256[](totalTokens);

        // prettier-ignore
        {
            if (totalTokens > 0) { scalingFactors[0] = _scalingFactor0; } else { return scalingFactors; }
            if (totalTokens > 1) { scalingFactors[1] = _scalingFactor1; } else { return scalingFactors; }
            if (totalTokens > 2) { scalingFactors[2] = _scalingFactor2; } else { return scalingFactors; }
            if (totalTokens > 3) { scalingFactors[3] = _scalingFactor3; } else { return scalingFactors; }
            if (totalTokens > 4) { scalingFactors[4] = _scalingFactor4; } else { return scalingFactors; }
            if (totalTokens > 5) { scalingFactors[5] = _scalingFactor5; } else { return scalingFactors; }
            if (totalTokens > 6) { scalingFactors[6] = _scalingFactor6; } else { return scalingFactors; }
            if (totalTokens > 7) { scalingFactors[7] = _scalingFactor7; } else { return scalingFactors; }
        }

        return scalingFactors;
    }

    /**
     * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed
     * scaling or not.
     */
    function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) {
        // Upscale rounding wouldn't necessarily always go in the same direction: in a swap for example the balance of
        // token in should be rounded up, and that of token out rounded down. This is the only place where we round in
        // the same direction for all amounts, as the impact of this rounding is expected to be minimal (and there's no
        // rounding error unless `_scalingFactor()` is overriden).
        return FixedPoint.mulDown(amount, scalingFactor);
    }

    /**
     * @dev Same as `_upscale`, but for an entire array. This function does not return anything, but instead *mutates*
     * the `amounts` array.
     */
    function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view {
        for (uint256 i = 0; i < _getTotalTokens(); ++i) {
            amounts[i] = FixedPoint.mulDown(amounts[i], scalingFactors[i]);
        }
    }

    /**
     * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on
     * whether it needed scaling or not. The result is rounded down.
     */
    function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) {
        return FixedPoint.divDown(amount, scalingFactor);
    }

    /**
     * @dev Same as `_downscaleDown`, but for an entire array. This function does not return anything, but instead
     * *mutates* the `amounts` array.
     */
    function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view {
        for (uint256 i = 0; i < _getTotalTokens(); ++i) {
            amounts[i] = FixedPoint.divDown(amounts[i], scalingFactors[i]);
        }
    }

    /**
     * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on
     * whether it needed scaling or not. The result is rounded up.
     */
    function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) {
        return FixedPoint.divUp(amount, scalingFactor);
    }

    /**
     * @dev Same as `_downscaleUp`, but for an entire array. This function does not return anything, but instead
     * *mutates* the `amounts` array.
     */
    function _downscaleUpArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view {
        for (uint256 i = 0; i < _getTotalTokens(); ++i) {
            amounts[i] = FixedPoint.divUp(amounts[i], scalingFactors[i]);
        }
    }

    function _getAuthorizer() internal view override returns (IAuthorizer) {
        // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which
        // accounts can call permissioned functions: for example, to perform emergency pauses.
        // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under
        // Governance control.
        return getVault().getAuthorizer();
    }

    function _queryAction(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData,
        function(bytes32, address, address, uint256[] memory, uint256, uint256, uint256[] memory, bytes memory)
            internal
            returns (uint256, uint256[] memory, uint256[] memory) _action,
        function(uint256[] memory, uint256[] memory) internal view _downscaleArray
    ) private {
        // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed
        // explanation.

        if (msg.sender != address(this)) {
            // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of
            // the preceding if statement will be executed instead.

            // solhint-disable-next-line avoid-low-level-calls
            (bool success, ) = address(this).call(msg.data);

            // solhint-disable-next-line no-inline-assembly
            assembly {
                // This call should always revert to decode the bpt and token amounts from the revert reason
                switch success
                    case 0 {
                        // Note we are manually writing the memory slot 0. We can safely overwrite whatever is
                        // stored there as we take full control of the execution and then immediately return.

                        // We copy the first 4 bytes to check if it matches with the expected signature, otherwise
                        // there was another revert reason and we should forward it.
                        returndatacopy(0, 0, 0x04)
                        let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)

                        // If the first 4 bytes don't match with the expected signature, we forward the revert reason.
                        if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) {
                            returndatacopy(0, 0, returndatasize())
                            revert(0, returndatasize())
                        }

                        // The returndata contains the signature, followed by the raw memory representation of the
                        // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded
                        // representation of these.
                        // An ABI-encoded response will include one additional field to indicate the starting offset of
                        // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the
                        // returndata.
                        //
                        // In returndata:
                        // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ]
                        // [  4 bytes  ][  32 bytes ][       32 bytes      ][ (32 * length) bytes ]
                        //
                        // We now need to return (ABI-encoded values):
                        // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ]
                        // [  32 bytes ][       32 bytes     ][       32 bytes      ][ (32 * length) bytes ]

                        // We copy 32 bytes for the `bptAmount` from returndata into memory.
                        // Note that we skip the first 4 bytes for the error signature
                        returndatacopy(0, 0x04, 32)

                        // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after
                        // the initial 64 bytes.
                        mstore(0x20, 64)

                        // We now copy the raw memory array for the `tokenAmounts` from returndata into memory.
                        // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also
                        // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount.
                        returndatacopy(0x40, 0x24, sub(returndatasize(), 36))

                        // We finally return the ABI-encoded uint256 and the array, which has a total length equal to
                        // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the
                        // error signature.
                        return(0, add(returndatasize(), 28))
                    }
                    default {
                        // This call should always revert, but we fail nonetheless if that didn't happen
                        invalid()
                    }
            }
        } else {
            uint256[] memory scalingFactors = _scalingFactors();
            _upscaleArray(balances, scalingFactors);

            (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action(
                poolId,
                sender,
                recipient,
                balances,
                lastChangeBlock,
                protocolSwapFeePercentage,
                scalingFactors,
                userData
            );

            _downscaleArray(tokenAmounts, scalingFactors);

            // solhint-disable-next-line no-inline-assembly
            assembly {
                // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of
                // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values
                // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32
                let size := mul(mload(tokenAmounts), 32)

                // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there
                // will be at least one available slot due to how the memory scratch space works.
                // We can safely overwrite whatever is stored in this slot as we will revert immediately after that.
                let start := sub(tokenAmounts, 0x20)
                mstore(start, bptAmount)

                // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb
                // We use the previous slot to `bptAmount`.
                mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb)
                start := sub(start, 0x04)

                // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return
                // the `bptAmount`, the array 's length, and the error signature.
                revert(start, add(size, 68))
            }
        }
    }
}

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

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

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

pragma solidity ^0.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);
}

File 14 of 36 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../helpers/BalancerErrors.sol";

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow checks.
 * Adapted from OpenZeppelin's SafeMath library
 */
library Math {
    /**
     * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        _require(c >= a, Errors.ADD_OVERFLOW);
        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW);
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        _require(b <= a, Errors.SUB_OVERFLOW);
        uint256 c = a - b;
        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW);
        return c;
    }

    /**
     * @dev Returns the largest of two numbers of 256 bits.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers of 256 bits.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a * b;
        _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW);
        return c;
    }

    function div(
        uint256 a,
        uint256 b,
        bool roundUp
    ) internal pure returns (uint256) {
        return roundUp ? divUp(a, b) : divDown(a, b);
    }

    function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
        _require(b != 0, Errors.ZERO_DIVISION);
        return a / b;
    }

    function divUp(uint256 a, uint256 b) internal pure returns (uint256) {
        _require(b != 0, Errors.ZERO_DIVISION);

        if (a == 0) {
            return 0;
        } else {
            return 1 + (a - 1) / b;
        }
    }
}

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

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

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

pragma solidity ^0.7.0;

import "./BalancerErrors.sol";
import "./ITemporarilyPausable.sol";

/**
 * @dev Allows for a contract to be paused during an initial period after deployment, disabling functionality. Can be
 * used as an emergency switch in case a security vulnerability or threat is identified.
 *
 * The contract can only be paused during the Pause Window, a period that starts at deployment. It can also be
 * unpaused and repaused any number of times during this period. This is intended to serve as a safety measure: it lets
 * system managers react quickly to potentially dangerous situations, knowing that this action is reversible if careful
 * analysis later determines there was a false alarm.
 *
 * If the contract is paused when the Pause Window finishes, it will remain in the paused state through an additional
 * Buffer Period, after which it will be automatically unpaused forever. This is to ensure there is always enough time
 * to react to an emergency, even if the threat is discovered shortly before the Pause Window expires.
 *
 * Note that since the contract can only be paused within the Pause Window, unpausing during the Buffer Period is
 * irreversible.
 */
abstract contract TemporarilyPausable is ITemporarilyPausable {
    // The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy.
    // solhint-disable not-rely-on-time

    uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days;
    uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days;

    uint256 private immutable _pauseWindowEndTime;
    uint256 private immutable _bufferPeriodEndTime;

    bool private _paused;

    constructor(uint256 pauseWindowDuration, uint256 bufferPeriodDuration) {
        _require(pauseWindowDuration <= _MAX_PAUSE_WINDOW_DURATION, Errors.MAX_PAUSE_WINDOW_DURATION);
        _require(bufferPeriodDuration <= _MAX_BUFFER_PERIOD_DURATION, Errors.MAX_BUFFER_PERIOD_DURATION);

        uint256 pauseWindowEndTime = block.timestamp + pauseWindowDuration;

        _pauseWindowEndTime = pauseWindowEndTime;
        _bufferPeriodEndTime = pauseWindowEndTime + bufferPeriodDuration;
    }

    /**
     * @dev Reverts if the contract is paused.
     */
    modifier whenNotPaused() {
        _ensureNotPaused();
        _;
    }

    /**
     * @dev Returns the current contract pause status, as well as the end times of the Pause Window and Buffer
     * Period.
     */
    function getPausedState()
        external
        view
        override
        returns (
            bool paused,
            uint256 pauseWindowEndTime,
            uint256 bufferPeriodEndTime
        )
    {
        paused = !_isNotPaused();
        pauseWindowEndTime = _getPauseWindowEndTime();
        bufferPeriodEndTime = _getBufferPeriodEndTime();
    }

    /**
     * @dev Sets the pause state to `paused`. The contract can only be paused until the end of the Pause Window, and
     * unpaused until the end of the Buffer Period.
     *
     * Once the Buffer Period expires, this function reverts unconditionally.
     */
    function _setPaused(bool paused) internal {
        if (paused) {
            _require(block.timestamp < _getPauseWindowEndTime(), Errors.PAUSE_WINDOW_EXPIRED);
        } else {
            _require(block.timestamp < _getBufferPeriodEndTime(), Errors.BUFFER_PERIOD_EXPIRED);
        }

        _paused = paused;
        emit PausedStateChanged(paused);
    }

    /**
     * @dev Reverts if the contract is paused.
     */
    function _ensureNotPaused() internal view {
        _require(_isNotPaused(), Errors.PAUSED);
    }

    /**
     * @dev Returns true if the contract is unpaused.
     *
     * Once the Buffer Period expires, the gas cost of calling this function is reduced dramatically, as storage is no
     * longer accessed.
     */
    function _isNotPaused() internal view returns (bool) {
        // After the Buffer Period, the (inexpensive) timestamp check short-circuits the storage access.
        return block.timestamp > _getBufferPeriodEndTime() || !_paused;
    }

    // These getters lead to reduced bytecode size by inlining the immutable variables in a single place.

    function _getPauseWindowEndTime() private view returns (uint256) {
        return _pauseWindowEndTime;
    }

    function _getBufferPeriodEndTime() private view returns (uint256) {
        return _bufferPeriodEndTime;
    }
}

File 16 of 36 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../helpers/BalancerErrors.sol";

import "./IERC20.sol";
import "./SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is IERC20 {
    using SafeMath for uint256;

    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

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

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view returns (uint8) {
        return _decimals;
    }

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(
            sender,
            msg.sender,
            _allowances[sender][msg.sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE)
        );
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(
            msg.sender,
            spender,
            _allowances[msg.sender][spender].sub(subtractedValue, Errors.ERC20_DECREASED_ALLOWANCE_BELOW_ZERO)
        );
        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_BALANCE);
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

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

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

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

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

        _balances[account] = _balances[account].sub(amount, Errors.ERC20_BURN_EXCEEDS_ALLOWANCE);
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

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

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

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

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

pragma 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
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./IVault.sol";
import "./IPoolSwapStructs.sol";

/**
 * @dev Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is not
 * the complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit from
 * either IGeneralPool or IMinimalSwapInfoPool
 */
interface IBasePool is IPoolSwapStructs {
    /**
     * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of
     * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault.
     * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect
     * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`.
     *
     * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join.
     *
     * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account
     * designated to receive any benefits (typically pool shares). `currentBalances` contains the total balances
     * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return.
     *
     * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total
     * balance.
     *
     * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of
     * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.)
     *
     * Contracts implementing this function should check that the caller is indeed the Vault before performing any
     * state-changing operations, such as minting pool shares.
     */
    function onJoinPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts);

    /**
     * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many
     * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes
     * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`,
     * as well as collect the reported amount in protocol fees, which the Pool should calculate based on
     * `protocolSwapFeePercentage`.
     *
     * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share.
     *
     * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account
     * to which the Vault will send the proceeds. `currentBalances` contains the total token balances for each token
     * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return.
     *
     * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total
     * balance.
     *
     * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of
     * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.)
     *
     * Contracts implementing this function should check that the caller is indeed the Vault before performing any
     * state-changing operations, such as burning pool shares.
     */
    function onExitPool(
        bytes32 poolId,
        address sender,
        address recipient,
        uint256[] memory balances,
        uint256 lastChangeBlock,
        uint256 protocolSwapFeePercentage,
        bytes memory userData
    ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts);

    function getPoolId() external view returns (bytes32);
}

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

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

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

pragma solidity ^0.7.0;

import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ERC20Permit.sol";

/**
 * @title Highly opinionated token implementation
 * @author Balancer Labs
 * @dev
 * - Includes functions to increase and decrease allowance as a workaround
 *   for the well-known issue with `approve`:
 *   https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not
 *   decreased by calls to transferFrom
 * - Lets a token holder use `transferFrom` to send their own tokens,
 *   without first setting allowance
 * - Emits 'Approval' events whenever allowance is changed by `transferFrom`
 */
contract BalancerPoolToken is ERC20, ERC20Permit {
    constructor(string memory tokenName, string memory tokenSymbol)
        ERC20(tokenName, tokenSymbol)
        ERC20Permit(tokenName)
    {
        // solhint-disable-previous-line no-empty-blocks
    }

    // Overrides

    /**
     * @dev Override to allow for 'infinite allowance' and let the token owner use `transferFrom` with no self-allowance
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public override returns (bool) {
        uint256 currentAllowance = allowance(sender, msg.sender);
        _require(msg.sender == sender || currentAllowance >= amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE);

        _transfer(sender, recipient, amount);

        if (msg.sender != sender && currentAllowance != uint256(-1)) {
            // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount
            _approve(sender, msg.sender, currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Override to allow decreasing allowance by more than the current amount (setting it to zero)
     */
    function decreaseAllowance(address spender, uint256 amount) public override returns (bool) {
        uint256 currentAllowance = allowance(msg.sender, spender);

        if (amount >= currentAllowance) {
            _approve(msg.sender, spender, 0);
        } else {
            // No risk of underflow due to if condition
            _approve(msg.sender, spender, currentAllowance - amount);
        }

        return true;
    }

    // Internal functions

    function _mintPoolTokens(address recipient, uint256 amount) internal {
        _mint(recipient, amount);
    }

    function _burnPoolTokens(address sender, uint256 amount) internal {
        _burn(sender, amount);
    }
}

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

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

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

pragma solidity ^0.7.0;

import "@balancer-labs/v2-solidity-utils/contracts/helpers/Authentication.sol";
import "@balancer-labs/v2-vault/contracts/interfaces/IAuthorizer.sol";

import "./BasePool.sol";

/**
 * @dev Base authorization layer implementation for Pools.
 *
 * The owner account can call some of the permissioned functions - access control of the rest is delegated to the
 * Authorizer. Note that this owner is immutable: more sophisticated permission schemes, such as multiple ownership,
 * granular roles, etc., could be built on top of this by making the owner a smart contract.
 *
 * Access control of all other permissioned functions is delegated to an Authorizer. It is also possible to delegate
 * control of *all* permissioned functions to the Authorizer by setting the owner address to `_DELEGATE_OWNER`.
 */
abstract contract BasePoolAuthorization is Authentication {
    address private immutable _owner;

    address private constant _DELEGATE_OWNER = 0xBA1BA1ba1BA1bA1bA1Ba1BA1ba1BA1bA1ba1ba1B;

    constructor(address owner) {
        _owner = owner;
    }

    function getOwner() public view returns (address) {
        return _owner;
    }

    function getAuthorizer() external view returns (IAuthorizer) {
        return _getAuthorizer();
    }

    function _canPerform(bytes32 actionId, address account) internal view override returns (bool) {
        if ((getOwner() != _DELEGATE_OWNER) && _isOwnerOnlyAction(actionId)) {
            // Only the owner can perform "owner only" actions, unless the owner is delegated.
            return msg.sender == getOwner();
        } else {
            // Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated.
            return _getAuthorizer().canPerform(actionId, account, address(this));
        }
    }

    function _isOwnerOnlyAction(bytes32 actionId) internal view virtual returns (bool);

    function _getAuthorizer() internal view virtual returns (IAuthorizer);
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol";

interface IAssetManager {
    /**
     * @notice Emitted when asset manager is rebalanced
     */
    event Rebalance(bytes32 poolId);

    /**
     * @notice Sets the config
     */
    function setConfig(bytes32 poolId, bytes calldata config) external;

    /**
     * @notice Returns the asset manager's token
     */
    function getToken() external view returns (IERC20);

    /**
     * @return the current assets under management of this asset manager
     */
    function getAUM(bytes32 poolId) external view returns (uint256);

    /**
     * @return poolCash - The up-to-date cash balance of the pool
     * @return poolManaged - The up-to-date managed balance of the pool
     */
    function getPoolBalances(bytes32 poolId) external view returns (uint256 poolCash, uint256 poolManaged);

    /**
     * @return The difference in tokens between the target investment
     * and the currently invested amount (i.e. the amount that can be invested)
     */
    function maxInvestableBalance(bytes32 poolId) external view returns (int256);

    /**
     * @notice Updates the Vault on the value of the pool's investment returns
     */
    function updateBalanceOfPool(bytes32 poolId) external;

    /**
     * @notice Determines whether the pool should rebalance given the provided balances
     */
    function shouldRebalance(uint256 cash, uint256 managed) external view returns (bool);

    /**
     * @notice Rebalances funds between the pool and the asset manager to maintain target investment percentage.
     * @param poolId - the poolId of the pool to be rebalanced
     * @param force - a boolean representing whether a rebalance should be forced even when the pool is near balance
     */
    function rebalance(bytes32 poolId, bool force) external;
}

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

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

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

pragma solidity ^0.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
        );
}

File 23 of 36 : SafeMath.sol
// 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;
    }
}

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

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

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

pragma solidity ^0.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);
}

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

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

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

pragma solidity ^0.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;
}

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

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

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

pragma solidity ^0.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
}

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

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

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

pragma solidity ^0.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);
}

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

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

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

pragma solidity ^0.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;
}

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

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

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

pragma solidity ^0.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);
}

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

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

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

pragma solidity ^0.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;
    }
}

File 31 of 36 : ERC20Permit.sol
// 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();
    }
}

File 32 of 36 : IERC20Permit.sol
// 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);
}

File 33 of 36 : EIP712.sol
// 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()
        }
    }
}

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

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

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

pragma solidity ^0.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);
}

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

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

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

pragma solidity ^0.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);
}

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

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

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

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./IBasePool.sol";

/**
 * @dev Pool contracts with the MinimalSwapInfo or TwoToken specialization settings should implement this interface.
 *
 * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool.
 * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will grant
 * to the pool in a 'given out' swap.
 *
 * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state
 * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is
 * indeed the Vault.
 */
interface IMinimalSwapInfoPool is IBasePool {
    function onSwap(
        SwapRequest memory swapRequest,
        uint256 currentBalanceTokenIn,
        uint256 currentBalanceTokenOut
    ) external returns (uint256 amount);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 9999
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IVault","name":"vault","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"amplificationParameter","type":"uint256"},{"internalType":"uint256","name":"swapFeePercentage","type":"uint256"},{"internalType":"uint256","name":"pauseWindowDuration","type":"uint256"},{"internalType":"uint256","name":"bufferPeriodDuration","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"startValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"AmpUpdateStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentValue","type":"uint256"}],"name":"AmpUpdateStopped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"PausedStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"swapFeePercentage","type":"uint256"}],"name":"SwapFeePercentageChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"getActionId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAmplificationParameter","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"isUpdating","type":"bool"},{"internalType":"uint256","name":"precision","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuthorizer","outputs":[{"internalType":"contract IAuthorizer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPausedState","outputs":[{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"uint256","name":"pauseWindowEndTime","type":"uint256"},{"internalType":"uint256","name":"bufferPeriodEndTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"onExitPool","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"onJoinPool","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IERC20","name":"tokenIn","type":"address"},{"internalType":"contract IERC20","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IPoolSwapStructs.SwapRequest","name":"swapRequest","type":"tuple"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"indexIn","type":"uint256"},{"internalType":"uint256","name":"indexOut","type":"uint256"}],"name":"onSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IERC20","name":"tokenIn","type":"address"},{"internalType":"contract IERC20","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IPoolSwapStructs.SwapRequest","name":"request","type":"tuple"},{"internalType":"uint256","name":"balanceTokenIn","type":"uint256"},{"internalType":"uint256","name":"balanceTokenOut","type":"uint256"}],"name":"onSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"queryExit","outputs":[{"internalType":"uint256","name":"bptIn","type":"uint256"},{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256","name":"lastChangeBlock","type":"uint256"},{"internalType":"uint256","name":"protocolSwapFeePercentage","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"queryJoin","outputs":[{"internalType":"uint256","name":"bptOut","type":"uint256"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bytes","name":"poolConfig","type":"bytes"}],"name":"setAssetManagerPoolConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"swapFeePercentage","type":"uint256"}],"name":"setSwapFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rawEndValue","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"startAmplificationParameterUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopAmplificationParameterUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

6103e06040527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9610120523480156200003757600080fd5b50604051620056cc380380620056cc8339810160408190526200005a9162000bf3565b8886516002146200006d57600062000070565b60025b8989898a516001600160401b03811180156200008b57600080fd5b50604051908082528060200260200182016040528015620000b6578160200160208202803683370190505b506040805180820190915260018152603160f81b602080830191909152336080526001600160601b031960608a901b1660a05285518c928c928c928c92859285928c928c92849283929183918691620001159160039185019062000a11565b5080516200012b90600490602084019062000a11565b50506005805460ff1916601217905550815160209283012060c052805191012060e05250507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61010052506200018a6276a70083111561019462000699565b6200019e62278d0082111561019562000699565b4290910161014081905201610160528551620001c0906002111560c862000699565b620001d860088751111560c96200069960201b60201c565b620001ee86620006ae60201b62000f831760201c565b620001f984620006ba565b6040516309b2760f60e01b81526000906001600160a01b038c16906309b2760f906200022a908d9060040162000d8f565b602060405180830381600087803b1580156200024557600080fd5b505af11580156200025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000280919062000bda565b604051633354e3e960e11b81529091506001600160a01b038c16906366a9c7d290620002b59084908b908b9060040162000cf3565b600060405180830381600087803b158015620002d057600080fd5b505af1158015620002e5573d6000803e3d6000fd5b505088516001600160601b031960608f901b16610180526101a08490526101c0819052915050806200031957600062000330565b876000815181106200032757fe5b60200260200101515b60601b6001600160601b0319166101e052600181116200035257600062000369565b876001815181106200036057fe5b60200260200101515b60601b6001600160601b03191661020052600281116200038b576000620003a2565b876002815181106200039957fe5b60200260200101515b60601b6001600160601b0319166102205260038111620003c4576000620003db565b87600381518110620003d257fe5b60200260200101515b60601b6001600160601b0319166102405260048111620003fd57600062000414565b876004815181106200040b57fe5b60200260200101515b60601b6001600160601b0319166102605260058111620004365760006200044d565b876005815181106200044457fe5b60200260200101515b60601b6001600160601b03191661028052600681116200046f57600062000486565b876006815181106200047d57fe5b60200260200101515b60601b6001600160601b0319166102a05260078111620004a8576000620004bf565b87600781518110620004b657fe5b60200260200101515b60601b6001600160601b0319166102c05280620004de57600062000504565b6200050488600081518110620004f057fe5b60200260200101516200072960201b60201c565b6102e05260018111620005195760006200052b565b6200052b88600181518110620004f057fe5b61030052600281116200054057600062000552565b6200055288600281518110620004f057fe5b61032052600381116200056757600062000579565b6200057988600381518110620004f057fe5b61034052600481116200058e576000620005a0565b620005a088600481518110620004f057fe5b6103605260058111620005b5576000620005c7565b620005c788600581518110620004f057fe5b6103805260068111620005dc576000620005ee565b620005ee88600681518110620004f057fe5b6103a052600781116200060357600062000615565b6200061588600781518110620004f057fe5b6103c05250508f516200063c9a5060051015985061012f9750506200069995505050505050565b6200064e600186101561012c62000699565b6200066161138886111561012d62000699565b60006200067c866103e8620007d560201b62000f8d1760201c565b9050620006898162000806565b5050505050505050505062000e11565b81620006aa57620006aa8162000845565b5050565b80620006aa8162000898565b620006cf64e8d4a5100082101560cb62000699565b620006e767016345785d8a000082111560ca62000699565b60088190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906200071e90839062000da4565b60405180910390a150565b600080826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200076657600080fd5b505afa1580156200077b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007a1919062000cd0565b60ff1690506000620007c06012836200092560201b62000fb11760201c565b600a0a670de0b6b3a764000002949350505050565b6000828202620007fd841580620007f5575083858381620007f257fe5b04145b600362000699565b90505b92915050565b62000814818042806200093d565b7fa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233816040516200071e919062000da4565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b600281511015620008a95762000922565b600081600081518110620008b957fe5b602002602001015190506000600190505b82518110156200091f576000838281518110620008e357fe5b6020026020010151905062000914816001600160a01b0316846001600160a01b03161060656200069960201b60201c565b9150600101620008ca565b50505b50565b60006200093783831115600162000699565b50900390565b6200095e816001600160401b031660c062000a0d60201b62000fc71760201c565b6200097f836001600160401b0316608062000a0d60201b62000fc71760201c565b620009a0856001600160401b0316604062000a0d60201b62000fc71760201c565b620009c1876001600160401b0316600062000a0d60201b62000fc71760201c565b1717176009556040517f1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf290620009ff90869086908690869062000dad565b60405180910390a150505050565b1b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1062000a5457805160ff191683800117855562000a84565b8280016001018555821562000a84579182015b8281111562000a8457825182559160200191906001019062000a67565b5062000a9292915062000a96565b5090565b5b8082111562000a92576000815560010162000a97565b8051620008008162000dfb565b600082601f83011262000acb578081fd5b81516001600160401b0381111562000ae1578182fd5b602080820262000af382820162000dc8565b8381529350818401858301828701840188101562000b1057600080fd5b600092505b8483101562000b4057805162000b2b8162000dfb565b82526001929092019190830190830162000b15565b505050505092915050565b600082601f83011262000b5c578081fd5b81516001600160401b0381111562000b72578182fd5b602062000b88601f8301601f1916820162000dc8565b9250818352848183860101111562000b9f57600080fd5b60005b8281101562000bbf57848101820151848201830152810162000ba2565b8281111562000bd15760008284860101525b50505092915050565b60006020828403121562000bec578081fd5b5051919050565b60008060008060008060008060006101208a8c03121562000c12578485fd5b62000c1e8b8b62000aad565b60208b01519099506001600160401b038082111562000c3b578687fd5b62000c498d838e0162000b4b565b995060408c015191508082111562000c5f578687fd5b62000c6d8d838e0162000b4b565b985060608c015191508082111562000c83578687fd5b5062000c928c828d0162000aba565b96505060808a0151945060a08a0151935060c08a0151925060e08a0151915062000cc18b6101008c0162000aad565b90509295985092959850929598565b60006020828403121562000ce2578081fd5b815160ff81168114620007fd578182fd5b60006060820185835260206060818501528186518084526080860191508288019350845b8181101562000d3f5762000d2c855162000def565b8352938301939183019160010162000d17565b505084810360408601528551808252908201925081860190845b8181101562000d815762000d6e835162000def565b8552938301939183019160010162000d59565b509298975050505050505050565b602081016003831062000d9e57fe5b91905290565b90815260200190565b93845260208401929092526040830152606082015260800190565b6040518181016001600160401b038111828210171562000de757600080fd5b604052919050565b6001600160a01b031690565b6001600160a01b03811681146200092257600080fd5b60805160a05160601c60c05160e051610100516101205161014051610160516101805160601c6101a0516101c0516101e05160601c6102005160601c6102205160601c6102405160601c6102605160601c6102805160601c6102a05160601c6102c05160601c6102e05161030051610320516103405161036051610380516103a0516103c05161475462000f786000398061124b528061221a52508061120852806121b95250806111c5528061215852508061118252806120f752508061113f52806120965250806110fc52806120355250806110b95280611fd45250806110685280611f735250806121df52508061217e52508061211d5250806120bc52508061205b525080611ffa525080611f99525080611f385280612b73525080610fcd5250806107b5525080610ae15250806114f15250806114cd525080610cf352508061174a52508061178c52508061176b525080610abd525080610a4752506147546000f3fe608060405234801561001057600080fd5b50600436106102265760003560e01c80636daccffa1161012a57806395d89b41116100bd578063aaabadc51161008c578063d5c096c411610071578063d5c096c41461046f578063dd62ed3e14610482578063eb0f24d61461049557610226565b8063aaabadc514610454578063d505accf1461045c57610226565b806395d89b41146104135780639d2c110c1461041b578063a457c2d71461042e578063a9059cbb1461044157610226565b8063851c1bb3116100f9578063851c1bb3146103d057806387ec6817146103e3578063893d20e8146103f65780638d928af81461040b57610226565b80636daccffa1461037257806370a082311461038957806374f3b0091461039c5780637ecebe00146103bd57610226565b8063313ce567116101bd578063395093511161018c57806355c676281161017157806355c67628146103415780636028bfd414610349578063679aefce1461036a57610226565b8063395093511461031b57806350dd6ed91461032e57610226565b8063313ce567146102e35780633644e515146102f857806338e9922e1461030057806338fff2d01461031357610226565b806318160ddd116101f957806318160ddd1461029e5780631c0de051146102a657806323b872dd146102bd5780632f1a0bc9146102d057610226565b806301ec954a1461022b57806306fdde0314610254578063095ea7b31461026957806316c38b3c14610289575b600080fd5b61023e6102393660046142d9565b61049d565b60405161024b9190614566565b60405180910390f35b61025c6104fc565b60405161024b919061463c565b61027c610277366004613f52565b6105b1565b60405161024b9190614543565b61029c610297366004614049565b6105c8565b005b61023e6105dc565b6102ae6105e2565b60405161024b9392919061454e565b61027c6102cb366004613e9d565b61060b565b61029c6102de3660046143ae565b61069f565b6102eb610782565b60405161024b9190614699565b61023e61078b565b61029c61030e366004614396565b61079a565b61023e6107b3565b61027c610329366004613f52565b6107d7565b61029c61033c366004614180565b610812565b61023e610830565b61035c610357366004614081565b610836565b60405161024b92919061464f565b61023e61086d565b61037a61094b565b60405161024b93929190614668565b61023e610397366004613e49565b610966565b6103af6103aa366004614081565b610985565b60405161024b92919061451e565b61023e6103cb366004613e49565b610a28565b61023e6103de366004614124565b610a43565b61035c6103f1366004614081565b610a95565b6103fe610abb565b60405161024b919061450a565b6103fe610adf565b61025c610b03565b61023e61042936600461434a565b610b82565b61027c61043c366004613f52565b610c69565b61027c61044f366004613f52565b610ca7565b6103fe610cb4565b61029c61046a366004613edd565b610cbe565b6103af61047d366004614081565b610e07565b61023e610490366004613e65565b610f2c565b61029c610f57565b60006104b183836104ac610fcb565b610fef565b60606104bb61100c565b90506000865160018111156104cc57fe5b146104e3576104de8686868685611289565b6104f0565b6104f08686868685611300565b9150505b949350505050565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b505050505090505b90565b60006105be338484611364565b5060015b92915050565b6105d06113cc565b6105d981611412565b50565b60025490565b60008060006105ef6114ae565b1592506105fa6114cb565b91506106046114ef565b9050909192565b6000806106188533610f2c565b905061063c336001600160a01b03871614806106345750838210155b61019e611513565b610647858585611521565b336001600160a01b0386161480159061068057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b15610692576106928533858403611364565b60019150505b9392505050565b6106a76113cc565b6106b7600183101561012c611513565b6106c861138883111561012d611513565b60006106d48242610fb1565b90506106e86201518082101561013d611513565b6000806106f3611601565b91509150610704811561013e611513565b6000610712866103e8610f8d565b905060008382116107415761073c61072d6201518086610f8d565b6107378488610f8d565b611675565b61075b565b61075b6107516201518084610f8d565b6107378688610f8d565b905061076d600282111561013f611513565b610779848342896116a8565b50505050505050565b60055460ff1690565b6000610795611746565b905090565b6107a26113cc565b6107aa6117e3565b6105d9816117f8565b7f000000000000000000000000000000000000000000000000000000000000000090565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105be91859061080d9086611856565b611364565b61081a6113cc565b6108226117e3565b61082c8282611868565b5050565b60085490565b6000606061084c8651610847610fcb565b611980565b6108618989898989898961198d611a31611a92565b97509795505050505050565b60006060610879610adf565b6001600160a01b031663f94d466861088f6107b3565b6040518263ffffffff1660e01b81526004016108ab9190614566565b60006040518083038186803b1580156108c357600080fd5b505afa1580156108d7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108ff9190810190613f7d565b50915050600061090d611601565b5090506109218261091c61100c565b611c22565b600061092f82846000611c83565b905061094361093c6105dc565b8290611e1f565b935050505090565b6000806000610958611601565b90949093506103e892509050565b6001600160a01b0381166000908152602081905260409020545b919050565b606080886109af610994610adf565b6001600160a01b0316336001600160a01b03161460cd611513565b6109c46109ba6107b3565b82146101f4611513565b60606109ce61100c565b90506109da8882611c22565b60006060806109ef8e8e8e8e8e8e8a8f61198d565b9250925092506109ff8d84611e70565b610a098285611a31565b610a138185611a31565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526006602052604090205490565b60007f000000000000000000000000000000000000000000000000000000000000000082604051602001610a78929190614494565b604051602081830303815290604052805190602001209050919050565b60006060610aa68651610847610fcb565b61086189898989898989611e7a611ed3611a92565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105a65780601f1061057b576101008083540402835291602001916105a6565b600080610b928560200151611f34565b90506000610ba38660400151611f34565b9050600086516001811115610bb457fe5b1415610c1a57610bc78660600151612249565b6060870152610bd6858361226d565b9450610be2848261226d565b9350610bf286606001518361226d565b60608701526000610c04878787612279565b9050610c1081836122bd565b9350505050610698565b610c24858361226d565b9450610c30848261226d565b9350610c4086606001518261226d565b60608701526000610c528787876122c9565b9050610c5e81846122f8565b9050610c1081612304565b600080610c763385610f2c565b9050808310610c9057610c8b33856000611364565b610c9d565b610c9d3385858403611364565b5060019392505050565b60006105be338484611521565b600061079561232d565b610ccc8442111560d1611513565b6001600160a01b0387166000908152600660209081526040808320549051909291610d23917f0000000000000000000000000000000000000000000000000000000000000000918c918c918c9188918d910161458e565b6040516020818303038152906040528051906020012090506000610d46826123a7565b9050600060018288888860405160008152602001604052604051610d6d949392919061461e565b6020604051602081039080840390855afa158015610d8f573d6000803e3d6000fd5b5050604051601f1901519150610dd190506001600160a01b03821615801590610dc957508b6001600160a01b0316826001600160a01b0316145b6101f8611513565b6001600160a01b038b166000908152600660205260409020600185019055610dfa8b8b8b611364565b5050505050505050505050565b60608088610e16610994610adf565b610e216109ba6107b3565b6060610e2b61100c565b9050610e356105dc565b610edc5760006060610e4a8d8d8d868b6123c3565b91509150610e5f620f424083101560cc611513565b610e6d6000620f4240612452565b610e7c8b620f42408403612452565b610e868184611ed3565b80610e8f610fcb565b67ffffffffffffffff81118015610ea557600080fd5b50604051908082528060200260200182016040528015610ecf578160200160208202803683370190505b5095509550505050610a1b565b610ee68882611c22565b6000606080610efb8e8e8e8e8e8e8a8f611e7a565b925092509250610f0b8c84612452565b610f158285611ed3565b610f1f8185611a31565b9095509350610a1b915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610f5f6113cc565b600080610f6a611601565b91509150610f7a81610140611513565b61082c8261245c565b8061082c81612497565b6000828202610698841580610faa575083858381610fa757fe5b04145b6003611513565b6000610fc1838311156001611513565b50900390565b1b90565b7f000000000000000000000000000000000000000000000000000000000000000090565b611007818410801561100057508183105b6064611513565b505050565b60606000611018610fcb565b905060608167ffffffffffffffff8111801561103357600080fd5b5060405190808252806020026020018201604052801561105d578160200160208202803683370190505b50905081156110a5577f00000000000000000000000000000000000000000000000000000000000000008160008151811061109457fe5b6020026020010181815250506110ae565b91506105ae9050565b60018211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816001815181106110e557fe5b60200260200101818152505060028211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160028151811061112857fe5b60200260200101818152505060038211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160038151811061116b57fe5b60200260200101818152505060048211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816004815181106111ae57fe5b60200260200101818152505060058211156110a5577f0000000000000000000000000000000000000000000000000000000000000000816005815181106111f157fe5b60200260200101818152505060068211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160068151811061123457fe5b60200260200101818152505060078211156110a5577f00000000000000000000000000000000000000000000000000000000000000008160078151811061127757fe5b60200260200101818152505091505090565b60006112958583611c22565b6112b686606001518385815181106112a957fe5b602002602001015161226d565b606087015260006112c987878787612510565b90506112e8818487815181106112db57fe5b60200260200101516122f8565b90506112f381612304565b9150505b95945050505050565b600061130f8660600151612249565b606087015261131e8583611c22565b61133286606001518386815181106112a957fe5b606087015260006113458787878761253a565b90506112f38184868151811061135757fe5b60200260200101516122bd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906113bf908590614566565b60405180910390a3505050565b60006113fb6000357fffffffff0000000000000000000000000000000000000000000000000000000016610a43565b90506105d961140a8233612564565b610191611513565b80156114325761142d6114236114cb565b4210610193611513565b611447565b61144761143d6114ef565b42106101a9611513565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be64906114a3908390614543565b60405180910390a150565b60006114b86114ef565b42118061079557505060075460ff161590565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b8161082c5761082c81612654565b6115386001600160a01b0384161515610198611513565b61154f6001600160a01b0383161515610199611513565b61155a838383611007565b6001600160a01b03831660009081526020819052604090205461158090826101a06126c1565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546115af9082611856565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906113bf908590614566565b6000806000806000806116126126d7565b93509350935093508042101561166557600194508383111561164957818103824203858503028161163f57fe5b0484019550611660565b818103824203848603028161165a57fe5b04840395505b61166d565b600094508295505b505050509091565b60006116848215156004611513565b82611691575060006105c2565b81600184038161169d57fe5b0460010190506105c2565b6116bd8167ffffffffffffffff1660c0610fc7565b6116d28367ffffffffffffffff166080610fc7565b6116e78567ffffffffffffffff166040610fc7565b6116fc8767ffffffffffffffff166000610fc7565b1717176009556040517f1835882ee7a34ac194f717a35e09bb1d24c82a3b9d854ab6c9749525b714cdf29061173890869086908690869061467e565b60405180910390a150505050565b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006117b361272e565b306040516020016117c89594939291906145c2565b60405160208183030381529060405280519060200120905090565b6117f66117ee6114ae565b610192611513565b565b61180b64e8d4a5100082101560cb611513565b61182167016345785d8a000082111560ca611513565b60088190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc906114a3908390614566565b60008282016106988482101583611513565b60006118726107b3565b9050600061187e610adf565b6001600160a01b031663b05f8e4883866040518363ffffffff1660e01b81526004016118ab929190614607565b60806040518083038186803b1580156118c357600080fd5b505afa1580156118d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fb91906143cf565b6040517f18e736d40000000000000000000000000000000000000000000000000000000081529094506001600160a01b03851693506318e736d492506119489150859087906004016145ee565b600060405180830381600087803b15801561196257600080fd5b505af1158015611976573d6000803e3d6000fd5b5050505050505050565b61082c8183146067611513565b600060608061199a6114ae565b156119bd576119a98887612732565b90506119b88882610fb161281f565b611a09565b6119c5610fcb565b67ffffffffffffffff811180156119db57600080fd5b50604051908082528060200260200182016040528015611a05578160200160208202803683370190505b5090505b611a1488868661288a565b9093509150611a2388836128f6565b985098509895505050505050565b60005b611a3c610fcb565b81101561100757611a73838281518110611a5257fe5b6020026020010151838381518110611a6657fe5b6020026020010151611e1f565b838281518110611a7f57fe5b6020908102919091010152600101611a34565b333014611b81576000306001600160a01b0316600036604051611ab69291906144c4565b6000604051808303816000865af19150503d8060008114611af3576040519150601f19603f3d011682016040523d82523d6000602084013e611af8565b606091505b505090508060008114611b0757fe5b60046000803e6000517fffffffff00000000000000000000000000000000000000000000000000000000167f43adbafb000000000000000000000000000000000000000000000000000000008114611b63573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6060611b8b61100c565b9050611b978782611c22565b60006060611baf8c8c8c8c8c8c898d8d63ffffffff16565b5091509150611bc281848663ffffffff16565b8051601f1982018390526343adbafb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08301526020027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82016044820181fd5b60005b611c2d610fcb565b81101561100757611c64838281518110611c4357fe5b6020026020010151838381518110611c5757fe5b6020026020010151612925565b838281518110611c7057fe5b6020908102919091010152600101611c25565b81516000908190815b81811015611cc457611cba868281518110611ca357fe5b60200260200101518461185690919063ffffffff16565b9250600101611c8c565b5081611cd557600092505050610698565b600082878302825b60ff811015611e07576000858a600081518110611cf657fe5b60200260200101510290506000600190505b86811015611d4a57611d40611d39611d33848e8581518110611d2657fe5b6020026020010151610f8d565b89610f8d565b868c612951565b9150600101611d08565b50839450611dbd611d8c611d73611d6a611d64878c610f8d565b85610f8d565b6103e88d612951565b611d86611d808a89610f8d565b88610f8d565b90611856565b611db7611daa611da06103e8880386610f8d565b6103e88e15612951565b611d868a60010189610f8d565b8b612951565b935084841115611de557600185850311611de05783975050505050505050610698565b611dfe565b600184860311611dfe5783975050505050505050610698565b50600101611cdd565b50611e13610142612654565b50505050509392505050565b6000611e2e8215156004611513565b82611e3b575060006105c2565b670de0b6b3a764000083810290611e5e90858381611e5557fe5b04146005611513565b828181611e6757fe5b049150506105c2565b61082c8282612971565b6000606080611e876117e3565b6060611e938988612732565b9050611ea28982610fb161281f565b60006060611eb18b8989612a2d565b91509150611ebf8b82612a86565b909d909c50909a5098505050505050505050565b60005b611ede610fcb565b81101561100757611f15838281518110611ef457fe5b6020026020010151838381518110611f0857fe5b6020026020010151612a93565b838281518110611f2157fe5b6020908102919091010152600101611ed6565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611f9757507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611ff857507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561205957507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156120ba57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561211b57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561217c57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156121dd57507f0000000000000000000000000000000000000000000000000000000000000000610980565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561223e57507f0000000000000000000000000000000000000000000000000000000000000000610980565b610980610135612654565b60008061226160085484612ae190919063ffffffff16565b90506106988382610fb1565b60006106988383612925565b6000612290612286610fcb565b60021460d2611513565b60606000806122a0878787612b3b565b9250925092506122b28784848461253a565b979650505050505050565b60006106988383611e1f565b60006122d6612286610fcb565b60606000806122e6878787612b3b565b9250925092506122b287848484612510565b60006106988383612a93565b60006105c2612326600854670de0b6b3a7640000610fb190919063ffffffff16565b8390612a93565b6000612337610adf565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b15801561236f57600080fd5b505afa158015612383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107959190614164565b60006123b1611746565b82604051602001610a789291906144d4565b600060606123cf6117e3565b60006123da84612c28565b90506123f560008260028111156123ed57fe5b1460ce611513565b606061240085612c3e565b905061240f8151610847610fcb565b6124198187611c22565b6000612423611601565b509050600061243482846001611c83565b9050806124418184612c54565b9b929a509198505050505050505050565b61082c8282612c5f565b612468818242426116a8565b7fa0d01593e47e69d07e0ccd87bece09411e07dd1ed40ca8f2e7af2976542a0233816040516114a39190614566565b6002815110156124a6576105d9565b6000816000815181106124b557fe5b602002602001015190506000600190505b82518110156110075760008382815181106124dd57fe5b60200260200101519050612506816001600160a01b0316846001600160a01b0316106065611513565b91506001016124c6565b600061251a6117e3565b6000612524611601565b50905060006122b2828787878b60600151612ced565b60006125446117e3565b600061254e611601565b50905060006122b2828787878b60600151612db1565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b612583610abb565b6001600160a01b03161415801561259e575061259e83612e59565b156125c6576125ab610abb565b6001600160a01b0316336001600160a01b03161490506105c2565b6125ce61232d565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b81526004016125fd9392919061456f565b60206040518083038186803b15801561261557600080fd5b505afa158015612629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264d9190614065565b90506105c2565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60006126d08484111583611513565b5050900390565b6000806000806126f36000600954612ec790919063ffffffff16565b600954909450612704906040612ec7565b600954909350612715906080612ec7565b6009549092506127269060c0612ec7565b905090919293565b4690565b60608061273d610fcb565b67ffffffffffffffff8111801561275357600080fd5b5060405190808252806020026020018201604052801561277d578160200160208202803683370190505b5090508261278c5790506105c2565b6000808560008151811061279c57fe5b602002602001015190506000600190505b6127b5610fcb565b8110156127ec5760008782815181106127ca57fe5b60200260200101519050828111156127e3578193508092505b506001016127ad565b506127fe600b5487600a548589612ed5565b83838151811061280a57fe5b60209081029190910101525090949350505050565b60005b61282a610fcb565b8110156128845761286584828151811061284057fe5b602002602001015184838151811061285457fe5b60200260200101518463ffffffff16565b84828151811061287157fe5b6020908102919091010152600101612822565b50505050565b60006060600061289984612c28565b905060008160028111156128a957fe5b14156128c3576128b98685612f49565b92509250506128ee565b60018160028111156128d157fe5b14156128e1576128b9868561300f565b6128b9868686613041565b505b935093915050565b6129038282610fb161281f565b600061290d611601565b50905061100761291f82856001611c83565b82612c54565b600082820261293f841580610faa575083858381610fa757fe5b670de0b6b3a764000090049392505050565b6000816129675761296284846130b8565b6104f4565b6104f48484611675565b6129886001600160a01b038316151561019b611513565b61299482600083611007565b6001600160a01b0382166000908152602081905260409020546129ba90826101a16126c1565b6001600160a01b0383166000908152602081905260409020556002546129e090826130d8565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b60405180910390a35050565b600060606000612a3c84612c28565b90506001816002811115612a4c57fe5b1415612a5d576128b98686866130e6565b6002816002811115612a6b57fe5b1415612a7b576128b9868561314b565b6128ec610136612654565b612903828261185661281f565b6000612aa28215156004611513565b82612aaf575060006105c2565b670de0b6b3a764000083810290612ac990858381611e5557fe5b826001820381612ad557fe5b046001019150506105c2565b6000828202612afb841580610faa575083858381610fa757fe5b80612b0a5760009150506105c2565b670de0b6b3a76400007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201612ad5565b6040805160028082526060828101909352600091829181602001602082028036833701905050925085602001516001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161415612be25760009150600190508483600081518110612bb757fe5b6020026020010181815250508383600181518110612bd157fe5b602002602001018181525050612c1f565b60009050600191508383600081518110612bf857fe5b6020026020010181815250508483600181518110612c1257fe5b6020026020010181815250505b93509350939050565b6000818060200190518101906105c291906141ce565b6060818060200190518101906106989190614294565b600a91909155600b55565b612c6b60008383611007565b600254612c789082611856565b6002556001600160a01b038216600090815260208190526040902054612c9e9082611856565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a21908590614566565b600080612cfc87876001611c83565b9050612d2483878681518110612d0e57fe5b6020026020010151610fb190919063ffffffff16565b868581518110612d3057fe5b6020026020010181815250506000612d4a888884896131db565b905083878681518110612d5957fe5b602002602001015101878681518110612d6e57fe5b602002602001018181525050612da56001611d86898981518110612d8e57fe5b602002602001015184610fb190919063ffffffff16565b98975050505050505050565b600080612dc087876001611c83565b9050612de883878781518110612dd257fe5b602002602001015161185690919063ffffffff16565b868681518110612df457fe5b6020026020010181815250506000612e0e888884886131db565b905083878781518110612e1d57fe5b602002602001015103878781518110612e3257fe5b602002602001018181525050612da56001612e53838a8981518110612d0e57fe5b90610fb1565b6000612e847f2f1a0bc900000000000000000000000000000000000000000000000000000000610a43565b821480612eb85750612eb57feb0f24d600000000000000000000000000000000000000000000000000000000610a43565b82145b806105c257506105c28261338b565b1c67ffffffffffffffff1690565b600080612ee4878787876131db565b905080868581518110612ef357fe5b602002602001015111612f0a5760009150506112f7565b600081878681518110612f1957fe5b6020026020010151039050612da5670de0b6b3a7640000612f43868461292590919063ffffffff16565b90611e1f565b60006060612f556117e3565b600080612f61856133ef565b91509150612f79612f70610fcb565b82106064611513565b6060612f83610fcb565b67ffffffffffffffff81118015612f9957600080fd5b50604051908082528060200260200182016040528015612fc3578160200160208202803683370190505b5090506000612fd0611601565b509050612fea81898587612fe26105dc565b600854613411565b828481518110612ff657fe5b6020908102919091010152509196919550909350505050565b60006060600061301e8461352d565b90506060613034868361302f6105dc565b613543565b9196919550909350505050565b6000606061304d6117e3565b6060600061305a856135f5565b9150915061306b8251610847610fcb565b6130758287611c22565b600061307f611601565b509050600061309a828a866130926105dc565b60085461360d565b90506130aa8382111560cf611513565b989297509195505050505050565b60006130c78215156004611513565b8183816130d057fe5b049392505050565b6000610698838360016126c1565b600060608060006130f6856135f5565b9150915061310c613105610fcb565b8351611980565b6131168287611c22565b6000613120611601565b509050600061313b828a866131336105dc565b6008546138a3565b90506130aa8382101560d0611513565b6000606060008061315b856133ef565b9150915061316a612f70610fcb565b6060613174610fcb565b67ffffffffffffffff8111801561318a57600080fd5b506040519080825280602002602001820160405280156131b4578160200160208202803683370190505b50905060006131c1611601565b509050612fea818985876131d36105dc565b600854613b32565b6000808451860290506000856000815181106131f357fe5b60200260200101519050600086518760008151811061320e57fe5b60200260200101510290506000600190505b87518110156132675761324c61324661323f848b8581518110611d2657fe5b8a51610f8d565b886130b8565b915061325d888281518110611ca357fe5b9250600101613220565b5086858151811061327457fe5b602002602001015182039150600061328c8788610f8d565b905060006132b86132ac6132a4846107378988610f8d565b6103e8610f8d565b8a8981518110611d2657fe5b905060006132d36132cc6132a48b896130b8565b8690611856565b90506000806132ef6132e58686611856565b6107378d86611856565b905060005b60ff81101561336f5781925061332461331186611d868586610f8d565b6107378e612e5388611d86886002610f8d565b91508282111561334d57600183830311613348575097506104f49650505050505050565b613367565b600182840311613367575097506104f49650505050505050565b6001016132f4565b5061337b610142612654565b5050505050505050949350505050565b60006133b67f38e9922e00000000000000000000000000000000000000000000000000000000610a43565b8214806105c257506133e77f50dd6ed900000000000000000000000000000000000000000000000000000000610a43565b909114919050565b60008082806020019051810190613406919061425e565b909590945092505050565b60008061342088886001611c83565b905060006134428261343c87613436818b610fb1565b90612a93565b90612ae1565b905060006134528a8a848b6131db565b90506000613466828b8b81518110612d0e57fe5b90506000805b8b518110156134a55761349b8c828151811061348457fe5b60200260200101518361185690919063ffffffff16565b915060010161346c565b5060006134ce828d8d815181106134b857fe5b6020026020010151611e1f90919063ffffffff16565b905060006134db82613c0f565b905060006134e98583612ae1565b905060006134f78683610fb1565b905061351861351183670de0b6b3a76400008e9003612925565b8290611856565b99505050505050505050509695505050505050565b6000818060200190518101906106989190614231565b606060006135518484611e1f565b90506060855167ffffffffffffffff8111801561356d57600080fd5b50604051908082528060200260200182016040528015613597578160200160208202803683370190505b50905060005b86518110156135eb576135cc838883815181106135b657fe5b602002602001015161292590919063ffffffff16565b8282815181106135d857fe5b602090810291909101015260010161359d565b5095945050505050565b606060008280602001905181019061340691906141ea565b600080805b86518110156136345761362a87828151811061348457fe5b9150600101613612565b506060855167ffffffffffffffff8111801561364f57600080fd5b50604051908082528060200260200182016040528015613679578160200160208202803683370190505b5090506000805b88518110156137405760006136b1858b848151811061369b57fe5b6020026020010151612a9390919063ffffffff16565b90506136ed8a83815181106136c257fe5b60200260200101516134368b85815181106136d957fe5b60200260200101518d8681518110612d0e57fe5b8483815181106136f957fe5b60200260200101818152505061373561372e8286858151811061371857fe5b6020026020010151612ae190919063ffffffff16565b8490611856565b925050600101613680565b506060885167ffffffffffffffff8111801561375b57600080fd5b50604051908082528060200260200182016040528015613785578160200160208202803683370190505b50905060005b89518110156138505760008482815181106137a257fe5b60200260200101518411156138095760006137cb6137bf86613c0f565b8d85815181106135b657fe5b905060006137df828d8681518110612d0e57fe5b90506138006137f982670de0b6b3a76400008d9003612a93565b8390611856565b92505050613820565b89828151811061381557fe5b602002602001015190505b613830818c8481518110612d0e57fe5b83838151811061383c57fe5b60209081029190910101525060010161378b565b50600061385f8b8b6001611c83565b9050600061386f8c846000611c83565b9050600061387d8284611e1f565b905061389261388b82613c0f565b8b90612ae1565b9d9c50505050505050505050505050565b600080805b86518110156138ca576138c087828151811061348457fe5b91506001016138a8565b506060855167ffffffffffffffff811180156138e557600080fd5b5060405190808252806020026020018201604052801561390f578160200160208202803683370190505b5090506000805b88518110156139a3576000613931858b84815181106134b857fe5b905061396d8a838151811061394257fe5b6020026020010151612f438b858151811061395957fe5b60200260200101518d8681518110612dd257fe5b84838151811061397957fe5b60200260200101818152505061399861372e828685815181106135b657fe5b925050600101613916565b506060885167ffffffffffffffff811180156139be57600080fd5b506040519080825280602002602001820160405280156139e8578160200160208202803683370190505b50905060005b8951811015613aa957600083858381518110613a0657fe5b60200260200101511115613a62576000613a2b6137bf86670de0b6b3a7640000610fb1565b90506000613a3f828d8681518110612d0e57fe5b9050613a596137f982670de0b6b3a76400008d9003612925565b92505050613a79565b898281518110613a6e57fe5b602002602001015190505b613a89818c8481518110612dd257fe5b838381518110613a9557fe5b6020908102919091010152506001016139ee565b506000613ab88b8b6001611c83565b90506000613ac88c846000611c83565b90506000613ad68284611e1f565b9050670de0b6b3a7640000811115613b2257613b148a7ffffffffffffffffffffffffffffffffffffffffffffffffff21f494c589c00008301612925565b9750505050505050506112f7565b60009750505050505050506112f7565b600080613b4188886001611c83565b90506000613b578261343c87613436818b611856565b90506000613b678a8a848b6131db565b90506000613b918a8a81518110613b7a57fe5b602002602001015183610fb190919063ffffffff16565b90506000805b8b51811015613bb957613baf8c828151811061348457fe5b9150600101613b97565b506000613bcc828d8d815181106134b857fe5b90506000613bd982613c0f565b90506000613be78583612ae1565b90506000613bf58683610fb1565b905061351861351183670de0b6b3a76400008e9003612a93565b6000670de0b6b3a76400008210613c275760006105c2565b50670de0b6b3a76400000390565b80356105c2816146ee565b600082601f830112613c50578081fd5b8135613c63613c5e826146ce565b6146a7565b818152915060208083019084810181840286018201871015613c8457600080fd5b60005b84811015613ca357813584529282019290820190600101613c87565b505050505092915050565b600082601f830112613cbe578081fd5b8151613ccc613c5e826146ce565b818152915060208083019084810181840286018201871015613ced57600080fd5b60005b84811015613ca357815184529282019290820190600101613cf0565b600082601f830112613d1c578081fd5b813567ffffffffffffffff811115613d32578182fd5b613d456020601f19601f840116016146a7565b9150808252836020828501011115613d5c57600080fd5b8060208401602084013760009082016020015292915050565b8035600281106105c257600080fd5b6000610120808385031215613d97578182fd5b613da0816146a7565b915050613dad8383613d75565b8152613dbc8360208401613c35565b6020820152613dce8360408401613c35565b6040820152606082013560608201526080820135608082015260a082013560a0820152613dfe8360c08401613c35565b60c0820152613e108360e08401613c35565b60e08201526101008083013567ffffffffffffffff811115613e3157600080fd5b613e3d85828601613d0c565b82840152505092915050565b600060208284031215613e5a578081fd5b8135610698816146ee565b60008060408385031215613e77578081fd5b8235613e82816146ee565b91506020830135613e92816146ee565b809150509250929050565b600080600060608486031215613eb1578081fd5b8335613ebc816146ee565b92506020840135613ecc816146ee565b929592945050506040919091013590565b600080600080600080600060e0888a031215613ef7578283fd5b8735613f02816146ee565b96506020880135613f12816146ee565b95506040880135945060608801359350608088013560ff81168114613f35578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613f64578182fd5b8235613f6f816146ee565b946020939093013593505050565b600080600060608486031215613f91578081fd5b835167ffffffffffffffff80821115613fa8578283fd5b818601915086601f830112613fbb578283fd5b8151613fc9613c5e826146ce565b80828252602080830192508086018b828387028901011115613fe9578788fd5b8796505b84871015614014578051614000816146ee565b845260019690960195928101928101613fed565b50890151909750935050508082111561402b578283fd5b5061403886828701613cae565b925050604084015190509250925092565b60006020828403121561405a578081fd5b813561069881614703565b600060208284031215614076578081fd5b815161069881614703565b600080600080600080600060e0888a03121561409b578081fd5b8735965060208801356140ad816146ee565b955060408801356140bd816146ee565b9450606088013567ffffffffffffffff808211156140d9578283fd5b6140e58b838c01613c40565b955060808a0135945060a08a0135935060c08a0135915080821115614108578283fd5b506141158a828b01613d0c565b91505092959891949750929550565b600060208284031215614135578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610698578182fd5b600060208284031215614175578081fd5b8151610698816146ee565b60008060408385031215614192578182fd5b823561419d816146ee565b9150602083013567ffffffffffffffff8111156141b8578182fd5b6141c485828601613d0c565b9150509250929050565b6000602082840312156141df578081fd5b815161069881614711565b6000806000606084860312156141fe578081fd5b835161420981614711565b602085015190935067ffffffffffffffff811115614225578182fd5b61403886828701613cae565b60008060408385031215614243578182fd5b825161424e81614711565b6020939093015192949293505050565b600080600060608486031215614272578081fd5b835161427d81614711565b602085015160409095015190969495509392505050565b600080604083850312156142a6578182fd5b82516142b181614711565b602084015190925067ffffffffffffffff8111156142cd578182fd5b6141c485828601613cae565b600080600080608085870312156142ee578182fd5b843567ffffffffffffffff80821115614305578384fd5b61431188838901613d84565b95506020870135915080821115614326578384fd5b5061433387828801613c40565b949794965050505060408301359260600135919050565b60008060006060848603121561435e578081fd5b833567ffffffffffffffff811115614374578182fd5b61438086828701613d84565b9660208601359650604090950135949350505050565b6000602082840312156143a7578081fd5b5035919050565b600080604083850312156143c0578182fd5b50508035926020909101359150565b600080600080608085870312156143e4578182fd5b8451935060208501519250604085015191506060850151614404816146ee565b939692955090935050565b6000815180845260208085019450808401835b8381101561443e57815187529582019590820190600101614422565b509495945050505050565b60008151808452815b8181101561446e57602081850181015186830182015201614452565b8181111561447f5782602083870101525b50601f01601f19169290920160200192915050565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6000828483379101908152919050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b600060408252614531604083018561440f565b82810360208401526112f7818561440f565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6000838252604060208301526104f46040830184614449565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526106986020830184614449565b6000838252604060208301526104f4604083018461440f565b9283529015156020830152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156146c657600080fd5b604052919050565b600067ffffffffffffffff8211156146e4578081fd5b5060209081020190565b6001600160a01b03811681146105d957600080fd5b80151581146105d957600080fd5b600381106105d957600080fdfea264697066735822122074699730ea8aa4fa00d2702d985bebe2cf30c6abf09e7ee52a1750d232c882ff64736f6c6343000701003300000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776000000000000000000000000000000000000000000000000000000000000001641204461692d61626f6c6963616c2042616c616e636500000000000000000000000000000000000000000000000000000000000000000000000000000000000c4250545f555344422d444149000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006fc9383486c163fa48becdec79d6058f984f62ca0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e

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

00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776000000000000000000000000000000000000000000000000000000000000001641204461692d61626f6c6963616c2042616c616e636500000000000000000000000000000000000000000000000000000000000000000000000000000000000c4250545f555344422d444149000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006fc9383486c163fa48becdec79d6058f984f62ca0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e

-----Decoded View---------------
Arg [0] : vault (address): 0x20dd72ed959b6147912c2e529f0a0c651c33c9ce
Arg [1] : name (string): A Dai-abolical Balance
Arg [2] : symbol (string): BPT_USDB-DAI
Arg [3] : tokens (address[]): 0x6fc9383486c163fa48becdec79d6058f984f62ca,0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e
Arg [4] : amplificationParameter (uint256): 10
Arg [5] : swapFeePercentage (uint256): 1000000000000000
Arg [6] : pauseWindowDuration (uint256): 0
Arg [7] : bufferPeriodDuration (uint256): 0
Arg [8] : owner (address): 0xcd983793adb846dce4830c22f30c7ef0c864a776

-----Encoded View---------------
16 Constructor Arguments found :
Arg [0] : 00000000000000000000000020dd72ed959b6147912c2e529f0a0c651c33c9ce
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [3] : 00000000000000000000000000000000000000000000000000000000000001a0
Arg [4] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [5] : 00000000000000000000000000000000000000000000000000038d7ea4c68000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 000000000000000000000000cd983793adb846dce4830c22f30c7ef0c864a776
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000016
Arg [10] : 41204461692d61626f6c6963616c2042616c616e636500000000000000000000
Arg [11] : 000000000000000000000000000000000000000000000000000000000000000c
Arg [12] : 4250545f555344422d4441490000000000000000000000000000000000000000
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [14] : 0000000000000000000000006fc9383486c163fa48becdec79d6058f984f62ca
Arg [15] : 0000000000000000000000008d11ec38a3eb5e956b052f67da8bdc9bef8abf3e


Deployed ByteCode Sourcemap

1191:26372:34:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1273:582:2;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2138:81:19;;;:::i;:::-;;;;;;;:::i;4172:164::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;9312:89:4:-;;;;;;:::i;:::-;;:::i;:::-;;3181:98:19;;;:::i;3154:363:12:-;;;:::i;:::-;;;;;;;;;:::i;1872:655:1:-;;;;;;:::i;:::-;;:::i;22837:1268:34:-;;;;;;:::i;:::-;;:::i;3040:81:19:-;;;:::i;:::-;;;;;;;:::i;2359:113:20:-;;;:::i;8265:156:4:-;;;;;;:::i;:::-;;:::i;7955:91::-;;;:::i;5584:211:19:-;;;;;;:::i;:::-;;:::i;8807:214:4:-;;;;;;:::i;:::-;;:::i;8153:106::-;;;:::i;15577:904::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;21792:589:34:-;;;:::i;24840:288::-;;;:::i;:::-;;;;;;;;;:::i;3337:117:19:-;;;;;;:::i;:::-;;:::i;12202:1197:4:-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;2127:108:20:-;;;;;;:::i;:::-;;:::i;2487:430:6:-;;;;;;:::i;:::-;;:::i;14052:902:4:-;;;;;;:::i;:::-;;:::i;1776:80:5:-;;;:::i;:::-;;;;;;;:::i;7870:79:4:-;;;:::i;2332:85:19:-;;;:::i;1329:1781:3:-;;;;;;:::i;:::-;;:::i;2653:429:1:-;;;;;;:::i;:::-;;:::i;3657:170:19:-;;;;;;:::i;:::-;;:::i;1862:101:5:-;;;:::i;1313:753:20:-;;;;;;:::i;:::-;;:::i;9912:2284:4:-;;;;;;:::i;:::-;;:::i;3885:149:19:-;;;;;;:::i;:::-;;:::i;24216:259:34:-;;;:::i;1273:582:2:-;1461:7;1480:54;1497:7;1506:8;1516:17;:15;:17::i;:::-;1480:16;:54::i;:::-;1544:31;1578:17;:15;:17::i;:::-;1544:51;-1:-1:-1;1645:24:2;1625:16;;:44;;;;;;;;;:223;;1777:71;1791:11;1804:8;1814:7;1823:8;1833:14;1777:13;:71::i;:::-;1625:223;;;1688:70;1701:11;1714:8;1724:7;1733:8;1743:14;1688:12;:70::i;:::-;1606:242;;;1273:582;;;;;;;:::o;2138:81:19:-;2207:5;2200:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2175:13;;2200:12;;2207:5;;2200:12;;2207:5;2200:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2138:81;;:::o;4172:164::-;4255:4;4271:37;4280:10;4292:7;4301:6;4271:8;:37::i;:::-;-1:-1:-1;4325:4:19;4172:164;;;;;:::o;9312:89:4:-;2156:21:6;:19;:21::i;:::-;9376:18:4::1;9387:6;9376:10;:18::i;:::-;9312:89:::0;:::o;3181:98:19:-;3260:12;;3181:98;:::o;3154:363:12:-;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;1872:655:1:-;2000:4;2016:24;2043:29;2053:6;2061:10;2043:9;:29::i;:::-;2016:56;-1:-1:-1;2082:101:1;2091:10;-1:-1:-1;;;;;2091:20:1;;;;:50;;;2135:6;2115:16;:26;;2091:50;8108:3:7;2082:8:1;:101::i;:::-;2194:36;2204:6;2212:9;2223:6;2194:9;:36::i;:::-;2245:10;-1:-1:-1;;;;;2245:20:1;;;;;;:55;;;2297:2;2269:16;:31;;2245:55;2241:258;;;2433:55;2442:6;2450:10;2481:6;2462:16;:25;2433:8;:55::i;:::-;2516:4;2509:11;;;1872:655;;;;;;:::o;22837:1268:34:-;2156:21:6;:19;:21::i;:::-;22950:49:34::1;1158:1:33;22959:11:34;:23;;5717:3:7;22950:8:34;:49::i;:::-;23009;1202:4:33;23018:11:34;:23;;5762:3:7;23009:8:34;:49::i;:::-;23069:16;23088:34;23097:7;23106:15;23088:8;:34::i;:::-;23069:53;;23132:69;2212:6;23141:8;:28;;6670:3:7;23132:8:34;:69::i;:::-;23213:20;23235:15:::0;23254:28:::1;:26;:28::i;:::-;23212:70;;;;23292:48;23302:10;23301:11;6726:3:7;23292:8:34;:48::i;:::-;23351:16;23370:37;23379:11;1255:3:33;23370:8:34;:37::i;:::-;23351:56;;23714:17;23745:12;23734:8;:23;:197;;23859:72;23870:30;23879:6;23887:12;23870:8;:30::i;:::-;23902:28;23911:8;23921;23902;:28::i;:::-;23859:10;:72::i;:::-;23734:197;;;23772:72;23783:26;23792:6;23800:8;23783;:26::i;:::-;23811:32;23820:12;23834:8;23811;:32::i;23772:72::-;23714:217;;23941:75;2278:1;23950:9;:39;;6781:3:7;23941:8:34;:75::i;:::-;24027:71;24049:12;24063:8;24073:15;24090:7;24027:21;:71::i;:::-;2187:1:6;;;;;22837:1268:34::0;;:::o;3040:81:19:-;3105:9;;;;3040:81;:::o;2359:113:20:-;2419:7;2445:20;:18;:20::i;:::-;2438:27;;2359:113;:::o;8265:156:4:-;2156:21:6;:19;:21::i;:::-;2970:18:12::1;:16;:18::i;:::-;8374:40:4::2;8396:17;8374:21;:40::i;7955:91::-:0;8032:7;7955:91;:::o;5584:211:19:-;5697:10;5672:4;5718:23;;;:11;:23;;;;;;;;-1:-1:-1;;;;;5718:32:19;;;;;;;;;;5672:4;;5688:79;;5709:7;;5718:48;;5755:10;5718:36;:48::i;:::-;5688:8;:79::i;8807:214:4:-;2156:21:6;:19;:21::i;:::-;2970:18:12::1;:16;:18::i;:::-;8969:45:4::2;8996:5;9003:10;8969:26;:45::i;:::-;8807:214:::0;;:::o;8153:106::-;8234:18;;8153:106;:::o;15577:904::-;15837:13;15852:27;15891:71;15927:8;:15;15944:17;:15;:17::i;:::-;15891:35;:71::i;:::-;15973:255;15999:6;16019;16039:9;16062:8;16084:15;16113:25;16152:8;16174:11;16199:19;15973:12;:255::i;:::-;15577:904;;;;;;;;;;:::o;21792:589:34:-;21832:7;21854:25;21885:10;:8;:10::i;:::-;-1:-1:-1;;;;;21885:24:34;;21910:11;:9;:11::i;:::-;21885:37;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;21885:37:34;;;;;;;;;;;;:::i;:::-;21851:71;;;;22130:18;22154:28;:26;:28::i;:::-;22129:53;;;22193:42;22207:8;22217:17;:15;:17::i;:::-;22193:13;:42::i;:::-;22246:17;22266:59;22297:10;22309:8;22319:5;22266:30;:59::i;:::-;22246:79;;22342:32;22360:13;:11;:13::i;:::-;22342:9;;:17;:32::i;:::-;22335:39;;;;;21792:589;:::o;24840:288::-;24937:13;24964:15;24993:17;25057:28;:26;:28::i;:::-;25035:50;;;;-1:-1:-1;1255:3:33;;-1:-1:-1;24840:288:34;-1:-1:-1;24840:288:34:o;3337:117:19:-;-1:-1:-1;;;;;3429:18:19;;3403:7;3429:18;;;;;;;;;;;3337:117;;;;:::o;12202:1197:4:-;12496:16;12514;12479:6;9755:68;9786:10;:8;:10::i;:::-;-1:-1:-1;;;;;9764:33:4;:10;-1:-1:-1;;;;;9764:33:4;;5392:3:7;9755:8:4;:68::i;:::-;9833:55;9852:11;:9;:11::i;:::-;9842:6;:21;9058:3:7;9833:8:4;:55::i;:::-;12542:31:::1;12576:17;:15;:17::i;:::-;12542:51;;12603:39;12617:8;12627:14;12603:13;:39::i;:::-;12654:19;12675:27;12704:38:::0;12746:224:::1;12771:6;12791;12811:9;12834:8;12856:15;12885:25;12924:14;12952:8;12746:11;:224::i;:::-;12653:317;;;;;;13076:36;13092:6;13100:11;13076:15;:36::i;:::-;13224:47;13244:10;13256:14;13224:19;:47::i;:::-;13281:58;13301:21;13324:14;13281:19;:58::i;:::-;13358:10:::0;;-1:-1:-1;13370:21:4;-1:-1:-1;;;9898:1:4::1;12202:1197:::0;;;;;;;;;;;:::o;2127:108:20:-;-1:-1:-1;;;;;2214:14:20;2188:7;2214:14;;;:7;:14;;;;;;;2127:108::o;2487:430:6:-;2555:7;2876:22;2900:8;2859:50;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2849:61;;;;;;2842:68;;2487:430;;;:::o;14052:902:4:-;14312:14;14328:26;14366:71;14402:8;:15;14419:17;:15;:17::i;14366:71::-;14448:253;14474:6;14494;14514:9;14537:8;14559:15;14588:25;14627:8;14649:11;14674:17;14448:12;:253::i;1776:80:5:-;1843:6;1776:80;:::o;7870:79:4:-;7936:6;7870:79;:::o;2332:85:19:-;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2371:13;;2396:14;;2403:7;;2396:14;;2403:7;2396:14;;;;;;;;;;;;;;;;;;;;;;;;1329:1781:3;1492:7;1511:28;1542:31;1557:7;:15;;;1542:14;:31::i;:::-;1511:62;;1583:29;1615:32;1630:7;:16;;;1615:14;:32::i;:::-;1583:64;-1:-1:-1;1678:24:3;1662:12;;:40;;;;;;;;;1658:1446;;;1847:38;1870:7;:14;;;1847:22;:38::i;:::-;1830:14;;;:55;1964:46;1973:14;1989:20;1964:8;:46::i;:::-;1947:63;;2042:48;2051:15;2068:21;2042:8;:48::i;:::-;2024:66;;2121:46;2130:7;:14;;;2146:20;2121:8;:46::i;:::-;2104:14;;;:63;2182:17;2202:56;2104:7;2226:14;2242:15;2202:14;:56::i;:::-;2182:76;;2352:48;2367:9;2378:21;2352:14;:48::i;:::-;2345:55;;;;;;;1658:1446;2495:46;2504:14;2520:20;2495:8;:46::i;:::-;2478:63;;2573:48;2582:15;2599:21;2573:8;:48::i;:::-;2555:66;;2652:47;2661:7;:14;;;2677:21;2652:8;:47::i;:::-;2635:14;;;:64;2714:16;2733:57;2635:7;2758:14;2774:15;2733;:57::i;:::-;2714:76;;2886:44;2899:8;2909:20;2886:12;:44::i;:::-;2875:55;;3066:27;3084:8;3066:17;:27::i;2653:429:1:-;2738:4;2754:24;2781:30;2791:10;2803:7;2781:9;:30::i;:::-;2754:57;;2836:16;2826:6;:26;2822:232;;2868:32;2877:10;2889:7;2898:1;2868:8;:32::i;:::-;2822:232;;;2987:56;2996:10;3008:7;3036:6;3017:16;:25;2987:8;:56::i;:::-;-1:-1:-1;3071:4:1;;2653:429;-1:-1:-1;;;2653:429:1:o;3657:170:19:-;3743:4;3759:40;3769:10;3781:9;3792:6;3759:9;:40::i;1862:101:5:-;1910:11;1940:16;:14;:16::i;1313:753:20:-;1575:60;1603:8;1584:15;:27;;5606:3:7;1575:8:20;:60::i;:::-;-1:-1:-1;;;;;1662:14:20;;1646:13;1662:14;;;:7;:14;;;;;;;;;1717:68;;1662:14;;1646:13;1717:68;;1728:16;;1670:5;;1753:7;;1762:5;;1662:14;;1776:8;;1717:68;;:::i;:::-;;;;;;;;;;;;;1707:79;;;;;;1686:100;;1797:12;1812:28;1829:10;1812:16;:28::i;:::-;1797:43;;1851:14;1868:24;1878:4;1884:1;1887;1890;1868:24;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1868:24:20;;-1:-1:-1;;1868:24:20;;;-1:-1:-1;1902:79:20;;-1:-1:-1;;;;;;1912:20:20;;;;;;1911:43;;;1948:5;-1:-1:-1;;;;;1938:15:20;:6;-1:-1:-1;;;;;1938:15:20;;1911:43;9291:3:7;1902:8:20;:79::i;:::-;-1:-1:-1;;;;;1992:14:20;;;;;;:7;:14;;;;;2017:1;2009:9;;1992:26;;2028:31;2000:5;2044:7;2053:5;2028:8;:31::i;:::-;1313:753;;;;;;;;;;;:::o;9912:2284:4:-;10206:16;10224;10189:6;9755:68;9786:10;:8;:10::i;9755:68::-;9833:55;9852:11;:9;:11::i;9833:55::-;10252:31:::1;10286:17;:15;:17::i;:::-;10252:51;;10318:13;:11;:13::i;:::-;10314:1876;;10353:20;10375:26;10405:164;10440:6;10464;10488:9;10515:14;10547:8;10405:17;:164::i;:::-;10352:217;;;;10864:58;3102:3;10873:12;:28;;5338:3:7;10864:8:4;:58::i;:::-;10936:41;10960:1;3102:3;10936:15;:41::i;:::-;10991:55;11007:9;3102:3;11018:12;:27;10991:15;:55::i;:::-;11133:44;11151:9;11162:14;11133:17;:44::i;:::-;11200:9;11225:17;:15;:17::i;:::-;11211:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;11211:32:4::1;;11192:52;;;;;;;;;10314:1876;11275:39;11289:8;11299:14;11275:13;:39::i;:::-;11329:20;11351:26;11379:38:::0;11421:260:::1;11450:6;11474;11498:9;11525:8;11551:15;11584:25;11627:14;11659:8;11421:11;:260::i;:::-;11328:353;;;;;;11795:40;11811:9;11822:12;11795:15;:40::i;:::-;11922:44;11940:9;11951:14;11922:17;:44::i;:::-;12065:58;12085:21;12108:14;12065:19;:58::i;:::-;12146:9:::0;;-1:-1:-1;12157:21:4;-1:-1:-1;12138:41:4::1;::::0;-1:-1:-1;;12138:41:4::1;3885:149:19::0;-1:-1:-1;;;;;4000:18:19;;;3974:7;4000:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3885:149::o;24216:259:34:-;2156:21:6;:19;:21::i;:::-;24293:20:34::1;24315:15:::0;24334:28:::1;:26;:28::i;:::-;24292:70;;;;24372:50;24381:10;6840:3:7;24372:8:34;:50::i;:::-;24433:35;24455:12;24433:21;:35::i;1135:274:11:-:0;1345:5;1369:33;1345:5;1369:19;:33::i;1793:180:16:-;1851:7;1882:5;;;1897:51;1906:6;;;:20;;;1925:1;1920;1916;:5;;;;;;:10;1906:20;4467:1:7;1897:8:16;:51::i;948:166::-;1006:7;1025:37;1039:1;1034;:6;;4370:1:7;1025:8:16;:37::i;:::-;-1:-1:-1;1084:5:16;;;948:166::o;4751:131:13:-;4859:15;;4751:131::o;8052:95:4:-;8128:12;8052:95;:::o;4745:203:2:-;4874:67;4893:5;4883:7;:15;:35;;;;;4913:5;4902:8;:16;4883:35;4838:3:7;4874:8:2;:67::i;:::-;4745:203;;;:::o;23592:1130:4:-;23650:16;23678:19;23700:17;:15;:17::i;:::-;23678:39;;23727:31;23775:11;23761:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;23761:26:4;-1:-1:-1;23727:60:4;-1:-1:-1;23843:15:4;;23839:93;;23882:15;23862:14;23877:1;23862:17;;;;;;;;;;;;;:35;;;;;23839:93;;;23915:14;-1:-1:-1;23908:21:4;;-1:-1:-1;23908:21:4;23839:93;23963:1;23949:11;:15;23945:93;;;23988:15;23968:14;23983:1;23968:17;;;;;;;;;;;;;:35;;;;;24069:1;24055:11;:15;24051:93;;;24094:15;24074:14;24089:1;24074:17;;;;;;;;;;;;;:35;;;;;24175:1;24161:11;:15;24157:93;;;24200:15;24180:14;24195:1;24180:17;;;;;;;;;;;;;:35;;;;;24281:1;24267:11;:15;24263:93;;;24306:15;24286:14;24301:1;24286:17;;;;;;;;;;;;;:35;;;;;24387:1;24373:11;:15;24369:93;;;24412:15;24392:14;24407:1;24392:17;;;;;;;;;;;;;:35;;;;;24493:1;24479:11;:15;24475:93;;;24518:15;24498:14;24513:1;24498:17;;;;;;;;;;;;;:35;;;;;24599:1;24585:11;:15;24581:93;;;24624:15;24604:14;24619:1;24604:17;;;;;;;;;;;;;:35;;;;;24701:14;-1:-1:-1;;23592:1130:4;:::o;2640:746:2:-;2859:7;2878:39;2892:8;2902:14;2878:13;:39::i;:::-;2948:54;2957:11;:18;;;2977:14;2992:8;2977:24;;;;;;;;;;;;;;2948:8;:54::i;:::-;2927:18;;;:75;3013:16;3032:57;2927:11;3061:8;3071:7;3080:8;3032:15;:57::i;:::-;3013:76;;3177:47;3190:8;3200:14;3215:7;3200:23;;;;;;;;;;;;;;3177:12;:47::i;:::-;3166:58;;3352:27;3370:8;3352:17;:27::i;:::-;3345:34;;;2640:746;;;;;;;;:::o;1861:773::-;2079:7;2227:42;2250:11;:18;;;2227:22;:42::i;:::-;2206:18;;;:63;2280:39;2294:8;2304:14;2280:13;:39::i;:::-;2350:53;2359:11;:18;;;2379:14;2394:7;2379:23;;;;;;;2350:53;2329:18;;;:74;2414:17;2434:56;2329:11;2462:8;2472:7;2481:8;2434:14;:56::i;:::-;2414:76;;2576:51;2591:9;2602:14;2617:8;2602:24;;;;;;;;;;;;;;2576:14;:51::i;9345:213:19:-;-1:-1:-1;;;;;9468:18:19;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;;:36;;;9519:32;;;;;9498:6;;9519:32;:::i;:::-;;;;;;;;9345:213;;;:::o;2300:181:6:-;2355:16;2374:20;2386:7;;;;2374:11;:20::i;:::-;2355:39;;2404:70;2413:33;2425:8;2435:10;2413:11;:33::i;:::-;7287:3:7;2404:8:6;:70::i;3793:358:12:-;3849:6;3845:232;;;3871:81;3898:24;:22;:24::i;:::-;3880:15;:42;7389:3:7;3871:8:12;:81::i;:::-;3845:232;;;3983:83;4010:25;:23;:25::i;:::-;3992:15;:43;8819:3:7;3983:8:12;:83::i;:::-;4087:7;:16;;;;;;;;;;4118:26;;;;;;4087:16;;4118:26;:::i;:::-;;;;;;;;3793:358;:::o;4544:237::-;4591:4;4737:25;:23;:25::i;:::-;4719:15;:43;:55;;;-1:-1:-1;;4767:7:12;;;;4766:8;;4544:237::o;4894:108::-;4976:19;4894:108;:::o;5008:110::-;5091:20;5008:110;:::o;866:101:7:-;935:9;930:34;;946:18;954:9;946:7;:18::i;7068:559:19:-;7195:71;-1:-1:-1;;;;;7204:20:19;;;;7704:3:7;7195:8:19;:71::i;:::-;7276:72;-1:-1:-1;;;;;7285:23:19;;;;7772:3:7;7276:8:19;:72::i;:::-;7359:47;7380:6;7388:9;7399:6;7359:20;:47::i;:::-;-1:-1:-1;;;;;7437:17:19;;:9;:17;;;;;;;;;;;:68;;7459:6;8250:3:7;7437:21:19;:68::i;:::-;-1:-1:-1;;;;;7417:17:19;;;:9;:17;;;;;;;;;;;:88;;;;7538:20;;;;;;;:32;;7563:6;7538:24;:32::i;:::-;-1:-1:-1;;;;;7515:20:19;;;:9;:20;;;;;;;;;;;;:55;;;;7585:35;;;;;;;;;;7613:6;;7585:35;:::i;25134:1248:34:-;25195:13;25210:15;25238:18;25258:16;25276:17;25295:15;25314:23;:21;:23::i;:::-;25237:100;;;;;;;;25487:7;25469:15;:25;25465:911;;;25523:4;25510:17;;25999:10;25988:8;:21;25984:303;;;26121:9;26111:7;:19;26096:9;26078:15;:27;26063:10;26052:8;:21;26051:55;26050:81;;;;;;26037:10;:94;26029:102;;25984:303;;;26262:9;26252:7;:19;26237:9;26219:15;:27;26206:8;26193:10;:21;26192:55;26191:81;;;;;;26178:10;:94;26170:102;;25984:303;25465:911;;;26330:5;26317:18;;26357:8;26349:16;;25465:911;25134:1248;;;;;;:::o;2311:232:16:-;2371:7;2390:38;2399:6;;;4516:1:7;2390:8:16;:38::i;:::-;2443:6;2439:98;;-1:-1:-1;2472:1:16;2465:8;;2439:98;2525:1;2520;2516;:5;2515:11;;;;;;2511:1;:15;2504:22;;;;26573:503:34;26950:45;26978:7;26950:45;;26988:6;26950:20;:45::i;:::-;26888:47;26916:9;26888:47;;26928:6;26888:20;:47::i;:::-;26831:42;26859:8;26831:42;;26870:2;26831:20;:42::i;:::-;26773:43;26801:10;26773:43;;26814:1;26773:20;:43::i;:::-;:100;:162;:222;26734:24;:261;27011:58;;;;;;27028:10;;27040:8;;27050:9;;27061:7;;27011:58;:::i;:::-;;;;;;;;26573:503;;;;:::o;2386:188:18:-;2447:7;2494:10;2506:12;2520:15;2537:13;:11;:13::i;:::-;2560:4;2483:83;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2473:94;;;;;;2466:101;;2386:188;:::o;4220:98:12:-;4272:39;4281:14;:12;:14::i;:::-;7331:3:7;4272:8:12;:39::i;:::-;4220:98::o;8427:374:4:-;8503:87;2971:4;8512:17;:45;;5289:3:7;8503:8:4;:87::i;:::-;8600;3044:4;8609:17;:45;;5228:3:7;8600:8:4;:87::i;:::-;8698:18;:38;;;8751:43;;;;;;8719:17;;8751:43;:::i;915:167:23:-;973:7;1004:5;;;1019:37;1028:6;;;;973:7;1019:8;:37::i;9027:279:4:-;9120:14;9137:11;:9;:11::i;:::-;9120:28;;9165:20;9189:10;:8;:10::i;:::-;-1:-1:-1;;;;;9189:27:4;;9217:6;9225:5;9189:42;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;9242:57;;;;;9158:73;;-1:-1:-1;;;;;;9242:37:4;;;-1:-1:-1;9242:37:4;;-1:-1:-1;9242:57:4;;-1:-1:-1;9280:6:4;;9288:10;;9242:57;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9027:279;;;;:::o;810:131:11:-;888:46;902:1;897;:6;5002:3:7;888:8:11;:46::i;12293:1857:34:-;12618:19;12651:27;12692:38;12914:14;:12;:14::i;:::-;12910:851;;;13280:62;13306:8;13316:25;13280;:62::i;:::-;13256:86;;13436:63;13451:8;13461:21;13484:14;13436;:63::i;:::-;12910:851;;;13732:17;:15;:17::i;:::-;13718:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;13718:32:34;;13694:56;;12910:851;13799:43;13807:8;13817:14;13833:8;13799:7;:43::i;:::-;13771:71;;-1:-1:-1;13771:71:34;-1:-1:-1;14030:47:34;14056:8;13771:71;14030:25;:47::i;:::-;12293:1857;;;;;;;;;;;;:::o;26418:253:4:-;26535:9;26530:135;26554:17;:15;:17::i;:::-;26550:1;:21;26530:135;;;26605:49;26624:7;26632:1;26624:10;;;;;;;;;;;;;;26636:14;26651:1;26636:17;;;;;;;;;;;;;;26605:18;:49::i;:::-;26592:7;26600:1;26592:10;;;;;;;;;;;;;;;;;:62;26573:3;;26530:135;;27951:6885;28650:10;28672:4;28650:27;28646:6184;;28946:12;28972:4;-1:-1:-1;;;;;28964:18:4;28983:8;;28964:28;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;28945:47;;;29210:7;29243:1;29238:3336;;;;32734:9;29238:3336;29714:4;29711:1;29708;29693:26;29767:1;29761:8;29771:66;29757:81;29999:66;29989:77;;29983:2;;30122:16;30119:1;30116;30101:38;30178:16;30175:1;30168:27;29983:2;;31589;31583:4;31580:1;31565:27;31786:2;31780:4;31773:16;32210:2;32192:16;32188:25;32182:4;32176;32161:53;32548:2;32530:16;32526:25;32523:1;32516:36;29076:3703;32809:31;32843:17;:15;:17::i;:::-;32809:51;;32874:39;32888:8;32898:14;32874:13;:39::i;:::-;32929:17;32948:29;32983:256;33008:6;33032;33056:9;33083:8;33109:15;33142:25;33185:14;33217:8;32983:7;:256;;:::i;:::-;32928:311;;;;;33254:45;33270:12;33284:14;33254:15;:45;;:::i;:::-;33780:19;;-1:-1:-1;;34167:23:4;;34207:24;;;34453:66;34435:16;;;34428:92;33801:2;33776:28;34546:16;;;34802:2;34792:13;;34546:16;34778:28;25632:247;25743:9;25738:135;25762:17;:15;:17::i;:::-;25758:1;:21;25738:135;;;25813:49;25832:7;25840:1;25832:10;;;;;;;;;;;;;;25844:14;25859:1;25844:17;;;;;;;;;;;;;;25813:18;:49::i;:::-;25800:7;25808:1;25800:10;;;;;;;;;;;;;;;;;:62;25781:3;;25738:135;;2338:2606:33;3434:15;;2493:7;;;;;3459:91;3483:9;3479:1;:13;3459:91;;;3519:20;3527:8;3536:1;3527:11;;;;;;;;;;;;;;3519:3;:7;;:20;;;;:::i;:::-;3513:26;-1:-1:-1;3494:3:33;;3459:91;;;-1:-1:-1;3563:8:33;3559:47;;3594:1;3587:8;;;;;;3559:47;3616:21;3671:3;3708:34;;;3616:21;3753:1125;3777:3;3773:1;:7;3753:1125;;;3801:11;3829:9;3815:8;3824:1;3815:11;;;;;;;;;;;;;;:23;3801:37;;3857:9;3869:1;3857:13;;3852:156;3876:9;3872:1;:13;3852:156;;;3916:77;3925:47;3934:26;3943:3;3948:8;3957:1;3948:11;;;;;;;;;;;;;;3934:8;:26::i;:::-;3962:9;3925:8;:47::i;:::-;3974:9;3985:7;3916:8;:77::i;:::-;3910:83;-1:-1:-1;3887:3:33;;3852:156;;;;4037:9;4021:25;;4072:534;4098:173;4175:78;4184:43;4193:28;4202:13;4217:3;4193:8;:28::i;:::-;4223:3;4184:8;:43::i;:::-;1255:3;4245:7;4175:8;:78::i;:::-;4098:51;4107:30;4116:9;4127;4107:8;:30::i;:::-;4139:9;4098:8;:51::i;:::-;:55;;:173::i;:::-;4289:278;4468:81;4477:45;1255:3;4486:13;:30;4518:3;4477:8;:45::i;:::-;1255:3;4541:7;4540:8;4468;:81::i;:::-;4289:34;4298:9;4310:1;4298:13;4313:9;4289:8;:34::i;:278::-;4585:7;4072:8;:534::i;:::-;4060:546;;4637:13;4625:9;:25;4621:247;;;4703:1;4686:13;4674:9;:25;:30;4670:93;;4735:9;4728:16;;;;;;;;;;;4670:93;4621:247;;;4816:1;4803:9;4787:13;:25;:30;4783:85;;4844:9;4837:16;;;;;;;;;;;4783:85;-1:-1:-1;3782:3:33;;3753:1125;;;;4888:49;6980:3:7;4888:7:33;:49::i;:::-;2338:2606;;;;;;;;;;:::o;2485:355:14:-;2547:7;2566:38;2575:6;;;4516:1:7;2566:8:14;:38::i;:::-;2619:6;2615:219;;-1:-1:-1;2648:1:14;2641:8;;2615:219;893:4;2700:7;;;;2721:51;;2700:1;:7;:1;2730:13;;;;;:20;4564:1:7;2721:8:14;:51::i;:::-;2822:1;2810:9;:13;;;;;;2803:20;;;;;3231:104:1;3307:21;3313:6;3321;3307:5;:21::i;8581:1410:34:-;8928:7;8949:16;8979;2970:18:12;:16;:18::i;:::-;9326:38:34::1;9367:62;9393:8;9403:25;9367;:62::i;:::-;9326:103;;9515:63;9530:8;9540:21;9563:14;9515;:63::i;:::-;9589:20;9611:26;9641:43;9649:8;9659:14;9675:8;9641:7;:43::i;:::-;9588:96;;;;9872:46;9898:8;9908:9;9872:25;:46::i;:::-;9937:12:::0;;;;-1:-1:-1;9962:21:34;;-1:-1:-1;8581:1410:34;-1:-1:-1;;;;;;;;;8581:1410:34:o;27202:249:4:-;27317:9;27312:133;27336:17;:15;:17::i;:::-;27332:1;:21;27312:133;;;27387:47;27404:7;27412:1;27404:10;;;;;;;;;;;;;;27416:14;27431:1;27416:17;;;;;;;;;;;;;;27387:16;:47::i;:::-;27374:7;27382:1;27374:10;;;;;;;;;;;;;;;;;:60;27355:3;;27312:133;;22690:679;22759:7;22818;-1:-1:-1;;;;;22809:16:4;:5;-1:-1:-1;;;;;22809:16:4;;22805:558;;;-1:-1:-1;22836:15:4;22829:22;;22805:558;22881:7;-1:-1:-1;;;;;22872:16:4;:5;-1:-1:-1;;;;;22872:16:4;;22868:495;;;-1:-1:-1;22899:15:4;22892:22;;22868:495;22944:7;-1:-1:-1;;;;;22935:16:4;:5;-1:-1:-1;;;;;22935:16:4;;22931:432;;;-1:-1:-1;22962:15:4;22955:22;;22931:432;23007:7;-1:-1:-1;;;;;22998:16:4;:5;-1:-1:-1;;;;;22998:16:4;;22994:369;;;-1:-1:-1;23025:15:4;23018:22;;22994:369;23070:7;-1:-1:-1;;;;;23061:16:4;:5;-1:-1:-1;;;;;23061:16:4;;23057:306;;;-1:-1:-1;23088:15:4;23081:22;;23057:306;23133:7;-1:-1:-1;;;;;23124:16:4;:5;-1:-1:-1;;;;;23124:16:4;;23120:243;;;-1:-1:-1;23151:15:4;23144:22;;23120:243;23196:7;-1:-1:-1;;;;;23187:16:4;:5;-1:-1:-1;;;;;23187:16:4;;23183:180;;;-1:-1:-1;23214:15:4;23207:22;;23183:180;23259:7;-1:-1:-1;;;;;23250:16:4;:5;-1:-1:-1;;;;;23250:16:4;;23246:117;;;-1:-1:-1;23277:15:4;23270:22;;23246:117;23323:29;6206:3:7;23323:7:4;:29::i;21050:279::-;21121:7;21232:17;21252:32;21265:18;;21252:6;:12;;:32;;;;:::i;:::-;21232:52;-1:-1:-1;21301:21:4;:6;21232:52;21301:10;:21::i;24884:579::-;24964:7;25415:41;25434:6;25442:13;25415:18;:41::i;5642:519:34:-;5817:7;5836:55;5845:17;:15;:17::i;:::-;5866:1;5845:22;5658:3:7;5836:8:34;:55::i;:::-;5903:25;5930:15;5947:16;5967:113;6002:11;6027:14;6055:15;5967:21;:113::i;:::-;5902:178;;;;;;6098:56;6113:11;6126:8;6136:7;6145:8;6098:14;:56::i;:::-;6091:63;5642:519;-1:-1:-1;;;;;;;5642:519:34:o;26083:160:4:-;26169:7;26195:41;26214:6;26222:13;26195:18;:41::i;6167:520:34:-;6343:7;6362:55;6371:17;:15;:17::i;6362:55::-;6429:25;6456:15;6473:16;6493:113;6528:11;6553:14;6581:15;6493:21;:113::i;:::-;6428:178;;;;;;6623:57;6639:11;6652:8;6662:7;6671:8;6623:15;:57::i;26873:156:4:-;26957:7;26983:39;27000:6;27008:13;26983:16;:39::i;20707:243::-;20773:7;20891:52;20904:38;20923:18;;893:4:14;20904:18:4;;:38;;;;:::i;:::-;20891:6;;:12;:52::i;27457:488::-;27515:11;27912:10;:8;:10::i;:::-;-1:-1:-1;;;;;27912:24:4;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;3199:183:18:-;3276:7;3341:20;:18;:20::i;:::-;3363:10;3312:62;;;;;;;;;:::i;7457:1105:34:-;7662:7;7671:16;2970:18:12;:16;:18::i;:::-;7854:24:34::1;7881:19;:8;:17;:19::i;:::-;7854:46:::0;-1:-1:-1;7910:64:34::1;7927:24;7919:4;:32;;;;;;;;;5443:3:7;7910:8:34;:64::i;:::-;7985:26;8014:27;:8;:25;:27::i;:::-;7985:56;;8051:72;8087:9;:16;8105:17;:15;:17::i;8051:72::-;8133:40;8147:9;8158:14;8133:13;:40::i;:::-;8185:18;8209:28;:26;:28::i;:::-;8184:53;;;8247:26;8276:59;8307:10;8319:9;8330:4;8276:30;:59::i;:::-;8247:88:::0;-1:-1:-1;8247:88:34;8460:52:::1;8247:88:::0;8501:10;8460:20:::1;:52::i;:::-;8531:12:::0;8545:9;;-1:-1:-1;7457:1105:34;;-1:-1:-1;;;;;;;;;7457:1105:34:o;3115:110:1:-;3194:24;3200:9;3211:6;3194:5;:24::i;26388:179:34:-;26452:69;26474:5;26481;26488:15;26505;26452:21;:69::i;:::-;26537:23;26554:5;26537:23;;;;;;:::i;1415:374:11:-;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;;;;;;;;;;;;;;1649:26;;1689:51;1709:7;-1:-1:-1;;;;;1698:18:11;:8;-1:-1:-1;;;;;1698:18:11;;4890:3:7;1689:8:11;:51::i;:::-;1765:7;-1:-1:-1;1630:3:11;;1592:191;;5129:431:34;5340:7;2970:18:12;:16;:18::i;:::-;5360::34::1;5384:28;:26;:28::i;:::-;5359:53;;;5422:16;5441:87;5468:10;5480:8;5490:7;5499:8;5509:11;:18;;;5441:26;:87::i;4691:432::-:0;4901:7;2970:18:12;:16;:18::i;:::-;4921::34::1;4945:28;:26;:28::i;:::-;4920:53;;;4983:17;5003:87;5030:10;5042:8;5052:7;5061:8;5071:11;:18;;;5003:26;:87::i;1969:544:5:-:0;2057:4;1663:42;2078:10;:8;:10::i;:::-;-1:-1:-1;;;;;2078:29:5;;;2077:63;;;;;2112:28;2131:8;2112:18;:28::i;:::-;2073:434;;;2272:10;:8;:10::i;:::-;-1:-1:-1;;;;;2258:24:5;:10;-1:-1:-1;;;;;2258:24:5;;2251:31;;;;2073:434;2435:16;:14;:16::i;:::-;-1:-1:-1;;;;;2435:27:5;;2463:8;2473:7;2490:4;2435:61;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2428:68;;;;1074:3172:7;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;1765:176:23;1842:7;1861:27;1875:1;1870;:6;;1878:9;1861:8;:27::i;:::-;-1:-1:-1;;1910:5:23;;;1765:176::o;27082:479:34:-;27174:18;27206:16;27236:17;27267:15;27320:40;27358:1;27320:24;;:37;;:40;;;;:::i;:::-;27381:24;;27307:53;;-1:-1:-1;27381:41:34;;27419:2;27381:37;:41::i;:::-;27444:24;;27370:52;;-1:-1:-1;27444:45:34;;27482:6;27444:37;:45::i;:::-;27509:24;;27432:57;;-1:-1:-1;27509:45:34;;27547:6;27509:37;:45::i;:::-;27499:55;;27082:479;;;;:::o;3388:427:18:-;3790:9;;3765:44::o;18209:1572:34:-;18352:16;18417:38;18472:17;:15;:17::i;:::-;18458:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;18458:32:34;-1:-1:-1;18417:73:34;-1:-1:-1;18586:30:34;18582:89;;18639:21;-1:-1:-1;18632:28:34;;18582:89;19086:24;19124:18;19145:8;19154:1;19145:11;;;;;;;;;;;;;;19124:32;;19171:9;19183:1;19171:13;;19166:253;19190:17;:15;:17::i;:::-;19186:1;:21;19166:253;;;19228:22;19253:8;19262:1;19253:11;;;;;;;;;;;;;;19228:36;;19299:10;19282:14;:27;19278:131;;;19348:1;19329:20;;19380:14;19367:27;;19278:131;-1:-1:-1;19209:3:34;;19166:253;;;;19530:205;19589:17;;19620:8;19642:14;;19670:16;19700:25;19530:45;:205::i;:::-;19488:21;19510:16;19488:39;;;;;;;;;;;;;;;;;:247;-1:-1:-1;19753:21:34;;18209:1572;-1:-1:-1;;;;18209:1572:34:o;21284:320::-;21481:9;21476:122;21500:17;:15;:17::i;:::-;21496:1;:21;21476:122;;;21552:35;21561:8;21570:1;21561:11;;;;;;;;;;;;;;21574:9;21584:1;21574:12;;;;;;;;;;;;;;21552:8;:35;;:::i;:::-;21538:8;21547:1;21538:11;;;;;;;;;;;;;;;;;:49;21519:3;;21476:122;;;;21284:320;;;:::o;14156:660::-;14308:7;14317:16;14345:13;14361:19;:8;:17;:19::i;:::-;14345:35;-1:-1:-1;14403:39:34;14395:4;:47;;;;;;;;;14391:419;;;14465:46;14492:8;14502;14465:26;:46::i;:::-;14458:53;;;;;;;14391:419;14540:36;14532:4;:44;;;;;;;;;14528:282;;;14599:47;14627:8;14637;14599:27;:47::i;14528:282::-;14736:63;14764:8;14774:14;14790:8;14736:27;:63::i;14528:282::-;14156:660;;;;;;;;:::o;20611:503::-;20720:52;20735:8;20745:10;20757:14;20720;:52::i;:::-;20784:18;20808:28;:26;:28::i;:::-;20783:53;;;21015:92;21036:58;21067:10;21079:8;21089:4;21036:30;:58::i;:::-;21096:10;21015:20;:92::i;1647:209:14:-;1709:7;1746:5;;;1761:57;1770:6;;;:26;;;1795:1;1790;1780:7;:11;;;;1761:57;893:4;1836:13;;;;-1:-1:-1;;;1647:209:14:o;1979:172:16:-;2081:7;2107;:37;;2131:13;2139:1;2142;2131:7;:13::i;:::-;2107:37;;;2117:11;2123:1;2126;2117:5;:11::i;8512:410:19:-;8587:68;-1:-1:-1;;;;;8596:21:19;;;;7902:3:7;8587:8:19;:68::i;:::-;8666:49;8687:7;8704:1;8708:6;8666:20;:49::i;:::-;-1:-1:-1;;;;;8747:18:19;;:9;:18;;;;;;;;;;;:67;;8770:6;8316:3:7;8747:22:19;:67::i;:::-;-1:-1:-1;;;;;8726:18:19;;:9;:18;;;;;;;;;;:88;8839:12;;:24;;8856:6;8839:16;:24::i;:::-;8824:12;:39;8878:37;;8904:1;;-1:-1:-1;;;;;8878:37:19;;;;;;;8908:6;;8878:37;:::i;:::-;;;;;;;;8512:410;;:::o;9997:585:34:-;10149:7;10158:16;10186:13;10202:19;:8;:17;:19::i;:::-;10186:35;-1:-1:-1;10244:36:34;10236:4;:44;;;;;;;;;10232:344;;;10303:63;10331:8;10341:14;10357:8;10303:27;:63::i;10232:344::-;10395:35;10387:4;:43;;;;;;;;;10383:193;;;10453:46;10480:8;10490;10453:26;:46::i;10383:193::-;10530:35;6263:3:7;10530:7:34;:35::i;19945:501::-;20053:51;20068:8;20078:9;20089:14;20053;:51::i;2846:682:14:-;2906:7;2925:38;2934:6;;;4516:1:7;2925:8:14;:38::i;:::-;2978:6;2974:548;;-1:-1:-1;3007:1:14;3000:8;;2974:548;893:4;3059:7;;;;3080:51;;3059:1;:7;:1;3089:13;;;3080:51;3505:1;3500;3488:9;:13;3487:19;;;;;;3510:1;3486:25;3479:32;;;;;1862:617;1922:7;1959:5;;;1974:57;1983:6;;;:26;;;2008:1;2003;1993:7;:11;;;;1974:57;2046:12;2042:431;;2081:1;2074:8;;;;;2042:431;893:4;2439:11;;;2438:19;;6693:739:34;7014:16;;;7028:1;7014:16;;;6894:25;7014:16;;;;;;6933:15;;;;7014:16;;;;;;;;;;;;-1:-1:-1;7014:16:34;7003:27;;7056:11;:19;;;-1:-1:-1;;;;;7045:30:34;:7;-1:-1:-1;;;;;7045:30:34;;7041:385;;;7101:1;7091:11;;7127:1;7116:12;;7157:14;7143:8;7152:1;7143:11;;;;;;;;;;;;;:28;;;;;7199:15;7185:8;7194:1;7185:11;;;;;;;;;;;;;:29;;;;;7041:385;;;7303:1;7292:12;;7328:1;7318:11;;7358:15;7344:8;7353:1;7344:11;;;;;;;;;;;;;:29;;;;;7401:14;7387:8;7396:1;7387:11;;;;;;;;;;;;;:28;;;;;7041:385;6693:739;;;;;;;:::o;859:144:35:-;919:19;968:4;957:39;;;;;;;;;;;;:::i;1173:179::-;1241:26;1306:4;1295:50;;;;;;;;;;;;:::i;17869:184:34:-;17968:14;:26;;;;18004:17;:42;17869:184::o;7898:294:19:-;7973:49;8002:1;8006:7;8015:6;7973:20;:49::i;:::-;8048:12;;:24;;8065:6;8048:16;:24::i;:::-;8033:12;:39;-1:-1:-1;;;;;8103:18:19;;:9;:18;;;;;;;;;;;:30;;8126:6;8103:22;:30::i;:::-;-1:-1:-1;;;;;8082:18:19;;:9;:18;;;;;;;;;;;:51;;;;8148:37;;8082:18;;:9;8148:37;;;;8178:6;;8148:37;:::i;7792:2462:33:-;8014:7;9504:17;9524:59;9544:22;9568:8;9578:4;9524:19;:59::i;:::-;9504:79;;9620:43;9648:14;9620:8;9629:13;9620:23;;;;;;;;;;;;;;:27;;:43;;;;:::i;:::-;9594:8;9603:13;9594:23;;;;;;;;;;;;;:69;;;;;9674:22;9699:166;9762:22;9798:8;9820:9;9843:12;9699:49;:166::i;:::-;9674:191;;10166:14;10140:8;10149:13;10140:23;;;;;;;;;;;;;;:40;10114:8;10123:13;10114:23;;;;;;;;;;;;;:66;;;;;10198:49;10245:1;10198:42;10217:8;10226:12;10217:22;;;;;;;;;;;;;;10198:14;:18;;:42;;;;:::i;:49::-;10191:56;7792:2462;-1:-1:-1;;;;;;;;7792:2462:33:o;5119:2455::-;5340:7;6834:17;6854:59;6874:22;6898:8;6908:4;6854:19;:59::i;:::-;6834:79;;6949:41;6976:13;6949:8;6958:12;6949:22;;;;;;;;;;;;;;:26;;:41;;;;:::i;:::-;6924:8;6933:12;6924:22;;;;;;;;;;;;;:66;;;;;7001:23;7027:167;7090:22;7126:8;7148:9;7171:13;7027:49;:167::i;:::-;7001:193;;7485:13;7460:8;7469:12;7460:22;;;;;;;;;;;;;;:38;7435:8;7444:12;7435:22;;;;;;;;;;;;;:63;;;;;7516:51;7565:1;7516:44;7544:15;7516:8;7525:13;7516:23;;;;;;;:44;:48;;:51::i;24481:353:34:-;24567:4;24615:66;24627:53;24615:11;:66::i;:::-;24603:8;:78;24602:175;;;-1:-1:-1;24711:65:34;24723:52;24711:11;:65::i;:::-;24699:8;:77;24602:175;:225;;;;24793:34;24818:8;24793:24;:34::i;6688:142:13:-;6797:14;1639:11;6789:34;;6688:142::o;21274:2412:33:-;21524:7;22928:28;22959:168;23022:22;23058:8;23080:13;23107:10;22959:49;:168::i;:::-;22928:199;;23166:20;23142:8;23151:10;23142:20;;;;;;;;;;;;;;:44;23138:319;;23445:1;23438:8;;;;;23138:319;23501:32;23559:20;23536:8;23545:10;23536:20;;;;;;;;;;;;;;:43;23501:78;;23596:83;893:4:14;23596:59:33;23629:25;23596:24;:32;;:59;;;;:::i;:::-;:67;;:83::i;14822:1073:34:-;14976:7;14985:16;2970:18:12;:16;:18::i;:::-;15088:19:34::1;15109:18:::0;15131:32:::1;:8;:30;:32::i;:::-;15087:76;;;;15274:62;15296:17;:15;:17::i;:::-;15283:10;:30;4838:3:7;15274:8:34;:62::i;:::-;15421:27;15465:17;:15;:17::i;:::-;15451:32;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;-1:-1:-1;15451:32:34::1;;15421:62;;15555:18;15579:28;:26;:28::i;:::-;15554:53;;;15642:203;15695:10;15719:8;15741:10;15765:11;15790:13;:11;:13::i;:::-;15817:18;;15642:39;:203::i;:::-;15617:10;15628;15617:22;;;;;;;;;::::0;;::::1;::::0;;;;;:228;-1:-1:-1;15864:11:34;;;;-1:-1:-1;14822:1073:34;;-1:-1:-1;;;;14822:1073:34:o;15901:908::-;16034:7;16043:16;16486:19;16508:33;:8;:31;:33::i;:::-;16486:55;;16652:27;16682:78;16723:8;16733:11;16746:13;:11;:13::i;:::-;16682:40;:78::i;:::-;16778:11;;;;-1:-1:-1;15901:908:34;;-1:-1:-1;;;;15901:908:34:o;16815:916::-;17001:7;17010:16;2970:18:12;:16;:18::i;:::-;17109:27:34::1;17138:22;17164:33;:8;:31;:33::i;:::-;17108:89;;;;17207:73;17243:10;:17;17262;:15;:17::i;17207:73::-;17290:41;17304:10;17316:14;17290:13;:41::i;:::-;17343:18;17367:28;:26;:28::i;:::-;17342:53;;;17405:19;17427:179;17481:10;17505:8;17527:10;17551:13;:11;:13::i;:::-;17578:18;;17427:40;:179::i;:::-;17405:201;;17616:65;17640:14;17625:11;:29;;5498:3:7;17616:8:34;:65::i;:::-;17700:11:::0;17713:10;;-1:-1:-1;16815:916:34;;-1:-1:-1;;;;;;16815:916:34:o;2157:148:16:-;2219:7;2238:38;2247:6;;;4516:1:7;2238:8:16;:38::i;:::-;2297:1;2293;:5;;;;;;;2157:148;-1:-1:-1;;;2157:148:16:o;1353:121:23:-;1411:7;1437:30;1441:1;1444;4370::7;1437:3:23;:30::i;10588:835:34:-;10760:7;10769:16;10798:26;10826:23;10853:33;:8;:31;:33::i;:::-;10797:89;;;;10896:72;10932:17;:15;:17::i;:::-;10951:9;:16;10896:35;:72::i;:::-;10979:40;10993:9;11004:14;10979:13;:40::i;:::-;11031:18;11055:28;:26;:28::i;:::-;11030:53;;;11093:20;11116:178;11170:10;11194:8;11216:9;11239:13;:11;:13::i;:::-;11266:18;;11116:40;:178::i;:::-;11093:201;;11305:68;11330:15;11314:12;:31;;5554:3:7;11305:8:34;:68::i;11429:845::-;11561:7;11570:16;11603:20;11625:18;11647:32;:8;:30;:32::i;:::-;11602:77;;;;11789:62;11811:17;:15;:17::i;11789:62::-;11862:26;11905:17;:15;:17::i;:::-;11891:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11891:32:34;;11862:61;;11934:18;11958:28;:26;:28::i;:::-;11933:53;;;12020:204;12073:10;12097:8;12119:10;12143:12;12169:13;:11;:13::i;:::-;12196:18;;12020:39;:204::i;23846:2084:33:-;24064:7;24120:21;24169:8;:15;24144:22;:40;24120:64;;24194:11;24208:8;24217:1;24208:11;;;;;;;;;;;;;;24194:25;;24229:11;24257:8;:15;24243:8;24252:1;24243:11;;;;;;;;;;;;;;:29;24229:43;;24287:9;24299:1;24287:13;;24282:195;24306:8;:15;24302:1;:19;24282:195;;;24348:78;24361:53;24370:26;24379:3;24384:8;24393:1;24384:11;;;;;;;24370:26;24398:8;:15;24361:8;:53::i;:::-;24416:9;24348:12;:78::i;:::-;24342:84;;24446:20;24454:8;24463:1;24454:11;;;;;;;24446:20;24440:26;-1:-1:-1;24323:3:33;;24282:195;;;;24616:8;24625:10;24616:20;;;;;;;;;;;;;;24610:3;:26;24604:32;;24647:12;24662:30;24671:9;24682;24662:8;:30::i;:::-;24647:45;;24761:9;24773:138;24795:72;24804:46;24815:4;24821:28;24830:13;24845:3;24821:8;:28::i;24804:46::-;1255:3;24795:8;:72::i;:::-;24881:8;24890:10;24881:20;;;;;;;24773:138;24761:150;;24921:9;24933:73;24941:64;24950:38;24963:9;24974:13;24950:12;:38::i;24941:64::-;24933:3;;:7;:73::i;:::-;24921:85;-1:-1:-1;25059:24:33;;25257:41;25268:11;:4;25277:1;25268:8;:11::i;:::-;25281:16;:9;25295:1;25281:13;:16::i;25257:41::-;25234:64;;25314:9;25309:555;25333:3;25329:1;:7;25309:555;;;25376:12;25357:31;;25418:150;25446:43;25487:1;25446:36;25455:12;25469;25446:8;:36::i;:43::-;25507:47;25544:9;25507:32;25537:1;25507:25;25516:12;25530:1;25507:8;:25::i;25418:150::-;25403:165;;25602:16;25587:12;:31;25583:271;;;25677:1;25657:16;25642:12;:31;:36;25638:102;;-1:-1:-1;25709:12:33;-1:-1:-1;25702:19:33;;-1:-1:-1;;;;;;;25702:19:33;25638:102;25583:271;;;25799:1;25783:12;25764:16;:31;:36;25760:94;;-1:-1:-1;25827:12:33;-1:-1:-1;25820:19:33;;-1:-1:-1;;;;;;;25820:19:33;25760:94;25338:3;;25309:555;;;;25874:49;6980:3:7;25874:7:33;:49::i;:::-;23846:2084;;;;;;;;;;;;;;:::o;9407:271:4:-;9493:4;9541:47;9553:34;9541:11;:47::i;:::-;9529:8;:59;9528:143;;;-1:-1:-1;9618:52:4;9630:39;9618:11;:52::i;:::-;9606:64;;;;9407:271;-1:-1:-1;9407:271:4:o;1868:218:35:-;1941:19;1962:18;2033:4;2022:57;;;;;;;;;;;;:::i;:::-;1992:87;;;;-1:-1:-1;1868:218:35;-1:-1:-1;;;1868:218:35:o;17690:2060:33:-;17937:7;18119:24;18146:40;18166:3;18171:8;18181:4;18146:19;:40::i;:::-;18119:67;-1:-1:-1;18196:20:33;18219:77;18119:67;18219:53;18257:14;18219:31;18257:14;18238:11;18219:18;:31::i;:::-;:37;;:53::i;:::-;:59;;:77::i;:::-;18196:100;;18351:28;18382:148;18445:3;18462:8;18484:12;18510:10;18382:49;:148::i;:::-;18351:179;;18540:27;18570:46;18595:20;18570:8;18579:10;18570:20;;;;;;;:46;18540:76;;18761:19;18799:9;18794:113;18818:8;:15;18814:1;:19;18794:113;;;18868:28;18884:8;18893:1;18884:11;;;;;;;;;;;;;;18868;:15;;:28;;;;:::i;:::-;18854:42;-1:-1:-1;18835:3:33;;18794:113;;;;19062:21;19086:41;19115:11;19086:8;19095:10;19086:20;;;;;;;;;;;;;;:28;;:41;;;;:::i;:::-;19062:65;;19137:25;19165:26;:13;:24;:26::i;:::-;19137:54;-1:-1:-1;19402:21:33;19426:44;:19;19137:54;19426:25;:44::i;:::-;19402:68;-1:-1:-1;19480:24:33;19507:38;:19;19402:68;19507:23;:38::i;:::-;19480:65;-1:-1:-1;19664:79:33;19685:57;:13;893:4:14;19707:34:33;;;19685:21;:57::i;:::-;19664:16;;:20;:79::i;:::-;19657:86;;;;;;;;;;;17690:2060;;;;;;;;:::o;2092:178:35:-;2166:19;2226:4;2215:48;;;;;;;;;;;;:::i;19756:1459:33:-;19920:16;20930;20949:35;:11;20969:14;20949:19;:35::i;:::-;20930:54;;20995:27;21039:8;:15;21025:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21025:30:33;;20995:60;;21070:9;21065:116;21089:8;:15;21085:1;:19;21065:116;;;21141:29;21161:8;21141;21150:1;21141:11;;;;;;;;;;;;;;:19;;:29;;;;:::i;:::-;21125:10;21136:1;21125:13;;;;;;;;;;;;;;;;;:45;21106:3;;21065:116;;;-1:-1:-1;21198:10:33;19756:1459;-1:-1:-1;;;;;19756:1459:33:o;2276:264:35:-;2374:27;2403:22;2485:4;2474:59;;;;;;;;;;;;:::i;15034:2650:33:-;15262:7;;;15520:113;15544:8;:15;15540:1;:19;15520:113;;;15594:28;15610:8;15619:1;15610:11;;;;;;;15594:28;15580:42;-1:-1:-1;15561:3:33;;15520:113;;;;15716:40;15773:10;:17;15759:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;15759:32:33;;15716:75;;15801:33;15853:9;15848:337;15872:8;:15;15868:1;:19;15848:337;;;15908:21;15932:30;15950:11;15932:8;15941:1;15932:11;;;;;;;;;;;;;;:17;;:30;;;;:::i;:::-;15908:54;;16005:49;16042:8;16051:1;16042:11;;;;;;;;;;;;;;16005:30;16021:10;16032:1;16021:13;;;;;;;;;;;;;;16005:8;16014:1;16005:11;;;;;;;:49;15976:23;16000:1;15976:26;;;;;;;;;;;;;:78;;;;;16096;16126:47;16159:13;16126:23;16150:1;16126:26;;;;;;;;;;;;;;:32;;:47;;;;:::i;:::-;16096:25;;:29;:78::i;:::-;16068:106;-1:-1:-1;;15889:3:33;;15848:337;;;;16298:28;16343:8;:15;16329:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16329:30:33;;16298:61;;16374:9;16369:911;16393:8;:15;16389:1;:19;16369:911;;;16617:24;16687:23;16711:1;16687:26;;;;;;;;;;;;;;16659:25;:54;16655:550;;;16733:24;16760:59;16780:38;:25;:36;:38::i;:::-;16760:8;16769:1;16760:11;;;;;;;:59;16733:86;;16837:21;16861:35;16879:16;16861:10;16872:1;16861:13;;;;;;;:35;16837:59;-1:-1:-1;17042:77:33;17063:55;16837:59;893:4:14;17083:34:33;;;17063:19;:55::i;:::-;17042:16;;:20;:77::i;:::-;17023:96;;16655:550;;;;;17177:10;17188:1;17177:13;;;;;;;;;;;;;;17158:32;;16655:550;17236:33;17252:16;17236:8;17245:1;17236:11;;;;;;;:33;17219:11;17231:1;17219:14;;;;;;;;;;;;;;;;;:50;-1:-1:-1;16410:3:33;;16369:911;;;;17363:24;17390:40;17410:3;17415:8;17425:4;17390:19;:40::i;:::-;17363:67;;17440:20;17463:44;17483:3;17488:11;17501:5;17463:19;:44::i;:::-;17440:67;-1:-1:-1;17517:22:33;17542:38;17440:67;17563:16;17542:20;:38::i;:::-;17517:63;;17628:49;17649:27;:14;:25;:27::i;:::-;17628:14;;:20;:49::i;:::-;17621:56;15034:2650;-1:-1:-1;;;;;;;;;;;;;15034:2650:33:o;10260:2779::-;10487:7;;;10749:113;10773:8;:15;10769:1;:19;10749:113;;;10823:28;10839:8;10848:1;10839:11;;;;;;;10823:28;10809:42;-1:-1:-1;10790:3:33;;10749:113;;;;10945:37;10999:9;:16;10985:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10985:31:33;;10945:71;;11090:30;11139:9;11134:330;11158:8;:15;11154:1;:19;11134:330;;;11194:21;11218:32;11238:11;11218:8;11227:1;11218:11;;;;;;;:32;11194:56;;11290:50;11328:8;11337:1;11328:11;;;;;;;;;;;;;;11290:29;11306:9;11316:1;11306:12;;;;;;;;;;;;;;11290:8;11299:1;11290:11;;;;;;;:50;11264:20;11285:1;11264:23;;;;;;;;;;;;;:76;;;;;11379:74;11406:46;11438:13;11406:20;11427:1;11406:23;;;;;;;11379:74;11354:99;-1:-1:-1;;11175:3:33;;11134:330;;;;11577:28;11622:8;:15;11608:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11608:30:33;;11577:61;;11653:9;11648:826;11672:8;:15;11668:1;:19;11648:826;;;11708:26;11875:22;11849:20;11870:1;11849:23;;;;;;;;;;;;;;:48;11845:552;;;11917:24;11944:63;11964:42;:22;893:4:14;11964:26:33;:42::i;11944:63::-;11917:90;;12025:21;12049:34;12066:16;12049:9;12059:1;12049:12;;;;;;;:34;12025:58;-1:-1:-1;12231:79:33;12252:57;12025:58;893:4:14;12274:34:33;;;12252:21;:57::i;12231:79::-;12210:100;;11845:552;;;;;12370:9;12380:1;12370:12;;;;;;;;;;;;;;12349:33;;11845:552;12428:35;12444:18;12428:8;12437:1;12428:11;;;;;;;:35;12411:11;12423:1;12411:14;;;;;;;;;;;;;;;;;:52;-1:-1:-1;11689:3:33;;11648:826;;;;12557:24;12584:40;12604:3;12609:8;12619:4;12584:19;:40::i;:::-;12557:67;;12634:20;12657:44;12677:3;12682:11;12695:5;12657:19;:44::i;:::-;12634:67;-1:-1:-1;12711:22:33;12736:38;12634:67;12757:16;12736:20;:38::i;:::-;12711:63;;893:4:14;12874:14:33;:31;12870:163;;;12928:55;:14;12951:31;;;12928:22;:55::i;:::-;12921:62;;;;;;;;;;;12870:163;13021:1;13014:8;;;;;;;;;;;13045:1811;13293:7;13395:24;13422:40;13442:3;13447:8;13457:4;13422:19;:40::i;:::-;13395:67;-1:-1:-1;13508:20:33;13531:78;13395:67;13531:54;13570:14;13531:32;13570:14;13550:12;13531:18;:32::i;:78::-;13508:101;;13664:28;13695:148;13758:3;13775:8;13797:12;13823:10;13695:49;:148::i;:::-;13664:179;;13853:26;13882:46;13907:8;13916:10;13907:20;;;;;;;;;;;;;;13882;:24;;:46;;;;:::i;:::-;13853:75;;14073:19;14111:9;14106:113;14130:8;:15;14126:1;:19;14106:113;;;14180:28;14196:8;14205:1;14196:11;;;;;;;14180:28;14166:42;-1:-1:-1;14147:3:33;;14106:113;;;;14373:21;14397:41;14426:11;14397:8;14406:10;14397:20;;;;;;;:41;14373:65;;14448:25;14476:26;:13;:24;:26::i;:::-;14448:54;-1:-1:-1;14512:21:33;14536:43;:18;14448:54;14536:24;:43::i;:::-;14512:67;-1:-1:-1;14589:24:33;14616:37;:18;14512:67;14616:22;:37::i;:::-;14589:64;-1:-1:-1;14772:77:33;14793:55;:13;893:4:14;14813:34:33;;;14793:19;:55::i;4812:112:14:-;4866:7;893:4;4893:1;:7;4892:25;;4916:1;4892:25;;;-1:-1:-1;893:4:14;4905:7;;4812:112::o;5:130:-1:-;72:20;;97:33;72:20;97:33;:::i;1102:707::-;;1219:3;1212:4;1204:6;1200:17;1196:27;1186:2;;-1:-1;;1227:12;1186:2;1274:6;1261:20;1296:80;1311:64;1368:6;1311:64;:::i;:::-;1296:80;:::i;:::-;1404:21;;;1287:89;-1:-1;1448:4;1461:14;;;;1436:17;;;1550;;;1541:27;;;;1538:36;-1:-1;1535:2;;;1587:1;;1577:12;1535:2;1612:1;1597:206;1622:6;1619:1;1616:13;1597:206;;;6336:20;;1690:50;;1754:14;;;;1782;;;;1644:1;1637:9;1597:206;;;1601:14;;;;;1179:630;;;;:::o;1835:722::-;;1963:3;1956:4;1948:6;1944:17;1940:27;1930:2;;-1:-1;;1971:12;1930:2;2011:6;2005:13;2033:80;2048:64;2105:6;2048:64;:::i;2033:80::-;2141:21;;;2024:89;-1:-1;2185:4;2198:14;;;;2173:17;;;2287;;;2278:27;;;;2275:36;-1:-1;2272:2;;;2324:1;;2314:12;2272:2;2349:1;2334:217;2359:6;2356:1;2353:13;2334:217;;;6484:13;;2427:61;;2502:14;;;;2530;;;;2381:1;2374:9;2334:217;;3104:440;;3205:3;3198:4;3190:6;3186:17;3182:27;3172:2;;-1:-1;;3213:12;3172:2;3260:6;3247:20;33841:18;33833:6;33830:30;33827:2;;;-1:-1;;33863:12;33827:2;3282:64;34004:4;-1:-1;;3198:4;33921:6;33917:17;33913:33;33994:15;3282:64;:::i;:::-;3273:73;;3366:6;3359:5;3352:21;3470:3;34004:4;3461:6;3394;3452:16;;3449:25;3446:2;;;3487:1;;3477:12;3446:2;37444:6;34004:4;3394:6;3390:17;34004:4;3428:5;3424:16;37421:30;37500:1;37482:16;;;34004:4;37482:16;37475:27;3428:5;3165:379;-1:-1;;3165:379::o;4405:156::-;4485:20;;39175:1;39165:12;;39155:2;;39191:1;;39181:12;4610:1652;;4728:6;;4716:9;4711:3;4707:19;4703:32;4700:2;;;-1:-1;;4738:12;4700:2;4766:22;4728:6;4766:22;:::i;:::-;4757:31;;;4870:62;4928:3;4904:22;4870:62;:::i;:::-;4852:16;4845:88;5030:64;5090:3;4997:2;5070:9;5066:22;5030:64;:::i;:::-;4997:2;5016:5;5012:16;5005:90;5193:64;5253:3;5160:2;5233:9;5229:22;5193:64;:::i;:::-;5160:2;5179:5;5175:16;5168:90;5321:2;5379:9;5375:22;6336:20;5321:2;5340:5;5336:16;5329:75;5467:3;5526:9;5522:22;2898:20;5467:3;5487:5;5483:16;5476:75;5623:3;5682:9;5678:22;6336:20;5623:3;5643:5;5639:16;5632:75;5802:49;5847:3;5768;5827:9;5823:22;5802:49;:::i;:::-;5768:3;5788:5;5784:16;5777:75;5945:49;5990:3;5911;5970:9;5966:22;5945:49;:::i;:::-;5911:3;5931:5;5927:16;5920:75;6088:3;;6077:9;6073:19;6060:33;6113:18;6105:6;6102:30;6099:2;;;4838:1;;6135:12;6099:2;6182:58;6236:3;6227:6;6216:9;6212:22;6182:58;:::i;:::-;6088:3;6166:5;6162:18;6155:86;;;4694:1568;;;;:::o;6680:241::-;;6784:2;6772:9;6763:7;6759:23;6755:32;6752:2;;;-1:-1;;6790:12;6752:2;85:6;72:20;97:33;124:5;97:33;:::i;6928:366::-;;;7049:2;7037:9;7028:7;7024:23;7020:32;7017:2;;;-1:-1;;7055:12;7017:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7107:63;-1:-1;7207:2;7246:22;;72:20;97:33;72:20;97:33;:::i;:::-;7215:63;;;;7011:283;;;;;:::o;7301:491::-;;;;7439:2;7427:9;7418:7;7414:23;7410:32;7407:2;;;-1:-1;;7445:12;7407:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7497:63;-1:-1;7597:2;7636:22;;72:20;97:33;72:20;97:33;:::i;:::-;7401:391;;7605:63;;-1:-1;;;7705:2;7744:22;;;;6336:20;;7401:391::o;7799:991::-;;;;;;;;8003:3;7991:9;7982:7;7978:23;7974:33;7971:2;;;-1:-1;;8010:12;7971:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8062:63;-1:-1;8162:2;8201:22;;72:20;97:33;72:20;97:33;:::i;:::-;8170:63;-1:-1;8270:2;8309:22;;6336:20;;-1:-1;8378:2;8417:22;;6336:20;;-1:-1;8486:3;8524:22;;6612:20;36466:4;36455:16;;39388:33;;39378:2;;-1:-1;;39425:12;39378:2;7965:825;;;;-1:-1;7965:825;;;;8495:61;8593:3;8633:22;;2898:20;;-1:-1;8702:3;8742:22;;;2898:20;;7965:825;-1:-1;;7965:825::o;8797:366::-;;;8918:2;8906:9;8897:7;8893:23;8889:32;8886:2;;;-1:-1;;8924:12;8886:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8976:63;9076:2;9115:22;;;;6336:20;;-1:-1;;;8880:283::o;9170:823::-;;;;9384:2;9372:9;9363:7;9359:23;9355:32;9352:2;;;-1:-1;;9390:12;9352:2;9441:17;9435:24;9479:18;;9471:6;9468:30;9465:2;;;-1:-1;;9501:12;9465:2;9618:6;9607:9;9603:22;;;452:3;445:4;437:6;433:17;429:27;419:2;;-1:-1;;460:12;419:2;500:6;494:13;522:95;537:79;609:6;537:79;:::i;522:95::-;623:16;659:6;652:5;645:21;689:4;;706:3;702:14;695:21;;689:4;681:6;677:17;811:3;689:4;;795:6;791:17;681:6;782:27;;779:36;776:2;;;-1:-1;;818:12;776:2;-1:-1;844:10;;838:232;863:6;860:1;857:13;838:232;;;3999:6;3993:13;4011:48;4053:5;4011:48;:::i;:::-;931:76;;885:1;878:9;;;;;1021:14;;;;1049;;838:232;;;-1:-1;9678:18;;9672:25;9521:114;;-1:-1;9672:25;-1:-1;;;9706:30;;;9703:2;;;-1:-1;;9739:12;9703:2;;9769:89;9850:7;9841:6;9830:9;9826:22;9769:89;:::i;:::-;9759:99;;;9895:2;9949:9;9945:22;6484:13;9903:74;;9346:647;;;;;:::o;10000:235::-;;10101:2;10089:9;10080:7;10076:23;10072:32;10069:2;;;-1:-1;;10107:12;10069:2;2642:6;2629:20;2654:30;2678:5;2654:30;:::i;10242:257::-;;10354:2;10342:9;10333:7;10329:23;10325:32;10322:2;;;-1:-1;;10360:12;10322:2;2777:6;2771:13;2789:30;2813:5;2789:30;:::i;10506:1235::-;;;;;;;;10746:3;10734:9;10725:7;10721:23;10717:33;10714:2;;;-1:-1;;10753:12;10714:2;2911:6;2898:20;10805:63;;10905:2;10948:9;10944:22;72:20;97:33;124:5;97:33;:::i;:::-;10913:63;-1:-1;11013:2;11052:22;;72:20;97:33;72:20;97:33;:::i;:::-;11021:63;-1:-1;11149:2;11134:18;;11121:32;11173:18;11162:30;;;11159:2;;;-1:-1;;11195:12;11159:2;11225:78;11295:7;11286:6;11275:9;11271:22;11225:78;:::i;:::-;11215:88;;11340:3;11384:9;11380:22;6336:20;11349:63;;11449:3;11493:9;11489:22;6336:20;11458:63;;11586:3;11575:9;11571:19;11558:33;11544:47;;11173:18;11603:6;11600:30;11597:2;;;-1:-1;;11633:12;11597:2;;11663:62;11717:7;11708:6;11697:9;11693:22;11663:62;:::i;:::-;11653:72;;;10708:1033;;;;;;;;;;:::o;11748:239::-;;11851:2;11839:9;11830:7;11826:23;11822:32;11819:2;;;-1:-1;;11857:12;11819:2;3047:6;3034:20;35878:66;38510:5;35867:78;38486:5;38483:34;38473:2;;-1:-1;;38521:12;11994:303;;12129:2;12117:9;12108:7;12104:23;12100:32;12097:2;;;-1:-1;;12135:12;12097:2;3656:6;3650:13;3668:53;3715:5;3668:53;:::i;12304:500::-;;;12449:2;12437:9;12428:7;12424:23;12420:32;12417:2;;;-1:-1;;12455:12;12417:2;3828:6;3815:20;3840:48;3882:5;3840:48;:::i;:::-;12507:78;-1:-1;12650:2;12635:18;;12622:32;12674:18;12663:30;;12660:2;;;-1:-1;;12696:12;12660:2;12726:62;12780:7;12771:6;12760:9;12756:22;12726:62;:::i;:::-;12716:72;;;12411:393;;;;;:::o;12811:289::-;;12939:2;12927:9;12918:7;12914:23;12910:32;12907:2;;;-1:-1;;12945:12;12907:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;13107:690::-;;;;13294:2;13282:9;13273:7;13269:23;13265:32;13262:2;;;-1:-1;;13300:12;13262:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;13497:2;13482:18;;13476:25;13352:87;;-1:-1;13521:18;13510:30;;13507:2;;;-1:-1;;13543:12;13507:2;13573:89;13654:7;13645:6;13634:9;13630:22;13573:89;:::i;13804:425::-;;;13949:2;13937:9;13928:7;13924:23;13920:32;13917:2;;;-1:-1;;13955:12;13917:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;14131:2;14181:22;;;;6484:13;14007:87;;6484:13;;-1:-1;;;13911:318::o;14236:561::-;;;;14398:2;14386:9;14377:7;14373:23;14369:32;14366:2;;;-1:-1;;14404:12;14366:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;14580:2;14630:22;;6484:13;14699:2;14749:22;;;6484:13;14456:87;;6484:13;;-1:-1;6484:13;14360:437;-1:-1;;;14360:437::o;15100:554::-;;;15270:2;15258:9;15249:7;15245:23;15241:32;15238:2;;;-1:-1;;15276:12;15238:2;4168:6;4162:13;4180:46;4220:5;4180:46;:::i;:::-;15473:2;15458:18;;15452:25;15328:87;;-1:-1;15497:18;15486:30;;15483:2;;;-1:-1;;15519:12;15483:2;15549:89;15630:7;15621:6;15610:9;15606:22;15549:89;:::i;16926:897::-;;;;;17135:3;17123:9;17114:7;17110:23;17106:33;17103:2;;;-1:-1;;17142:12;17103:2;17200:17;17187:31;17238:18;;17230:6;17227:30;17224:2;;;-1:-1;;17260:12;17224:2;17290:82;17364:7;17355:6;17344:9;17340:22;17290:82;:::i;:::-;17280:92;;17437:2;17426:9;17422:18;17409:32;17395:46;;17238:18;17453:6;17450:30;17447:2;;;-1:-1;;17483:12;17447:2;;17513:78;17583:7;17574:6;17563:9;17559:22;17513:78;:::i;:::-;17097:726;;17503:88;;-1:-1;;;;17628:2;17667:22;;6336:20;;17736:2;17775:22;6336:20;;17097:726;-1:-1;17097:726::o;17830:635::-;;;;17997:2;17985:9;17976:7;17972:23;17968:32;17965:2;;;-1:-1;;18003:12;17965:2;18061:17;18048:31;18099:18;18091:6;18088:30;18085:2;;;-1:-1;;18121:12;18085:2;18151:82;18225:7;18216:6;18205:9;18201:22;18151:82;:::i;:::-;18141:92;18270:2;18309:22;;6336:20;;-1:-1;18378:2;18417:22;;;6336:20;;17959:506;-1:-1;;;;17959:506::o;18472:241::-;;18576:2;18564:9;18555:7;18551:23;18547:32;18544:2;;;-1:-1;;18582:12;18544:2;-1:-1;6336:20;;18538:175;-1:-1;18538:175::o;18720:366::-;;;18841:2;18829:9;18820:7;18816:23;18812:32;18809:2;;;-1:-1;;18847:12;18809:2;-1:-1;;6336:20;;;18999:2;19038:22;;;6336:20;;-1:-1;18803:283::o;19093:672::-;;;;;19259:3;19247:9;19238:7;19234:23;19230:33;19227:2;;;-1:-1;;19266:12;19227:2;6490:6;6484:13;19318:74;;19429:2;19483:9;19479:22;6484:13;19437:74;;19548:2;19602:9;19598:22;6484:13;19556:74;;19667:2;19721:9;19717:22;220:13;238:33;265:5;238:33;:::i;:::-;19221:544;;;;-1:-1;19221:544;;-1:-1;;19221:544::o;20105:690::-;;20298:5;34287:12;34831:6;34826:3;34819:19;34868:4;;34863:3;34859:14;20310:93;;34868:4;20474:5;34141:14;-1:-1;20513:260;20538:6;20535:1;20532:13;20513:260;;;20599:13;;20985:37;;19926:14;;;;34674;;;;20560:1;20553:9;20513:260;;;-1:-1;20779:10;;20229:566;-1:-1;;;;;20229:566::o;21689:343::-;;21831:5;34287:12;34831:6;34826:3;34819:19;-1:-1;37589:101;37603:6;37600:1;37597:13;37589:101;;;34868:4;37670:11;;;;;37664:18;37651:11;;;;;37644:39;37618:10;37589:101;;;37705:6;37702:1;37699:13;37696:2;;;-1:-1;34868:4;37761:6;34863:3;37752:16;;37745:27;37696:2;-1:-1;38042:2;38022:14;-1:-1;;38018:28;21988:39;;;;34868:4;21988:39;;21779:253;-1:-1;;21779:253::o;23643:387::-;20985:37;;;35878:66;35867:78;23894:2;23885:12;;21280:56;23994:11;;;23785:245::o;24037:291::-;;37444:6;37439:3;37434;37421:30;37482:16;;37475:27;;;37482:16;24181:147;-1:-1;24181:147::o;24335:659::-;23188:66;23168:87;;23153:1;23274:11;;20985:37;;;;24846:12;;;20985:37;24957:12;;;24580:414::o;25001:222::-;-1:-1;;;;;36250:54;;;;20025:37;;25128:2;25113:18;;25099:124::o;25230:629::-;;25485:2;25506:17;25499:47;25560:108;25485:2;25474:9;25470:18;25654:6;25560:108;:::i;:::-;25716:9;25710:4;25706:20;25701:2;25690:9;25686:18;25679:48;25741:108;25844:4;25835:6;25741:108;:::i;25866:210::-;35701:13;;35694:21;20868:34;;25987:2;25972:18;;25958:118::o;26083:432::-;35701:13;;35694:21;20868:34;;26418:2;26403:18;;20985:37;;;;26501:2;26486:18;;20985:37;26260:2;26245:18;;26231:284::o;26522:222::-;20985:37;;;26649:2;26634:18;;26620:124::o;26751:444::-;20985:37;;;-1:-1;;;;;36250:54;;;27098:2;27083:18;;20025:37;36250:54;27181:2;27166:18;;20025:37;26934:2;26919:18;;26905:290::o;27202:780::-;20985:37;;;-1:-1;;;;;36250:54;;;27634:2;27619:18;;20025:37;36250:54;;;;27717:2;27702:18;;20025:37;27800:2;27785:18;;20985:37;27883:3;27868:19;;20985:37;;;;27967:3;27952:19;;20985:37;27469:3;27454:19;;27440:542::o;27989:668::-;20985:37;;;28393:2;28378:18;;20985:37;;;;28476:2;28461:18;;20985:37;;;;28559:2;28544:18;;20985:37;-1:-1;;;;;36250:54;28642:3;28627:19;;20025:37;28228:3;28213:19;;28199:458::o;28664:417::-;;21015:5;20992:3;20985:37;28837:2;28955;28944:9;28940:18;28933:48;28995:76;28837:2;28826:9;28822:18;29057:6;28995:76;:::i;29088:363::-;20985:37;;;-1:-1;;;;;36250:54;29437:2;29422:18;;22130:70;29258:2;29243:18;;29229:222::o;29458:548::-;20985:37;;;36466:4;36455:16;;;;29826:2;29811:18;;23596:35;29909:2;29894:18;;20985:37;29992:2;29977:18;;20985:37;29665:3;29650:19;;29636:370::o;30541:310::-;;30688:2;30709:17;30702:47;30763:78;30688:2;30677:9;30673:18;30827:6;30763:78;:::i;31087:481::-;;21015:5;20992:3;20985:37;31292:2;31410;31399:9;31395:18;31388:48;31450:108;31292:2;31281:9;31277:18;31544:6;31450:108;:::i;31575:432::-;20985:37;;;35701:13;;35694:21;31910:2;31895:18;;20868:34;31993:2;31978:18;;20985:37;31752:2;31737:18;;31723:284::o;32014:556::-;20985:37;;;32390:2;32375:18;;20985:37;;;;32473:2;32458:18;;20985:37;32556:2;32541:18;;20985:37;32225:3;32210:19;;32196:374::o;32577:214::-;36466:4;36455:16;;;;23596:35;;32700:2;32685:18;;32671:120::o;32798:256::-;32860:2;32854:9;32886:17;;;32961:18;32946:34;;32982:22;;;32943:62;32940:2;;;33018:1;;33008:12;32940:2;32860;33027:22;32838:216;;-1:-1;32838:216::o;33061:319::-;;33235:18;33227:6;33224:30;33221:2;;;-1:-1;;33257:12;33221:2;-1:-1;33302:4;33290:17;;;33355:15;;33158:222::o;38059:117::-;-1:-1;;;;;38146:5;36250:54;38121:5;38118:35;38108:2;;38167:1;;38157:12;38183:111;38264:5;35701:13;35694:21;38242:5;38239:32;38229:2;;38285:1;;38275:12;38865:107;38947:1;38940:5;38937:12;38927:2;;38963:1;;38953:12

Swarm Source

ipfs://74699730ea8aa4fa00d2702d985bebe2cf30c6abf09e7ee52a1750d232c882ff
Loading