Address Details
contract

0xCFf82ec7E6De78191D78753b7B944Ea8f28a0ce8

Contract Name
BondingCurveController
Creator
0x49670e–a21bb1 at 0x4fdf7c–5d939a
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
2 Transactions
Transfers
0 Transfers
Gas Used
11,621,489
Last Balance Update
20597651
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
BondingCurveController




Optimization enabled
true
Compiler version
v0.7.6+commit.7338295f




Optimization runs
200
EVM Version
istanbul




Verified at
2023-07-15T12:57:11.297121Z

project:/contracts/BondingCurveController.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./base/BaseController.sol";
import "./lib/SupportLib.sol";

contract BondingCurveController is BaseController {

    struct CurveValues {
        IManagedPool managedPool;
        bytes32 poolId;
        bool bJoin;
        bool bExit;
        IVault.ExitPoolRequest newExitRequest;
        IVault.JoinPoolRequest newJoinRequest;
        uint256[] tokenPrices;
        int256[] oraclePriceDeltas;
        uint256[] tokenBalancesToAdd;
        uint256[] tokenBalancesToRemove;
        uint256[] normalizedWeights;
        IERC20[] tokens;
        uint256[] balances;
        IAsset[] assets;
    }

    /**
     * @notice Constructor for the controller implementation class
     *
     * @param _vaultAddress - Vault contract address
     * @param _managedPoolFactory - Managed pool contract address
     */
    constructor(address _vaultAddress,
                address _managedPoolFactory) BaseController(_vaultAddress, _managedPoolFactory) {}

    /**
     * @notice Runs a check and transfers reserve tokens as needed
     * @dev To avoid too many fees, this should be run at wide intervals such as daily
     *
     * @param _poolAddress - Address of pool being worked on.
     */
    function runCheck(address _poolAddress) public restricted nonReentrant
    {
        CurveValues memory curveInfo;
        curveInfo.managedPool = IManagedPool(_poolAddress);
        curveInfo.poolId = curveInfo.managedPool.getPoolId();
        vault.getPool(curveInfo.poolId);
        curveInfo.normalizedWeights = curveInfo.managedPool.getNormalizedWeights();

        (curveInfo.tokens, curveInfo.balances,) = vault.getPoolTokens(curveInfo.poolId);
        curveInfo.assets = SupportLib._convertERC20sToAssets(curveInfo.tokens);

        curveInfo.bJoin = false;
        curveInfo.bExit = false;
        if (curveInfo.balances[0]  > 0)
        {
            curveInfo.tokenPrices[0] = (curveInfo.balances[1] / curveInfo.normalizedWeights[1]) / (curveInfo.balances[0] / curveInfo.normalizedWeights[0]);
        }

        // Get price of other tokens
        for (uint256 i = 1; i < curveInfo.tokens.length; i++) {
            if (curveInfo.balances[i] > 0)
            {
                curveInfo.tokenPrices[i] = (curveInfo.balances[0] / curveInfo.normalizedWeights[0]) / (curveInfo.balances[i] / curveInfo.normalizedWeights[i]);
            }
        }

        // We now have a list of tokens and prices in this pool so we next get token prices from an external oracle and record the delta.
        // We don't presently have an oracle so for testing we'll use the tolerance value set when creating the pool
        for (uint256 i = 1; i < curveInfo.tokens.length; i++) {
            if (curveInfo.tokenPrices[i] > 0)
            {
                curveInfo.oraclePriceDeltas[i] = int256(managedPools[_poolAddress].tolerance);
            }
        }

        for (uint256 i = 1; i < curveInfo.tokens.length; i++) {
            if (curveInfo.oraclePriceDeltas[i] >= int256(managedPools[_poolAddress].tolerance))
            {
                curveInfo.tokenBalancesToRemove[i] = curveInfo.balances[i] / 100 * managedPools[_poolAddress].tolerance;
                curveInfo.bExit = true;
            }
            else if (curveInfo.oraclePriceDeltas[i] <= -int256(managedPools[_poolAddress].tolerance))
            {
                curveInfo.tokenBalancesToAdd[i] = curveInfo.balances[i] / 100 * managedPools[_poolAddress].tolerance;
                curveInfo.bJoin = true;
            }
            else
            {
                curveInfo.tokenBalancesToAdd[i] = 0;
                curveInfo.tokenBalancesToRemove[i] = 0;
            }
        }

        // If there's tokens to remove then call exitPool
        if (curveInfo.bExit)
        {
            curveInfo.newExitRequest.assets = curveInfo.assets;
            curveInfo.newExitRequest.userData = "";
            curveInfo.newExitRequest.toInternalBalance = true;
            curveInfo.newExitRequest.minAmountsOut = curveInfo.tokenBalancesToRemove;

            vault.exitPool(curveInfo.poolId,
                               address(this),
                               payable(_poolAddress),
                               curveInfo.newExitRequest);
        }

        // If there's tokens to add then call joinPool
        if (curveInfo.bJoin)
        {
            curveInfo.newJoinRequest.assets = curveInfo.assets;
            curveInfo.newJoinRequest.userData = "";
            curveInfo.newJoinRequest.fromInternalBalance = true;
            curveInfo.newJoinRequest.maxAmountsIn = curveInfo.tokenBalancesToAdd;

            vault.joinPool(curveInfo.poolId,
                           address(this),
                           payable(_poolAddress),
                           curveInfo.newJoinRequest);
        }
    }
}
        

/_balancer-labs/v2-interfaces/contracts/pool-utils/IManagedPool.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 <0.9.0;

import "../solidity-utils/openzeppelin/IERC20.sol";
import "../vault/IBasePool.sol";

interface IManagedPool is IBasePool {
    event GradualSwapFeeUpdateScheduled(
        uint256 startTime,
        uint256 endTime,
        uint256 startSwapFeePercentage,
        uint256 endSwapFeePercentage
    );
    event GradualWeightUpdateScheduled(
        uint256 startTime,
        uint256 endTime,
        uint256[] startWeights,
        uint256[] endWeights
    );
    event SwapEnabledSet(bool swapEnabled);
    event JoinExitEnabledSet(bool joinExitEnabled);
    event MustAllowlistLPsSet(bool mustAllowlistLPs);
    event AllowlistAddressAdded(address indexed member);
    event AllowlistAddressRemoved(address indexed member);
    event ManagementAumFeePercentageChanged(uint256 managementAumFeePercentage);
    event ManagementAumFeeCollected(uint256 bptAmount);
    event CircuitBreakerSet(
        IERC20 indexed token,
        uint256 bptPrice,
        uint256 lowerBoundPercentage,
        uint256 upperBoundPercentage
    );
    event TokenAdded(IERC20 indexed token, uint256 normalizedWeight);
    event TokenRemoved(IERC20 indexed token);

    /**
     * @notice Returns the effective BPT supply.
     *
     * @dev The Pool owes debt to the Protocol and the Pool's owner in the form of unminted BPT, which will be minted
     * immediately before the next join or exit. We need to take these into account since, even if they don't yet exist,
     * they will effectively be included in any Pool operation that involves BPT.
     *
     * In the vast majority of cases, this function should be used instead of `totalSupply()`.
     *
     * WARNING: since this function reads balances directly from the Vault, it is potentially subject to manipulation
     * via reentrancy. See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
     *
     * To call this function safely, attempt to trigger the reentrancy guard in the Vault by calling a non-reentrant
     * function before calling `getActualSupply`. That will make the transaction revert in an unsafe context.
     * (See `whenNotInVaultContext` in `ManagedPoolSettings`).
     */
    function getActualSupply() external view returns (uint256);

    // Swap fee percentage

    /**
     * @notice Schedule a gradual swap fee update.
     * @dev The swap fee will change from the given starting value (which may or may not be the current
     * value) to the given ending fee percentage, over startTime to endTime.
     *
     * Note that calling this with a starting swap fee different from the current value will immediately change the
     * current swap fee to `startSwapFeePercentage`, before commencing the gradual change at `startTime`.
     * Emits the GradualSwapFeeUpdateScheduled event.
     * This is a permissioned function.
     *
     * @param startTime - The timestamp when the swap fee change will begin.
     * @param endTime - The timestamp when the swap fee change will end (must be >= startTime).
     * @param startSwapFeePercentage - The starting value for the swap fee change.
     * @param endSwapFeePercentage - The ending value for the swap fee change. If the current timestamp >= endTime,
     * `getSwapFeePercentage()` will return this value.
     */
    function updateSwapFeeGradually(
        uint256 startTime,
        uint256 endTime,
        uint256 startSwapFeePercentage,
        uint256 endSwapFeePercentage
    ) external;

    /**
     * @notice Returns the current gradual swap fee update parameters.
     * @dev The current swap fee can be retrieved via `getSwapFeePercentage()`.
     * @return startTime - The timestamp when the swap fee update will begin.
     * @return endTime - The timestamp when the swap fee update will end.
     * @return startSwapFeePercentage - The starting swap fee percentage (could be different from the current value).
     * @return endSwapFeePercentage - The final swap fee percentage, when the current timestamp >= endTime.
     */
    function getGradualSwapFeeUpdateParams()
        external
        view
        returns (
            uint256 startTime,
            uint256 endTime,
            uint256 startSwapFeePercentage,
            uint256 endSwapFeePercentage
        );

    // Token weights

    /**
     * @notice Schedule a gradual weight change.
     * @dev The weights will change from their current values to the given endWeights, over startTime to endTime.
     * This is a permissioned function.
     *
     * Since, unlike with swap fee updates, we generally do not want to allow instantaneous weight changes,
     * the weights always start from their current values. This also guarantees a smooth transition when
     * updateWeightsGradually is called during an ongoing weight change.
     * @param startTime - The timestamp when the weight change will begin.
     * @param endTime - The timestamp when the weight change will end (can be >= startTime).
     * @param tokens - The tokens associated with the target weights (must match the current pool tokens).
     * @param endWeights - The target weights. If the current timestamp >= endTime, `getNormalizedWeights()`
     * will return these values.
     */
    function updateWeightsGradually(
        uint256 startTime,
        uint256 endTime,
        IERC20[] memory tokens,
        uint256[] memory endWeights
    ) external;

    /**
     * @notice Returns all normalized weights, in the same order as the Pool's tokens.
     */
    function getNormalizedWeights() external view returns (uint256[] memory);

    /**
     * @notice Returns the current gradual weight change update parameters.
     * @dev The current weights can be retrieved via `getNormalizedWeights()`.
     * @return startTime - The timestamp when the weight update will begin.
     * @return endTime - The timestamp when the weight update will end.
     * @return startWeights - The starting weights, when the weight change was initiated.
     * @return endWeights - The final weights, when the current timestamp >= endTime.
     */
    function getGradualWeightUpdateParams()
        external
        view
        returns (
            uint256 startTime,
            uint256 endTime,
            uint256[] memory startWeights,
            uint256[] memory endWeights
        );

