{
    "Function": "calculateAMMSwapFeesLiquidityChunk",
    "File": "contracts/libraries/FeesCalc.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "LiquidityChunk",
        "Math",
        "LiquidityChunk",
        "Math",
        "LeftRight",
        "LeftRight"
    ],
    "Internal Calls": [
        "_getAMMSwapFeesPerLiquidityCollected"
    ],
    "Library Calls": [
        "toLeftSlot",
        "mulDiv128",
        "tickLower",
        "tickUpper",
        "mulDiv128",
        "toRightSlot"
    ],
    "Low-Level Calls": [],
    "Code": "function calculateAMMSwapFeesLiquidityChunk(\n        IUniswapV3Pool univ3pool,\n        int24 currentTick,\n        uint128 startingLiquidity,\n        uint256 liquidityChunk\n    ) public view returns (int256 feesEachToken) {\n        // extract the amount of AMM fees collected within the liquidity chunk`\n        // note: the fee variables are *per unit of liquidity*; so more \"rate\" variables\n        (\n            uint256 ammFeesPerLiqToken0X128,\n            uint256 ammFeesPerLiqToken1X128\n        ) = _getAMMSwapFeesPerLiquidityCollected(\n                univ3pool,\n                currentTick,\n                liquidityChunk.tickLower(),\n                liquidityChunk.tickUpper()\n            );\n\n        // Use the fee growth (rate) variable to compute the absolute fees accumulated within the chunk:\n        //   ammFeesToken0X128 * liquidity / (2**128)\n        // to store the (absolute) fees as int128:\n        feesEachToken = feesEachToken\n            .toRightSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken0X128, startingLiquidity))))\n            .toLeftSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken1X128, startingLiquidity))));\n    }"
}