creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/CalculatorLiquidation.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {CalculatorBase} from \"./CalculatorBase.sol\";\n\n// EBTC\nimport {IMultiCdpGetter} from \"./interfaces/IMultiCdpGetter.sol\";\nimport {EbtcMath} from \"ebtc/contracts/Dependencies/EbtcMath.sol\";\n\n// import {console2 as console} from \"forge-std/console2.sol\";\n\n/// @title Calculator for Finding Profitable Liquidations\n/// @dev Extends CalculatorBase to calculate liquidations with potential profit\n/// @notice This contract is used to find CDPs that can be profitably liquidated given current market conditions\ncontract CalculatorLiquidation is CalculatorBase {\n    ////////////////////////////////////////////////////////////////////////////\n    // STRUCT\n    ////////////////////////////////////////////////////////////////////////////\n\n    struct LiquidationTotals {\n        uint256 totalDebtInSequence;\n        uint256 totalDebtToBurn;\n        uint256 totalCollToSendToLiquidator;\n        uint256 totalDebtToRedistribute;\n        uint256 totalCollSurplus;\n        uint256 totalCollReward;\n    }\n\n    struct LocalVariables_OuterLiquidationFunction {\n        uint256 price;\n        bool recoveryModeAtStart;\n        uint256 liquidatedDebt;\n        uint256 liquidatedColl;\n    }\n\n    struct LocalVariables_LiquidationSequence {\n        uint256 i;\n        uint256 ICR;\n        bytes32 cdpId;\n        bool backToNormalMode;\n        uint256 entireSystemDebt;\n        uint256 entireSystemColl;\n        uint256 price;\n        uint256 TCR;\n    }\n\n    struct LiquidationValues {\n        uint256 entireCdpDebt;\n        uint256 debtToBurn;\n        uint256 totalCollToSendToLiquidator;\n        uint256 debtToRedistribute;\n        uint256 collSurplus;\n        uint256 liquidatorCollSharesReward;\n    }\n\n    struct LiquidationRecoveryModeLocals {\n        uint256 entireSystemDebt;\n        uint256 entireSystemColl;\n        uint256 totalDebtToBurn;\n        uint256 totalCollSharesToSend;\n        uint256 totalSurplusCollShares;\n        bytes32 cdpId;\n        uint256 price;\n        uint256 ICR;\n        uint256 totalDebtToRedistribute;\n        uint256 totalLiquidatorRewardCollShares;\n    }\n\n    struct LiquidationLocals {\n        bytes32 cdpId;\n        uint256 partialAmount; // used only for partial liquidation, default 0 means full liquidation\n        uint256 price;\n        uint256 ICR;\n        bytes32 upperPartialHint;\n        bytes32 lowerPartialHint;\n        bool recoveryModeAtStart;\n        uint256 TCR;\n        uint256 totalSurplusCollShares;\n        uint256 totalCollSharesToSend;\n        uint256 totalDebtToBurn;\n        uint256 totalDebtToRedistribute;\n        uint256 totalLiquidatorRewardCollShares;\n    }\n\n    struct BatchLiquidationCdp {\n        bytes32 id;\n        uint256 debt;\n        uint256 coll;\n        uint256 collToSendToLiquidator;\n        uint256 debtToBurn;\n    }\n\n    constructor(\n        address _ebtc,\n        address _collateral,\n        address _cdp,\n        address _bo,\n        address _ap,\n        address _multiCdpGetter,\n        address _ebtcFeed,\n        address _sortedCdps,\n        address _hintHelpers\n    ) CalculatorBase(_ebtc, _collateral, _cdp, _bo, _ap, _multiCdpGetter, _ebtcFeed, _sortedCdps, _hintHelpers) {}\n\n    ////////////////////////////////////////////////////////////////////////////\n    // MAIN FUNCTIONS\n    ////////////////////////////////////////////////////////////////////////////\n\n    /// @dev Find profitable liquidations CDPs\n    /// @return profitableCdps, totalColToReceive, totalEbtcProfit, totalEbtcConvertedToETH\n    function findProfitableLiquidationsCdps()\n        public\n        returns (BatchLiquidationCdp[] memory, uint256, uint256, uint256, uint256)\n    {\n        // if (msg.sender != owner) revert NotOwner(msg.sender);\n\n        IMultiCdpGetter.CombinedCdpData[] memory cdpsSortedByCol = multiCdpGetter.getMultipleSortedCdps(-1, 1000);\n\n        // sort cdpsSortedByCol by coll\n        for (uint256 i = 0; i < cdpsSortedByCol.length; i++) {\n            for (uint256 j = 0; j < cdpsSortedByCol.length - i - 1; j++) {\n                if (cdpsSortedByCol[j].coll < cdpsSortedByCol[j + 1].coll) {\n                    // Swap cdpsSortedByCol[j] and cdpsSortedByCol[j + 1]\n                    IMultiCdpGetter.CombinedCdpData memory temp = cdpsSortedByCol[j];\n                    cdpsSortedByCol[j] = cdpsSortedByCol[j + 1];\n                    cdpsSortedByCol[j + 1] = temp;\n                }\n            }\n        }\n\n        if (cdpsSortedByCol.length <= 1) {\n            return (new BatchLiquidationCdp[](0), 0, 0, 0, 0);\n        }\n\n        BatchLiquidationCdp[] memory batchLiquidationCdp = _simulateBatchLiquidateCdps(cdpsSortedByCol);\n\n        uint256 totalColToReceive = 0;\n        uint256 totalEbtcDebt = 0;\n        uint256 totalColConvertedToEbtc = 0;\n        uint256 index = 0;\n\n        BatchLiquidationCdp[] memory tempProfitableCdps = new BatchLiquidationCdp[](batchLiquidationCdp.length);\n\n        for (uint256 i = 0; i < batchLiquidationCdp.length; i++) {\n            if (batchLiquidationCdp[i].id != 0) {\n                uint256 ebtcOut = _evaluateLiquidationProfitability(\n                    batchLiquidationCdp[i].debtToBurn, batchLiquidationCdp[i].collToSendToLiquidator\n                );\n                if (ebtcOut > 0) {\n                    tempProfitableCdps[index] = batchLiquidationCdp[i];\n                    totalColToReceive += batchLiquidationCdp[i].collToSendToLiquidator;\n                    totalEbtcDebt += batchLiquidationCdp[i].debtToBurn;\n                    totalColConvertedToEbtc += ebtcOut;\n                    index++;\n                }\n            }\n        }\n\n        if (index == 0) {\n            return (new BatchLiquidationCdp[](0), 0, 0, 0, 0);\n        }\n\n        // Copy the profitable CDPs to a correctly sized array\n        BatchLiquidationCdp[] memory profitableCdps = new BatchLiquidationCdp[](index);\n        for (uint256 i = 0; i < index; i++) {\n            profitableCdps[i] = tempProfitableCdps[i];\n        }\n\n        uint256 totalEbtcProfit = totalColConvertedToEbtc - (totalEbtcDebt + bo.flashFee(address(ebtc), totalEbtcDebt));\n        uint256 totalEbtcConvertedToETH = _uniQuoteEbtcToEth(totalEbtcProfit);\n        uint256 minEbtcOut = _uniQuoteStethToEbtc(totalColToReceive);\n\n        // TODO: maxSwapThreshold\n\n        return (profitableCdps, totalColToReceive, totalEbtcProfit, totalEbtcConvertedToETH, minEbtcOut);\n    }\n\n    ////////////////////////////////////////////////////////////////////////////\n    // INTERNAL\n    ////////////////////////////////////////////////////////////////////////////\n\n    /// @dev Check if a CDP is profitable to liquidate by swapping steth to ebtc and comparing the debt\n    /// @param ebtcDebt The debt of the CDP\n    /// @param collReceived The collateral received from liquidation\n    /// @return number of ebtc to receive\n    function _evaluateLiquidationProfitability(\n        uint256 ebtcDebt,\n        // uint256 collLiquidity,\n        // uint256 wethLiquidity,\n        uint256 collReceived\n    ) internal returns (uint256) {\n        // if (\n        //     collReceived > ((collLiquidity * SWAP_THRESHOLD) / 10) ||\n        //     collReceived > ((wethLiquidity * SWAP_THRESHOLD) / 10)\n        // ) {\n        //     return false;\n        // }\n\n        uint256 ebtcOut = _uniQuoteStethToEbtc(collReceived);\n\n        return ebtcOut > ebtcDebt ? ebtcOut : 0;\n    }\n\n    /// @dev Simulates the batch liquidation of multiple CDPs.\n    /// @param _cdpArray An array of `CombinedCdpData` structs representing the CDPs to be liquidated.\n    /// @return liquidatableCdps, collateralReceivedArray\n    function _simulateBatchLiquidateCdps(IMultiCdpGetter.CombinedCdpData[] memory _cdpArray)\n        internal\n        returns (BatchLiquidationCdp[] memory)\n    {\n        require(_cdpArray.length != 0, \"LiquidationLibrary: Calldata address array must not be empty\");\n\n        LocalVariables_OuterLiquidationFunction memory vars;\n\n        vars.price = ebtcFeed.fetchPrice();\n        (uint256 _TCR, uint256 systemColl, uint256 systemDebt) = _getTCRWithSystemDebtAndCollShares(vars.price);\n        vars.recoveryModeAtStart = _TCR < CCR ? true : false;\n\n        // Perform the appropriate batch liquidation - tally values and obtain their totals.\n        return vars.recoveryModeAtStart\n            ? _getTotalFromBatchLiquidate_RecoveryMode(vars.price, systemColl, systemDebt, _cdpArray)\n            : _getTotalsFromBatchLiquidate_NormalMode(vars.price, _TCR, _cdpArray);\n    }\n\n    /// @dev Calculate the amount of collateral to be sent to the liquidator and the surplus to be sent to the CDP owner\n    /// @param _ICR The ICR of the CDP\n    /// @param _price The current price of the collateral\n    /// @param _totalDebtToBurn The total debt to be burned\n    /// @param _totalColToSend The total collateral to be sent to the liquidator\n    /// @return toLiquidator The amount of collateral to be sent to the liquidator\n    /// @return collSurplus The surplus collateral to be sent to the CDP owner\n    /// @return debtToRedistribute The amount of debt to be redistributed\n    function _calculateFullLiquidationSurplusAndCap(\n        uint256 _ICR,\n        uint256 _price,\n        uint256 _totalDebtToBurn,\n        uint256 _totalColToSend\n    ) private view returns (uint256 toLiquidator, uint256 collSurplus, uint256 debtToRedistribute) {\n        uint256 _incentiveColl;\n\n        if (_ICR > LICR) {\n            _incentiveColl = (_totalDebtToBurn * (_ICR > MCR ? MCR : _ICR)) / _price;\n\n            // Convert back to shares\n            toLiquidator = collateral.getSharesByPooledEth(_incentiveColl);\n        } else {\n            // for full liquidation, there would be some bad debt to redistribute\n            _incentiveColl = collateral.getPooledEthByShares(_totalColToSend);\n\n            // Since it's full and there's bad debt we use spot conversion to\n            // Determine the amount of debt that willl be repaid after adding the LICR discount\n            // Basically this is buying underwater Coll\n            // By repaying debt at 3% discount\n            // Can there be a rounding error where the _debtToRepay > debtToBurn?\n            uint256 _debtToRepay = (_incentiveColl * _price) / LICR;\n\n            debtToRedistribute = _debtToRepay < _totalDebtToBurn\n                ? _totalDebtToBurn - _debtToRepay //  Bad Debt (to be redistributed) is (CdpDebt - Repaid)\n                : 0; // Else 0 (note we may underpay per the comment above, althought that may be imaginary)\n\n            // now CDP owner should have zero surplus to claim\n            toLiquidator = _totalColToSend;\n        }\n\n        toLiquidator = toLiquidator < _totalColToSend ? toLiquidator : _totalColToSend;\n        collSurplus = (toLiquidator == _totalColToSend) ? 0 : _totalColToSend - toLiquidator;\n    }\n\n    /// @dev Calculate TCR given an price, and the entire system coll and debt.\n    /// @param _price The current price of the collateral\n    /// @return TCR\n    /// @return _coll\n    /// @return _debt\n    function _getTCRWithSystemDebtAndCollShares(uint256 _price)\n        internal\n        view\n        returns (uint256 TCR, uint256 _coll, uint256 _debt)\n    {\n        uint256 systemCollShares = ap.getSystemCollShares();\n        uint256 systemDebt = _getSystemDebt();\n\n        uint256 _systemStEthBalance = collateral.getPooledEthByShares(systemCollShares);\n        TCR = EbtcMath._computeCR(_systemStEthBalance, systemDebt, _price);\n\n        return (TCR, systemCollShares, systemDebt);\n    }\n\n    /// @dev Calculate TCR given an price, and the entire system coll and debt.\n    /// @param _systemCollShares The total collateral in the system\n    /// @param _systemDebt The total debt in the system\n    /// @param _price The current price of the collateral\n    /// @return TCR\n    function _computeTCRWithGivenSystemValues(uint256 _systemCollShares, uint256 _systemDebt, uint256 _price)\n        internal\n        view\n        returns (uint256)\n    {\n        uint256 _totalColl = collateral.getPooledEthByShares(_systemCollShares);\n        return EbtcMath._computeCR(_totalColl, _systemDebt, _price);\n    }\n\n    /// @dev Perform the batch liquidation of multiple CDPs in recovery mode.\n    /// @param _price The current price of the collateral\n    /// @param _systemCollShares The total collateral in the system\n    /// @param _systemDebt The total debt in the system\n    /// @param _cdpArray An array of `CombinedCdpData` structs representing the CDPs to be liquidated.\n    /// @return batchLiquidationCdp The CDPs that are liquidatable\n    function _getTotalFromBatchLiquidate_RecoveryMode(\n        uint256 _price,\n        uint256 _systemCollShares,\n        uint256 _systemDebt,\n        IMultiCdpGetter.CombinedCdpData[] memory _cdpArray\n    ) internal view returns (BatchLiquidationCdp[] memory) {\n        LocalVariables_LiquidationSequence memory vars;\n        vars.price = _price;\n        LiquidationValues memory singleLiquidation;\n\n        vars.backToNormalMode = false;\n        vars.entireSystemDebt = _systemDebt;\n        vars.entireSystemColl = _systemCollShares;\n        uint256 _TCR = _computeTCRWithGivenSystemValues(vars.entireSystemColl, vars.entireSystemDebt, vars.price);\n        uint256 _cnt = sortedCdps.getSize() == _cdpArray.length ? _cdpArray.length - 1 : _cdpArray.length;\n\n        BatchLiquidationCdp[] memory batchLiquidationCdp = new BatchLiquidationCdp[](_cnt);\n        LiquidationTotals memory totals;\n        uint256 _start;\n        uint256 index = 0;\n\n        for (vars.i = _start;;) {\n            vars.cdpId = _cdpArray[vars.i].id;\n            // only for active cdps\n\n            if (vars.cdpId != bytes32(0) && cdp.getCdpStatus(vars.cdpId) == 1) {\n                vars.ICR = cdp.getSyncedICR(vars.cdpId, vars.price);\n\n                if (\n                    !vars.backToNormalMode\n                        && (_checkICRAgainstMCR(vars.ICR) || cdp.canLiquidateRecoveryMode(vars.ICR, _TCR))\n                ) {\n                    _getLiquidationValuesRecoveryMode(\n                        vars.price, vars.entireSystemDebt, vars.entireSystemColl, vars, singleLiquidation\n                    );\n\n                    // Update aggregate trackers\n                    vars.entireSystemDebt = vars.entireSystemDebt - singleLiquidation.debtToBurn;\n                    vars.entireSystemColl = vars.entireSystemColl - singleLiquidation.totalCollToSendToLiquidator\n                        - singleLiquidation.collSurplus;\n\n                    // Add liquidation values to their respective running totals\n                    totals = _addLiquidationValuesToTotals(totals, singleLiquidation);\n\n                    _TCR = _computeTCRWithGivenSystemValues(vars.entireSystemColl, vars.entireSystemDebt, vars.price);\n                    vars.backToNormalMode = _TCR < CCR ? false : true;\n\n                    batchLiquidationCdp[index] = BatchLiquidationCdp({\n                        id: vars.cdpId,\n                        debt: _cdpArray[vars.i].debt,\n                        coll: _cdpArray[vars.i].coll,\n                        collToSendToLiquidator: collateral.getPooledEthByShares(\n                            singleLiquidation.totalCollToSendToLiquidator + singleLiquidation.liquidatorCollSharesReward\n                            ),\n                        debtToBurn: singleLiquidation.debtToBurn\n                    });\n\n                    index++;\n                } else if (vars.backToNormalMode && _checkICRAgainstMCR(vars.ICR)) {\n                    _getLiquidationValuesNormalMode(_price, _TCR, vars, singleLiquidation);\n                    // Add liquidation values to their respective running totals\n                    totals = _addLiquidationValuesToTotals(totals, singleLiquidation);\n\n                    batchLiquidationCdp[index] = BatchLiquidationCdp({\n                        id: vars.cdpId,\n                        debt: _cdpArray[vars.i].debt,\n                        coll: _cdpArray[vars.i].coll,\n                        collToSendToLiquidator: collateral.getPooledEthByShares(\n                            singleLiquidation.totalCollToSendToLiquidator + singleLiquidation.liquidatorCollSharesReward\n                            ),\n                        debtToBurn: singleLiquidation.debtToBurn\n                    });\n                    index++;\n                }\n                // In Normal Mode skip cdps with ICR >= MCR\n            }\n            ++vars.i;\n            if (vars.i == _cnt) {\n                break;\n            }\n        }\n        return batchLiquidationCdp;\n    }\n\n    /// @dev Perform the batch liquidation of multiple CDPs in normal mode.\n    /// @param _price The current price of the collateral\n    /// @param _systemDebt The total debt in the system\n    /// @param _systemCollShares The total collateral in the system\n    /// @param vars The current state of the liquidation\n    /// @param singleLiquidation The values of the current liquidation\n    function _getLiquidationValuesRecoveryMode(\n        uint256 _price,\n        uint256 _systemDebt,\n        uint256 _systemCollShares,\n        LocalVariables_LiquidationSequence memory vars,\n        LiquidationValues memory singleLiquidation\n    ) internal view {\n        LiquidationRecoveryModeLocals memory _recState =\n            LiquidationRecoveryModeLocals(_systemDebt, _systemCollShares, 0, 0, 0, vars.cdpId, _price, vars.ICR, 0, 0);\n\n        LiquidationRecoveryModeLocals memory _outputState = _liquidateIndividualCdpSetupCDPInRecoveryMode(_recState);\n\n        singleLiquidation.entireCdpDebt = _outputState.totalDebtToBurn;\n        singleLiquidation.debtToBurn = _outputState.totalDebtToBurn;\n        singleLiquidation.totalCollToSendToLiquidator = _outputState.totalCollSharesToSend;\n        singleLiquidation.collSurplus = _outputState.totalSurplusCollShares;\n        singleLiquidation.debtToRedistribute = _outputState.totalDebtToRedistribute;\n        singleLiquidation.liquidatorCollSharesReward = _outputState.totalLiquidatorRewardCollShares;\n    }\n\n    /// @dev Perform the batch liquidation of multiple CDPs in normal mode.\n    /// @param _price The current price of the collateral\n    /// @param _TCR The current TCR of the system\n    /// @param _cdpArray An array of `CombinedCdpData` structs representing the CDPs to be liquidated.\n    /// @return batchLiquidationCdp The CDPs that are liquidatable\n    function _getTotalsFromBatchLiquidate_NormalMode(\n        uint256 _price,\n        uint256 _TCR,\n        // bytes32[] memory _cdpArray\n        IMultiCdpGetter.CombinedCdpData[] memory _cdpArray\n    ) internal view returns (BatchLiquidationCdp[] memory) {\n        LocalVariables_LiquidationSequence memory vars;\n        LiquidationValues memory singleLiquidation;\n        uint256 _cnt = sortedCdps.getSize() == _cdpArray.length ? _cdpArray.length - 1 : _cdpArray.length;\n        uint256 _start;\n        BatchLiquidationCdp[] memory batchLiquidationCdp = new BatchLiquidationCdp[](_cnt);\n        LiquidationTotals memory totals;\n        vars.price = _price;\n        uint256 index = 0;\n        for (vars.i = _start;;) {\n            vars.cdpId = _cdpArray[vars.i].id;\n            // only for active cdps\n            if (vars.cdpId != bytes32(0) && cdp.getCdpStatus(vars.cdpId) == 1) {\n                vars.ICR = cdp.getSyncedICR(vars.cdpId, vars.price);\n\n                if (_checkICRAgainstMCR(vars.ICR)) {\n                    _getLiquidationValuesNormalMode(vars.price, _TCR, vars, singleLiquidation);\n\n                    // Add liquidation values to their respective running totals\n                    totals = _addLiquidationValuesToTotals(totals, singleLiquidation);\n\n                    batchLiquidationCdp[index] = BatchLiquidationCdp({\n                        id: vars.cdpId,\n                        debt: _cdpArray[vars.i].debt,\n                        coll: _cdpArray[vars.i].coll,\n                        collToSendToLiquidator: collateral.getPooledEthByShares(\n                            singleLiquidation.totalCollToSendToLiquidator + singleLiquidation.liquidatorCollSharesReward\n                            ),\n                        debtToBurn: singleLiquidation.debtToBurn\n                    });\n                    index++;\n                }\n            }\n            ++vars.i;\n            if (vars.i == _cnt) {\n                break;\n            }\n        }\n        return batchLiquidationCdp;\n    }\n\n    /// @dev Liquidate an individual CDP in recovery mode\n    /// @param _recoveryState The current state of the liquidation\n    /// @return The updated state of the liquidation\n    function _liquidateIndividualCdpSetupCDPInRecoveryMode(LiquidationRecoveryModeLocals memory _recoveryState)\n        private\n        view\n        returns (LiquidationRecoveryModeLocals memory)\n    {\n        // liquidate entire debt\n        (uint256 _totalDebtToBurn, uint256 _totalColToSend) = cdp.getSyncedDebtAndCollShares(_recoveryState.cdpId);\n        uint256 _liquidatorReward = cdp.getCdpLiquidatorRewardShares(_recoveryState.cdpId);\n\n        // cap the liquidated collateral if required\n        uint256 _cappedColPortion;\n        uint256 _collSurplus;\n        uint256 _debtToRedistribute;\n\n        // avoid stack too deep\n        {\n            (_cappedColPortion, _collSurplus, _debtToRedistribute) = _calculateFullLiquidationSurplusAndCap(\n                _recoveryState.ICR, _recoveryState.price, _totalDebtToBurn, _totalColToSend\n            );\n            if (_collSurplus > 0) {\n                _recoveryState.totalSurplusCollShares = _recoveryState.totalSurplusCollShares + _collSurplus;\n\n                if (_checkICRAgainstMCR(_recoveryState.ICR)) {\n                    _cappedColPortion = _collSurplus + _cappedColPortion;\n                    _collSurplus = 0;\n                } else {\n                    // collSurplusPool.increaseSurplusCollShares(_recoveryState.cdpId, _borrower, _collSurplus, 0);\n                    _recoveryState.totalSurplusCollShares = _recoveryState.totalSurplusCollShares + _collSurplus;\n                }\n            }\n            if (_debtToRedistribute > 0) {\n                _totalDebtToBurn = _totalDebtToBurn - _debtToRedistribute;\n            }\n        }\n        _recoveryState.totalDebtToBurn = _recoveryState.totalDebtToBurn + _totalDebtToBurn;\n        _recoveryState.totalCollSharesToSend = _recoveryState.totalCollSharesToSend + _cappedColPortion;\n        _recoveryState.totalDebtToRedistribute = _recoveryState.totalDebtToRedistribute + _debtToRedistribute;\n        _recoveryState.totalLiquidatorRewardCollShares =\n            _recoveryState.totalLiquidatorRewardCollShares + _liquidatorReward;\n\n        // check if system back to normal mode\n        _recoveryState.entireSystemDebt =\n            _recoveryState.entireSystemDebt > _totalDebtToBurn ? _recoveryState.entireSystemDebt - _totalDebtToBurn : 0;\n        _recoveryState.entireSystemColl =\n            _recoveryState.entireSystemColl > _totalColToSend ? _recoveryState.entireSystemColl - _totalColToSend : 0;\n\n        return _recoveryState;\n    }\n\n    /// @dev Liquidate an individual CDP in normal mode\n    /// @param _liqState The current state of the liquidation\n    /// @return The updated state of the liquidation\n    function _liquidateIndividualCdpSetupCDPInNormalMode(LiquidationLocals memory _liqState)\n        private\n        view\n        returns (LiquidationLocals memory)\n    {\n        // liquidate entire debt\n        (uint256 _totalDebtToBurn, uint256 _totalColToSend) = cdp.getSyncedDebtAndCollShares(_liqState.cdpId);\n        uint256 _liquidatorReward = cdp.getCdpLiquidatorRewardShares(_liqState.cdpId);\n\n        uint256 _cappedColPortion;\n        uint256 _collSurplus;\n        uint256 _debtToRedistribute;\n\n        {\n            (_cappedColPortion, _collSurplus, _debtToRedistribute) = _calculateFullLiquidationSurplusAndCap(\n                _liqState.ICR, _liqState.price, _totalDebtToBurn, _totalColToSend\n            );\n            if (_collSurplus > 0) {\n                // due to division precision loss, should be zero surplus in normal mode\n                _cappedColPortion = _cappedColPortion + _collSurplus;\n                _collSurplus = 0;\n            }\n            if (_debtToRedistribute > 0) {\n                _totalDebtToBurn = _totalDebtToBurn - _debtToRedistribute;\n            }\n        }\n        _liqState.totalDebtToBurn = _liqState.totalDebtToBurn + _totalDebtToBurn;\n        _liqState.totalCollSharesToSend = _liqState.totalCollSharesToSend + _cappedColPortion;\n        _liqState.totalDebtToRedistribute = _liqState.totalDebtToRedistribute + _debtToRedistribute;\n        _liqState.totalLiquidatorRewardCollShares = _liqState.totalLiquidatorRewardCollShares + _liquidatorReward;\n\n        return _liqState;\n    }\n\n    /// @dev Add the values of a single liquidation to the running totals\n    /// @param oldTotals The current running totals\n    /// @param singleLiquidation The values of the current liquidation\n    /// @return newTotals The updated running totals\n    function _addLiquidationValuesToTotals(\n        LiquidationTotals memory oldTotals,\n        LiquidationValues memory singleLiquidation\n    ) internal pure returns (LiquidationTotals memory newTotals) {\n        // Tally all the values with their respective running totals\n        newTotals.totalDebtInSequence = oldTotals.totalDebtInSequence + singleLiquidation.entireCdpDebt;\n        newTotals.totalDebtToBurn = oldTotals.totalDebtToBurn + singleLiquidation.debtToBurn;\n        newTotals.totalCollToSendToLiquidator =\n            oldTotals.totalCollToSendToLiquidator + singleLiquidation.totalCollToSendToLiquidator;\n        newTotals.totalDebtToRedistribute = oldTotals.totalDebtToRedistribute + singleLiquidation.debtToRedistribute;\n        newTotals.totalCollSurplus = oldTotals.totalCollSurplus + singleLiquidation.collSurplus;\n        newTotals.totalCollReward = oldTotals.totalCollReward + singleLiquidation.liquidatorCollSharesReward;\n\n        return newTotals;\n    }\n\n    /// @dev Get the total debt in the system\n    /// @param _price The current price\n    /// @param _TCR The current TCR\n    /// @param vars The current state of the liquidation\n    /// @param singleLiquidation The values of the current liquidation\n    function _getLiquidationValuesNormalMode(\n        uint256 _price,\n        uint256 _TCR,\n        LocalVariables_LiquidationSequence memory vars,\n        LiquidationValues memory singleLiquidation\n    ) internal view {\n        LiquidationLocals memory _liqState =\n            LiquidationLocals(vars.cdpId, 0, _price, vars.ICR, vars.cdpId, vars.cdpId, (false), _TCR, 0, 0, 0, 0, 0);\n\n        LiquidationLocals memory _outputState = _liquidateIndividualCdpSetupCDPInNormalMode(_liqState);\n\n        singleLiquidation.entireCdpDebt = _outputState.totalDebtToBurn;\n        singleLiquidation.debtToBurn = _outputState.totalDebtToBurn;\n        singleLiquidation.totalCollToSendToLiquidator = _outputState.totalCollSharesToSend;\n        singleLiquidation.collSurplus = _outputState.totalSurplusCollShares;\n        singleLiquidation.debtToRedistribute = _outputState.totalDebtToRedistribute;\n        singleLiquidation.liquidatorCollSharesReward = _outputState.totalLiquidatorRewardCollShares;\n    }\n\n    /// @dev return true if given ICR is qualified for liquidation compared to MCR\n    /// @param _icr The ICR of the CDP\n    /// @return true if the CDP is qualified for liquidation\n    function _checkICRAgainstMCR(uint256 _icr) internal pure returns (bool) {\n        return _icr < MCR;\n    }\n}\n"
      },
      "src/CalculatorBase.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Uniswap\nimport {IV3SwapRouter} from \"swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol\";\nimport {IQuoterV2} from \"swap-router-contracts/contracts/interfaces/IQuoterV2.sol\";\nimport \"./libraries/FullMath.sol\";\nimport \"./libraries/TickMath.sol\";\nimport \"./libraries/LiquidityAmounts.sol\";\nimport \"./libraries/PoolAddress.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\";\nimport \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\n\n// ERC20\nimport {IERC20} from \"./interfaces/IERC20.sol\";\nimport {IWstETH} from \"./interfaces/IWstETH.sol\";\n\n// EBTC\nimport {IBO} from \"./interfaces/IBO.sol\";\nimport {ICdpManager} from \"./interfaces/ICdpManager.sol\";\nimport {EbtcMath} from \"ebtc/contracts/Dependencies/EbtcMath.sol\";\nimport {IActivePool} from \"./interfaces/IActivePool.sol\";\nimport {ISortedCdps} from \"ebtc/contracts/Interfaces/ISortedCdps.sol\";\nimport {IPriceFeed} from \"./interfaces/IPriceFeed.sol\";\nimport {ICollateralToken} from \"ebtc/contracts/Dependencies/ICollateralToken.sol\";\nimport {IMultiCdpGetter} from \"./interfaces/IMultiCdpGetter.sol\";\nimport {IHintHelpers} from \"./interfaces/IHintHelpers.sol\";\n\n// import {console2 as console} from \"forge-std/console2.sol\";\n\n/// @notice This contract is used to find CDPs that can be profitably adjusted given current market conditions\n/// @dev Extends CalculatorBase to calculate ceilings with potential profit\ncontract CalculatorBase {\n    ////////////////////////////////////////////////////////////////////////////\n    // CONSTANTS\n    ////////////////////////////////////////////////////////////////////////////\n    uint256 constant SWAP_THRESHOLD = 3; // Represent 0.3 as 3 to keep everything in bigint\n\n    // Minimum collateral ratio for individual cdps\n    uint256 public constant MCR = 1100000000000000000; // 110%\n\n    // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered.\n    uint256 public constant CCR = 1250000000000000000; // 125%\n\n    // Amount of stETH collateral to be locked in active pool on opening cdps\n    uint256 public constant LIQUIDATOR_REWARD = 2e17;\n\n    // Minimum amount of stETH collateral a CDP must have\n    uint256 public constant MIN_NET_STETH_BALANCE = 2e18;\n\n    uint256 public constant MINER_REWARDS = 1e16;\n\n    uint256 public constant SECONDS_IN_ONE_MINUTE = 60;\n\n    uint256 public minuteDecayFactor = 999037758833783000;\n\n    uint256 public constant MIN_CHANGE = 1000;\n\n    // Collateral Ratio applied for Liquidation Incentive\n    // i.e., liquidator repay $1 worth of debt to get back $1.03 worth of collateral\n    uint256 public constant LICR = 1030000000000000000; // 103%\n\n    uint256 public constant DECIMAL_PRECISION = 1e18;\n\n    uint256 public constant MAX_TCR = type(uint256).max;\n\n    IQuoterV2 internal constant quoter = IQuoterV2(0x61fFE014bA17989E743c5F6cB21bF9697530B21e);\n\n    IERC20 internal constant WBTC = IERC20(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);\n    IERC20 internal constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n    IWstETH internal constant wstETH = IWstETH(0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0);\n\n    uint24 constant poolFee100 = 100;\n    uint24 constant poolFee500 = 500;\n    uint24 constant poolFee3000 = 3000;\n\n    ////////////////////////////////////////////////////////////////////////////\n    // STRUCT\n    ////////////////////////////////////////////////////////////////////////////\n\n    struct ReturnComputedHash {\n        bytes32 hashed;\n        uint256 ebtcWbtcPeg;\n        uint256 price;\n        uint256 tcr;\n        bool inRecoveryMode;\n        uint256 wbtcLiq;\n        uint256 ebtcLiq;\n    }\n\n    ////////////////////////////////////////////////////////////////////////////\n    // STORAGE\n    ////////////////////////////////////////////////////////////////////////////\n\n    address immutable owner;\n    IERC20 immutable ebtc;\n    ICollateralToken immutable collateral;\n    ICdpManager immutable cdp;\n    IBO immutable bo;\n    IActivePool immutable ap;\n    IMultiCdpGetter immutable multiCdpGetter;\n    IPriceFeed immutable ebtcFeed;\n    ISortedCdps immutable sortedCdps;\n    IHintHelpers immutable hintHelpers;\n\n    ////////////////////////////////////////////////////////////////////////////\n    // ERRORS\n    ////////////////////////////////////////////////////////////////////////////\n    error NotOwner(address caller);\n    error ZeroAddress();\n\n    constructor(\n        address _ebtc,\n        address _collateral,\n        address _cdp,\n        address _bo,\n        address _ap,\n        address _multiCdpGetter,\n        address _ebtcFeed,\n        address _sortedCdps,\n        address _hintHelpers\n    ) {\n        if (\n            _ebtc == address(0) || _collateral == address(0) || _cdp == address(0) || _bo == address(0)\n                || _ap == address(0) || _multiCdpGetter == address(0) || _ebtcFeed == address(0)\n                || _sortedCdps == address(0) || _hintHelpers == address(0)\n        ) {\n            revert ZeroAddress();\n        }\n\n        owner = msg.sender;\n        ebtc = IERC20(_ebtc);\n        collateral = ICollateralToken(_collateral);\n        cdp = ICdpManager(_cdp);\n        bo = IBO(_bo);\n        ap = IActivePool(_ap);\n        multiCdpGetter = IMultiCdpGetter(_multiCdpGetter);\n        ebtcFeed = IPriceFeed(_ebtcFeed);\n        sortedCdps = ISortedCdps(_sortedCdps);\n        hintHelpers = IHintHelpers(_hintHelpers);\n    }\n\n    ////////////////////////////////////////////////////////////////////////////\n    // MAIN SHARABLE FUNCTIONS\n    ////////////////////////////////////////////////////////////////////////////\n    /// @notice Computes the hash of the current state\n    /// @return v The computed hash\n    function computeHash() public returns (ReturnComputedHash memory) {\n        uint256 price = ebtcFeed.fetchPrice();\n\n        (uint256 wbtcLiq, uint256 ebtcLiq) = _getAmountsForLiquidity();\n\n        ReturnComputedHash memory v = ReturnComputedHash({\n            ebtcWbtcPeg: _getEbtcWbtcPeg(1e18),\n            tcr: cdp.getSyncedTCR(price),\n            inRecoveryMode: cdp.checkRecoveryMode(price),\n            wbtcLiq: wbtcLiq,\n            ebtcLiq: ebtcLiq,\n            price: price,\n            hashed: 0\n        });\n        v.hashed = keccak256(abi.encodePacked(price, v.tcr, v.inRecoveryMode, wbtcLiq, ebtcLiq));\n        return v;\n    }\n\n    ////////////////////////////////////////////////////////////////////////////\n    // QUOTES FUNCTIONS\n    ////////////////////////////////////////////////////////////////////////////\n\n    /// @notice Converts the specified collateral amount in StETH to an equivalent amount in eBTC using Uniswap\n    /// @param _collAmountIn The amount of collateral in StETH to convert\n    /// @return The equivalent amount of eBTC\n    function _uniQuoteStethToEbtc(uint256 _collAmountIn) internal returns (uint256) {\n        (uint256 ebtcOut,,,) = quoter.quoteExactInput(\n            abi.encodePacked(\n                address(wstETH), poolFee100, address(WETH), poolFee500, address(WBTC), poolFee500, address(ebtc)\n            ),\n            wstETH.getWstETHByStETH(_collAmountIn)\n        );\n\n        return ebtcOut;\n    }\n\n    /// @notice Converts the specified amount of wrapped StETH to an equivalent amount in eBTC using Uniswap\n    /// @param _wstETHAmount The amount of wrapped StETH to convert\n    /// @return The equivalent amount of eBTC\n    function _uniQuoteWstETHToWbtc(uint256 _wstETHAmount) internal returns (uint256) {\n        // WSTETH -> WETH -> WBTC\n        (uint256 amountOut,,,) = quoter.quoteExactInput(\n            abi.encodePacked(address(wstETH), poolFee100, address(WETH), /*poolFee3000*/ poolFee500, address(WBTC)),\n            _wstETHAmount\n        );\n        return amountOut;\n    }\n\n    /// @notice Converts the specified amount of WBTC to an equivalent amount in eBTC using Uniswap\n    /// @param _wbtcAmount The amount of WBTC to convert\n    /// @return The equivalent amount of eBTC\n    function _uniQuoteWbtcToEbtc(uint256 _wbtcAmount) internal returns (uint256) {\n        // WBTC -> EBTC\n        IQuoterV2.QuoteExactInputSingleParams memory params = IQuoterV2.QuoteExactInputSingleParams({\n            tokenIn: address(WBTC),\n            tokenOut: address(ebtc),\n            amountIn: _wbtcAmount,\n            fee: poolFee500,\n            sqrtPriceLimitX96: 0\n        });\n\n        (uint256 amountOut,,,) = quoter.quoteExactInputSingle(params);\n        return amountOut;\n    }\n\n    /// @notice Converts the specified amount of eBTC to an equivalent amount in WBTC using Uniswap\n    /// @param _amountIn The amount of eBTC to convert\n    /// @return The equivalent amount of WBTC\n    function _uniQuoteEbtcToWbtc(uint256 _amountIn) internal returns (uint256) {\n        //  EBTC -> WBTC\n        IQuoterV2.QuoteExactInputSingleParams memory params = IQuoterV2.QuoteExactInputSingleParams({\n            tokenIn: address(ebtc),\n            tokenOut: address(WBTC),\n            amountIn: _amountIn,\n            fee: poolFee500,\n            sqrtPriceLimitX96: 0\n        });\n\n        (uint256 amountOut,,,) = quoter.quoteExactInputSingle(params);\n        return amountOut;\n    }\n\n    /// @notice Converts the specified amount of eBTC to an equivalent amount in ETH using Uniswap\n    /// @param _ebtcIn The amount of eBTC to convert\n    /// @return The equivalent amount of ETH\n    function _uniQuoteEbtcToEth(uint256 _ebtcIn) internal returns (uint256) {\n        // EBTC -> WBTC -> WETH\n        (uint256 amountOut,,,) = quoter.quoteExactInput(\n            abi.encodePacked(address(ebtc), poolFee500, address(WBTC), poolFee3000, address(WETH)), _ebtcIn\n        );\n\n        return amountOut;\n    }\n\n    ////////////////////////////////////////////////////////////////////////////\n    // INTERNAL\n    ////////////////////////////////////////////////////////////////////////////\n\n    function _getEbtcWbtcPeg(uint256 ebtcAmountIn) internal returns (uint256) {\n        uint256 wbtcAmountOut = _uniQuoteEbtcToWbtc(ebtcAmountIn);\n        return ((wbtcAmountOut * 1e10) * 1e18) / ebtcAmountIn;\n    }\n\n    /// @notice Returns the amount of WBTC and eBTC in the Uniswap pool\n    /// @return amount0 The amount of WBTC in the pool\n    /// @return amount1 The amount of eBTC in the pool\n    function _getAmountsForLiquidity() internal view returns (uint256 amount0, uint256 amount1) {\n        address factoryAddress = 0x1F98431c8aD98523631AE4a59f267346ea31F984;\n\n        PoolAddress.PoolKey memory poolKey =\n            PoolAddress.PoolKey({token0: address(WBTC), token1: address(ebtc), fee: poolFee500});\n        IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factoryAddress, poolKey));\n\n        // compute the liquidity amount\n        {\n            (uint160 sqrtPriceX96,,,,,,) = pool.slot0();\n            int24 tickSpacing = pool.tickSpacing();\n            int24 tickLower = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\n            int24 tickUpper = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\n            uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n            uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n            uint128 liquidity = pool.liquidity();\n            (amount0, amount1) =\n                LiquidityAmounts.getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, liquidity);\n        }\n        return (amount0, amount1);\n    }\n\n    function _getSystemDebt() internal view returns (uint256 entireSystemDebt) {\n        return (ap.getSystemDebt());\n    }\n}\n"
      },
      "src/interfaces/IMultiCdpGetter.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.17;\n\ninterface IMultiCdpGetter {\n    struct CombinedCdpData {\n        bytes32 id;\n        uint256 debt;\n        uint256 coll;\n        uint256 stake;\n        uint256 snapshotEBTCDebt;\n    }\n\n    /// @notice Retrieves multiple sorted Cdps\n    /// @param _startIdx The start index for the linked list, determines the direction of traversal.\n    /// @param _count The count of Cdps to retrieve, specifying how many CDPs data to return.\n    /// @return _cdps An array of CombinedCdpData structs with CDP details.\n    function getMultipleSortedCdps(\n        int _startIdx,\n        uint256 _count\n    ) external view returns (CombinedCdpData[] memory _cdps);\n}\n"
      },
      "lib/ebtc/packages/contracts/contracts/Dependencies/EbtcMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nlibrary EbtcMath {\n    uint256 internal constant DECIMAL_PRECISION = 1e18;\n    uint256 public constant MAX_TCR = type(uint256).max;\n\n    /* Precision for Nominal ICR (independent of price). Rationale for the value:\n     *\n     * - Making it “too high” could lead to overflows.\n     * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division.\n     *\n     * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 ETH,\n     * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n     *\n     */\n    uint256 internal constant NICR_PRECISION = 1e20;\n\n    function _min(uint256 _a, uint256 _b) internal pure returns (uint256) {\n        return (_a < _b) ? _a : _b;\n    }\n\n    function _max(uint256 _a, uint256 _b) internal pure returns (uint256) {\n        return (_a >= _b) ? _a : _b;\n    }\n\n    /**\n     * credit to OpenZeppelin\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"EbtcMath: downcast to uint128 will overflow\");\n        return uint128(value);\n    }\n\n    /*\n     * Multiply two decimal numbers and use normal rounding rules:\n     * -round product up if 19'th mantissa digit >= 5\n     * -round product down if 19'th mantissa digit < 5\n     *\n     * Used only inside the exponentiation, _decPow().\n     */\n    function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {\n        uint256 prod_xy = x * y;\n\n        decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION;\n    }\n\n    /*\n     * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n.\n     *\n     * Uses the efficient \"exponentiation by squaring\" algorithm. O(log(n)) complexity.\n     *\n     * Called by two functions that represent time in units of minutes:\n     * 1) CdpManager._calcDecayedBaseRate\n     * 2) CommunityIssuance._getCumulativeIssuanceFraction\n     *\n     * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals\n     * \"minutes in 1000 years\": 60 * 24 * 365 * 1000\n     *\n     * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be\n     * negligibly different from just passing the cap, since:\n     *\n     * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years\n     * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible\n     */\n    function _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) {\n        if (_minutes > 525600000) {\n            _minutes = 525600000;\n        } // cap to avoid overflow\n\n        if (_minutes == 0) {\n            return DECIMAL_PRECISION;\n        }\n\n        uint256 y = DECIMAL_PRECISION;\n        uint256 x = _base;\n        uint256 n = _minutes;\n\n        // Exponentiation-by-squaring\n        while (n > 1) {\n            if (n % 2 == 0) {\n                x = decMul(x, x);\n                n = n / 2;\n            } else {\n                // if (n % 2 != 0)\n                y = decMul(x, y);\n                x = decMul(x, x);\n                n = (n - 1) / 2;\n            }\n        }\n\n        return decMul(x, y);\n    }\n\n    function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) {\n        return (_a >= _b) ? (_a - _b) : (_b - _a);\n    }\n\n    function _computeNominalCR(uint256 _collShares, uint256 _debt) internal pure returns (uint256) {\n        if (_debt > 0) {\n            return (_collShares * NICR_PRECISION) / _debt;\n        }\n        // Return the maximal value for uint256 if the Cdp has a debt of 0. Represents \"infinite\" CR.\n        else {\n            // if (_debt == 0)\n            return MAX_TCR;\n        }\n    }\n\n    /// @dev Compute collateralization ratio, given stETH balance, price, and debt balance\n    function _computeCR(\n        uint256 _stEthBalance,\n        uint256 _debt,\n        uint256 _price\n    ) internal pure returns (uint256) {\n        if (_debt > 0) {\n            uint256 newCollRatio = (_stEthBalance * _price) / _debt;\n\n            return newCollRatio;\n        }\n        // Return the maximal value for uint256 if the Cdp has a debt of 0. Represents \"infinite\" CR.\n        else {\n            // if (_debt == 0)\n            return MAX_TCR;\n        }\n    }\n}\n"
      },
      "lib/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n    struct ExactInputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint24 fee;\n        address recipient;\n        uint256 amountIn;\n        uint256 amountOutMinimum;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Swaps `amountIn` of one token for as much as possible of another token\n    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n    /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n    /// @return amountOut The amount of the received token\n    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n    struct ExactInputParams {\n        bytes path;\n        address recipient;\n        uint256 amountIn;\n        uint256 amountOutMinimum;\n    }\n\n    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n    /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n    /// @return amountOut The amount of the received token\n    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n    struct ExactOutputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint24 fee;\n        address recipient;\n        uint256 amountOut;\n        uint256 amountInMaximum;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Swaps as little as possible of one token for `amountOut` of another token\n    /// that may remain in the router after the swap.\n    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n    /// @return amountIn The amount of the input token\n    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n    struct ExactOutputParams {\n        bytes path;\n        address recipient;\n        uint256 amountOut;\n        uint256 amountInMaximum;\n    }\n\n    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n    /// that may remain in the router after the swap.\n    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n    /// @return amountIn The amount of the input token\n    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n"
      },
      "lib/swap-router-contracts/contracts/interfaces/IQuoterV2.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title QuoterV2 Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps.\n/// @notice For each pool also tells you the number of initialized ticks crossed and the sqrt price of the pool after the swap.\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IQuoterV2 {\n    /// @notice Returns the amount out received for a given exact input swap without executing the swap\n    /// @param path The path of the swap, i.e. each token pair and the pool fee\n    /// @param amountIn The amount of the first token to swap\n    /// @return amountOut The amount of the last token that would be received\n    /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path\n    /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path\n    /// @return gasEstimate The estimate of the gas that the swap consumes\n    function quoteExactInput(bytes memory path, uint256 amountIn)\n        external\n        returns (\n            uint256 amountOut,\n            uint160[] memory sqrtPriceX96AfterList,\n            uint32[] memory initializedTicksCrossedList,\n            uint256 gasEstimate\n        );\n\n    struct QuoteExactInputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint256 amountIn;\n        uint24 fee;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n    /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`\n    /// tokenIn The token being swapped in\n    /// tokenOut The token being swapped out\n    /// fee The fee of the token pool to consider for the pair\n    /// amountIn The desired input amount\n    /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n    /// @return amountOut The amount of `tokenOut` that would be received\n    /// @return sqrtPriceX96After The sqrt price of the pool after the swap\n    /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed\n    /// @return gasEstimate The estimate of the gas that the swap consumes\n    function quoteExactInputSingle(QuoteExactInputSingleParams memory params)\n        external\n        returns (\n            uint256 amountOut,\n            uint160 sqrtPriceX96After,\n            uint32 initializedTicksCrossed,\n            uint256 gasEstimate\n        );\n\n    /// @notice Returns the amount in required for a given exact output swap without executing the swap\n    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n    /// @param amountOut The amount of the last token to receive\n    /// @return amountIn The amount of first token required to be paid\n    /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path\n    /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path\n    /// @return gasEstimate The estimate of the gas that the swap consumes\n    function quoteExactOutput(bytes memory path, uint256 amountOut)\n        external\n        returns (\n            uint256 amountIn,\n            uint160[] memory sqrtPriceX96AfterList,\n            uint32[] memory initializedTicksCrossedList,\n            uint256 gasEstimate\n        );\n\n    struct QuoteExactOutputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint256 amount;\n        uint24 fee;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n    /// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams`\n    /// tokenIn The token being swapped in\n    /// tokenOut The token being swapped out\n    /// fee The fee of the token pool to consider for the pair\n    /// amountOut The desired output amount\n    /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n    /// @return sqrtPriceX96After The sqrt price of the pool after the swap\n    /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed\n    /// @return gasEstimate The estimate of the gas that the swap consumes\n    function quoteExactOutputSingle(QuoteExactOutputSingleParams memory params)\n        external\n        returns (\n            uint256 amountIn,\n            uint160 sqrtPriceX96After,\n            uint32 initializedTicksCrossed,\n            uint256 gasEstimate\n        );\n}\n"
      },
      "src/libraries/FullMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary FullMath {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(\n        uint256 a,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return\n                result +\n                (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(\n        uint256 value,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return\n                result +\n                (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(\n        uint256 value,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return\n                result +\n                (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(\n        uint256 value,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return\n                result +\n                (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "src/libraries/TickMath.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n    int24 internal constant MIN_TICK = -887272;\n    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n    int24 internal constant MAX_TICK = -MIN_TICK;\n\n    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n    uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n    /// @notice Calculates sqrt(1.0001^tick) * 2^96\n    /// @dev Throws if |tick| > max tick\n    /// @param tick The input tick for the above formula\n    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n    /// at the given tick\n    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n        require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n        if (absTick & 0x2 != 0) {\n            ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n        }\n        if (absTick & 0x4 != 0) {\n            ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n        }\n        if (absTick & 0x8 != 0) {\n            ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n        }\n        if (absTick & 0x10 != 0) {\n            ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n        }\n        if (absTick & 0x20 != 0) {\n            ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n        }\n        if (absTick & 0x40 != 0) {\n            ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n        }\n        if (absTick & 0x80 != 0) {\n            ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n        }\n        if (absTick & 0x100 != 0) {\n            ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n        }\n        if (absTick & 0x200 != 0) {\n            ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n        }\n        if (absTick & 0x400 != 0) {\n            ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n        }\n        if (absTick & 0x800 != 0) {\n            ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n        }\n        if (absTick & 0x1000 != 0) {\n            ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n        }\n        if (absTick & 0x2000 != 0) {\n            ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n        }\n        if (absTick & 0x4000 != 0) {\n            ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n        }\n        if (absTick & 0x8000 != 0) {\n            ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n        }\n        if (absTick & 0x10000 != 0) {\n            ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n        }\n        if (absTick & 0x20000 != 0) {\n            ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n        }\n        if (absTick & 0x40000 != 0) {\n            ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n        }\n        if (absTick & 0x80000 != 0) {\n            ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n        }\n\n        if (tick > 0) ratio = type(uint256).max / ratio;\n\n        // Adjust for Solidity ^0.8.0: Safe arithmetic operations are by default\n        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) > 0 ? 1 : 0));\n    }\n}\n"
      },
      "src/libraries/LiquidityAmounts.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport \"./FullMath.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\";\n\n/// @title Liquidity amount functions\n/// @notice Provides functions for computing liquidity amounts from token amounts and prices\nlibrary LiquidityAmounts {\n    /// @notice Downcasts uint256 to uint128\n    /// @param x The uint258 to be downcasted\n    /// @return y The passed value, downcasted to uint128\n    function toUint128(uint256 x) private pure returns (uint128 y) {\n        require((y = uint128(x)) == x);\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range\n    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount0 The amount0 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount0(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        uint256 intermediate = FullMath.mulDiv(\n            sqrtRatioAX96,\n            sqrtRatioBX96,\n            FixedPoint96.Q96\n        );\n        return\n            toUint128(\n                FullMath.mulDiv(\n                    amount0,\n                    intermediate,\n                    sqrtRatioBX96 - sqrtRatioAX96\n                )\n            );\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range\n    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount1 The amount1 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount1(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        return\n            toUint128(\n                FullMath.mulDiv(\n                    amount1,\n                    FixedPoint96.Q96,\n                    sqrtRatioBX96 - sqrtRatioAX96\n                )\n            );\n    }\n\n    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current\n    /// pool prices and the prices at the tick boundaries\n    /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount0 The amount of token0 being sent in\n    /// @param amount1 The amount of token1 being sent in\n    /// @return liquidity The maximum amount of liquidity received\n    function getLiquidityForAmounts(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            liquidity = getLiquidityForAmount0(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                amount0\n            );\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            uint128 liquidity0 = getLiquidityForAmount0(\n                sqrtRatioX96,\n                sqrtRatioBX96,\n                amount0\n            );\n            uint128 liquidity1 = getLiquidityForAmount1(\n                sqrtRatioAX96,\n                sqrtRatioX96,\n                amount1\n            );\n\n            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;\n        } else {\n            liquidity = getLiquidityForAmount1(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                amount1\n            );\n        }\n    }\n\n    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount0 The amount of token0\n    function getAmount0ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        return\n            FullMath.mulDiv(\n                uint256(liquidity) << FixedPoint96.RESOLUTION,\n                sqrtRatioBX96 - sqrtRatioAX96,\n                sqrtRatioBX96\n            ) / sqrtRatioAX96;\n    }\n\n    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount1 The amount of token1\n    function getAmount1ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        return\n            FullMath.mulDiv(\n                liquidity,\n                sqrtRatioBX96 - sqrtRatioAX96,\n                FixedPoint96.Q96\n            );\n    }\n\n    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current\n    /// pool prices and the prices at the tick boundaries\n    /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount0 The amount of token0\n    /// @return amount1 The amount of token1\n    function getAmountsForLiquidity(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0, uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            amount0 = getAmount0ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            amount0 = getAmount0ForLiquidity(\n                sqrtRatioX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n            amount1 = getAmount1ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioX96,\n                liquidity\n            );\n        } else {\n            amount1 = getAmount1ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n        }\n    }\n}\n"
      },
      "src/libraries/PoolAddress.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.0;\n\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\nlibrary PoolAddress {\n    bytes32 internal constant POOL_INIT_CODE_HASH =\n        0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\n\n    /// @notice The identifying key of the pool\n    struct PoolKey {\n        address token0;\n        address token1;\n        uint24 fee;\n    }\n\n    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\n    /// @param tokenA The first token of a pool, unsorted\n    /// @param tokenB The second token of a pool, unsorted\n    /// @param fee The fee level of the pool\n    /// @return Poolkey The pool details with ordered token0 and token1 assignments\n    function getPoolKey(\n        address tokenA,\n        address tokenB,\n        uint24 fee\n    ) internal pure returns (PoolKey memory) {\n        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\n        return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\n    }\n\n    /// @notice Deterministically computes the pool address given the factory and PoolKey\n    /// @param factory The Uniswap V3 factory contract address\n    /// @param key The PoolKey\n    /// @return pool The contract address of the V3 pool\n    function computeAddress(\n        address factory,\n        PoolKey memory key\n    ) internal pure returns (address pool) {\n        require(key.token0 < key.token1);\n        pool = address(\n            uint160(\n                uint256(\n                    keccak256(\n                        abi.encodePacked(\n                            hex\"ff\",\n                            factory,\n                            keccak256(\n                                abi.encode(key.token0, key.token1, key.fee)\n                            ),\n                            POOL_INIT_CODE_HASH\n                        )\n                    )\n                )\n            )\n        );\n    }\n}\n"
      },
      "lib/v3-core/contracts/libraries/FixedPoint96.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n    uint8 internal constant RESOLUTION = 96;\n    uint256 internal constant Q96 = 0x1000000000000000000000000;\n}\n"
      },
      "lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport './pool/IUniswapV3PoolImmutables.sol';\nimport './pool/IUniswapV3PoolState.sol';\nimport './pool/IUniswapV3PoolDerivedState.sol';\nimport './pool/IUniswapV3PoolActions.sol';\nimport './pool/IUniswapV3PoolOwnerActions.sol';\nimport './pool/IUniswapV3PoolEvents.sol';\n\n/// @title The interface for a Uniswap V3 Pool\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\n/// to the ERC20 specification\n/// @dev The pool interface is broken up into many smaller pieces\ninterface IUniswapV3Pool is\n    IUniswapV3PoolImmutables,\n    IUniswapV3PoolState,\n    IUniswapV3PoolDerivedState,\n    IUniswapV3PoolActions,\n    IUniswapV3PoolOwnerActions,\n    IUniswapV3PoolEvents\n{\n\n}\n"
      },
      "src/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\ninterface IERC20 {\n    function allowance(address, address) external view returns (uint256);\n\n    function approve(address, uint256) external;\n\n    function balanceOf(address) external returns (uint256);\n\n    function transfer(address, uint256) external returns (bool);\n\n    // NOTE: temporal additions for `CollateralTokenTester.sol` matching abi\n    function withdraw(uint256) external;\n    function deposit() external payable;\n    function forceDeposit(uint256) external;\n}\n"
      },
      "src/interfaces/IWstETH.sol": {
        "content": "// SPDX-FileCopyrightText: 2020 Lido <info@lido.fi>\n\n// SPDX-License-Identifier: GPL-3.0\n\n/* See contracts/COMPILERS.md */\npragma solidity 0.8.17;\n\n/// @notice Check https://etherscan.io/token/0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0#code\ninterface IWstETH {\n    /// @notice Exchanges wstETH to stETH\n    function unwrap(uint256 _wstETHAmount) external returns (uint256);\n\n    /// @notice Exchanges stETH to wstETH\n    function wrap(uint256 _stETHAmount) external returns (uint256);\n\n    /// @notice Get amount of wstETH for a given amount of stETH\n    function getWstETHByStETH(\n        uint256 _stETHAmount\n    ) external view returns (uint256);\n\n    /// @notice Get amount of stETH for a given amount of wstETH\n    function getStETHByWstETH(\n        uint256 _stETHAmount\n    ) external view returns (uint256);\n\n    function balanceOf(address _account) external view returns (uint256);\n\n    function approve(address _spender, uint256 _amount) external returns (bool);\n}\n"
      },
      "src/interfaces/IBO.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IBO {\n    function flashLoan(\n        address receiver,\n        address token,\n        uint256 amount,\n        bytes calldata data\n    ) external returns (bool);\n\n    function openCdp(\n        uint256 _EBTCAmount,\n        bytes32 _upperHint,\n        bytes32 _lowerHint,\n        uint256 _collAmount\n    ) external returns (bytes32);\n\n    function flashFee(\n        address token,\n        uint256 amount\n    ) external view returns (uint256);\n}\n"
      },
      "src/interfaces/ICdpManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\n// Common interface for the Cdp Manager.\ninterface ICdpManager {\n    function redemptionsPaused() external view returns (bool);\n    function beta() external view returns (uint256);\n    function CCR() external pure returns (uint256);\n    function redemptionFeeFloor() external pure returns (uint256);\n    function minuteDecayFactor() external pure returns (uint256);\n    function baseRate() external pure returns (uint256);\n    function lastRedemptionTimestamp() external pure returns (uint256);\n\n    function MCR() external pure returns (uint256);\n\n    function batchLiquidateCdps(bytes32[] memory _cdpArray) external;\n\n    function redeemCollateral(\n        uint256 _EBTCamount,\n        bytes32 _firstRedemptionHint,\n        bytes32 _upperPartialRedemptionHint,\n        bytes32 _lowerPartialRedemptionHint,\n        uint256 _partialRedemptionHintNICR,\n        uint256 _maxIterations,\n        uint256 _maxFeePercentage\n    ) external;\n\n    function getCachedTCR(uint256 _price) external view returns (uint256);\n\n    function checkRecoveryMode(uint256 _price) external view returns (bool);\n\n    function getSyncedTCR(uint256 _price) external view returns (uint256);\n\n    function getRedemptionRateWithDecay() external view returns (uint256);\n\n    function getRedemptionFeeWithDecay(uint256 _stETHToRedeem) external view returns (uint256);\n\n    function getCdpStatus(bytes32 _cdpId) external view returns (uint256);\n\n    function getSyncedICR(bytes32 _cdpId, uint256 _price) external view returns (uint256);\n    function getCachedICR(bytes32 _cdpId, uint256 _price) external view returns (uint256);\n\n    function canLiquidateRecoveryMode(uint256 icr, uint256 tcr) external view returns (bool);\n\n    function getSyncedDebtAndCollShares(bytes32 _cdpId) external view returns (uint256 debt, uint256 coll);\n\n    function getCdpLiquidatorRewardShares(bytes32 _cdpId) external view returns (uint256);\n\n    function getRedemptionRate() external view returns (uint256);\n\n    function getCdpDebt(bytes32 _cdpId) external view returns (uint256);\n\n    function getCdpCollShares(bytes32 _cdpId) external view returns (uint256);\n}\n"
      },
      "src/interfaces/IActivePool.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IActivePool {\n    function flashLoan(address receiver, address token, uint256 amount, bytes calldata data) external returns (bool);\n    function maxFlashLoan(address token) external view returns (uint256);\n    function getSystemDebt() external view returns (uint256);\n    function getSystemCollShares() external view returns (uint256);\n    function flashFee(address token, uint256 amount) external view returns (uint256);\n\n    function twapDisabled() external view returns (bool);\n    function observe() external returns (uint256);\n    function twapSystemDebtAtStart() external returns (uint256);\n}\n"
      },
      "lib/ebtc/packages/contracts/contracts/Interfaces/ISortedCdps.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\n// Common interface for the SortedCdps Doubly Linked List.\ninterface ISortedCdps {\n    // --- Events ---\n\n    event NodeAdded(bytes32 _id, uint _NICR);\n    event NodeRemoved(bytes32 _id);\n\n    // --- Functions ---\n\n    function remove(bytes32 _id) external;\n\n    function batchRemove(bytes32[] memory _ids) external;\n\n    function reInsert(bytes32 _id, uint256 _newICR, bytes32 _prevId, bytes32 _nextId) external;\n\n    function contains(bytes32 _id) external view returns (bool);\n\n    function isFull() external view returns (bool);\n\n    function isEmpty() external view returns (bool);\n\n    function getSize() external view returns (uint256);\n\n    function getMaxSize() external view returns (uint256);\n\n    function getFirst() external view returns (bytes32);\n\n    function getLast() external view returns (bytes32);\n\n    function getNext(bytes32 _id) external view returns (bytes32);\n\n    function getPrev(bytes32 _id) external view returns (bytes32);\n\n    function validInsertPosition(\n        uint256 _ICR,\n        bytes32 _prevId,\n        bytes32 _nextId\n    ) external view returns (bool);\n\n    function findInsertPosition(\n        uint256 _ICR,\n        bytes32 _prevId,\n        bytes32 _nextId\n    ) external view returns (bytes32, bytes32);\n\n    function insert(\n        address owner,\n        uint256 _ICR,\n        bytes32 _prevId,\n        bytes32 _nextId\n    ) external returns (bytes32);\n\n    function getOwnerAddress(bytes32 _id) external pure returns (address);\n\n    function nonExistId() external view returns (bytes32);\n\n    function cdpCountOf(address owner) external view returns (uint256);\n\n    function getCdpCountOf(\n        address owner,\n        bytes32 startNodeId,\n        uint maxNodes\n    ) external view returns (uint256, bytes32);\n\n    function getCdpsOf(address owner) external view returns (bytes32[] memory);\n\n    function getAllCdpsOf(\n        address owner,\n        bytes32 startNodeId,\n        uint maxNodes\n    ) external view returns (bytes32[] memory, uint256, bytes32);\n\n    function cdpOfOwnerByIndex(address owner, uint256 index) external view returns (bytes32);\n\n    function cdpOfOwnerByIdx(\n        address owner,\n        uint256 index,\n        bytes32 startNodeId,\n        uint maxNodes\n    ) external view returns (bytes32, bool);\n\n    function toCdpId(\n        address owner,\n        uint256 blockHeight,\n        uint256 nonce\n    ) external pure returns (bytes32);\n\n    function nextCdpNonce() external view returns (uint256);\n}\n"
      },
      "src/interfaces/IPriceFeed.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\ninterface IPriceFeed {\n    // --- Function ---\n    function primaryOracle() external returns (uint256);\n    function secondaryOracle() external returns (uint256);\n    function fetchPrice() external returns (uint256);\n    function lastGoodPrice() external returns (uint256);\n}\n"
      },
      "lib/ebtc/packages/contracts/contracts/Dependencies/ICollateralToken.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport \"./IERC20.sol\";\n\n/**\n * Based on the stETH:\n *  -   https://docs.lido.fi/contracts/lido#\n */\ninterface ICollateralToken is IERC20 {\n    // Returns the amount of shares that corresponds to _ethAmount protocol-controlled Ether\n    function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256);\n\n    // Returns the amount of Ether that corresponds to _sharesAmount token shares\n    function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);\n\n    // Moves `_sharesAmount` token shares from the caller's account to the `_recipient` account.\n    function transferShares(address _recipient, uint256 _sharesAmount) external returns (uint256);\n\n    // Returns the amount of shares owned by _account\n    function sharesOf(address _account) external view returns (uint256);\n\n    // Returns authorized oracle address\n    function getOracle() external view returns (address);\n}\n"
      },
      "src/interfaces/IHintHelpers.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\ninterface IHintHelpers {\n    function getRedemptionHints(\n        uint256 _EBTCamount,\n        uint256 _price,\n        uint256 _maxIterations\n    ) external view returns (\n        bytes32 firstRedemptionHint,\n        uint256 partialRedemptionHintNICR,\n        uint256 truncatedEBTCamount,\n        uint256 partialRedemptionNewColl\n    );\n\n    function getApproxHint(\n        uint256 _CR,\n        uint256 _numTrials,\n        uint256 _inputRandomSeed\n    ) external view returns (bytes32 hint, uint256 diff, uint256 latestRandomSeed);\n\n    function sortedCdpsToArray() external view returns (bytes32[] memory cdpIdArray);\n\n    function computeNominalCR(uint256 _coll, uint256 _debt) external pure returns (uint256);\n\n    function computeCR(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _price\n    ) external pure returns (uint256);\n}\n"
      },
      "lib/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n    /// @dev In the implementation you must pay the pool tokens owed for the swap.\n    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n    function uniswapV3SwapCallback(\n        int256 amount0Delta,\n        int256 amount1Delta,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n    /// @return The contract address\n    function factory() external view returns (address);\n\n    /// @notice The first of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token0() external view returns (address);\n\n    /// @notice The second of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token1() external view returns (address);\n\n    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n    /// @return The fee\n    function fee() external view returns (uint24);\n\n    /// @notice The pool tick spacing\n    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n    /// This value is an int24 to avoid casting even though it is always positive.\n    /// @return The tick spacing\n    function tickSpacing() external view returns (int24);\n\n    /// @notice The maximum amount of position liquidity that can use any tick in the range\n    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n    /// @return The max amount of liquidity per tick\n    function maxLiquidityPerTick() external view returns (uint128);\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\n/// per transaction\ninterface IUniswapV3PoolState {\n    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\n    /// when accessed externally.\n    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\n    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\n    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\n    /// boundary.\n    /// observationIndex The index of the last oracle observation that was written,\n    /// observationCardinality The current maximum number of observations stored in the pool,\n    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\n    /// feeProtocol The protocol fee for both tokens of the pool.\n    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\n    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\n    /// unlocked Whether the pool is currently locked to reentrancy\n    function slot0()\n        external\n        view\n        returns (\n            uint160 sqrtPriceX96,\n            int24 tick,\n            uint16 observationIndex,\n            uint16 observationCardinality,\n            uint16 observationCardinalityNext,\n            uint8 feeProtocol,\n            bool unlocked\n        );\n\n    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal0X128() external view returns (uint256);\n\n    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal1X128() external view returns (uint256);\n\n    /// @notice The amounts of token0 and token1 that are owed to the protocol\n    /// @dev Protocol fees will never exceed uint128 max in either token\n    function protocolFees() external view returns (uint128 token0, uint128 token1);\n\n    /// @notice The currently in range liquidity available to the pool\n    /// @dev This value has no relationship to the total liquidity across all ticks\n    function liquidity() external view returns (uint128);\n\n    /// @notice Look up information about a specific tick in the pool\n    /// @param tick The tick to look up\n    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or\n    /// tick upper,\n    /// liquidityNet how much liquidity changes when the pool price crosses the tick,\n    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\n    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\n    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\n    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\n    /// secondsOutside the seconds spent on the other side of the tick from the current tick,\n    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\n    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\n    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\n    /// a specific position.\n    function ticks(int24 tick)\n        external\n        view\n        returns (\n            uint128 liquidityGross,\n            int128 liquidityNet,\n            uint256 feeGrowthOutside0X128,\n            uint256 feeGrowthOutside1X128,\n            int56 tickCumulativeOutside,\n            uint160 secondsPerLiquidityOutsideX128,\n            uint32 secondsOutside,\n            bool initialized\n        );\n\n    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\n    function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n    /// @notice Returns the information about a position by the position's key\n    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\n    /// @return _liquidity The amount of liquidity in the position,\n    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\n    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\n    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\n    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\n    function positions(bytes32 key)\n        external\n        view\n        returns (\n            uint128 _liquidity,\n            uint256 feeGrowthInside0LastX128,\n            uint256 feeGrowthInside1LastX128,\n            uint128 tokensOwed0,\n            uint128 tokensOwed1\n        );\n\n    /// @notice Returns data about a specific observation index\n    /// @param index The element of the observations array to fetch\n    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\n    /// ago, rather than at a specific index in the array.\n    /// @return blockTimestamp The timestamp of the observation,\n    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\n    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,\n    /// Returns initialized whether the observation has been initialized and the values are safe to use\n    function observations(uint256 index)\n        external\n        view\n        returns (\n            uint32 blockTimestamp,\n            int56 tickCumulative,\n            uint160 secondsPerLiquidityCumulativeX128,\n            bool initialized\n        );\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that is not stored\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\n/// blockchain. The functions here may have variable gas costs.\ninterface IUniswapV3PoolDerivedState {\n    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\n    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\n    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\n    /// you must call it with secondsAgos = [3600, 0].\n    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\n    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\n    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\n    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\n    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\n    /// timestamp\n    function observe(uint32[] calldata secondsAgos)\n        external\n        view\n        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\n\n    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\n    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\n    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\n    /// snapshot is taken and the second snapshot is taken.\n    /// @param tickLower The lower tick of the range\n    /// @param tickUpper The upper tick of the range\n    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\n    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\n    /// @return secondsInside The snapshot of seconds per liquidity for the range\n    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\n        external\n        view\n        returns (\n            int56 tickCumulativeInside,\n            uint160 secondsPerLiquidityInsideX128,\n            uint32 secondsInside\n        );\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n    /// @notice Sets the initial price for the pool\n    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n    function initialize(uint160 sqrtPriceX96) external;\n\n    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n    /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n    /// @param recipient The address for which the liquidity will be created\n    /// @param tickLower The lower tick of the position in which to add liquidity\n    /// @param tickUpper The upper tick of the position in which to add liquidity\n    /// @param amount The amount of liquidity to mint\n    /// @param data Any data that should be passed through to the callback\n    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    function mint(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount,\n        bytes calldata data\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Collects tokens owed to a position\n    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n    /// @param recipient The address which should receive the fees collected\n    /// @param tickLower The lower tick of the position for which to collect fees\n    /// @param tickUpper The upper tick of the position for which to collect fees\n    /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n    /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n    /// @return amount0 The amount of fees collected in token0\n    /// @return amount1 The amount of fees collected in token1\n    function collect(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n\n    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n    /// @dev Fees must be collected separately via a call to #collect\n    /// @param tickLower The lower tick of the position for which to burn liquidity\n    /// @param tickUpper The upper tick of the position for which to burn liquidity\n    /// @param amount How much liquidity to burn\n    /// @return amount0 The amount of token0 sent to the recipient\n    /// @return amount1 The amount of token1 sent to the recipient\n    function burn(\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Swap token0 for token1, or token1 for token0\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n    /// @param recipient The address to receive the output of the swap\n    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n    /// @param data Any data to be passed through to the callback\n    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n    function swap(\n        address recipient,\n        bool zeroForOne,\n        int256 amountSpecified,\n        uint160 sqrtPriceLimitX96,\n        bytes calldata data\n    ) external returns (int256 amount0, int256 amount1);\n\n    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n    /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n    /// @param recipient The address which will receive the token0 and token1 amounts\n    /// @param amount0 The amount of token0 to send\n    /// @param amount1 The amount of token1 to send\n    /// @param data Any data to be passed through to the callback\n    function flash(\n        address recipient,\n        uint256 amount0,\n        uint256 amount1,\n        bytes calldata data\n    ) external;\n\n    /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n    /// the input observationCardinalityNext.\n    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissioned pool actions\n/// @notice Contains pool methods that may only be called by the factory owner\ninterface IUniswapV3PoolOwnerActions {\n    /// @notice Set the denominator of the protocol's % share of the fees\n    /// @param feeProtocol0 new protocol fee for token0 of the pool\n    /// @param feeProtocol1 new protocol fee for token1 of the pool\n    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\n\n    /// @notice Collect the protocol fee accrued to the pool\n    /// @param recipient The address to which collected protocol fees should be sent\n    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\n    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\n    /// @return amount0 The protocol fee collected in token0\n    /// @return amount1 The protocol fee collected in token1\n    function collectProtocol(\n        address recipient,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n}\n"
      },
      "lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Events emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IUniswapV3PoolEvents {\n    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\n    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\n    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\n    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\n    event Initialize(uint160 sqrtPriceX96, int24 tick);\n\n    /// @notice Emitted when liquidity is minted for a given position\n    /// @param sender The address that minted the liquidity\n    /// @param owner The owner of the position and recipient of any minted liquidity\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity minted to the position range\n    /// @param amount0 How much token0 was required for the minted liquidity\n    /// @param amount1 How much token1 was required for the minted liquidity\n    event Mint(\n        address sender,\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted when fees are collected by the owner of a position\n    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\n    /// @param owner The owner of the position for which fees are collected\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount0 The amount of token0 fees collected\n    /// @param amount1 The amount of token1 fees collected\n    event Collect(\n        address indexed owner,\n        address recipient,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount0,\n        uint128 amount1\n    );\n\n    /// @notice Emitted when a position's liquidity is removed\n    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\n    /// @param owner The owner of the position for which liquidity is removed\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity to remove\n    /// @param amount0 The amount of token0 withdrawn\n    /// @param amount1 The amount of token1 withdrawn\n    event Burn(\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted by the pool for any swaps between token0 and token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the output of the swap\n    /// @param amount0 The delta of the token0 balance of the pool\n    /// @param amount1 The delta of the token1 balance of the pool\n    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\n    /// @param liquidity The liquidity of the pool after the swap\n    /// @param tick The log base 1.0001 of price of the pool after the swap\n    event Swap(\n        address indexed sender,\n        address indexed recipient,\n        int256 amount0,\n        int256 amount1,\n        uint160 sqrtPriceX96,\n        uint128 liquidity,\n        int24 tick\n    );\n\n    /// @notice Emitted by the pool for any flashes of token0/token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the tokens from flash\n    /// @param amount0 The amount of token0 that was flashed\n    /// @param amount1 The amount of token1 that was flashed\n    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\n    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\n    event Flash(\n        address indexed sender,\n        address indexed recipient,\n        uint256 amount0,\n        uint256 amount1,\n        uint256 paid0,\n        uint256 paid1\n    );\n\n    /// @notice Emitted by the pool for increases to the number of observations that can be stored\n    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\n    /// just before a mint/swap/burn.\n    /// @param observationCardinalityNextOld The previous value of the next observation cardinality\n    /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n    event IncreaseObservationCardinalityNext(\n        uint16 observationCardinalityNextOld,\n        uint16 observationCardinalityNextNew\n    );\n\n    /// @notice Emitted when the protocol fee is changed by the pool\n    /// @param feeProtocol0Old The previous value of the token0 protocol fee\n    /// @param feeProtocol1Old The previous value of the token1 protocol fee\n    /// @param feeProtocol0New The updated value of the token0 protocol fee\n    /// @param feeProtocol1New The updated value of the token1 protocol fee\n    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\n\n    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\n    /// @param sender The address that collects the protocol fees\n    /// @param recipient The address that receives the collected protocol fees\n    /// @param amount0 The amount of token0 protocol fees that is withdrawn\n    /// @param amount0 The amount of token1 protocol fees that is withdrawn\n    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\n}\n"
      },
      "lib/ebtc/packages/contracts/contracts/Dependencies/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\n/**\n * Based on the OpenZeppelin IER20 interface:\n * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol\n *\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, 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    function increaseAllowance(address spender, uint256 addedValue) external returns (bool);\n\n    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);\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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);\n\n    function name() external view returns (string memory);\n\n    function symbol() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\n\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"
      }
    },
    "settings": {
      "remappings": [
        "forge-std/=lib/forge-std/src/",
        "ebtc/=lib/ebtc/packages/contracts/",
        "@openzeppelin/=lib/openzeppelin-contracts/",
        "@uniswap/v3-core/=lib/v3-core/",
        "@uniswap/v3-periphery/=lib/v3-periphery/",
        "swap-router-contracts/=lib/swap-router-contracts/",
        "ERC4626/=lib/ebtc/packages/contracts/lib/properties/lib/ERC4626/contracts/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/ebtc/packages/contracts/lib/openzeppelin-contracts/lib/erc4626-tests/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
        "properties/=lib/ebtc/packages/contracts/lib/properties/contracts/",
        "solmate/=lib/ebtc/packages/contracts/lib/properties/lib/solmate/src/",
        "v3-core/=lib/v3-core/",
        "v3-periphery/=lib/v3-periphery/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": false,
      "libraries": {}
    }
  }}