    // Join and Exit enable/disable

    /**
     * @notice Enable or disable joins and exits. Note that this does not affect Recovery Mode exits.
     * @dev Emits the JoinExitEnabledSet event. This is a permissioned function.
     * @param joinExitEnabled - The new value of the join/exit enabled flag.
     */
    function setJoinExitEnabled(bool joinExitEnabled) external;

    /**
     * @notice Returns whether joins and exits are enabled.
     */
    function getJoinExitEnabled() external view returns (bool);

    // Swap enable/disable

    /**
     * @notice Enable or disable trading.
     * @dev Emits the SwapEnabledSet event. This is a permissioned function.
     * @param swapEnabled - The new value of the swap enabled flag.
     */
    function setSwapEnabled(bool swapEnabled) external;

    /**
     * @notice Returns whether swaps are enabled.
     */
    function getSwapEnabled() external view returns (bool);

    // LP Allowlist

    /**
     * @notice Enable or disable the LP allowlist.
     * @dev Note that any addresses added to the allowlist will be retained if the allowlist is toggled off and
     * back on again, because this action does not affect the list of LP addresses.
     * Emits the MustAllowlistLPsSet event. This is a permissioned function.
     * @param mustAllowlistLPs - The new value of the mustAllowlistLPs flag.
     */
    function setMustAllowlistLPs(bool mustAllowlistLPs) external;

    /**
     * @notice Adds an address to the LP allowlist.
     * @dev Will fail if the address is already allowlisted.
     * Emits the AllowlistAddressAdded event. This is a permissioned function.
     * @param member - The address to be added to the allowlist.
     */
    function addAllowedAddress(address member) external;

    /**
     * @notice Removes an address from the LP allowlist.
     * @dev Will fail if the address was not previously allowlisted.
     * Emits the AllowlistAddressRemoved event. This is a permissioned function.
     * @param member - The address to be removed from the allowlist.
     */
    function removeAllowedAddress(address member) external;

    /**
     * @notice Returns whether the allowlist for LPs is enabled.
     */
    function getMustAllowlistLPs() external view returns (bool);

    /**
     * @notice Check whether an LP address is on the allowlist.
     * @dev This simply checks the list, regardless of whether the allowlist feature is enabled.
     * @param member - The address to check against the allowlist.
     * @return true if the given address is on the allowlist.
     */
    function isAddressOnAllowlist(address member) external view returns (bool);

    // Management fees

    /**
     * @notice Collect any accrued AUM fees and send them to the pool manager.
     * @dev This can be called by anyone to collect accrued AUM fees - and will be called automatically
     * whenever the supply changes (e.g., joins and exits, add and remove token), and before the fee
     * percentage is changed by the manager, to prevent fees from being applied retroactively.
     *
     * Correct behavior depends on the current supply, which is potentially manipulable if the pool
     * is reentered during execution of a Vault hook. This is protected where overridden in ManagedPoolSettings,
     * and so is safe to call on ManagedPool.
     *
     * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
     *
     * @return The amount of BPT minted to the manager.
     */
    function collectAumManagementFees() external returns (uint256);

    /**
     * @notice Setter for the yearly percentage AUM management fee, which is payable to the pool manager.
     * @dev Attempting to collect AUM fees in excess of the maximum permitted percentage will revert.
     * To avoid retroactive fee increases, we force collection at the current fee percentage before processing
     * the update. Emits the ManagementAumFeePercentageChanged event. This is a permissioned function.
     *
     * To prevent changing management fees retroactively, this triggers payment of protocol fees before applying
     * the change. Correct behavior depends on the current supply, which is potentially manipulable if the pool
     * is reentered during execution of a Vault hook. This is protected where overridden in ManagedPoolSettings,
     * and so is safe to call on ManagedPool.
     *
     * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
     *
     * @param managementAumFeePercentage - The new management AUM fee percentage.
     * @return amount - The amount of BPT minted to the manager before the update, if any.
     */
    function setManagementAumFeePercentage(uint256 managementAumFeePercentage) external returns (uint256);

    /**
     * @notice Returns the management AUM fee percentage as an 18-decimal fixed point number and the timestamp of the
     * last collection of AUM fees.
     */
    function getManagementAumFeeParams()
        external
        view
        returns (uint256 aumFeePercentage, uint256 lastCollectionTimestamp);

    // Circuit Breakers

    /**
     * @notice Set a circuit breaker for one or more tokens.
     * @dev This is a permissioned function. The lower and upper bounds are percentages, corresponding to a
     * relative change in the token's spot price: e.g., a lower bound of 0.8 means the breaker should prevent
     * trades that result in the value of the token dropping 20% or more relative to the rest of the pool.
     */
    function setCircuitBreakers(
        IERC20[] memory tokens,
        uint256[] memory bptPrices,
        uint256[] memory lowerBoundPercentages,
        uint256[] memory upperBoundPercentages
    ) external;

    /**
     * @notice Return the full circuit breaker state for the given token.
     * @dev These are the reference values (BPT price and reference weight) passed in when the breaker was set,
     * along with the percentage bounds. It also returns the current BPT price bounds, needed to check whether
     * the circuit breaker should trip.
     */
    function getCircuitBreakerState(IERC20 token)
        external
        view
        returns (
            uint256 bptPrice,
            uint256 referenceWeight,
            uint256 lowerBound,
            uint256 upperBound,
            uint256 lowerBptPriceBound,
            uint256 upperBptPriceBound
        );

    // Add/remove tokens

    /**
     * @notice Adds a token to the Pool's list of tradeable tokens. This is a permissioned function.
     *
     * @dev By adding a token to the Pool's composition, the weights of all other tokens will be decreased. The new
     * token will have no balance - it is up to the owner to provide some immediately after calling this function.
     * Note however that regular join functions will not work while the new token has no balance: the only way to
     * deposit an initial amount is by using an Asset Manager.
     *
     * Token addition is forbidden during a weight change, or if one is scheduled to happen in the future.
     *
     * The caller may additionally pass a non-zero `mintAmount` to have some BPT be minted for them, which might be
     * useful in some scenarios to account for the fact that the Pool will have more tokens.
     *
     * Emits the TokenAdded event. This is a permissioned function.
     *
     * Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
     * the pool during execution of a Vault hook. This is protected where overridden in ManagedPoolSettings,
     * and so is safe to call on ManagedPool.
     *
     * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
     *
     * @param tokenToAdd - The ERC20 token to be added to the Pool.
     * @param assetManager - The Asset Manager for the token.
     * @param tokenToAddNormalizedWeight - The normalized weight of `token` relative to the other tokens in the Pool.
     * @param mintAmount - The amount of BPT to be minted as a result of adding `token` to the Pool.
     * @param recipient - The address to receive the BPT minted by the Pool.
     */
    function addToken(
        IERC20 tokenToAdd,
        address assetManager,
        uint256 tokenToAddNormalizedWeight,
        uint256 mintAmount,
        address recipient
    ) external;

