creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "node_modules/@gearbox-protocol/integrations-v3/contracts/adapters/balancer/BalancerV2VaultAdapter.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport {RAY} from \"@gearbox-protocol/core-v2/contracts/libraries/Constants.sol\";\nimport {BitMask} from \"@gearbox-protocol/core-v3/contracts/libraries/BitMask.sol\";\n\nimport {AbstractAdapter} from \"../AbstractAdapter.sol\";\nimport {AdapterType} from \"@gearbox-protocol/sdk-gov/contracts/AdapterType.sol\";\n\nimport {IAsset} from \"../../integrations/balancer/IAsset.sol\";\nimport {\n    IBalancerV2Vault,\n    SwapKind,\n    SingleSwap,\n    FundManagement,\n    BatchSwapStep,\n    JoinPoolRequest,\n    ExitPoolRequest\n} from \"../../integrations/balancer/IBalancerV2Vault.sol\";\nimport {\n    IBalancerV2VaultAdapter, SingleSwapDiff, PoolStatus\n} from \"../../interfaces/balancer/IBalancerV2VaultAdapter.sol\";\n\n/// @title Balancer V2 Vault adapter\n/// @notice Implements logic allowing CAs to swap through and LP in Balancer vaults\ncontract BalancerV2VaultAdapter is AbstractAdapter, IBalancerV2VaultAdapter {\n    using BitMask for uint256;\n\n    AdapterType public constant override _gearboxAdapterType = AdapterType.BALANCER_VAULT;\n    uint16 public constant override _gearboxAdapterVersion = 3_00;\n\n    /// @notice Mapping from poolId to status of the pool: whether it is not supported, fully supported or swap-only\n    mapping(bytes32 => PoolStatus) public override poolStatus;\n\n    /// @notice Constructor\n    /// @param _creditManager Credit manager address\n    /// @param _vault Balancer vault address\n    constructor(address _creditManager, address _vault)\n        AbstractAdapter(_creditManager, _vault) // U:[BAL2-1]\n    {}\n\n    // ----- //\n    // SWAPS //\n    // ----- //\n\n    /// @notice Swaps a token for another token within a single pool\n    /// @param singleSwap Struct containing swap parameters\n    ///        * `poolId` - ID of the pool to perform a swap in\n    ///        * `kind` - type of swap (GIVEN IN / GIVEN OUT)\n    ///        * `assetIn` - asset to send\n    ///        * `assetOut` - asset to receive\n    ///        * `amount` - amount of input asset to send (for GIVEN IN) or output asset to receive (for GIVEN OUT)\n    ///        * `userData` - generic blob used to pass extra data\n    /// @param limit The minimal amount of `assetOut` to receive or maximal amount of `assetIn` to spend (depending on `kind`)\n    /// @param deadline The latest timestamp at which the swap would be executed\n    /// @dev `fundManagement` param from the original interface is ignored, as the adapter does not use internal balances and\n    ///       only has one sender/recipient\n    /// @dev The function reverts if the poolId status is not ALLOWED or SWAP_ONLY\n    function swap(SingleSwap memory singleSwap, FundManagement memory, uint256 limit, uint256 deadline)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        if (poolStatus[singleSwap.poolId] == PoolStatus.NOT_ALLOWED) {\n            revert PoolNotSupportedException(); // U:[BAL2-3]\n        }\n\n        address creditAccount = _creditAccount(); // U:[BAL2-3]\n\n        address tokenIn = address(singleSwap.assetIn);\n        address tokenOut = address(singleSwap.assetOut);\n\n        FundManagement memory fundManagement = _getDefaultFundManagement(creditAccount); // U:[BAL2-3]\n\n        // calling `_executeSwap` because we need to check if output token is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapSafeApprove(\n            tokenIn,\n            tokenOut,\n            abi.encodeCall(IBalancerV2Vault.swap, (singleSwap, fundManagement, limit, deadline)),\n            false\n        ); // U:[BAL2-3]\n    }\n\n    /// @notice Swaps the entire balance of a token for another token within a single pool, except the specified amount\n    /// @param singleSwapDiff Struct containing swap parameters\n    ///        * `poolId` - ID of the pool to perform a swap in\n    ///        * `leftoverAmount` - amount of assetIn to leave after operation\n    ///        * `assetIn` - asset to send\n    ///        * `assetOut` - asset to receive\n    ///        * `userData` - additional generic blob used to pass extra data\n    /// @param limitRateRAY The minimal resulting exchange rate of assetOut to assetIn, scaled by 1e27\n    /// @param deadline The latest timestamp at which the swap would be executed\n    /// @dev The function reverts if the poolId status is not ALLOWED or SWAP_ONLY\n    function swapDiff(SingleSwapDiff memory singleSwapDiff, uint256 limitRateRAY, uint256 deadline)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        address creditAccount = _creditAccount(); // U:[BAL2-4]\n\n        if (poolStatus[singleSwapDiff.poolId] == PoolStatus.NOT_ALLOWED) {\n            revert PoolNotSupportedException(); // U:[BAL2-4]\n        }\n\n        uint256 amount = IERC20(address(singleSwapDiff.assetIn)).balanceOf(creditAccount); // U:[BAL2-4]\n        if (amount <= singleSwapDiff.leftoverAmount) return (0, 0);\n\n        unchecked {\n            amount -= singleSwapDiff.leftoverAmount; // U:[BAL2-4]\n        }\n\n        FundManagement memory fundManagement = _getDefaultFundManagement(creditAccount); // U:[BAL2-4]\n\n        // calling `_executeSwap` because we need to check if output token is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapSafeApprove(\n            address(singleSwapDiff.assetIn),\n            address(singleSwapDiff.assetOut),\n            abi.encodeCall(\n                IBalancerV2Vault.swap,\n                (\n                    SingleSwap({\n                        poolId: singleSwapDiff.poolId,\n                        kind: SwapKind.GIVEN_IN,\n                        assetIn: singleSwapDiff.assetIn,\n                        assetOut: singleSwapDiff.assetOut,\n                        amount: amount,\n                        userData: singleSwapDiff.userData\n                    }),\n                    fundManagement,\n                    (amount * limitRateRAY) / RAY,\n                    deadline\n                )\n            ),\n            singleSwapDiff.leftoverAmount <= 1\n        ); // U:[BAL2-4]\n    }\n\n    /// @notice Performs a multi-hop swap through several Balancer pools\n    /// @param kind Type of swap (GIVEN IN or GIVEN OUT)\n    /// @param swaps Array of structs containing data for each individual swap:\n    ///        * `poolId` - ID of the pool to perform a swap in\n    ///        * `assetInIndex` - Index of the input asset in the pool (in an alphanumerically sorted array of asset addresses)\n    ///        * `assetOutIndex` - Index of the output asset in the pool (in an alphanumerically sorted array of asset addresses)\n    ///        * `amount` - amount of asset to send / receive. 0 signals to either spend the entire amount received from the last step,\n    ///           or to receive the exact amount needed for the next step\n    ///        * `userData` - generic blob used to pass extra data\n    /// @param assets Array of all assets participating in the swap\n    /// @param limits Array of minimal received (negative) / maximal spent (positive) amounts, in the same order as the assets array\n    /// @param deadline The latest timestamp at which the swap would be executed\n    /// @dev `fundManagement` param from the original interface is ignored, as the adapter does not use internal balances and\n    ///       only has one sender/recipient\n    /// @dev The function reverts if any of the poolId statuses is not ALLOWED or SWAP_ONLY\n    function batchSwap(\n        SwapKind kind,\n        BatchSwapStep[] memory swaps,\n        IAsset[] memory assets,\n        FundManagement memory,\n        int256[] memory limits,\n        uint256 deadline\n    )\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        unchecked {\n            for (uint256 i; i < swaps.length; ++i) {\n                if (poolStatus[swaps[i].poolId] == PoolStatus.NOT_ALLOWED) {\n                    revert PoolNotSupportedException(); // U:[BAL2-5]\n                }\n            }\n        }\n\n        address creditAccount = _creditAccount(); // U:[BAL2-5]\n\n        FundManagement memory fundManagement = _getDefaultFundManagement(creditAccount); // U:[BAL2-5]\n\n        _approveAssets(assets, limits, type(uint256).max); // U:[BAL2-5]\n\n        int256[] memory assetDeltas = abi.decode(\n            _execute(\n                abi.encodeCall(IBalancerV2Vault.batchSwap, (kind, swaps, assets, fundManagement, limits, deadline))\n            ),\n            (int256[])\n        ); // U:[BAL2-5]\n\n        _approveAssets(assets, limits, 1); // U:[BAL2-5]\n\n        (tokensToEnable, tokensToDisable) = (_getTokensToEnable(assets, assetDeltas), 0); // U:[BAL2-5]\n    }\n\n    // --------- //\n    // JOIN POOL //\n    // --------- //\n\n    /// @notice Deposits liquidity into a Balancer pool in exchange for BPT\n    /// @param poolId ID of the pool to deposit into\n    /// @param request A struct containing data for executing a deposit:\n    ///        * `assets` - Array of assets in the pool\n    ///        * `maxAmountsIn` - Array of maximal amounts to be spent for each asset\n    ///        * `userData` - a blob encoding the type of deposit and additional parameters\n    ///          (see https://dev.balancer.fi/resources/joins-and-exits/pool-joins#userdata for more info)\n    ///        * `fromInternalBalance` - whether to use internal balances for assets\n    ///          (ignored as the adapter does not use internal balances)\n    /// @dev `sender` and `recipient` are ignored, since they are always set to the CA address\n    /// @dev The function reverts if poolId status is not ALLOWED\n    function joinPool(bytes32 poolId, address, address, JoinPoolRequest memory request)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        if (poolStatus[poolId] != PoolStatus.ALLOWED) {\n            revert PoolNotSupportedException(); // U:[BAL2-6]\n        }\n\n        address creditAccount = _creditAccount(); // U:[BAL2-6]\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        request.fromInternalBalance = false; // U:[BAL2-6]\n\n        _approveAssets(request.assets, request.maxAmountsIn, type(uint256).max); // U:[BAL2-6]\n        _execute(abi.encodeCall(IBalancerV2Vault.joinPool, (poolId, creditAccount, creditAccount, request))); // U:[BAL2-6]\n        _approveAssets(request.assets, request.maxAmountsIn, 1); // U:[BAL2-6]\n        (tokensToEnable, tokensToDisable) = (_getMaskOrRevert(bpt), 0); // U:[BAL2-6]\n    }\n\n    /// @notice Deposits single asset as liquidity into a Balancer pool\n    /// @param poolId ID of the pool to deposit into\n    /// @param assetIn Asset to deposit\n    /// @param amountIn Amount of asset to deposit\n    /// @param minAmountOut The minimal amount of BPT to receive\n    /// @dev The function reverts if poolId status is not ALLOWED\n    function joinPoolSingleAsset(bytes32 poolId, IAsset assetIn, uint256 amountIn, uint256 minAmountOut)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        if (poolStatus[poolId] != PoolStatus.ALLOWED) {\n            revert PoolNotSupportedException(); // U:[BAL2-7]\n        }\n\n        address creditAccount = _creditAccount(); // U:[BAL2-7]\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        // calling `_executeSwap` because we need to check if BPT is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapSafeApprove(\n            address(assetIn),\n            bpt,\n            abi.encodeCall(\n                IBalancerV2Vault.joinPool,\n                (\n                    poolId,\n                    creditAccount,\n                    creditAccount,\n                    _getJoinSingleAssetRequest(poolId, assetIn, amountIn, minAmountOut, bpt)\n                )\n            ),\n            false\n        ); // U:[BAL2-7]\n    }\n\n    /// @notice Deposits the entire balance of given asset, except a specified amount, as liquidity into a Balancer pool\n    /// @param poolId ID of the pool to deposit into\n    /// @param assetIn Asset to deposit\n    /// @param leftoverAmount Amount of underlying to keep on the account\n    /// @param minRateRAY The minimal exchange rate of assetIn to BPT, scaled by 1e27\n    /// @dev The function reverts if poolId status is not ALLOWED\n    function joinPoolSingleAssetDiff(bytes32 poolId, IAsset assetIn, uint256 leftoverAmount, uint256 minRateRAY)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        address creditAccount = _creditAccount(); // U:[BAL2-8]\n\n        if (poolStatus[poolId] != PoolStatus.ALLOWED) {\n            revert PoolNotSupportedException(); // U:[BAL2-8]\n        }\n\n        uint256 amount = IERC20(address(assetIn)).balanceOf(creditAccount); // U:[BAL2-8]\n        if (amount <= leftoverAmount) return (0, 0);\n\n        unchecked {\n            amount -= leftoverAmount; // U:[BAL2-8]\n        }\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        uint256 amountOutMin = (amount * minRateRAY) / RAY; // U:[BAL2-8]\n        JoinPoolRequest memory request = _getJoinSingleAssetRequest(poolId, assetIn, amount, amountOutMin, bpt); // U:[BAL2-8]\n\n        // calling `_executeSwap` because we need to check if BPT is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapSafeApprove(\n            address(assetIn),\n            bpt,\n            abi.encodeCall(IBalancerV2Vault.joinPool, (poolId, creditAccount, creditAccount, request)),\n            leftoverAmount <= 1\n        ); // U:[BAL2-8]\n    }\n\n    /// @dev Internal function that builds a `JoinPoolRequest` struct for one-sided deposits\n    function _getJoinSingleAssetRequest(\n        bytes32 poolId,\n        IAsset assetIn,\n        uint256 amountIn,\n        uint256 minAmountOut,\n        address bpt\n    ) internal view returns (JoinPoolRequest memory request) {\n        (IERC20[] memory tokens,,) = IBalancerV2Vault(targetContract).getPoolTokens(poolId);\n\n        uint256 len = tokens.length;\n\n        request.assets = new IAsset[](tokens.length);\n        request.maxAmountsIn = new uint256[](tokens.length);\n        uint256 bptIndex = tokens.length;\n\n        unchecked {\n            for (uint256 i; i < len; ++i) {\n                request.assets[i] = IAsset(address(tokens[i]));\n\n                if (request.assets[i] == assetIn) {\n                    request.maxAmountsIn[i] = amountIn; // U:[BAL2-7,8]\n                }\n\n                if (address(request.assets[i]) == bpt) {\n                    bptIndex = i;\n                }\n            }\n        }\n\n        request.userData = abi.encode(uint256(1), _removeIndex(request.maxAmountsIn, bptIndex), minAmountOut); // U:[BAL2-7,8]\n    }\n\n    // --------- //\n    // EXIT POOL //\n    // --------- //\n\n    /// @notice Withdraws liquidity from a Balancer pool, burning BPT and receiving assets\n    /// @param poolId ID of the pool to withdraw from\n    /// @param request A struct containing data for executing a withdrawal:\n    ///        * `assets` - Array of all assets in the pool\n    ///        * `minAmountsOut` - The minimal amounts to receive for each asset\n    ///        * `userData` - a blob encoding the type of deposit and additional parameters\n    ///          (see https://dev.balancer.fi/resources/joins-and-exits/pool-exits#userdata for more info)\n    ///        * `toInternalBalance` - whether to use internal balances for assets\n    ///          (ignored as the adapter does not use internal balances)\n    /// @dev `sender` and `recipient` are ignored, since they are always set to the CA address\n    function exitPool(bytes32 poolId, address, address payable, ExitPoolRequest memory request)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        address creditAccount = _creditAccount(); // U:[BAL2-9]\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        request.toInternalBalance = false; // U:[BAL2-9]\n\n        _execute(abi.encodeCall(IBalancerV2Vault.exitPool, (poolId, creditAccount, payable(creditAccount), request))); // U:[BAL2-9]\n\n        _getMaskOrRevert(bpt); // U:[BAL2-9]\n        (tokensToEnable, tokensToDisable) =\n            (_getTokensToEnable(request.assets, _getBalancesFilter(creditAccount, request.assets)), 0); // U:[BAL2-9]\n    }\n\n    /// @notice Withdraws liquidity from a Balancer pool, burning BPT and receiving a single asset\n    /// @param poolId ID of the pool to withdraw from\n    /// @param assetOut Asset to withdraw\n    /// @param amountIn Amount of BPT to burn\n    /// @param minAmountOut Minimal amount of asset to receive\n    function exitPoolSingleAsset(bytes32 poolId, IAsset assetOut, uint256 amountIn, uint256 minAmountOut)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        address creditAccount = _creditAccount(); // U:[BAL2-10]\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        // calling `_executeSwap` because we need to check if asset is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapNoApprove(\n            bpt,\n            address(assetOut),\n            abi.encodeCall(\n                IBalancerV2Vault.exitPool,\n                (\n                    poolId,\n                    creditAccount,\n                    payable(creditAccount),\n                    _getExitSingleAssetRequest(poolId, assetOut, amountIn, minAmountOut, bpt)\n                )\n            ),\n            false\n        ); // U:[BAL2-10]\n    }\n\n    /// @notice Withdraws all liquidity from a Balancer pool except the specified amount, burning BPT and receiving a single asset\n    /// @param poolId ID of the pool to withdraw from\n    /// @param assetOut Asset to withdraw\n    /// @param leftoverAmount Amount of pool token to keep on the account\n    /// @param minRateRAY Minimal exchange rate of BPT to assetOut, scaled by 1e27\n    function exitPoolSingleAssetDiff(bytes32 poolId, IAsset assetOut, uint256 leftoverAmount, uint256 minRateRAY)\n        external\n        override\n        creditFacadeOnly // U:[BAL2-2]\n        returns (uint256 tokensToEnable, uint256 tokensToDisable)\n    {\n        address creditAccount = _creditAccount(); // U:[BAL2-11]\n\n        (address bpt,) = IBalancerV2Vault(targetContract).getPool(poolId);\n\n        uint256 amount = IERC20(bpt).balanceOf(creditAccount); // U:[BAL2-11]\n        if (amount <= leftoverAmount) return (0, 0);\n\n        unchecked {\n            amount -= leftoverAmount; // U:[BAL2-11]\n        }\n\n        uint256 amountOutMin = (amount * minRateRAY) / RAY; // U:[BAL2-11]\n        ExitPoolRequest memory request = _getExitSingleAssetRequest(poolId, assetOut, amount, amountOutMin, bpt); // U:[BAL2-11]\n\n        // calling `_executeSwap` because we need to check if asset is registered as collateral token in the CM\n        (tokensToEnable, tokensToDisable,) = _executeSwapNoApprove(\n            bpt,\n            address(assetOut),\n            abi.encodeCall(IBalancerV2Vault.exitPool, (poolId, creditAccount, payable(creditAccount), request)),\n            leftoverAmount <= 1\n        ); // U:[BAL2-11]\n    }\n\n    /// @dev Internal function that builds an `ExitPoolRequest` struct for one-sided withdrawals\n    function _getExitSingleAssetRequest(\n        bytes32 poolId,\n        IAsset assetOut,\n        uint256 amountIn,\n        uint256 minAmountOut,\n        address bpt\n    ) internal view returns (ExitPoolRequest memory request) {\n        (IERC20[] memory tokens,,) = IBalancerV2Vault(targetContract).getPoolTokens(poolId);\n\n        uint256 len = tokens.length;\n\n        request.assets = new IAsset[](tokens.length);\n        request.minAmountsOut = new uint256[](tokens.length);\n        uint256 tokenIndex = tokens.length;\n        uint256 bptIndex = tokens.length;\n\n        unchecked {\n            for (uint256 i; i < len; ++i) {\n                request.assets[i] = IAsset(address(tokens[i]));\n\n                if (request.assets[i] == assetOut) {\n                    request.minAmountsOut[i] = minAmountOut; // U:[BAL2-10,11]\n                    tokenIndex = i;\n                }\n\n                if (address(request.assets[i]) == bpt) {\n                    bptIndex = i;\n                }\n            }\n        }\n\n        tokenIndex = tokenIndex > bptIndex ? tokenIndex - 1 : tokenIndex; // U:[BAL2-10,11]\n\n        request.userData = abi.encode(uint256(0), amountIn, tokenIndex);\n    }\n\n    // ------- //\n    // HELPERS //\n    // ------- //\n\n    /// @dev Internal function that changes approval for a batch of assets in the vault\n    function _approveAssets(IAsset[] memory assets, int256[] memory filter, uint256 amount) internal {\n        uint256 len = assets.length;\n\n        unchecked {\n            for (uint256 i; i < len; ++i) {\n                if (filter[i] > 1) _approveToken(address(assets[i]), amount);\n            }\n        }\n    }\n\n    /// @dev Internal function that changes approval for a batch of assets in the vault (overloading)\n    function _approveAssets(IAsset[] memory assets, uint256[] memory filter, uint256 amount) internal {\n        uint256 len = assets.length;\n\n        unchecked {\n            for (uint256 i = 0; i < len; ++i) {\n                if (filter[i] > 1) _approveToken(address(assets[i]), amount);\n            }\n        }\n    }\n\n    /// @dev Returns mask of all tokens that should be enabled, based on balances / balance changes\n    function _getTokensToEnable(IAsset[] memory assets, int256[] memory filter)\n        internal\n        view\n        returns (uint256 tokensToEnable)\n    {\n        uint256 len = assets.length;\n\n        unchecked {\n            for (uint256 i; i < len; ++i) {\n                if (filter[i] < -1) tokensToEnable = tokensToEnable.enable(_getMaskOrRevert(address(assets[i])));\n            }\n        }\n    }\n\n    /// @dev Internal function that creates a filter based on CA token balances\n    function _getBalancesFilter(address creditAccount, IAsset[] memory assets)\n        internal\n        view\n        returns (int256[] memory filter)\n    {\n        uint256 len = assets.length;\n\n        filter = new int256[](len);\n\n        for (uint256 i = 0; i < len;) {\n            filter[i] = -int256(IERC20(address(assets[i])).balanceOf(creditAccount));\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /// @dev Returns a standard `FundManagement` struct used by the adapter\n    function _getDefaultFundManagement(address creditAccount) internal pure returns (FundManagement memory) {\n        return FundManagement({\n            sender: creditAccount,\n            fromInternalBalance: false,\n            recipient: payable(creditAccount),\n            toInternalBalance: false\n        });\n    }\n\n    /// @dev Returns copy of `array` without an element at `index`\n    function _removeIndex(uint256[] memory array, uint256 index) internal pure returns (uint256[] memory res) {\n        uint256 len = array.length;\n\n        if (index >= len) {\n            return array;\n        }\n\n        len = len - 1;\n\n        res = new uint256[](len);\n\n        for (uint256 i = 0; i < len;) {\n            if (i < index) {\n                res[i] = array[i];\n            } else {\n                res[i] = array[i + 1];\n            }\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    // ------------- //\n    // CONFIGURATION //\n    // ------------- //\n\n    /// @notice Sets the pool status\n    function setPoolStatus(bytes32 poolId, PoolStatus newStatus)\n        external\n        override\n        configuratorOnly // U:[BAL2-12]\n    {\n        if (poolStatus[poolId] != newStatus) {\n            poolStatus[poolId] = newStatus; // U:[BAL2-12]\n            emit SetPoolStatus(poolId, newStatus); // U:[BAL2-12]\n        }\n    }\n}\n"
      },
      "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v2/contracts/libraries/Constants.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Holdings, 2022\npragma solidity ^0.8.10;\n\n// Denominations\n\nuint256 constant WAD = 1e18;\nuint256 constant RAY = 1e27;\nuint16 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals\n\n// 25% of type(uint256).max\nuint256 constant ALLOWANCE_THRESHOLD = type(uint96).max >> 3;\n\n// FEE = 50%\nuint16 constant DEFAULT_FEE_INTEREST = 50_00; // 50%\n\n// LIQUIDATION_FEE 1.5%\nuint16 constant DEFAULT_FEE_LIQUIDATION = 1_50; // 1.5%\n\n// LIQUIDATION PREMIUM 4%\nuint16 constant DEFAULT_LIQUIDATION_PREMIUM = 4_00; // 4%\n\n// LIQUIDATION_FEE_EXPIRED 2%\nuint16 constant DEFAULT_FEE_LIQUIDATION_EXPIRED = 1_00; // 2%\n\n// LIQUIDATION PREMIUM EXPIRED 2%\nuint16 constant DEFAULT_LIQUIDATION_PREMIUM_EXPIRED = 2_00; // 2%\n\n// DEFAULT PROPORTION OF MAX BORROWED PER BLOCK TO MAX BORROWED PER ACCOUNT\nuint16 constant DEFAULT_LIMIT_PER_BLOCK_MULTIPLIER = 2;\n\n// Seconds in a year\nuint256 constant SECONDS_PER_YEAR = 365 days;\nuint256 constant SECONDS_PER_ONE_AND_HALF_YEAR = (SECONDS_PER_YEAR * 3) / 2;\n\n// OPERATIONS\n\n// Leverage decimals - 100 is equal to 2x leverage (100% * collateral amount + 100% * borrowed amount)\nuint8 constant LEVERAGE_DECIMALS = 100;\n\n// Maximum withdraw fee for pool in PERCENTAGE_FACTOR format\nuint8 constant MAX_WITHDRAW_FEE = 100;\n\nuint256 constant EXACT_INPUT = 1;\nuint256 constant EXACT_OUTPUT = 2;\n\naddress constant UNIVERSAL_CONTRACT = 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC;\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/libraries/BitMask.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IncorrectParameterException} from \"../interfaces/IExceptions.sol\";\n\nuint256 constant UNDERLYING_TOKEN_MASK = 1;\n\n/// @title Bit mask library\n/// @notice Implements functions that manipulate bit masks\n///         Bit masks are utilized extensively by Gearbox to efficiently store token sets (enabled tokens on accounts\n///         or forbidden tokens) and check for set inclusion. A mask is a uint256 number that has its i-th bit set to\n///         1 if i-th item is included into the set. For example, each token has a mask equal to 2**i, so set inclusion\n///         can be checked by checking tokenMask & setMask != 0.\nlibrary BitMask {\n    /// @dev Calculates an index of an item based on its mask (using a binary search)\n    /// @dev The input should always have only 1 bit set, otherwise the result may be unpredictable\n    function calcIndex(uint256 mask) internal pure returns (uint8 index) {\n        if (mask == 0) revert IncorrectParameterException(); // U:[BM-1]\n        uint16 lb = 0; // U:[BM-2]\n        uint16 ub = 256; // U:[BM-2]\n        uint16 mid = 128; // U:[BM-2]\n\n        unchecked {\n            while (true) {\n                uint256 newMask = 1 << mid;\n                if (newMask & mask != 0) return uint8(mid); // U:[BM-2]\n\n                if (newMask > mask) ub = mid; // U:[BM-2]\n\n                else lb = mid; // U:[BM-2]\n                mid = (lb + ub) >> 1; // U:[BM-2]\n            }\n        }\n    }\n\n    /// @dev Calculates the number of `1` bits\n    /// @param enabledTokensMask Bit mask to compute the number of `1` bits in\n    function calcEnabledTokens(uint256 enabledTokensMask) internal pure returns (uint256 totalTokensEnabled) {\n        unchecked {\n            while (enabledTokensMask > 0) {\n                enabledTokensMask &= enabledTokensMask - 1; // U:[BM-3]\n                ++totalTokensEnabled; // U:[BM-3]\n            }\n        }\n    }\n\n    /// @dev Enables bits from the second mask in the first mask\n    /// @param enabledTokenMask The initial mask\n    /// @param bitsToEnable Mask of bits to enable\n    function enable(uint256 enabledTokenMask, uint256 bitsToEnable) internal pure returns (uint256) {\n        return enabledTokenMask | bitsToEnable; // U:[BM-4]\n    }\n\n    /// @dev Disables bits from the second mask in the first mask\n    /// @param enabledTokenMask The initial mask\n    /// @param bitsToDisable Mask of bits to disable\n    function disable(uint256 enabledTokenMask, uint256 bitsToDisable) internal pure returns (uint256) {\n        return enabledTokenMask & ~bitsToDisable; // U:[BM-4]\n    }\n\n    /// @dev Computes a new mask with sets of new enabled and disabled bits\n    /// @dev bitsToEnable and bitsToDisable are applied sequentially to original mask\n    /// @param enabledTokensMask The initial mask\n    /// @param bitsToEnable Mask with bits to enable\n    /// @param bitsToDisable Mask with bits to disable\n    function enableDisable(uint256 enabledTokensMask, uint256 bitsToEnable, uint256 bitsToDisable)\n        internal\n        pure\n        returns (uint256)\n    {\n        return (enabledTokensMask | bitsToEnable) & (~bitsToDisable); // U:[BM-5]\n    }\n\n    /// @dev Enables bits from the second mask in the first mask, skipping specified bits\n    /// @param enabledTokenMask The initial mask\n    /// @param bitsToEnable Mask with bits to enable\n    /// @param invertedSkipMask An inversion of mask of immutable bits\n    function enable(uint256 enabledTokenMask, uint256 bitsToEnable, uint256 invertedSkipMask)\n        internal\n        pure\n        returns (uint256)\n    {\n        return enabledTokenMask | (bitsToEnable & invertedSkipMask); // U:[BM-6]\n    }\n\n    /// @dev Disables bits from the second mask in the first mask, skipping specified bits\n    /// @param enabledTokenMask The initial mask\n    /// @param bitsToDisable Mask with bits to disable\n    /// @param invertedSkipMask An inversion of mask of immutable bits\n    function disable(uint256 enabledTokenMask, uint256 bitsToDisable, uint256 invertedSkipMask)\n        internal\n        pure\n        returns (uint256)\n    {\n        return enabledTokenMask & (~(bitsToDisable & invertedSkipMask)); // U:[BM-6]\n    }\n\n    /// @dev Computes a new mask with sets of new enabled and disabled bits, skipping some bits\n    /// @dev bitsToEnable and bitsToDisable are applied sequentially to original mask. Skipmask is applied in both cases.\n    /// @param enabledTokensMask The initial mask\n    /// @param bitsToEnable Mask with bits to enable\n    /// @param bitsToDisable Mask with bits to disable\n    /// @param invertedSkipMask An inversion of mask of immutable bits\n    function enableDisable(\n        uint256 enabledTokensMask,\n        uint256 bitsToEnable,\n        uint256 bitsToDisable,\n        uint256 invertedSkipMask\n    ) internal pure returns (uint256) {\n        return (enabledTokensMask | (bitsToEnable & invertedSkipMask)) & (~(bitsToDisable & invertedSkipMask)); // U:[BM-7]\n    }\n}\n"
      },
      "node_modules/@gearbox-protocol/integrations-v3/contracts/adapters/AbstractAdapter.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IAdapter} from \"@gearbox-protocol/core-v2/contracts/interfaces/IAdapter.sol\";\nimport {ICreditManagerV3} from \"@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol\";\nimport {CallerNotCreditFacadeException} from \"@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol\";\nimport {ACLTrait} from \"@gearbox-protocol/core-v3/contracts/traits/ACLTrait.sol\";\n\n/// @title Abstract adapter\n/// @dev Inheriting adapters MUST use provided internal functions to perform all operations with credit accounts\nabstract contract AbstractAdapter is IAdapter, ACLTrait {\n    /// @notice Credit manager the adapter is connected to\n    address public immutable override creditManager;\n\n    /// @notice Address provider contract\n    address public immutable override addressProvider;\n\n    /// @notice Address of the contract the adapter is interacting with\n    address public immutable override targetContract;\n\n    /// @notice Constructor\n    /// @param _creditManager Credit manager to connect the adapter to\n    /// @param _targetContract Address of the adapted contract\n    constructor(address _creditManager, address _targetContract)\n        ACLTrait(ICreditManagerV3(_creditManager).addressProvider())\n        nonZeroAddress(_targetContract)\n    {\n        creditManager = _creditManager;\n        addressProvider = ICreditManagerV3(_creditManager).addressProvider();\n        targetContract = _targetContract;\n    }\n\n    /// @dev Ensures that caller of the function is credit facade connected to the credit manager\n    /// @dev Inheriting adapters MUST use this modifier in all external functions that operate on credit accounts\n    modifier creditFacadeOnly() {\n        _revertIfCallerNotCreditFacade();\n        _;\n    }\n\n    /// @dev Ensures that caller is credit facade connected to the credit manager\n    function _revertIfCallerNotCreditFacade() internal view {\n        if (msg.sender != ICreditManagerV3(creditManager).creditFacade()) {\n            revert CallerNotCreditFacadeException();\n        }\n    }\n\n    /// @dev Ensures that active credit account is set and returns its address\n    function _creditAccount() internal view returns (address) {\n        return ICreditManagerV3(creditManager).getActiveCreditAccountOrRevert();\n    }\n\n    /// @dev Ensures that token is registered as collateral in the credit manager and returns its mask\n    function _getMaskOrRevert(address token) internal view returns (uint256 tokenMask) {\n        tokenMask = ICreditManagerV3(creditManager).getTokenMaskOrRevert(token);\n    }\n\n    /// @dev Approves target contract to spend given token from the active credit account\n    ///      Reverts if active credit account is not set or token is not registered as collateral\n    /// @param token Token to approve\n    /// @param amount Amount to approve\n    function _approveToken(address token, uint256 amount) internal {\n        ICreditManagerV3(creditManager).approveCreditAccount(token, amount);\n    }\n\n    /// @dev Executes an external call from the active credit account to the target contract\n    ///      Reverts if active credit account is not set\n    /// @param callData Data to call the target contract with\n    /// @return result Call result\n    function _execute(bytes memory callData) internal returns (bytes memory result) {\n        return ICreditManagerV3(creditManager).execute(callData);\n    }\n\n    /// @dev Executes a swap operation without input token approval\n    ///      Reverts if active credit account is not set or any of passed tokens is not registered as collateral\n    /// @param tokenIn Input token that credit account spends in the call\n    /// @param tokenOut Output token that credit account receives after the call\n    /// @param callData Data to call the target contract with\n    /// @param disableTokenIn Whether `tokenIn` should be disabled after the call\n    ///        (for operations that spend the entire account's balance of the input token)\n    /// @return tokensToEnable Bit mask of tokens that should be enabled after the call\n    /// @return tokensToDisable Bit mask of tokens that should be disabled after the call\n    /// @return result Call result\n    function _executeSwapNoApprove(address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn)\n        internal\n        returns (uint256 tokensToEnable, uint256 tokensToDisable, bytes memory result)\n    {\n        tokensToEnable = _getMaskOrRevert(tokenOut);\n        uint256 tokenInMask = _getMaskOrRevert(tokenIn);\n        if (disableTokenIn) tokensToDisable = tokenInMask;\n        result = _execute(callData);\n    }\n\n    /// @dev Executes a swap operation with maximum input token approval, and revokes approval after the call\n    ///      Reverts if active credit account is not set or any of passed tokens is not registered as collateral\n    /// @param tokenIn Input token that credit account spends in the call\n    /// @param tokenOut Output token that credit account receives after the call\n    /// @param callData Data to call the target contract with\n    /// @param disableTokenIn Whether `tokenIn` should be disabled after the call\n    ///        (for operations that spend the entire account's balance of the input token)\n    /// @return tokensToEnable Bit mask of tokens that should be enabled after the call\n    /// @return tokensToDisable Bit mask of tokens that should be disabled after the call\n    /// @return result Call result\n    /// @custom:expects Credit manager reverts when trying to approve non-collateral token\n    function _executeSwapSafeApprove(address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn)\n        internal\n        returns (uint256 tokensToEnable, uint256 tokensToDisable, bytes memory result)\n    {\n        tokensToEnable = _getMaskOrRevert(tokenOut);\n        if (disableTokenIn) tokensToDisable = _getMaskOrRevert(tokenIn);\n        _approveToken(tokenIn, type(uint256).max);\n        result = _execute(callData);\n        _approveToken(tokenIn, 1);\n    }\n}\n"
      },
      "node_modules/@gearbox-protocol/sdk-gov/contracts/AdapterType.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n// Gearbox. Generalized leverage protocol that allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.\n// (c) Gearbox Foundation, 2023\npragma solidity ^0.8.17;\n\nenum AdapterType {\n    ABSTRACT,\n    UNISWAP_V2_ROUTER,\n    UNISWAP_V3_ROUTER,\n    CURVE_V1_EXCHANGE_ONLY,\n    YEARN_V2,\n    CURVE_V1_2ASSETS,\n    CURVE_V1_3ASSETS,\n    CURVE_V1_4ASSETS,\n    CURVE_V1_STECRV_POOL,\n    CURVE_V1_WRAPPER,\n    CONVEX_V1_BASE_REWARD_POOL,\n    CONVEX_V1_BOOSTER,\n    CONVEX_V1_CLAIM_ZAP,\n    LIDO_V1,\n    UNIVERSAL,\n    LIDO_WSTETH_V1,\n    BALANCER_VAULT,\n    AAVE_V2_LENDING_POOL,\n    AAVE_V2_WRAPPED_ATOKEN,\n    COMPOUND_V2_CERC20,\n    COMPOUND_V2_CETHER,\n    ERC4626_VAULT,\n    VELODROME_V2_ROUTER,\n    CURVE_STABLE_NG,\n    CAMELOT_V3_ROUTER\n}\n"
      },
      "node_modules/@gearbox-protocol/integrations-v3/contracts/integrations/balancer/IAsset.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero\n * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like\n * types.\n *\n * This concept is unrelated to a Pool's Asset Managers.\n */\ninterface IAsset {\n// solhint-disable-previous-line no-empty-blocks\n}\n"
      },
      "node_modules/@gearbox-protocol/integrations-v3/contracts/integrations/balancer/IBalancerV2Vault.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IAsset} from \"./IAsset.sol\";\n\nenum SwapKind {\n    GIVEN_IN,\n    GIVEN_OUT\n}\n\nenum PoolSpecialization {\n    GENERAL,\n    MINIMAL_SWAP_INFO,\n    TWO_TOKEN\n}\n\nenum JoinKind {\n    INIT,\n    EXACT_TOKENS_IN_FOR_BPT_OUT,\n    TOKEN_IN_FOR_EXACT_BPT_OUT,\n    ALL_TOKENS_IN_FOR_EXACT_BPT_OUT\n}\n\nenum ExitKind {\n    EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,\n    EXACT_BPT_IN_FOR_TOKENS_OUT,\n    BPT_IN_FOR_EXACT_TOKENS_OUT\n}\n\nstruct SingleSwap {\n    bytes32 poolId;\n    SwapKind kind;\n    IAsset assetIn;\n    IAsset assetOut;\n    uint256 amount;\n    bytes userData;\n}\n\nstruct BatchSwapStep {\n    bytes32 poolId;\n    uint256 assetInIndex;\n    uint256 assetOutIndex;\n    uint256 amount;\n    bytes userData;\n}\n\nstruct FundManagement {\n    address sender;\n    bool fromInternalBalance;\n    address payable recipient;\n    bool toInternalBalance;\n}\n\nstruct JoinPoolRequest {\n    IAsset[] assets;\n    uint256[] maxAmountsIn;\n    bytes userData;\n    bool fromInternalBalance;\n}\n\nstruct ExitPoolRequest {\n    IAsset[] assets;\n    uint256[] minAmountsOut;\n    bytes userData;\n    bool toInternalBalance;\n}\n\ninterface IBalancerV2VaultGetters {\n    function getPool(bytes32 poolId) external view returns (address, PoolSpecialization);\n\n    function getPoolTokenInfo(bytes32 poolId, IERC20 token)\n        external\n        view\n        returns (uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager);\n\n    function getPoolTokens(bytes32 poolId)\n        external\n        view\n        returns (IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock);\n}\n\ninterface IBalancerV2Vault is IBalancerV2VaultGetters {\n    function batchSwap(\n        SwapKind kind,\n        BatchSwapStep[] memory swaps,\n        IAsset[] memory assets,\n        FundManagement memory funds,\n        int256[] memory limits,\n        uint256 deadline\n    ) external returns (int256[] memory assetDeltas);\n\n    function queryBatchSwap(\n        SwapKind kind,\n        BatchSwapStep[] memory swaps,\n        IAsset[] memory assets,\n        FundManagement memory funds\n    ) external returns (int256[] memory assetDeltas);\n\n    function swap(SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline)\n        external\n        returns (uint256 amountCalculated);\n\n    function joinPool(bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request) external;\n\n    function exitPool(bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request)\n        external;\n}\n"
      },
      "node_modules/@gearbox-protocol/integrations-v3/contracts/interfaces/balancer/IBalancerV2VaultAdapter.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IAdapter} from \"@gearbox-protocol/core-v2/contracts/interfaces/IAdapter.sol\";\n\nimport {\n    IAsset,\n    SingleSwap,\n    FundManagement,\n    SwapKind,\n    BatchSwapStep,\n    JoinPoolRequest,\n    ExitPoolRequest\n} from \"../../integrations/balancer/IBalancerV2Vault.sol\";\n\nenum PoolStatus {\n    NOT_ALLOWED,\n    ALLOWED,\n    SWAP_ONLY\n}\n\nstruct SingleSwapDiff {\n    bytes32 poolId;\n    uint256 leftoverAmount;\n    IAsset assetIn;\n    IAsset assetOut;\n    bytes userData;\n}\n\ninterface IBalancerV2VaultAdapterEvents {\n    /// @notice Emitted when new status is set for a pool with given ID\n    event SetPoolStatus(bytes32 indexed poolId, PoolStatus newStatus);\n}\n\ninterface IBalancerV2VaultAdapterExceptions {\n    /// @notice Thrown when attempting to swap or change liqudity in the pool that is not supported for that action\n    error PoolNotSupportedException();\n}\n\n/// @title Balancer V2 Vault adapter interface\ninterface IBalancerV2VaultAdapter is IAdapter, IBalancerV2VaultAdapterEvents, IBalancerV2VaultAdapterExceptions {\n    // ----- //\n    // SWAPS //\n    // ----- //\n\n    function swap(SingleSwap memory singleSwap, FundManagement memory, uint256 limit, uint256 deadline)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function swapDiff(SingleSwapDiff memory singleSwapDiff, uint256 limitRateRAY, uint256 deadline)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function batchSwap(\n        SwapKind kind,\n        BatchSwapStep[] memory swaps,\n        IAsset[] memory assets,\n        FundManagement memory,\n        int256[] memory limits,\n        uint256 deadline\n    ) external returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    // --------- //\n    // JOIN POOL //\n    // --------- //\n\n    function joinPool(bytes32 poolId, address, address, JoinPoolRequest memory request)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function joinPoolSingleAsset(bytes32 poolId, IAsset assetIn, uint256 amountIn, uint256 minAmountOut)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function joinPoolSingleAssetDiff(bytes32 poolId, IAsset assetIn, uint256 leftoverAmount, uint256 minRateRAY)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    // --------- //\n    // EXIT POOL //\n    // --------- //\n\n    function exitPool(bytes32 poolId, address, address payable, ExitPoolRequest memory request)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function exitPoolSingleAsset(bytes32 poolId, IAsset assetOut, uint256 amountIn, uint256 minAmountOut)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function exitPoolSingleAssetDiff(bytes32 poolId, IAsset assetOut, uint256 leftoverAmount, uint256 minRateRAY)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    // ------------- //\n    // CONFIGURATION //\n    // ------------- //\n\n    function poolStatus(bytes32 poolId) external view returns (PoolStatus);\n\n    function setPoolStatus(bytes32 poolId, PoolStatus newStatus) external;\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\n// ------- //\n// GENERAL //\n// ------- //\n\n/// @notice Thrown on attempting to set an important address to zero address\nerror ZeroAddressException();\n\n/// @notice Thrown when attempting to pass a zero amount to a funding-related operation\nerror AmountCantBeZeroException();\n\n/// @notice Thrown on incorrect input parameter\nerror IncorrectParameterException();\n\n/// @notice Thrown when balance is insufficient to perform an operation\nerror InsufficientBalanceException();\n\n/// @notice Thrown if parameter is out of range\nerror ValueOutOfRangeException();\n\n/// @notice Thrown when trying to send ETH to a contract that is not allowed to receive ETH directly\nerror ReceiveIsNotAllowedException();\n\n/// @notice Thrown on attempting to set an EOA as an important contract in the system\nerror AddressIsNotContractException(address);\n\n/// @notice Thrown on attempting to receive a token that is not a collateral token or was forbidden\nerror TokenNotAllowedException();\n\n/// @notice Thrown on attempting to add a token that is already in a collateral list\nerror TokenAlreadyAddedException();\n\n/// @notice Thrown when attempting to use quota-related logic for a token that is not quoted in quota keeper\nerror TokenIsNotQuotedException();\n\n/// @notice Thrown on attempting to interact with an address that is not a valid target contract\nerror TargetContractNotAllowedException();\n\n/// @notice Thrown if function is not implemented\nerror NotImplementedException();\n\n// ------------------ //\n// CONTRACTS REGISTER //\n// ------------------ //\n\n/// @notice Thrown when an address is expected to be a registered credit manager, but is not\nerror RegisteredCreditManagerOnlyException();\n\n/// @notice Thrown when an address is expected to be a registered pool, but is not\nerror RegisteredPoolOnlyException();\n\n// ---------------- //\n// ADDRESS PROVIDER //\n// ---------------- //\n\n/// @notice Reverts if address key isn't found in address provider\nerror AddressNotFoundException();\n\n// ----------------- //\n// POOL, PQK, GAUGES //\n// ----------------- //\n\n/// @notice Thrown by pool-adjacent contracts when a credit manager being connected has a wrong pool address\nerror IncompatibleCreditManagerException();\n\n/// @notice Thrown when attempting to set an incompatible successor staking contract\nerror IncompatibleSuccessorException();\n\n/// @notice Thrown when attempting to vote in a non-approved contract\nerror VotingContractNotAllowedException();\n\n/// @notice Thrown when attempting to unvote more votes than there are\nerror InsufficientVotesException();\n\n/// @notice Thrown when attempting to borrow more than the second point on a two-point curve\nerror BorrowingMoreThanU2ForbiddenException();\n\n/// @notice Thrown when a credit manager attempts to borrow more than its limit in the current block, or in general\nerror CreditManagerCantBorrowException();\n\n/// @notice Thrown when attempting to connect a quota keeper to an incompatible pool\nerror IncompatiblePoolQuotaKeeperException();\n\n/// @notice Thrown when the quota is outside of min/max bounds\nerror QuotaIsOutOfBoundsException();\n\n// -------------- //\n// CREDIT MANAGER //\n// -------------- //\n\n/// @notice Thrown on failing a full collateral check after multicall\nerror NotEnoughCollateralException();\n\n/// @notice Thrown if an attempt to approve a collateral token to adapter's target contract fails\nerror AllowanceFailedException();\n\n/// @notice Thrown on attempting to perform an action for a credit account that does not exist\nerror CreditAccountDoesNotExistException();\n\n/// @notice Thrown on configurator attempting to add more than 255 collateral tokens\nerror TooManyTokensException();\n\n/// @notice Thrown if more than the maximum number of tokens were enabled on a credit account\nerror TooManyEnabledTokensException();\n\n/// @notice Thrown when attempting to execute a protocol interaction without active credit account set\nerror ActiveCreditAccountNotSetException();\n\n/// @notice Thrown when trying to update credit account's debt more than once in the same block\nerror DebtUpdatedTwiceInOneBlockException();\n\n/// @notice Thrown when trying to repay all debt while having active quotas\nerror DebtToZeroWithActiveQuotasException();\n\n/// @notice Thrown when a zero-debt account attempts to update quota\nerror UpdateQuotaOnZeroDebtAccountException();\n\n/// @notice Thrown when attempting to close an account with non-zero debt\nerror CloseAccountWithNonZeroDebtException();\n\n/// @notice Thrown when value of funds remaining on the account after liquidation is insufficient\nerror InsufficientRemainingFundsException();\n\n/// @notice Thrown when Credit Facade tries to write over a non-zero active Credit Account\nerror ActiveCreditAccountOverridenException();\n\n// ------------------- //\n// CREDIT CONFIGURATOR //\n// ------------------- //\n\n/// @notice Thrown on attempting to use a non-ERC20 contract or an EOA as a token\nerror IncorrectTokenContractException();\n\n/// @notice Thrown if the newly set LT if zero or greater than the underlying's LT\nerror IncorrectLiquidationThresholdException();\n\n/// @notice Thrown if borrowing limits are incorrect: minLimit > maxLimit or maxLimit > blockLimit\nerror IncorrectLimitsException();\n\n/// @notice Thrown if the new expiration date is less than the current expiration date or current timestamp\nerror IncorrectExpirationDateException();\n\n/// @notice Thrown if a contract returns a wrong credit manager or reverts when trying to retrieve it\nerror IncompatibleContractException();\n\n/// @notice Thrown if attempting to forbid an adapter that is not registered in the credit manager\nerror AdapterIsNotRegisteredException();\n\n// ------------- //\n// CREDIT FACADE //\n// ------------- //\n\n/// @notice Thrown when attempting to perform an action that is forbidden in whitelisted mode\nerror ForbiddenInWhitelistedModeException();\n\n/// @notice Thrown if credit facade is not expirable, and attempted aciton requires expirability\nerror NotAllowedWhenNotExpirableException();\n\n/// @notice Thrown if a selector that doesn't match any allowed function is passed to the credit facade in a multicall\nerror UnknownMethodException();\n\n/// @notice Thrown when trying to close an account with enabled tokens\nerror CloseAccountWithEnabledTokensException();\n\n/// @notice Thrown if a liquidator tries to liquidate an account with a health factor above 1\nerror CreditAccountNotLiquidatableException();\n\n/// @notice Thrown if too much new debt was taken within a single block\nerror BorrowedBlockLimitException();\n\n/// @notice Thrown if the new debt principal for a credit account falls outside of borrowing limits\nerror BorrowAmountOutOfLimitsException();\n\n/// @notice Thrown if a user attempts to open an account via an expired credit facade\nerror NotAllowedAfterExpirationException();\n\n/// @notice Thrown if expected balances are attempted to be set twice without performing a slippage check\nerror ExpectedBalancesAlreadySetException();\n\n/// @notice Thrown if attempting to perform a slippage check when excepted balances are not set\nerror ExpectedBalancesNotSetException();\n\n/// @notice Thrown if balance of at least one token is less than expected during a slippage check\nerror BalanceLessThanExpectedException();\n\n/// @notice Thrown when trying to perform an action that is forbidden when credit account has enabled forbidden tokens\nerror ForbiddenTokensException();\n\n/// @notice Thrown when new forbidden tokens are enabled during the multicall\nerror ForbiddenTokenEnabledException();\n\n/// @notice Thrown when enabled forbidden token balance is increased during the multicall\nerror ForbiddenTokenBalanceIncreasedException();\n\n/// @notice Thrown when the remaining token balance is increased during the liquidation\nerror RemainingTokenBalanceIncreasedException();\n\n/// @notice Thrown if `botMulticall` is called by an address that is not approved by account owner or is forbidden\nerror NotApprovedBotException();\n\n/// @notice Thrown when attempting to perform a multicall action with no permission for it\nerror NoPermissionException(uint256 permission);\n\n/// @notice Thrown when attempting to give a bot unexpected permissions\nerror UnexpectedPermissionsException();\n\n/// @notice Thrown when a custom HF parameter lower than 10000 is passed into the full collateral check\nerror CustomHealthFactorTooLowException();\n\n/// @notice Thrown when submitted collateral hint is not a valid token mask\nerror InvalidCollateralHintException();\n\n// ------ //\n// ACCESS //\n// ------ //\n\n/// @notice Thrown on attempting to call an access restricted function not as credit account owner\nerror CallerNotCreditAccountOwnerException();\n\n/// @notice Thrown on attempting to call an access restricted function not as configurator\nerror CallerNotConfiguratorException();\n\n/// @notice Thrown on attempting to call an access-restructed function not as account factory\nerror CallerNotAccountFactoryException();\n\n/// @notice Thrown on attempting to call an access restricted function not as credit manager\nerror CallerNotCreditManagerException();\n\n/// @notice Thrown on attempting to call an access restricted function not as credit facade\nerror CallerNotCreditFacadeException();\n\n/// @notice Thrown on attempting to call an access restricted function not as controller or configurator\nerror CallerNotControllerException();\n\n/// @notice Thrown on attempting to pause a contract without pausable admin rights\nerror CallerNotPausableAdminException();\n\n/// @notice Thrown on attempting to unpause a contract without unpausable admin rights\nerror CallerNotUnpausableAdminException();\n\n/// @notice Thrown on attempting to call an access restricted function not as gauge\nerror CallerNotGaugeException();\n\n/// @notice Thrown on attempting to call an access restricted function not as quota keeper\nerror CallerNotPoolQuotaKeeperException();\n\n/// @notice Thrown on attempting to call an access restricted function not as voter\nerror CallerNotVoterException();\n\n/// @notice Thrown on attempting to call an access restricted function not as allowed adapter\nerror CallerNotAdapterException();\n\n/// @notice Thrown on attempting to call an access restricted function not as migrator\nerror CallerNotMigratorException();\n\n/// @notice Thrown when an address that is not the designated executor attempts to execute a transaction\nerror CallerNotExecutorException();\n\n/// @notice Thrown on attempting to call an access restricted function not as veto admin\nerror CallerNotVetoAdminException();\n\n// ------------------- //\n// CONTROLLER TIMELOCK //\n// ------------------- //\n\n/// @notice Thrown when the new parameter values do not satisfy required conditions\nerror ParameterChecksFailedException();\n\n/// @notice Thrown when attempting to execute a non-queued transaction\nerror TxNotQueuedException();\n\n/// @notice Thrown when attempting to execute a transaction that is either immature or stale\nerror TxExecutedOutsideTimeWindowException();\n\n/// @notice Thrown when execution of a transaction fails\nerror TxExecutionRevertedException();\n\n/// @notice Thrown when the value of a parameter on execution is different from the value on queue\nerror ParameterChangedAfterQueuedTxException();\n\n// -------- //\n// BOT LIST //\n// -------- //\n\n/// @notice Thrown when attempting to set non-zero permissions for a forbidden or special bot\nerror InvalidBotException();\n\n// --------------- //\n// ACCOUNT FACTORY //\n// --------------- //\n\n/// @notice Thrown when trying to deploy second master credit account for a credit manager\nerror MasterCreditAccountAlreadyDeployedException();\n\n/// @notice Thrown when trying to rescue funds from a credit account that is currently in use\nerror CreditAccountIsInUseException();\n\n// ------------ //\n// PRICE ORACLE //\n// ------------ //\n\n/// @notice Thrown on attempting to set a token price feed to an address that is not a correct price feed\nerror IncorrectPriceFeedException();\n\n/// @notice Thrown on attempting to interact with a price feed for a token not added to the price oracle\nerror PriceFeedDoesNotExistException();\n\n/// @notice Thrown when price feed returns incorrect price for a token\nerror IncorrectPriceException();\n\n/// @notice Thrown when token's price feed becomes stale\nerror StalePriceException();\n"
      },
      "node_modules/@gearbox-protocol/core-v2/contracts/interfaces/IAdapter.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.0;\n\nimport { AdapterType } from \"@gearbox-protocol/sdk-gov/contracts/AdapterType.sol\";\n\n/// @title Adapter interface\ninterface IAdapter {\n    function _gearboxAdapterType() external view returns (AdapterType);\n\n    function _gearboxAdapterVersion() external view returns (uint16);\n\n    function creditManager() external view returns (address);\n\n    function addressProvider() external view returns (address);\n\n    function targetContract() external view returns (address);\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IVersion} from \"@gearbox-protocol/core-v2/contracts/interfaces/IVersion.sol\";\n\nuint8 constant BOT_PERMISSIONS_SET_FLAG = 1;\n\nuint8 constant DEFAULT_MAX_ENABLED_TOKENS = 4;\naddress constant INACTIVE_CREDIT_ACCOUNT_ADDRESS = address(1);\n\n/// @notice Debt management type\n///         - `INCREASE_DEBT` borrows additional funds from the pool, updates account's debt and cumulative interest index\n///         - `DECREASE_DEBT` repays debt components (quota interest and fees -> base interest and fees -> debt principal)\n///           and updates all corresponding state varibles (base interest index, quota interest and fees, debt).\n///           When repaying all the debt, ensures that account has no enabled quotas.\nenum ManageDebtAction {\n    INCREASE_DEBT,\n    DECREASE_DEBT\n}\n\n/// @notice Collateral/debt calculation mode\n///         - `GENERIC_PARAMS` returns generic data like account debt and cumulative indexes\n///         - `DEBT_ONLY` is same as `GENERIC_PARAMS` but includes more detailed debt info, like accrued base/quota\n///           interest and fees\n///         - `FULL_COLLATERAL_CHECK_LAZY` checks whether account is sufficiently collateralized in a lazy fashion,\n///           i.e. it stops iterating over collateral tokens once TWV reaches the desired target.\n///           Since it may return underestimated TWV, it's only available for internal use.\n///         - `DEBT_COLLATERAL` is same as `DEBT_ONLY` but also returns total value and total LT-weighted value of\n///           account's tokens, this mode is used during account liquidation\n///         - `DEBT_COLLATERAL_SAFE_PRICES` is same as `DEBT_COLLATERAL` but uses safe prices from price oracle\nenum CollateralCalcTask {\n    GENERIC_PARAMS,\n    DEBT_ONLY,\n    FULL_COLLATERAL_CHECK_LAZY,\n    DEBT_COLLATERAL,\n    DEBT_COLLATERAL_SAFE_PRICES\n}\n\nstruct CreditAccountInfo {\n    uint256 debt;\n    uint256 cumulativeIndexLastUpdate;\n    uint128 cumulativeQuotaInterest;\n    uint128 quotaFees;\n    uint256 enabledTokensMask;\n    uint16 flags;\n    uint64 lastDebtUpdate;\n    address borrower;\n}\n\nstruct CollateralDebtData {\n    uint256 debt;\n    uint256 cumulativeIndexNow;\n    uint256 cumulativeIndexLastUpdate;\n    uint128 cumulativeQuotaInterest;\n    uint256 accruedInterest;\n    uint256 accruedFees;\n    uint256 totalDebtUSD;\n    uint256 totalValue;\n    uint256 totalValueUSD;\n    uint256 twvUSD;\n    uint256 enabledTokensMask;\n    uint256 quotedTokensMask;\n    address[] quotedTokens;\n    address _poolQuotaKeeper;\n}\n\nstruct CollateralTokenData {\n    address token;\n    uint16 ltInitial;\n    uint16 ltFinal;\n    uint40 timestampRampStart;\n    uint24 rampDuration;\n}\n\nstruct RevocationPair {\n    address spender;\n    address token;\n}\n\ninterface ICreditManagerV3Events {\n    /// @notice Emitted when new credit configurator is set\n    event SetCreditConfigurator(address indexed newConfigurator);\n}\n\n/// @title Credit manager V3 interface\ninterface ICreditManagerV3 is IVersion, ICreditManagerV3Events {\n    function pool() external view returns (address);\n\n    function underlying() external view returns (address);\n\n    function creditFacade() external view returns (address);\n\n    function creditConfigurator() external view returns (address);\n\n    function addressProvider() external view returns (address);\n\n    function accountFactory() external view returns (address);\n\n    function name() external view returns (string memory);\n\n    // ------------------ //\n    // ACCOUNT MANAGEMENT //\n    // ------------------ //\n\n    function openCreditAccount(address onBehalfOf) external returns (address);\n\n    function closeCreditAccount(address creditAccount) external;\n\n    function liquidateCreditAccount(\n        address creditAccount,\n        CollateralDebtData calldata collateralDebtData,\n        address to,\n        bool isExpired\n    ) external returns (uint256 remainingFunds, uint256 loss);\n\n    function manageDebt(address creditAccount, uint256 amount, uint256 enabledTokensMask, ManageDebtAction action)\n        external\n        returns (uint256 newDebt, uint256 tokensToEnable, uint256 tokensToDisable);\n\n    function addCollateral(address payer, address creditAccount, address token, uint256 amount)\n        external\n        returns (uint256 tokensToEnable);\n\n    function withdrawCollateral(address creditAccount, address token, uint256 amount, address to)\n        external\n        returns (uint256 tokensToDisable);\n\n    function externalCall(address creditAccount, address target, bytes calldata callData)\n        external\n        returns (bytes memory result);\n\n    function approveToken(address creditAccount, address token, address spender, uint256 amount) external;\n\n    function revokeAdapterAllowances(address creditAccount, RevocationPair[] calldata revocations) external;\n\n    // -------- //\n    // ADAPTERS //\n    // -------- //\n\n    function adapterToContract(address adapter) external view returns (address targetContract);\n\n    function contractToAdapter(address targetContract) external view returns (address adapter);\n\n    function execute(bytes calldata data) external returns (bytes memory result);\n\n    function approveCreditAccount(address token, uint256 amount) external;\n\n    function setActiveCreditAccount(address creditAccount) external;\n\n    function getActiveCreditAccountOrRevert() external view returns (address creditAccount);\n\n    // ----------------- //\n    // COLLATERAL CHECKS //\n    // ----------------- //\n\n    function priceOracle() external view returns (address);\n\n    function fullCollateralCheck(\n        address creditAccount,\n        uint256 enabledTokensMask,\n        uint256[] calldata collateralHints,\n        uint16 minHealthFactor,\n        bool useSafePrices\n    ) external returns (uint256 enabledTokensMaskAfter);\n\n    function isLiquidatable(address creditAccount, uint16 minHealthFactor) external view returns (bool);\n\n    function calcDebtAndCollateral(address creditAccount, CollateralCalcTask task)\n        external\n        view\n        returns (CollateralDebtData memory cdd);\n\n    // ------ //\n    // QUOTAS //\n    // ------ //\n\n    function poolQuotaKeeper() external view returns (address);\n\n    function quotedTokensMask() external view returns (uint256);\n\n    function updateQuota(address creditAccount, address token, int96 quotaChange, uint96 minQuota, uint96 maxQuota)\n        external\n        returns (uint256 tokensToEnable, uint256 tokensToDisable);\n\n    // --------------------- //\n    // CREDIT MANAGER PARAMS //\n    // --------------------- //\n\n    function maxEnabledTokens() external view returns (uint8);\n\n    function fees()\n        external\n        view\n        returns (\n            uint16 feeInterest,\n            uint16 feeLiquidation,\n            uint16 liquidationDiscount,\n            uint16 feeLiquidationExpired,\n            uint16 liquidationDiscountExpired\n        );\n\n    function collateralTokensCount() external view returns (uint8);\n\n    function getTokenMaskOrRevert(address token) external view returns (uint256 tokenMask);\n\n    function getTokenByMask(uint256 tokenMask) external view returns (address token);\n\n    function liquidationThresholds(address token) external view returns (uint16 lt);\n\n    function ltParams(address token)\n        external\n        view\n        returns (uint16 ltInitial, uint16 ltFinal, uint40 timestampRampStart, uint24 rampDuration);\n\n    function collateralTokenByMask(uint256 tokenMask)\n        external\n        view\n        returns (address token, uint16 liquidationThreshold);\n\n    // ------------ //\n    // ACCOUNT INFO //\n    // ------------ //\n\n    function creditAccountInfo(address creditAccount)\n        external\n        view\n        returns (\n            uint256 debt,\n            uint256 cumulativeIndexLastUpdate,\n            uint128 cumulativeQuotaInterest,\n            uint128 quotaFees,\n            uint256 enabledTokensMask,\n            uint16 flags,\n            uint64 lastDebtUpdate,\n            address borrower\n        );\n\n    function getBorrowerOrRevert(address creditAccount) external view returns (address borrower);\n\n    function flagsOf(address creditAccount) external view returns (uint16);\n\n    function setFlagFor(address creditAccount, uint16 flag, bool value) external;\n\n    function enabledTokensMaskOf(address creditAccount) external view returns (uint256);\n\n    function creditAccounts() external view returns (address[] memory);\n\n    function creditAccounts(uint256 offset, uint256 limit) external view returns (address[] memory);\n\n    function creditAccountsLen() external view returns (uint256);\n\n    // ------------- //\n    // CONFIGURATION //\n    // ------------- //\n\n    function addToken(address token) external;\n\n    function setCollateralTokenData(\n        address token,\n        uint16 ltInitial,\n        uint16 ltFinal,\n        uint40 timestampRampStart,\n        uint24 rampDuration\n    ) external;\n\n    function setFees(\n        uint16 feeInterest,\n        uint16 feeLiquidation,\n        uint16 liquidationDiscount,\n        uint16 feeLiquidationExpired,\n        uint16 liquidationDiscountExpired\n    ) external;\n\n    function setQuotedMask(uint256 quotedTokensMask) external;\n\n    function setMaxEnabledTokens(uint8 maxEnabledTokens) external;\n\n    function setContractAllowance(address adapter, address targetContract) external;\n\n    function setCreditFacade(address creditFacade) external;\n\n    function setPriceOracle(address priceOracle) external;\n\n    function setCreditConfigurator(address creditConfigurator) external;\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/traits/ACLTrait.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IACL} from \"@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol\";\n\nimport {AP_ACL, IAddressProviderV3, NO_VERSION_CONTROL} from \"../interfaces/IAddressProviderV3.sol\";\nimport {CallerNotConfiguratorException} from \"../interfaces/IExceptions.sol\";\n\nimport {SanityCheckTrait} from \"./SanityCheckTrait.sol\";\n\n/// @title ACL trait\n/// @notice Utility class for ACL (access-control list) consumers\nabstract contract ACLTrait is SanityCheckTrait {\n    /// @notice ACL contract address\n    address public immutable acl;\n\n    /// @notice Constructor\n    /// @param addressProvider Address provider contract address\n    constructor(address addressProvider) nonZeroAddress(addressProvider) {\n        acl = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_ACL, NO_VERSION_CONTROL);\n    }\n\n    /// @dev Ensures that function caller has configurator role\n    modifier configuratorOnly() {\n        _ensureCallerIsConfigurator();\n        _;\n    }\n\n    /// @dev Reverts if the caller is not the configurator\n    /// @dev Used to cut contract size on modifiers\n    function _ensureCallerIsConfigurator() internal view {\n        if (!_isConfigurator({account: msg.sender})) {\n            revert CallerNotConfiguratorException();\n        }\n    }\n\n    /// @dev Checks whether given account has configurator role\n    function _isConfigurator(address account) internal view returns (bool) {\n        return IACL(acl).isConfigurator(account);\n    }\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v2/contracts/interfaces/IVersion.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Holdings, 2022\npragma solidity ^0.8.10;\n\n/// @title Version interface\n/// @notice Defines contract version\ninterface IVersion {\n    /// @notice Contract version\n    function version() external view returns (uint256);\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v2/contracts/interfaces/IACL.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Holdings, 2022\npragma solidity ^0.8.10;\nimport { IVersion } from \"./IVersion.sol\";\n\ninterface IACLExceptions {\n    /// @dev Thrown when attempting to delete an address from a set that is not a pausable admin\n    error AddressNotPausableAdminException(address addr);\n\n    /// @dev Thrown when attempting to delete an address from a set that is not a unpausable admin\n    error AddressNotUnpausableAdminException(address addr);\n}\n\ninterface IACLEvents {\n    /// @dev Emits when a new admin is added that can pause contracts\n    event PausableAdminAdded(address indexed newAdmin);\n\n    /// @dev Emits when a Pausable admin is removed\n    event PausableAdminRemoved(address indexed admin);\n\n    /// @dev Emits when a new admin is added that can unpause contracts\n    event UnpausableAdminAdded(address indexed newAdmin);\n\n    /// @dev Emits when an Unpausable admin is removed\n    event UnpausableAdminRemoved(address indexed admin);\n}\n\n/// @title ACL interface\ninterface IACL is IACLEvents, IACLExceptions, IVersion {\n    /// @dev Returns true if the address is a pausable admin and false if not\n    /// @param addr Address to check\n    function isPausableAdmin(address addr) external view returns (bool);\n\n    /// @dev Returns true if the address is unpausable admin and false if not\n    /// @param addr Address to check\n    function isUnpausableAdmin(address addr) external view returns (bool);\n\n    /// @dev Returns true if an address has configurator rights\n    /// @param account Address to check\n    function isConfigurator(address account) external view returns (bool);\n\n    /// @dev Returns address of configurator\n    function owner() external view returns (address);\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/interfaces/IAddressProviderV3.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {IVersion} from \"@gearbox-protocol/core-v2/contracts/interfaces/IVersion.sol\";\n\nuint256 constant NO_VERSION_CONTROL = 0;\n\nbytes32 constant AP_CONTRACTS_REGISTER = \"CONTRACTS_REGISTER\";\nbytes32 constant AP_ACL = \"ACL\";\nbytes32 constant AP_PRICE_ORACLE = \"PRICE_ORACLE\";\nbytes32 constant AP_ACCOUNT_FACTORY = \"ACCOUNT_FACTORY\";\nbytes32 constant AP_DATA_COMPRESSOR = \"DATA_COMPRESSOR\";\nbytes32 constant AP_TREASURY = \"TREASURY\";\nbytes32 constant AP_GEAR_TOKEN = \"GEAR_TOKEN\";\nbytes32 constant AP_WETH_TOKEN = \"WETH_TOKEN\";\nbytes32 constant AP_WETH_GATEWAY = \"WETH_GATEWAY\";\nbytes32 constant AP_ROUTER = \"ROUTER\";\nbytes32 constant AP_BOT_LIST = \"BOT_LIST\";\nbytes32 constant AP_GEAR_STAKING = \"GEAR_STAKING\";\nbytes32 constant AP_ZAPPER_REGISTER = \"ZAPPER_REGISTER\";\n\ninterface IAddressProviderV3Events {\n    /// @notice Emitted when an address is set for a contract key\n    event SetAddress(bytes32 indexed key, address indexed value, uint256 indexed version);\n}\n\n/// @title Address provider V3 interface\ninterface IAddressProviderV3 is IAddressProviderV3Events, IVersion {\n    function addresses(bytes32 key, uint256 _version) external view returns (address);\n\n    function getAddressOrRevert(bytes32 key, uint256 _version) external view returns (address result);\n\n    function setAddress(bytes32 key, address value, bool saveVersion) external;\n}\n"
      },
      "node_modules/@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n// Gearbox Protocol. Generalized leverage for DeFi protocols\n// (c) Gearbox Foundation, 2023.\npragma solidity ^0.8.17;\n\nimport {ZeroAddressException} from \"../interfaces/IExceptions.sol\";\n\n/// @title Sanity check trait\nabstract contract SanityCheckTrait {\n    /// @dev Ensures that passed address is non-zero\n    modifier nonZeroAddress(address addr) {\n        _revertIfZeroAddress(addr);\n        _;\n    }\n\n    /// @dev Reverts if address is zero\n    function _revertIfZeroAddress(address addr) private pure {\n        if (addr == address(0)) revert ZeroAddressException();\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@1inch/=node_modules/@1inch/",
        "@arbitrum/=node_modules/@arbitrum/",
        "@chainlink/=node_modules/@chainlink/",
        "@eth-optimism/=node_modules/@eth-optimism/",
        "@gearbox-protocol/=node_modules/@gearbox-protocol/",
        "@openzeppelin/=node_modules/@openzeppelin/",
        "@redstone-finance/=node_modules/@redstone-finance/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "eth-gas-reporter/=node_modules/eth-gas-reporter/",
        "forge-std/=lib/forge-std/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "libraries": {}
    }
  }}