{
    "Function": "_getAMMSwapFeesPerLiquidityCollected",
    "File": "contracts/libraries/FeesCalc.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "IUniswapV3Pool",
        "IUniswapV3Pool",
        "IUniswapV3Pool",
        "IUniswapV3Pool"
    ],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _getAMMSwapFeesPerLiquidityCollected(\n        IUniswapV3Pool univ3pool,\n        int24 currentTick,\n        int24 tickLower,\n        int24 tickUpper\n    ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n        // Get feesGrowths from the option position's lower+upper ticks\n        // lowerOut0: For token0: fee growth per unit of liquidity on the _other_ side of tickLower (relative to currentTick)\n        // only has relative meaning, not absolute \u2014 the value depends on when the tick is initialized\n        // (...)\n        // upperOut1: For token1: fee growth on the _other_ side of tickUpper (again: relative to currentTick)\n        // the point is: the range covered by lowerOut0 changes depending on where currentTick is.\n        (, , uint256 lowerOut0, uint256 lowerOut1, , , , ) = univ3pool.ticks(tickLower);\n        (, , uint256 upperOut0, uint256 upperOut1, , , , ) = univ3pool.ticks(tickUpper);\n\n        // compute the effective feeGrowth, depending on whether price is above/below/within range\n        unchecked {\n            if (currentTick < tickLower) {\n                /**\n                  Diagrams shown for token0, and applies for token1 the same\n                  L = lowerTick, U = upperTick\n\n                    liquidity         lowerOut0 (all fees collected in this price tick range for token0)\n                        \u25b2            \u25c4\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500^v\u2500\u2500\u2500\u25ba (to MAX_TICK)\n                        \u2502\n                        \u2502                      upperOut0\n                        \u2502                     \u25c4\u2500\u2500\u2500\u2500\u2500^v\u2500\u2500\u2500\u25ba\n                        \u2502           \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n                        \u2502           \u2502 chunk  \u2502\n                        \u2502           \u2502        \u2502\n                        \u2514\u2500\u2500\u2500\u2500\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba price tick\n                              \u2502     L        U\n                              \u2502\n                           current\n                            tick\n                */\n                feeGrowthInside0X128 = lowerOut0 - upperOut0; // fee growth inside the chunk\n                feeGrowthInside1X128 = lowerOut1 - upperOut1;\n            } else if (currentTick >= tickUpper) {\n                /**\n                    liquidity\n                        \u25b2           upperOut0\n                        \u2502\u25c4\u2500^v\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\n                        \u2502     \n                        \u2502     lowerOut0  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n                        \u2502\u25c4\u2500^v\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502 chunk  \u2502\n                        \u2502                \u2502        \u2502\n                        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u25ba price tick\n                                         L        U \u2502\n                                                    \u2502\n                                                 current\n                                                  tick\n                 */\n                feeGrowthInside0X128 = upperOut0 - lowerOut0;\n                feeGrowthInside1X128 = upperOut1 - lowerOut1;\n            } else {\n                /**\n                  current AMM tick is within the option position range (within the chunk)\n\n                     liquidity\n                        \u25b2        feeGrowthGlobal0X128 = global fee growth\n                        \u2502                             = (all fees collected for the entire price range for token 0)\n                        \u2502\n                        \u2502                        \n                        \u2502     lowerOut0  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 upperOut0\n                        \u2502\u25c4\u2500^v\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502              \u2502\u25c4\u2500\u2500\u2500\u2500\u2500^v\u2500\u2500\u2500\u25ba\n                        \u2502                \u2502     chunk    \u2502\n                        \u2502                \u2502              \u2502\n                        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u25ba price tick\n                                         L       \u2502      U\n                                                 \u2502\n                                              current\n                                               tick\n                */\n                feeGrowthInside0X128 = univ3pool.feeGrowthGlobal0X128() - lowerOut0 - upperOut0;\n                feeGrowthInside1X128 = univ3pool.feeGrowthGlobal1X128() - lowerOut1 - upperOut1;\n            }\n        }\n    }"
}