    /**
     * @notice Removes a token from the Pool's list of tradeable tokens.
     * @dev Tokens can only be removed if the Pool has more than 2 tokens, as it can never have fewer than 2 (not
     * including BPT). Token removal is also forbidden during a weight change, or if one is scheduled to happen in
     * the future.
     *
     * Emits the TokenRemoved event. This is a permissioned function.
     * Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
     * the pool during execution of a Vault hook. This is protected where overridden in ManagedPoolSettings,
     * and so is safe to call on ManagedPool.
     *
     * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
     *
     * The caller may additionally pass a non-zero `burnAmount` to burn some of their BPT, which might be useful
     * in some scenarios to account for the fact that the Pool now has fewer tokens. This is a permissioned function.
     * @param tokenToRemove - The ERC20 token to be removed from the Pool.
     * @param burnAmount - The amount of BPT to be burned after removing `token` from the Pool.
     * @param sender - The address to burn BPT from.
     */
    function removeToken(
        IERC20 tokenToRemove,
        uint256 burnAmount,
        address sender
    ) external;
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/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 <0.9.0;

// solhint-disable

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

/**
 * @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,
    bytes3 prefix
) pure {
    if (!condition) _revert(errorCode, prefix);
}

/**
 * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
 * Uses the default 'BAL' prefix for the error code
 */
function _revert(uint256 errorCode) pure {
    _revert(errorCode, 0x42414c); // This is the raw byte representation of "BAL"
}

/**
 * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
 */
function _revert(uint256 errorCode, bytes3 prefix) pure {
    uint256 prefixUint = uint256(uint24(prefix));
    // 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.
        // We first append the '#' character (0x23) to the prefix. In the case of 'BAL', it results in 0x42414c23 ('BAL#')
        // Then, we 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 formattedPrefix := shl(24, add(0x23, shl(8, prefixUint)))

        let revertReason := shl(200, add(formattedPrefix, 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;
    uint256 internal constant INSUFFICIENT_DATA = 105;

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

    // Pools
    uint256 internal constant MIN_AMP = 300;
    uint256 internal constant MAX_AMP = 301;
    uint256 internal constant MIN_WEIGHT = 302;
    uint256 internal constant MAX_STABLE_TOKENS = 303;
    uint256 internal constant MAX_IN_RATIO = 304;
    uint256 internal constant MAX_OUT_RATIO = 305;
    uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306;
    uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307;
    uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308;
    uint256 internal constant INVALID_TOKEN = 309;
    uint256 internal constant UNHANDLED_JOIN_KIND = 310;
    uint256 internal constant ZERO_INVARIANT = 311;
    uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312;
    uint256 internal constant ORACLE_NOT_INITIALIZED = 313;
    uint256 internal constant ORACLE_QUERY_TOO_OLD = 314;
    uint256 internal constant ORACLE_INVALID_INDEX = 315;
    uint256 internal constant ORACLE_BAD_SECS = 316;
    uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317;
    uint256 internal constant AMP_ONGOING_UPDATE = 318;
    uint256 internal constant AMP_RATE_TOO_HIGH = 319;
    uint256 internal constant AMP_NO_ONGOING_UPDATE = 320;
    uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321;
    uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322;
    uint256 internal constant RELAYER_NOT_CONTRACT = 323;
    uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324;
    uint256 internal constant REBALANCING_RELAYER_REENTERED = 325;
    uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326;
    uint256 internal constant SWAPS_DISABLED = 327;
    uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328;
    uint256 internal constant PRICE_RATE_OVERFLOW = 329;
    uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330;
    uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331;
    uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332;
    uint256 internal constant UPPER_TARGET_TOO_HIGH = 333;
    uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334;
    uint256 internal constant OUT_OF_TARGET_RANGE = 335;
    uint256 internal constant UNHANDLED_EXIT_KIND = 336;
    uint256 internal constant UNAUTHORIZED_EXIT = 337;
    uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338;
    uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339;
    uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340;
    uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341;
    uint256 internal constant INVALID_INITIALIZATION = 342;
    uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343;
    uint256 internal constant FEATURE_DISABLED = 344;
    uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345;
    uint256 internal constant SET_SWAP_FEE_DURING_FEE_CHANGE = 346;
    uint256 internal constant SET_SWAP_FEE_PENDING_FEE_CHANGE = 347;
    uint256 internal constant CHANGE_TOKENS_DURING_WEIGHT_CHANGE = 348;
    uint256 internal constant CHANGE_TOKENS_PENDING_WEIGHT_CHANGE = 349;
    uint256 internal constant MAX_WEIGHT = 350;
    uint256 internal constant UNAUTHORIZED_JOIN = 351;
    uint256 internal constant MAX_MANAGEMENT_AUM_FEE_PERCENTAGE = 352;
    uint256 internal constant FRACTIONAL_TARGET = 353;
    uint256 internal constant ADD_OR_REMOVE_BPT = 354;
    uint256 internal constant INVALID_CIRCUIT_BREAKER_BOUNDS = 355;
    uint256 internal constant CIRCUIT_BREAKER_TRIPPED = 356;
    uint256 internal constant MALICIOUS_QUERY_REVERT = 357;
    uint256 internal constant JOINS_EXITS_DISABLED = 358;

    // Lib
    uint256 internal constant REENTRANCY = 400;
    uint256 internal constant SENDER_NOT_ALLOWED = 401;
    uint256 internal constant PAUSED = 402;
    uint256 internal constant PAUSE_WINDOW_EXPIRED = 403;
    uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404;
    uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405;
    uint256 internal constant INSUFFICIENT_BALANCE = 406;
    uint256 internal constant INSUFFICIENT_ALLOWANCE = 407;
    uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408;
    uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409;
    uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410;
    uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411;
    uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412;
    uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413;
    uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414;
    uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415;
    uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416;
    uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417;
    uint256 internal constant SAFE_ERC20_CALL_FAILED = 418;
    uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419;
    uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420;
    uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421;
    uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422;
    uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423;
    uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424;
    uint256 internal constant BUFFER_PERIOD_EXPIRED = 425;
    uint256 internal constant CALLER_IS_NOT_OWNER = 426;
    uint256 internal constant NEW_OWNER_IS_ZERO = 427;
    uint256 internal constant CODE_DEPLOYMENT_FAILED = 428;
    uint256 internal constant CALL_TO_NON_CONTRACT = 429;
    uint256 internal constant LOW_LEVEL_CALL_FAILED = 430;
    uint256 internal constant NOT_PAUSED = 431;
    uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432;
    uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433;
    uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434;
    uint256 internal constant INVALID_OPERATION = 435;
    uint256 internal constant CODEC_OVERFLOW = 436;
    uint256 internal constant IN_RECOVERY_MODE = 437;
    uint256 internal constant NOT_IN_RECOVERY_MODE = 438;
    uint256 internal constant INDUCED_FAILURE = 439;
    uint256 internal constant EXPIRED_SIGNATURE = 440;
    uint256 internal constant MALFORMED_SIGNATURE = 441;
    uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_UINT64 = 442;
    uint256 internal constant UNHANDLED_FEE_TYPE = 443;
    uint256 internal constant BURN_FROM_ZERO = 444;

    // 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;
    uint256 internal constant AUM_FEE_PERCENTAGE_TOO_HIGH = 603;

    // FeeSplitter
    uint256 internal constant SPLITTER_FEE_PERCENTAGE_TOO_HIGH = 700;

    // Misc
    uint256 internal constant UNIMPLEMENTED = 998;
    uint256 internal constant SHOULD_NOT_HAPPEN = 999;
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/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 <0.9.0;

interface IAuthentication {
    /**
     * @dev Returns the action identifier associated with the external function described by `selector`.
     */
    function getActionId(bytes4 selector) external view returns (bytes32);
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/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 <0.9.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);
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/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 <0.9.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
        );
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/misc/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 <0.9.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;
}
          

/_balancer-labs/v2-interfaces/contracts/solidity-utils/openzeppelin/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.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);
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.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
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.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);
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.0;
pragma experimental ABIEncoderV2;

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

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

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

    /**
     * @dev Returns this Pool's ID, used when interacting with the Vault (to e.g. join the Pool or swap with it).
     */
    function getPoolId() external view returns (bytes32);

    /**
     * @dev Returns the current swap fee percentage as a 18 decimal fixed point number, so e.g. 1e17 corresponds to a
     * 10% swap fee.
     */
    function getSwapFeePercentage() external view returns (uint256);

    /**
     * @dev Returns the scaling factors of each of the Pool's tokens. This is an implementation detail that is typically
     * not relevant for outside parties, but which might be useful for some types of Pools.
     */
    function getScalingFactors() external view returns (uint256[] memory);

    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);

    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);
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.0;

// Inspired by Aave Protocol's IFlashLoanReceiver.

import "../solidity-utils/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;
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.0;
pragma experimental ABIEncoderV2;

import "../solidity-utils/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;
    }
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 <0.9.0;
pragma experimental ABIEncoderV2;

import "../solidity-utils/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);
}
          

/_balancer-labs/v2-interfaces/contracts/vault/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 "../solidity-utils/openzeppelin/IERC20.sol";
import "../solidity-utils/helpers/IAuthentication.sol";
import "../solidity-utils/helpers/ISignaturesValidator.sol";
import "../solidity-utils/helpers/ITemporarilyPausable.sol";
import "../solidity-utils/misc/IWETH.sol";

import "./IAsset.sol";
import "./IAuthorizer.sol";
import "./IFlashLoanRecipient.sol";
import "./IProtocolFeesCollector.sol";

pragma solidity >=0.7.0 <0.9.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, IAuthentication {
    // 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
}
          

/_balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

// Based on the ReentrancyGuard library from OpenZeppelin Contracts, altered to reduce bytecode size.
// Modifier code is inlined by the compiler, which causes its code to appear multiple times in the codebase. By using
// private functions, we achieve the same end result with slightly higher runtime gas costs, but reduced bytecode size.

pragma solidity ^0.7.0;

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _enterNonReentrant();
        _;
        _exitNonReentrant();
    }

    function _enterNonReentrant() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        _require(_status != _ENTERED, Errors.REENTRANCY);

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _exitNonReentrant() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
          

/project_/contracts/ManagedPoolFactory.sol

// SPDX-License-Identifier: UNLICENSED
// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.6.6. SEE SOURCE BELOW. !!
pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

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

interface ManagedPoolFactory {

event FactoryDisabled(  ) ;
event PoolCreated( address indexed pool ) ;
function create( ManagedPoolParams memory params,ManagedPoolSettingsParams memory settingsParams,address owner,bytes32 salt ) external  returns (address pool) ;
function disable(  ) external   ;
function getActionId( bytes4 selector ) external view returns (bytes32 ) ;
function getAuthorizer(  ) external view returns (address ) ;
function getCreationCode(  ) external view returns (bytes memory ) ;
function getCreationCodeContracts(  ) external view returns (address contractA, address contractB) ;
function getPauseConfiguration(  ) external view returns (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) ;
function getPoolVersion(  ) external view returns (string memory ) ;
function getProtocolFeePercentagesProvider(  ) external view returns (address ) ;
function getRecoveryModeHelper(  ) external view returns (address ) ;
function getVault(  ) external view returns (address ) ;
function getWeightedMath(  ) external view returns (address ) ;
function isDisabled(  ) external view returns (bool ) ;
function isPoolFromFactory( address pool ) external view returns (bool ) ;
function version(  ) external view returns (string memory ) ;
}


struct ManagedPoolParams { string name;
string symbol;
address[] assetManagers; }


struct ManagedPoolSettingsParams { IERC20[] tokens;
uint256[] normalizedWeights;
uint256 swapFeePercentage;
bool swapEnabledOnStart;
bool mustAllowlistLPs;
uint256 managementAumFeePercentage;
uint256 aumFeeId; }

          

/project_/contracts/base/BaseController.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";
import "@balancer-labs/v2-interfaces/contracts/pool-utils/IManagedPool.sol";
import "../ManagedPoolFactory.sol";
import "./BaseUtils.sol";
struct PoolSettings {
    string poolName;
    string poolSymbol;
    uint256 tolerance;
    IERC20[] poolTokens;
}

abstract contract BaseController is ReentrancyGuard, BaseUtils {
    IVault internal immutable vault;
    ManagedPoolFactory public immutable managedPoolFactory;
    mapping(address => PoolSettings) public managedPools; // Pools and their prices
    address[] private poolsUnderManagement;

     /**
     * @notice Constructor for the controller base class
     *
     * @param _vaultAddress - Vault contract address
     * @param _managedPoolFactory - Managed pool contract address
     */
    constructor(address _vaultAddress, 
                address _managedPoolFactory) {
        manager = msg.sender;
        vault = IVault(_vaultAddress);
        managedPoolFactory = ManagedPoolFactory(_managedPoolFactory);
    }

     /**
     * @notice Create a new managed pool
     *
     * @param _name - Pool name
     * @param _symbol - Symbol representing the pool
     * @param _tokens - Tokens in the pool
     * @param _normalizedWeights - Normalized weights in the pool
     * @param _assetManagers - Asset manager for the pool
     * @param _swapFeePercentage - Fee applied to swaps
     * @param _swapEnabledOnStart - Whether swaps are enabled straight away
     * @param _mustAllowlistLPs - List of LP's allowed in the pool
     * @param _managementAumFeePercentage - Management Aum fee to apply
     * @param _aumFeeId - Aum Fee Id
     */
    function createPool(string memory _name,
                        string memory _symbol,
                        IERC20[] memory _tokens,
                        uint256[] memory _normalizedWeights,
                        address[] memory _assetManagers,
                        uint256 _swapFeePercentage,
                        bool _swapEnabledOnStart,
                        bool _mustAllowlistLPs,
                        uint256 _managementAumFeePercentage,
                        uint256 _aumFeeId,
                        uint256 _tolerance,
                        bytes32 _salt) public restricted nonReentrant {
        ManagedPoolParams memory poolParams;
        poolParams.name = _name;
        poolParams.symbol = _symbol;
        poolParams.assetManagers = _assetManagers;

        ManagedPoolSettingsParams memory poolSettingsParams;
        poolSettingsParams.tokens = _tokens;
        poolSettingsParams.normalizedWeights = _normalizedWeights;
        poolSettingsParams.swapFeePercentage = _swapFeePercentage;
        poolSettingsParams.swapEnabledOnStart = _swapEnabledOnStart;
        poolSettingsParams.mustAllowlistLPs = _mustAllowlistLPs;
        poolSettingsParams.managementAumFeePercentage = _managementAumFeePercentage;
        poolSettingsParams.aumFeeId = _aumFeeId;

        address _poolAddress = managedPoolFactory.create(poolParams, poolSettingsParams, address(this), _salt);
        poolsUnderManagement.push(_poolAddress);
        
        managedPools[_poolAddress].poolName = _name;
        managedPools[_poolAddress].poolSymbol = _symbol;
        managedPools[_poolAddress].tolerance = _tolerance;
        managedPools[_poolAddress].poolTokens = _tokens;
    }

    /**
     * @notice returns a list of pools under management by this controller
     *
     */
    function getPoolsUnderManagement() public view returns (address[] memory) {
        return poolsUnderManagement;
    }
    
    /**
     * @notice Schedule a gradual swap fee update.
     * @dev The swap fee will change from the given starting value (which may or may not be the current
     * value) to the given ending fee percentage, over startTime to endTime.
     *
     * Note that calling this with a starting swap fee different from the current value will immediately change the
     * current swap fee to `startSwapFeePercentage`, before commencing the gradual change at `startTime`.
     * Emits the GradualSwapFeeUpdateScheduled event.
     * This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _startTime - The timestamp when the swap fee change will begin.
     * @param _endTime - The timestamp when the swap fee change will end (must be >= startTime).
     * @param _startSwapFeePercentage - The starting value for the swap fee change.
     * @param _endSwapFeePercentage - The ending value for the swap fee change. If the current timestamp >= endTime,
     * `getSwapFeePercentage()` will return this value.
     */
    function updateSwapFeeGradually(
        address _poolAddress,
        uint256 _startTime,
        uint256 _endTime,
        uint256 _startSwapFeePercentage,
        uint256 _endSwapFeePercentage) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.updateSwapFeeGradually(_startTime, _endTime, _startSwapFeePercentage, _endSwapFeePercentage);
    }

    /**
     * @notice Schedule a gradual weight change.
     * @dev The weights will change from their current values to the given endWeights, over startTime to endTime.
     * This is a permissioned function.
     *
     * Since, unlike with swap fee updates, we generally do not want to allow instantaneous weight changes,
     * the weights always start from their current values. This also guarantees a smooth transition when
     * updateWeightsGradually is called during an ongoing weight change.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _startTime - The timestamp when the weight change will begin.
     * @param _endTime - The timestamp when the weight change will end (can be >= startTime).
     * @param _tokens - The tokens associated with the target weights (must match the current pool tokens).
     * @param _endWeights - The target weights. If the current timestamp >= endTime, `getNormalizedWeights()`
     * will return these values.
     */
    function updateWeightsGradually(
        address _poolAddress,
        uint256 _startTime,
        uint256 _endTime,
        IERC20[] memory _tokens,
        uint256[] memory _endWeights) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.updateWeightsGradually(_startTime, _endTime, _tokens, _endWeights);
    }

    /**
     * @notice Returns the pools Id
     *
     * @param _poolAddress - Pool to get the Id for
     */
    function getPoolId(address _poolAddress) public view returns (bytes32) {
        return IManagedPool(_poolAddress).getPoolId();
    }

    /**
     * @notice Enable or disable joins and exits. Note that this does not affect Recovery Mode exits.
     * @dev Emits the JoinExitEnabledSet event. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _joinExitEnabled - The new value of the join/exit enabled flag.
     */
    function setJoinExitEnabled(
        address _poolAddress,
        bool _joinExitEnabled) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.setJoinExitEnabled(_joinExitEnabled);
    }

    /**
     * @notice Returns the whether swapping is enabled for pool
     *
     * @param _poolAddress - Pool to get the swap state for
     */
    function getSwapEnabled(address _poolAddress) public view returns (bool) {
        return IManagedPool(_poolAddress).getSwapEnabled();
    }

    /**
     * @notice Enable or disable trading.
     * @dev Emits the SwapEnabledSet event. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _swapEnabled - The new value of the swap enabled flag.
     */
    function setSwapEnabled(
        address _poolAddress,
        bool _swapEnabled) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.setSwapEnabled(_swapEnabled);
    }

    /**
     * @notice Enable or disable the LP allowlist.
     * @dev Note that any addresses added to the allowlist will be retained if the allowlist is toggled off and
     * back on again, because this action does not affect the list of LP addresses.
     * Emits the MustAllowlistLPsSet event. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _mustAllowlistLPs - The new value of the mustAllowlistLPs flag.
     */
    function setMustAllowlistLPs(
        address _poolAddress,
        bool _mustAllowlistLPs) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.setMustAllowlistLPs(_mustAllowlistLPs);
    }

    /**
     * @notice Adds an address to the LP allowlist.
     * @dev Will fail if the address is already allowlisted.
     * Emits the AllowlistAddressAdded event. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _member - The address to be added to the allowlist.
     */
    function addAllowedAddress(
        address _poolAddress,
        address _member) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.addAllowedAddress(_member);
    }

    /**
     * @notice Removes an address from the _poolAddress - Address of pool being worked on.
     *
     * @param _poolAddress - Pool address being worked on
     * @param _member - The address to be removed from the allowlist.
     */
    function removeAllowedAddress(
        address _poolAddress,
        address _member) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.removeAllowedAddress(_member);
    }

    /**
     * @notice Collect any accrued AUM fees and send them to the pool manager.
     * @dev This can be called by anyone to collect accrued AUM fees - and will be called automatically
     * whenever the supply changes (e.g., joins and exits, add and remove token), and before the fee
     * percentage is changed by the manager, to prevent fees from being applied retroactively.
     *
     * @param _poolAddress - Address of pool being worked on.
     */
    function collectAumManagementFees(
        address _poolAddress) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.collectAumManagementFees();
    }
    
    /**
     * @notice Setter for the yearly percentage AUM management fee, which is payable to the pool manager.
     * @dev Attempting to collect AUM fees in excess of the maximum permitted percentage will revert.
     * To avoid retroactive fee increases, we force collection at the current fee percentage before processing
     * the update. Emits the ManagementAumFeePercentageChanged event. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _managementAumFeePercentage - The new management AUM fee percentage.
     */
    function setManagementAumFeePercentage(
        address _poolAddress,
        uint256 _managementAumFeePercentage) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.setManagementAumFeePercentage(_managementAumFeePercentage);
    }

    /**
     * @notice Set a circuit breaker for one or more tokens.
     * @dev This is a permissioned function. The lower and upper bounds are percentages, corresponding to a
     * relative change in the token's spot price: e.g., a lower bound of 0.8 means the breaker should prevent
     * trades that result in the value of the token dropping 20% or more relative to the rest of the pool.
     *
     * @param _poolAddress - Pool to have a circruit breaker set
     * @param _tokens - Tokens in the pool
     * @param _bptPrices - Token prices to for the circuit breaker
     * @param _lowerBoundPercentages - The lower limit to trigger the circuit breaker
     * @param _upperBoundPercentages - The upper limit to trigger the circuit breaker
     */
    function setCircuitBreakers(
        address _poolAddress,
        IERC20[] memory _tokens,
        uint256[] memory _bptPrices,
        uint256[] memory _lowerBoundPercentages,
        uint256[] memory _upperBoundPercentages) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.setCircuitBreakers(_tokens, _bptPrices, _lowerBoundPercentages, _upperBoundPercentages);
    }

    /**
     * @notice Adds a token to the Pool's list of tradeable tokens. This is a permissioned function.
     *
     * @dev By adding a token to the Pool's composition, the weights of all other tokens will be decreased. The new
     * token will have no balance - it is up to the owner to provide some immediately after calling this function.
     * Note however that regular join functions will not work while the new token has no balance: the only way to
     * deposit an initial amount is by using an Asset Manager.
     *
     * Token addition is forbidden during a weight change, or if one is scheduled to happen in the future.
     *
     * The caller may additionally pass a non-zero `mintAmount` to have some BPT be minted for them, which might be
     * useful in some scenarios to account for the fact that the Pool will have more tokens.
     *
     * Emits the TokenAdded event.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _tokenToAdd - The ERC20 token to be added to the Pool.
     * @param _assetManager - The Asset Manager for the token.
     * @param _tokenToAddNormalizedWeight - The normalized weight of `token` relative to the other tokens in the Pool.
     * @param _mintAmount - The amount of BPT to be minted as a result of adding `token` to the Pool.
     * @param _recipient - The address to receive the BPT minted by the Pool.
     */
    function addToken(
        address _poolAddress,
        IERC20 _tokenToAdd,
        address _assetManager,
        uint256 _tokenToAddNormalizedWeight,
        uint256 _mintAmount,
        address _recipient) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.addToken(_tokenToAdd, _assetManager, _tokenToAddNormalizedWeight, _mintAmount, _recipient);
    }

    /**
     * @notice Removes a token from the Pool's list of tradeable tokens.
     * @dev Tokens can only be removed if the Pool has more than 2 tokens, as it can never have fewer than 2 (not
     * including BPT). Token removal is also forbidden during a weight change, or if one is scheduled to happen in
     * the future.
     *
     * Emits the TokenRemoved event. This is a permissioned function.
     *
     * The caller may additionally pass a non-zero `burnAmount` to burn some of their BPT, which might be useful
     * in some scenarios to account for the fact that the Pool now has fewer tokens. This is a permissioned function.
     *
     * @param _poolAddress - Address of pool being worked on.
     * @param _tokenToRemove - The ERC20 token to be removed from the Pool.
     * @param _burnAmount - The amount of BPT to be burned after removing `token` from the Pool.
     * @param _sender - The address to burn BPT from.
     */
    function removeToken(
        address _poolAddress,
        IERC20 _tokenToRemove,
        uint256 _burnAmount,
        address _sender) public restricted nonReentrant {

        IManagedPool managedPool;
        managedPool = IManagedPool(_poolAddress);
        managedPool.removeToken(_tokenToRemove, _burnAmount, _sender);
    }

    /**
     * @notice Withdraw tokens from controller
     * @dev Transfers an amount of an ERC20 token
     *
     * @param _recipientAddress - Address of wallet receiving funds.
     * @param _tokenAddress - Address of token to be withdrawn.
     * @param _amount - Amount to withdraw.
     */
    function withdrawFunds(
        address _recipientAddress,
        address _tokenAddress,
        uint256 _amount) public restricted nonReentrant {

        IERC20 _token = IERC20(_tokenAddress);
        _token.transferFrom(address(this), _recipientAddress, _amount);
    }

    /**
     * @notice Deposit tokens to controller
     * @dev Transfers an amount of an ERC20 token
     *
     * @param _amount - Amount to deposit.
     * @param _tokenAddress - Address of token to be deposited.
     */
    function depositTokens(
        uint _amount,
        address _tokenAddress) public restricted nonReentrant checkAllowance(_amount, _tokenAddress) {
        IERC20 token = IERC20(_tokenAddress);
        token.transferFrom(msg.sender, address(this), _amount);
    }
}
          

/project_/contracts/base/BaseUtils.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

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

abstract contract BaseUtils {
    address public manager;

    /**
     * @notice Transfer the manager to a new address
     * @dev Only one manager can presently be set
     *
     * @param _manager - New manager.
     */
    function transferManagement(address _manager) public restricted {
        manager = _manager;
    }


    /**
     * @dev Modifier to restrict access to the set manager
     */
    modifier restricted() {
        require(msg.sender == manager);
        _;
    }

    /**
     * @dev Modifier to check token allowance
     */
    modifier checkAllowance(uint _amount,
                            address _tokenAddress) {
        IERC20 token = IERC20(_tokenAddress);
        require(token.allowance(msg.sender, address(this)) >= _amount, "Error");
        _;
    }
}
          

/project_/contracts/lib/SupportLib.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-interfaces/contracts/vault/IAsset.sol";
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/openzeppelin/IERC20.sol";

library SupportLib {
    /**
     * @dev This helper function is a fast and cheap way to convert between IERC20 and IAsset types
     *
     * @param _tokens - Tokens to convert to assets
     */
    function _convertERC20sToAssets(IERC20[] memory _tokens) internal pure returns (IAsset[] memory assets) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            assets := _tokens
        }
    }
}
          

Compiler Settings

{"remappings":[],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"project:/contracts/BondingCurveController.sol":"BondingCurveController"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_vaultAddress","internalType":"address"},{"type":"address","name":"_managedPoolFactory","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAllowedAddress","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"address","name":"_member","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addToken","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"address","name":"_tokenToAdd","internalType":"contract IERC20"},{"type":"address","name":"_assetManager","internalType":"address"},{"type":"uint256","name":"_tokenToAddNormalizedWeight","internalType":"uint256"},{"type":"uint256","name":"_mintAmount","internalType":"uint256"},{"type":"address","name":"_recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectAumManagementFees","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createPool","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"},{"type":"address[]","name":"_tokens","internalType":"contract IERC20[]"},{"type":"uint256[]","name":"_normalizedWeights","internalType":"uint256[]"},{"type":"address[]","name":"_assetManagers","internalType":"address[]"},{"type":"uint256","name":"_swapFeePercentage","internalType":"uint256"},{"type":"bool","name":"_swapEnabledOnStart","internalType":"bool"},{"type":"bool","name":"_mustAllowlistLPs","internalType":"bool"},{"type":"uint256","name":"_managementAumFeePercentage","internalType":"uint256"},{"type":"uint256","name":"_aumFeeId","internalType":"uint256"},{"type":"uint256","name":"_tolerance","internalType":"uint256"},{"type":"bytes32","name":"_salt","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"depositTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getPoolId","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getPoolsUnderManagement","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getSwapEnabled","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ManagedPoolFactory"}],"name":"managedPoolFactory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"poolName","internalType":"string"},{"type":"string","name":"poolSymbol","internalType":"string"},{"type":"uint256","name":"tolerance","internalType":"uint256"}],"name":"managedPools","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"manager","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeAllowedAddress","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"address","name":"_member","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeToken","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"address","name":"_tokenToRemove","internalType":"contract IERC20"},{"type":"uint256","name":"_burnAmount","internalType":"uint256"},{"type":"address","name":"_sender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"runCheck","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCircuitBreakers","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"address[]","name":"_tokens","internalType":"contract IERC20[]"},{"type":"uint256[]","name":"_bptPrices","internalType":"uint256[]"},{"type":"uint256[]","name":"_lowerBoundPercentages","internalType":"uint256[]"},{"type":"uint256[]","name":"_upperBoundPercentages","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setJoinExitEnabled","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"bool","name":"_joinExitEnabled","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setManagementAumFeePercentage","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"uint256","name":"_managementAumFeePercentage","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMustAllowlistLPs","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"bool","name":"_mustAllowlistLPs","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSwapEnabled","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"bool","name":"_swapEnabled","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferManagement","inputs":[{"type":"address","name":"_manager","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateSwapFeeGradually","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"uint256","name":"_startTime","internalType":"uint256"},{"type":"uint256","name":"_endTime","internalType":"uint256"},{"type":"uint256","name":"_startSwapFeePercentage","internalType":"uint256"},{"type":"uint256","name":"_endSwapFeePercentage","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateWeightsGradually","inputs":[{"type":"address","name":"_poolAddress","internalType":"address"},{"type":"uint256","name":"_startTime","internalType":"uint256"},{"type":"uint256","name":"_endTime","internalType":"uint256"},{"type":"address[]","name":"_tokens","internalType":"contract IERC20[]"},{"type":"uint256[]","name":"_endWeights","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawFunds","inputs":[{"type":"address","name":"_recipientAddress","internalType":"address"},{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x60c06040523480156200001157600080fd5b506040516200280238038062002802833981016040819052620000349162000087565b6001600081905580546001600160a01b031916331790556001600160601b0319606092831b8116608052911b1660a052620000be565b80516001600160a01b03811681146200008257600080fd5b919050565b600080604083850312156200009a578182fd5b620000a5836200006a565b9150620000b5602084016200006a565b90509250929050565b60805160601c60a05160601c612706620000fc600039806106b1528061175c525080610a935280610bb35280611098528061116452506127066000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806351d48cea116100c3578063c90d3a041161007c578063c90d3a04146102c0578063caa9a08d146102d3578063cbe04b0c146102f3578063d4f25a4b14610306578063e4444feb1461030e578063e4edf852146103215761014d565b806351d48cea1461023d578063556f1eb9146102505780637b35a88f146102635780638722081a14610285578063875e7cd91461029a578063abd796bf146102ad5761014d565b806341bfc4bc1161011557806341bfc4bc146101c957806342da1cb1146101dc578063458aa92b146101ef578063481c6a75146102025780634e4858d9146102175780634f6300a21461022a5761014d565b80631c20fadd1461015257806321f1e0cd146101675780632abbd3ad1461017a578063315fa7651461018d578063404ac21e146101b6575b600080fd5b610165610160366004611c9b565b610334565b005b610165610175366004611dc3565b6103e6565b610165610188366004611d96565b61047e565b6101a061019b366004611c24565b61050a565b6040516101ad919061243e565b60405180910390f35b6101656101c4366004611c24565b610585565b6101656101d73660046120b6565b610629565b6101656101ea366004611eb5565b610886565b6101656101fd366004611cdb565b61092f565b61020a6109c4565b6040516101ad9190612381565b610165610225366004611c24565b6109d3565b6101656102383660046121f7565b6111d7565b61016561024b366004611d96565b611327565b61016561025e366004611d96565b611374565b610276610271366004611c24565b6113c1565b6040516101ad939291906124e1565b61028d611500565b6040516101ad91906123d3565b6101656102a8366004611f38565b611562565b6101656102bb366004611c63565b6115b5565b6101656102ce366004611ee0565b611602565b6102e66102e1366004611c24565b611655565b6040516101ad9190612449565b610165610301366004611e32565b6116c8565b61020a61175a565b61016561031c366004611c63565b61177e565b61016561032f366004611c24565b6117cb565b6001546001600160a01b0316331461034b57600080fd5b610353611804565b6040516323b872dd60e01b815282906001600160a01b038216906323b872dd90610385903090889087906004016123af565b602060405180830381600087803b15801561039f57600080fd5b505af11580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d79190612082565b50506103e161181d565b505050565b6001546001600160a01b031633146103fd57600080fd5b610405611804565b6040516306946dbf60e31b815286906001600160a01b038216906334a36df89061043b908990899089908990899060040161248e565b600060405180830381600087803b15801561045557600080fd5b505af1158015610469573d6000803e3d6000fd5b505050505061047661181d565b505050505050565b6001546001600160a01b0316331461049557600080fd5b61049d611804565b604051637b749c4560e01b815282906001600160a01b03821690637b749c45906104cb90859060040161243e565b600060405180830381600087803b1580156104e557600080fd5b505af11580156104f9573d6000803e3d6000fd5b505050505061050661181d565b5050565b6000816001600160a01b03166347bc4d926040518163ffffffff1660e01b815260040160206040518083038186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d9190612082565b90505b919050565b6001546001600160a01b0316331461059c57600080fd5b6105a4611804565b6000819050806001600160a01b03166373656f896040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156105e457600080fd5b505af11580156105f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061c919061209e565b505061062661181d565b50565b6001546001600160a01b0316331461064057600080fd5b610648611804565b61065061188d565b8c8152602081018c9052604081018990526106696118ae565b8b8152602081018b905260408082018a90528815156060830152871515608083015260a0820187905260c0820186905251637304b8b960e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637304b8b9906106ec908690869030908a90600401612536565b602060405180830381600087803b15801561070657600080fd5b505af115801561071a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073e9190611c47565b90506003819080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055508e60026000836001600160a01b03166001600160a01b0316815260200190815260200160002060000190805190602001906107c59291906118ef565b508d60026000836001600160a01b03166001600160a01b0316815260200190815260200160002060010190805190602001906108029291906118ef565b508460026000836001600160a01b03166001600160a01b03168152602001908152602001600020600201819055508c60026000836001600160a01b03166001600160a01b03168152602001908152602001600020600301908051906020019061086c92919061197b565b5050505061087861181d565b505050505050505050505050565b6001546001600160a01b0316331461089d57600080fd5b6108a5611804565b604051632a9a032360e01b815282906001600160a01b03821690632a9a0323906108d3908590600401612449565b602060405180830381600087803b1580156108ed57600080fd5b505af1158015610901573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610925919061209e565b505061050661181d565b6001546001600160a01b0316331461094657600080fd5b61094e611804565b60405163f885a4bb60e01b815285906001600160a01b0382169063f885a4bb906109829088908890889088906004016123e6565b600060405180830381600087803b15801561099c57600080fd5b505af11580156109b0573d6000803e3d6000fd5b50505050506109bd61181d565b5050505050565b6001546001600160a01b031681565b6001546001600160a01b031633146109ea57600080fd5b6109f2611804565b6109fa6119d0565b6001600160a01b0382168082526040805163038fff2d60e41b815290516338fff2d091600480820192602092909190829003018186803b158015610a3d57600080fd5b505afa158015610a51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a75919061209e565b6020820181905260405163f6c0092760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163f6c0092791610ac79190600401612449565b604080518083038186803b158015610ade57600080fd5b505afa158015610af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b169190611e84565b505080600001516001600160a01b031663f89f27ed6040518163ffffffff1660e01b815260040160006040518083038186803b158015610b5557600080fd5b505afa158015610b69573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b919190810190612047565b6101408201526020810151604051631f29a8cd60e31b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163f94d466891610be79190600401612449565b60006040518083038186803b158015610bff57600080fd5b505afa158015610c13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c3b9190810190611f7b565b506101808301526101608201819052610c5390611824565b6101a08201526000604082018190526060820181905261018082015180518290610c7957fe5b60200260200101511115610d2557806101400151600081518110610c9957fe5b6020026020010151816101800151600081518110610cb357fe5b602002602001015181610cc257fe5b04816101400151600181518110610cd557fe5b6020026020010151826101800151600181518110610cef57fe5b602002602001015181610cfe57fe5b0481610d0657fe5b048160c00151600081518110610d1857fe5b6020026020010181815250505b60015b81610160015151811015610dfa5760008261018001518281518110610d4957fe5b60200260200101511115610df2578161014001518181518110610d6857fe5b60200260200101518261018001518281518110610d8157fe5b602002602001015181610d9057fe5b04826101400151600081518110610da357fe5b6020026020010151836101800151600081518110610dbd57fe5b602002602001015181610dcc57fe5b0481610dd457fe5b048260c001518281518110610de557fe5b6020026020010181815250505b600101610d28565b5060015b81610160015151811015610e6f5760008260c001518281518110610e1e57fe5b60200260200101511115610e67576001600160a01b0383166000908152600260208190526040909120015460e0830151805183908110610e5a57fe5b6020026020010181815250505b600101610dfe565b5060015b81610160015151811015611036576001600160a01b0383166000908152600260208190526040909120015460e0830151805183908110610eaf57fe5b602002602001015112610f315760026000846001600160a01b03166001600160a01b031681526020019081526020016000206002015460648361018001518381518110610ef857fe5b602002602001015181610f0757fe5b04028261012001518281518110610f1a57fe5b60209081029190910101526001606083015261102e565b60026000846001600160a01b03166001600160a01b03168152602001908152602001600020600201546000038260e001518281518110610f6d57fe5b602002602001015113610fef5760026000846001600160a01b03166001600160a01b031681526020019081526020016000206002015460648361018001518381518110610fb657fe5b602002602001015181610fc557fe5b04028261010001518281518110610fd857fe5b60209081029190910101526001604083015261102e565b6000826101000151828151811061100257fe5b6020026020010181815250506000826101200151828151811061102157fe5b6020026020010181815250505b600101610e73565b50806060015115611102576101a081015160808201805191909152604080516020808201835260008252835183019190915282516001606090910152610120840151835182015283015191519051638bdb391360e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692638bdb3913926110cf9230918891600401612452565b600060405180830381600087803b1580156110e957600080fd5b505af11580156110fd573d6000803e3d6000fd5b505050505b8060400151156111ce576101a081015160a082018051919091526040805160208082018352600082528351830191909152825160016060919091015261010084015183518201528301519151905163172b958560e31b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169263b95cac289261119b9230918891600401612452565b600060405180830381600087803b1580156111b557600080fd5b505af11580156111c9573d6000803e3d6000fd5b505050505b5061062661181d565b6001546001600160a01b031633146111ee57600080fd5b6111f6611804565b604051636eb1769f60e11b815282908290819083906001600160a01b0383169063dd62ed3e9061122c9033903090600401612395565b60206040518083038186803b15801561124457600080fd5b505afa158015611258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127c919061209e565b10156112a35760405162461bcd60e51b815260040161129a90612517565b60405180910390fd5b6040516323b872dd60e01b815284906001600160a01b038216906323b872dd906112d590339030908b906004016123af565b602060405180830381600087803b1580156112ef57600080fd5b505af1158015611303573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f99190612082565b6001546001600160a01b0316331461133e57600080fd5b611346611804565b604051633806be4b60e21b815282906001600160a01b0382169063e01af92c906104cb90859060040161243e565b6001546001600160a01b0316331461138b57600080fd5b611393611804565b60405163de3d2b2d60e01b815282906001600160a01b0382169063de3d2b2d906104cb90859060040161243e565b600260208181526000928352604092839020805484516001821615610100026000190190911693909304601f81018390048302840183019094528383529283918301828280156114525780601f1061142757610100808354040283529160200191611452565b820191906000526020600020905b81548152906001019060200180831161143557829003601f168201915b505050505090806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114f05780601f106114c5576101008083540402835291602001916114f0565b820191906000526020600020905b8154815290600101906020018083116114d357829003601f168201915b5050505050908060020154905083565b6060600380548060200260200160405190810160405280929190818152602001828054801561155857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161153a575b5050505050905090565b6001546001600160a01b0316331461157957600080fd5b611581611804565b604051635b160f8360e11b815285906001600160a01b0382169063b62c1f0690610982908890889088908890600401612650565b6001546001600160a01b031633146115cc57600080fd5b6115d4611804565b6040516381788e2b60e01b815282906001600160a01b038216906381788e2b906104cb908590600401612381565b6001546001600160a01b0316331461161957600080fd5b611621611804565b60405163819c70f360e01b815285906001600160a01b0382169063819c70f39061098290889088908890889060040161261f565b6000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561169057600080fd5b505afa1580156116a4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d919061209e565b6001546001600160a01b031633146116df57600080fd5b6116e7611804565b6040516397bb15c960e01b815284906001600160a01b038216906397bb15c990611719908790879087906004016124be565b600060405180830381600087803b15801561173357600080fd5b505af1158015611747573d6000803e3d6000fd5b505050505061175461181d565b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001546001600160a01b0316331461179557600080fd5b61179d611804565b604051630793b27760e31b815282906001600160a01b03821690633c9d93b8906104cb908590600401612381565b6001546001600160a01b031633146117e257600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61181660026000541415610190611827565b6002600055565b6001600055565b90565b816105065762461bcd60e51b600090815260206004526007602452600a808304818106603090810160081b83860601918390049283060160101b016642414c230000300160c81b604452610506918391610626916210905360ea1b906242414c90606490fd5b60405180606001604052806060815260200160608152602001606081525090565b6040518060e0016040528060608152602001606081526020016000815260200160001515815260200160001515815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282611925576000855561196b565b82601f1061193e57805160ff191683800117855561196b565b8280016001018555821561196b579182015b8281111561196b578251825591602001919060010190611950565b50611977929150611a4c565b5090565b82805482825590600052602060002090810192821561196b579160200282015b8281111561196b57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061199b565b604080516101c081018252600080825260208201819052918101829052606081019190915260808101611a01611a61565b8152602001611a0e611a61565b815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b5b808211156119775760008155600101611a4d565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b600082601f830112611a9b578081fd5b81356020611ab0611aab8361268f565b61266b565b8281528181019085830183850287018401881015611acc578586fd5b855b85811015611af3578135611ae1816126ad565b84529284019290840190600101611ace565b5090979650505050505050565b600082601f830112611b10578081fd5b81356020611b20611aab8361268f565b8281528181019085830183850287018401881015611b3c578586fd5b855b85811015611af357813584529284019290840190600101611b3e565b600082601f830112611b6a578081fd5b81516020611b7a611aab8361268f565b8281528181019085830183850287018401881015611b96578586fd5b855b85811015611af357815184529284019290840190600101611b98565b8035610580816126c2565b600082601f830112611bcf578081fd5b813567ffffffffffffffff811115611be357fe5b611bf6601f8201601f191660200161266b565b818152846020838601011115611c0a578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215611c35578081fd5b8135611c40816126ad565b9392505050565b600060208284031215611c58578081fd5b8151611c40816126ad565b60008060408385031215611c75578081fd5b8235611c80816126ad565b91506020830135611c90816126ad565b809150509250929050565b600080600060608486031215611caf578081fd5b8335611cba816126ad565b92506020840135611cca816126ad565b929592945050506040919091013590565b600080600080600060a08688031215611cf2578283fd5b8535611cfd816126ad565b9450602086013567ffffffffffffffff80821115611d19578485fd5b611d2589838a01611a8b565b95506040880135915080821115611d3a578485fd5b611d4689838a01611b00565b94506060880135915080821115611d5b578283fd5b611d6789838a01611b00565b93506080880135915080821115611d7c578283fd5b50611d8988828901611b00565b9150509295509295909350565b60008060408385031215611da8578182fd5b8235611db3816126ad565b91506020830135611c90816126c2565b60008060008060008060c08789031215611ddb578384fd5b8635611de6816126ad565b95506020870135611df6816126ad565b94506040870135611e06816126ad565b9350606087013592506080870135915060a0870135611e24816126ad565b809150509295509295509295565b60008060008060808587031215611e47578182fd5b8435611e52816126ad565b93506020850135611e62816126ad565b9250604085013591506060850135611e79816126ad565b939692955090935050565b60008060408385031215611e96578182fd5b8251611ea1816126ad565b602084015190925060038110611c90578182fd5b60008060408385031215611ec7578182fd5b8235611ed2816126ad565b946020939093013593505050565b600080600080600060a08688031215611ef7578283fd5b8535611f02816126ad565b94506020860135935060408601359250606086013567ffffffffffffffff80821115611f2c578283fd5b611d6789838a01611a8b565b600080600080600060a08688031215611f4f578283fd5b8535611f5a816126ad565b97602087013597506040870135966060810135965060800135945092505050565b600080600060608486031215611f8f578081fd5b835167ffffffffffffffff80821115611fa6578283fd5b818601915086601f830112611fb9578283fd5b81516020611fc9611aab8361268f565b82815281810190858301838502870184018c1015611fe5578788fd5b8796505b84871015612010578051611ffc816126ad565b835260019690960195918301918301611fe9565b5091890151919750909350505080821115612029578283fd5b5061203686828701611b5a565b925050604084015190509250925092565b600060208284031215612058578081fd5b815167ffffffffffffffff81111561206e578182fd5b61207a84828501611b5a565b949350505050565b600060208284031215612093578081fd5b8151611c40816126c2565b6000602082840312156120af578081fd5b5051919050565b6000806000806000806000806000806000806101808d8f0312156120d857898afd5b67ffffffffffffffff8d3511156120ed57898afd5b6120fa8e8e358f01611bbf565b9b5067ffffffffffffffff60208e0135111561211457898afd5b6121248e60208f01358f01611bbf565b9a5067ffffffffffffffff60408e0135111561213e57898afd5b61214e8e60408f01358f01611a8b565b995067ffffffffffffffff60608e01351115612168578586fd5b6121788e60608f01358f01611b00565b985067ffffffffffffffff60808e01351115612192578586fd5b6121a28e60808f01358f01611a8b565b975060a08d013596506121b760c08e01611bb4565b95506121c560e08e01611bb4565b94506101008d013593506101208d013592506101408d013591506101608d013590509295989b509295989b509295989b565b60008060408385031215612209578182fd5b823591506020830135611c90816126ad565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156122605781516001600160a01b03168752958201959082019060010161223b565b509495945050505050565b6000815180845260208085019450808401835b838110156122605781518752958201959082019060010161227e565b15159052565b60008151808452815b818110156122c5576020818501810151868301820152016122a9565b818111156122d65782602083870101525b50601f01601f19169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b818110156123305783516001600160a01b03168352928401929184019160010161230b565b505082850151915085810383870152612349818361226b565b925050506040830151848203604086015261236482826122a0565b9150506060830151612379606086018261229a565b509392505050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060208252611c406020830184612228565b6000608082526123f96080830187612228565b828103602084015261240b818761226b565b9050828103604084015261241f818661226b565b90508281036060840152612433818561226b565b979650505050505050565b901515815260200190565b90815260200190565b8481526001600160a01b03848116602083015283166040820152608060608201819052600090612484908301846122eb565b9695505050505050565b6001600160a01b039586168152938516602085015260408401929092526060830152909116608082015260a00190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6000606082526124f460608301866122a0565b828103602084015261250681866122a0565b915050826040830152949350505050565b60208082526005908201526422b93937b960d91b604082015260600190565b60006080825285516060608084015261255260e08401826122a0565b90506020870151607f19808584030160a086015261257083836122a0565b925060408901519150808584030160c08601525061258e8282612228565b9150508281036020840152855160e082526125ac60e0830182612228565b9050602087015182820360208401526125c5828261226b565b9150506040870151604083015260608701511515606083015260808701511515608083015260a087015160a083015260c087015160c08301528092505050612610604083018561221b565b82606083015295945050505050565b60008582528460208301526080604083015261263e6080830185612228565b8281036060840152612433818561226b565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff8111828210171561268757fe5b604052919050565b600067ffffffffffffffff8211156126a357fe5b5060209081020190565b6001600160a01b038116811461062657600080fd5b801515811461062657600080fdfea26469706673582212209ccab25c132b8f1c5ff19f1fb8e7636f13f6a0f1080451688e25d5791c5559aa64736f6c63430007060033000000000000000000000000d25e02047e76b688445ab154785f2642c6fe3f730000000000000000000000006672dba088b0151f29d05dd52117626fde4a8b0c

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806351d48cea116100c3578063c90d3a041161007c578063c90d3a04146102c0578063caa9a08d146102d3578063cbe04b0c146102f3578063d4f25a4b14610306578063e4444feb1461030e578063e4edf852146103215761014d565b806351d48cea1461023d578063556f1eb9146102505780637b35a88f146102635780638722081a14610285578063875e7cd91461029a578063abd796bf146102ad5761014d565b806341bfc4bc1161011557806341bfc4bc146101c957806342da1cb1146101dc578063458aa92b146101ef578063481c6a75146102025780634e4858d9146102175780634f6300a21461022a5761014d565b80631c20fadd1461015257806321f1e0cd146101675780632abbd3ad1461017a578063315fa7651461018d578063404ac21e146101b6575b600080fd5b610165610160366004611c9b565b610334565b005b610165610175366004611dc3565b6103e6565b610165610188366004611d96565b61047e565b6101a061019b366004611c24565b61050a565b6040516101ad919061243e565b60405180910390f35b6101656101c4366004611c24565b610585565b6101656101d73660046120b6565b610629565b6101656101ea366004611eb5565b610886565b6101656101fd366004611cdb565b61092f565b61020a6109c4565b6040516101ad9190612381565b610165610225366004611c24565b6109d3565b6101656102383660046121f7565b6111d7565b61016561024b366004611d96565b611327565b61016561025e366004611d96565b611374565b610276610271366004611c24565b6113c1565b6040516101ad939291906124e1565b61028d611500565b6040516101ad91906123d3565b6101656102a8366004611f38565b611562565b6101656102bb366004611c63565b6115b5565b6101656102ce366004611ee0565b611602565b6102e66102e1366004611c24565b611655565b6040516101ad9190612449565b610165610301366004611e32565b6116c8565b61020a61175a565b61016561031c366004611c63565b61177e565b61016561032f366004611c24565b6117cb565b6001546001600160a01b0316331461034b57600080fd5b610353611804565b6040516323b872dd60e01b815282906001600160a01b038216906323b872dd90610385903090889087906004016123af565b602060405180830381600087803b15801561039f57600080fd5b505af11580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d79190612082565b50506103e161181d565b505050565b6001546001600160a01b031633146103fd57600080fd5b610405611804565b6040516306946dbf60e31b815286906001600160a01b038216906334a36df89061043b908990899089908990899060040161248e565b600060405180830381600087803b15801561045557600080fd5b505af1158015610469573d6000803e3d6000fd5b505050505061047661181d565b505050505050565b6001546001600160a01b0316331461049557600080fd5b61049d611804565b604051637b749c4560e01b815282906001600160a01b03821690637b749c45906104cb90859060040161243e565b600060405180830381600087803b1580156104e557600080fd5b505af11580156104f9573d6000803e3d6000fd5b505050505061050661181d565b5050565b6000816001600160a01b03166347bc4d926040518163ffffffff1660e01b815260040160206040518083038186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d9190612082565b90505b919050565b6001546001600160a01b0316331461059c57600080fd5b6105a4611804565b6000819050806001600160a01b03166373656f896040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156105e457600080fd5b505af11580156105f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061c919061209e565b505061062661181d565b50565b6001546001600160a01b0316331461064057600080fd5b610648611804565b61065061188d565b8c8152602081018c9052604081018990526106696118ae565b8b8152602081018b905260408082018a90528815156060830152871515608083015260a0820187905260c0820186905251637304b8b960e01b81526000906001600160a01b037f0000000000000000000000006672dba088b0151f29d05dd52117626fde4a8b0c1690637304b8b9906106ec908690869030908a90600401612536565b602060405180830381600087803b15801561070657600080fd5b505af115801561071a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073e9190611c47565b90506003819080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055508e60026000836001600160a01b03166001600160a01b0316815260200190815260200160002060000190805190602001906107c59291906118ef565b508d60026000836001600160a01b03166001600160a01b0316815260200190815260200160002060010190805190602001906108029291906118ef565b508460026000836001600160a01b03166001600160a01b03168152602001908152602001600020600201819055508c60026000836001600160a01b03166001600160a01b03168152602001908152602001600020600301908051906020019061086c92919061197b565b5050505061087861181d565b505050505050505050505050565b6001546001600160a01b0316331461089d57600080fd5b6108a5611804565b604051632a9a032360e01b815282906001600160a01b03821690632a9a0323906108d3908590600401612449565b602060405180830381600087803b1580156108ed57600080fd5b505af1158015610901573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610925919061209e565b505061050661181d565b6001546001600160a01b0316331461094657600080fd5b61094e611804565b60405163f885a4bb60e01b815285906001600160a01b0382169063f885a4bb906109829088908890889088906004016123e6565b600060405180830381600087803b15801561099c57600080fd5b505af11580156109b0573d6000803e3d6000fd5b50505050506109bd61181d565b5050505050565b6001546001600160a01b031681565b6001546001600160a01b031633146109ea57600080fd5b6109f2611804565b6109fa6119d0565b6001600160a01b0382168082526040805163038fff2d60e41b815290516338fff2d091600480820192602092909190829003018186803b158015610a3d57600080fd5b505afa158015610a51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a75919061209e565b6020820181905260405163f6c0092760e01b81526001600160a01b037f000000000000000000000000d25e02047e76b688445ab154785f2642c6fe3f73169163f6c0092791610ac79190600401612449565b604080518083038186803b158015610ade57600080fd5b505afa158015610af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b169190611e84565b505080600001516001600160a01b031663f89f27ed6040518163ffffffff1660e01b815260040160006040518083038186803b158015610b5557600080fd5b505afa158015610b69573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b919190810190612047565b6101408201526020810151604051631f29a8cd60e31b81526001600160a01b037f000000000000000000000000d25e02047e76b688445ab154785f2642c6fe3f73169163f94d466891610be79190600401612449565b60006040518083038186803b158015610bff57600080fd5b505afa158015610c13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c3b9190810190611f7b565b506101808301526101608201819052610c5390611824565b6101a08201526000604082018190526060820181905261018082015180518290610c7957fe5b60200260200101511115610d2557806101400151600081518110610c9957fe5b6020026020010151816101800151600081518110610cb357fe5b602002602001015181610cc257fe5b04816101400151600181518110610cd557fe5b6020026020010151826101800151600181518110610cef57fe5b602002602001015181610cfe57fe5b0481610d0657fe5b048160c00151600081518110610d1857fe5b6020026020010181815250505b60015b81610160015151811015610dfa5760008261018001518281518110610d4957fe5b60200260200101511115610df2578161014001518181518110610d6857fe5b60200260200101518261018001518281518110610d8157fe5b602002602001015181610d9057fe5b04826101400151600081518110610da357fe5b6020026020010151836101800151600081518110610dbd57fe5b602002602001015181610dcc57fe5b0481610dd457fe5b048260c001518281518110610de557fe5b6020026020010181815250505b600101610d28565b5060015b81610160015151811015610e6f5760008260c001518281518110610e1e57fe5b60200260200101511115610e67576001600160a01b0383166000908152600260208190526040909120015460e0830151805183908110610e5a57fe5b6020026020010181815250505b600101610dfe565b5060015b81610160015151811015611036576001600160a01b0383166000908152600260208190526040909120015460e0830151805183908110610eaf57fe5b602002602001015112610f315760026000846001600160a01b03166001600160a01b031681526020019081526020016000206002015460648361018001518381518110610ef857fe5b602002602001015181610f0757fe5b04028261012001518281518110610f1a57fe5b60209081029190910101526001606083015261102e565b60026000846001600160a01b03166001600160a01b03168152602001908152602001600020600201546000038260e001518281518110610f6d57fe5b602002602001015113610fef5760026000846001600160a01b03166001600160a01b031681526020019081526020016000206002015460648361018001518381518110610fb657fe5b602002602001015181610fc557fe5b04028261010001518281518110610fd857fe5b60209081029190910101526001604083015261102e565b6000826101000151828151811061100257fe5b6020026020010181815250506000826101200151828151811061102157fe5b6020026020010181815250505b600101610e73565b50806060015115611102576101a081015160808201805191909152604080516020808201835260008252835183019190915282516001606090910152610120840151835182015283015191519051638bdb391360e01b81526001600160a01b037f000000000000000000000000d25e02047e76b688445ab154785f2642c6fe3f731692638bdb3913926110cf9230918891600401612452565b600060405180830381600087803b1580156110e957600080fd5b505af11580156110fd573d6000803e3d6000fd5b505050505b8060400151156111ce576101a081015160a082018051919091526040805160208082018352600082528351830191909152825160016060919091015261010084015183518201528301519151905163172b958560e31b81526001600160a01b037f000000000000000000000000d25e02047e76b688445ab154785f2642c6fe3f73169263b95cac289261119b9230918891600401612452565b600060405180830381600087803b1580156111b557600080fd5b505af11580156111c9573d6000803e3d6000fd5b505050505b5061062661181d565b6001546001600160a01b031633146111ee57600080fd5b6111f6611804565b604051636eb1769f60e11b815282908290819083906001600160a01b0383169063dd62ed3e9061122c9033903090600401612395565b60206040518083038186803b15801561124457600080fd5b505afa158015611258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127c919061209e565b10156112a35760405162461bcd60e51b815260040161129a90612517565b60405180910390fd5b6040516323b872dd60e01b815284906001600160a01b038216906323b872dd906112d590339030908b906004016123af565b602060405180830381600087803b1580156112ef57600080fd5b505af1158015611303573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f99190612082565b6001546001600160a01b0316331461133e57600080fd5b611346611804565b604051633806be4b60e21b815282906001600160a01b0382169063e01af92c906104cb90859060040161243e565b6001546001600160a01b0316331461138b57600080fd5b611393611804565b60405163de3d2b2d60e01b815282906001600160a01b0382169063de3d2b2d906104cb90859060040161243e565b600260208181526000928352604092839020805484516001821615610100026000190190911693909304601f81018390048302840183019094528383529283918301828280156114525780601f1061142757610100808354040283529160200191611452565b820191906000526020600020905b81548152906001019060200180831161143557829003601f168201915b505050505090806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114f05780601f106114c5576101008083540402835291602001916114f0565b820191906000526020600020905b8154815290600101906020018083116114d357829003601f168201915b5050505050908060020154905083565b6060600380548060200260200160405190810160405280929190818152602001828054801561155857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161153a575b5050505050905090565b6001546001600160a01b0316331461157957600080fd5b611581611804565b604051635b160f8360e11b815285906001600160a01b0382169063b62c1f0690610982908890889088908890600401612650565b6001546001600160a01b031633146115cc57600080fd5b6115d4611804565b6040516381788e2b60e01b815282906001600160a01b038216906381788e2b906104cb908590600401612381565b6001546001600160a01b0316331461161957600080fd5b611621611804565b60405163819c70f360e01b815285906001600160a01b0382169063819c70f39061098290889088908890889060040161261f565b6000816001600160a01b03166338fff2d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561169057600080fd5b505afa1580156116a4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057d919061209e565b6001546001600160a01b031633146116df57600080fd5b6116e7611804565b6040516397bb15c960e01b815284906001600160a01b038216906397bb15c990611719908790879087906004016124be565b600060405180830381600087803b15801561173357600080fd5b505af1158015611747573d6000803e3d6000fd5b505050505061175461181d565b50505050565b7f0000000000000000000000006672dba088b0151f29d05dd52117626fde4a8b0c81565b6001546001600160a01b0316331461179557600080fd5b61179d611804565b604051630793b27760e31b815282906001600160a01b03821690633c9d93b8906104cb908590600401612381565b6001546001600160a01b031633146117e257600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61181660026000541415610190611827565b6002600055565b6001600055565b90565b816105065762461bcd60e51b600090815260206004526007602452600a808304818106603090810160081b83860601918390049283060160101b016642414c230000300160c81b604452610506918391610626916210905360ea1b906242414c90606490fd5b60405180606001604052806060815260200160608152602001606081525090565b6040518060e0016040528060608152602001606081526020016000815260200160001515815260200160001515815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282611925576000855561196b565b82601f1061193e57805160ff191683800117855561196b565b8280016001018555821561196b579182015b8281111561196b578251825591602001919060010190611950565b50611977929150611a4c565b5090565b82805482825590600052602060002090810192821561196b579160200282015b8281111561196b57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061199b565b604080516101c081018252600080825260208201819052918101829052606081019190915260808101611a01611a61565b8152602001611a0e611a61565b815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b5b808211156119775760008155600101611a4d565b60405180608001604052806060815260200160608152602001606081526020016000151581525090565b600082601f830112611a9b578081fd5b81356020611ab0611aab8361268f565b61266b565b8281528181019085830183850287018401881015611acc578586fd5b855b85811015611af3578135611ae1816126ad565b84529284019290840190600101611ace565b5090979650505050505050565b600082601f830112611b10578081fd5b81356020611b20611aab8361268f565b8281528181019085830183850287018401881015611b3c578586fd5b855b85811015611af357813584529284019290840190600101611b3e565b600082601f830112611b6a578081fd5b81516020611b7a611aab8361268f565b8281528181019085830183850287018401881015611b96578586fd5b855b85811015611af357815184529284019290840190600101611b98565b8035610580816126c2565b600082601f830112611bcf578081fd5b813567ffffffffffffffff811115611be357fe5b611bf6601f8201601f191660200161266b565b818152846020838601011115611c0a578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215611c35578081fd5b8135611c40816126ad565b9392505050565b600060208284031215611c58578081fd5b8151611c40816126ad565b60008060408385031215611c75578081fd5b8235611c80816126ad565b91506020830135611c90816126ad565b809150509250929050565b600080600060608486031215611caf578081fd5b8335611cba816126ad565b92506020840135611cca816126ad565b929592945050506040919091013590565b600080600080600060a08688031215611cf2578283fd5b8535611cfd816126ad565b9450602086013567ffffffffffffffff80821115611d19578485fd5b611d2589838a01611a8b565b95506040880135915080821115611d3a578485fd5b611d4689838a01611b00565b94506060880135915080821115611d5b578283fd5b611d6789838a01611b00565b93506080880135915080821115611d7c578283fd5b50611d8988828901611b00565b9150509295509295909350565b60008060408385031215611da8578182fd5b8235611db3816126ad565b91506020830135611c90816126c2565b60008060008060008060c08789031215611ddb578384fd5b8635611de6816126ad565b95506020870135611df6816126ad565b94506040870135611e06816126ad565b9350606087013592506080870135915060a0870135611e24816126ad565b809150509295509295509295565b60008060008060808587031215611e47578182fd5b8435611e52816126ad565b93506020850135611e62816126ad565b9250604085013591506060850135611e79816126ad565b939692955090935050565b60008060408385031215611e96578182fd5b8251611ea1816126ad565b602084015190925060038110611c90578182fd5b60008060408385031215611ec7578182fd5b8235611ed2816126ad565b946020939093013593505050565b600080600080600060a08688031215611ef7578283fd5b8535611f02816126ad565b94506020860135935060408601359250606086013567ffffffffffffffff80821115611f2c578283fd5b611d6789838a01611a8b565b600080600080600060a08688031215611f4f578283fd5b8535611f5a816126ad565b97602087013597506040870135966060810135965060800135945092505050565b600080600060608486031215611f8f578081fd5b835167ffffffffffffffff80821115611fa6578283fd5b818601915086601f830112611fb9578283fd5b81516020611fc9611aab8361268f565b82815281810190858301838502870184018c1015611fe5578788fd5b8796505b84871015612010578051611ffc816126ad565b835260019690960195918301918301611fe9565b5091890151919750909350505080821115612029578283fd5b5061203686828701611b5a565b925050604084015190509250925092565b600060208284031215612058578081fd5b815167ffffffffffffffff81111561206e578182fd5b61207a84828501611b5a565b949350505050565b600060208284031215612093578081fd5b8151611c40816126c2565b6000602082840312156120af578081fd5b5051919050565b6000806000806000806000806000806000806101808d8f0312156120d857898afd5b67ffffffffffffffff8d3511156120ed57898afd5b6120fa8e8e358f01611bbf565b9b5067ffffffffffffffff60208e0135111561211457898afd5b6121248e60208f01358f01611bbf565b9a5067ffffffffffffffff60408e0135111561213e57898afd5b61214e8e60408f01358f01611a8b565b995067ffffffffffffffff60608e01351115612168578586fd5b6121788e60608f01358f01611b00565b985067ffffffffffffffff60808e01351115612192578586fd5b6121a28e60808f01358f01611a8b565b975060a08d013596506121b760c08e01611bb4565b95506121c560e08e01611bb4565b94506101008d013593506101208d013592506101408d013591506101608d013590509295989b509295989b509295989b565b60008060408385031215612209578182fd5b823591506020830135611c90816126ad565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156122605781516001600160a01b03168752958201959082019060010161223b565b509495945050505050565b6000815180845260208085019450808401835b838110156122605781518752958201959082019060010161227e565b15159052565b60008151808452815b818110156122c5576020818501810151868301820152016122a9565b818111156122d65782602083870101525b50601f01601f19169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b818110156123305783516001600160a01b03168352928401929184019160010161230b565b505082850151915085810383870152612349818361226b565b925050506040830151848203604086015261236482826122a0565b9150506060830151612379606086018261229a565b509392505050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060208252611c406020830184612228565b6000608082526123f96080830187612228565b828103602084015261240b818761226b565b9050828103604084015261241f818661226b565b90508281036060840152612433818561226b565b979650505050505050565b901515815260200190565b90815260200190565b8481526001600160a01b03848116602083015283166040820152608060608201819052600090612484908301846122eb565b9695505050505050565b6001600160a01b039586168152938516602085015260408401929092526060830152909116608082015260a00190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6000606082526124f460608301866122a0565b828103602084015261250681866122a0565b915050826040830152949350505050565b60208082526005908201526422b93937b960d91b604082015260600190565b60006080825285516060608084015261255260e08401826122a0565b90506020870151607f19808584030160a086015261257083836122a0565b925060408901519150808584030160c08601525061258e8282612228565b9150508281036020840152855160e082526125ac60e0830182612228565b9050602087015182820360208401526125c5828261226b565b9150506040870151604083015260608701511515606083015260808701511515608083015260a087015160a083015260c087015160c08301528092505050612610604083018561221b565b82606083015295945050505050565b60008582528460208301526080604083015261263e6080830185612228565b8281036060840152612433818561226b565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff8111828210171561268757fe5b604052919050565b600067ffffffffffffffff8211156126a357fe5b5060209081020190565b6001600160a01b038116811461062657600080fd5b801515811461062657600080fdfea26469706673582212209ccab25c132b8f1c5ff19f1fb8e7636f13f6a0f1080451688e25d5791c5559aa64736f6c63430007060033