{
    "Function": "_getFeesBase",
    "File": "contracts/SemiFungiblePositionManager.sol",
    "Parent Contracts": [
        "contracts/multicall/Multicall.sol",
        "contracts/tokens/ERC1155Minimal.sol"
    ],
    "High-Level Calls": [
        "IUniswapV3Pool",
        "Math",
        "LiquidityChunk",
        "LeftRight",
        "Math",
        "LiquidityChunk",
        "LeftRight"
    ],
    "Internal Calls": [
        "keccak256(bytes)",
        "abi.encodePacked()"
    ],
    "Library Calls": [
        "toRightSlot",
        "toLeftSlot",
        "tickLower",
        "mulDiv128",
        "tickUpper",
        "mulDiv128"
    ],
    "Low-Level Calls": [],
    "Code": "function _getFeesBase(\n        IUniswapV3Pool univ3pool,\n        uint128 liquidity,\n        uint256 liquidityChunk\n    ) private view returns (int256 feesBase) {\n        // now collect fee growth within the liquidity chunk in `liquidityChunk`\n        // this is the fee accumulated in Uniswap for this chunk of liquidity\n\n        // read the latest feeGrowth directly from the Uniswap pool\n        (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = univ3pool\n            .positions(\n                keccak256(\n                    abi.encodePacked(\n                        address(this),\n                        liquidityChunk.tickLower(),\n                        liquidityChunk.tickUpper()\n                    )\n                )\n            );\n\n        // (feegrowth * liquidity) / 2 ** 128\n        /// @dev here we're converting the value to an int128 even though all values (feeGrowth, liquidity, Q128) are strictly positive.\n        /// That's because of the way feeGrowthInside works in Uniswap v3, where it can underflow when stored for the first time.\n        /// This is not a problem in Uniswap v3 because the fees are always calculated by taking the difference of the feeGrowths,\n        /// so that the net different is always positive.\n        /// So by using int128 instead of uint128, we remove the need to handle extremely large underflows and simply allow it to be negative\n        feesBase = int256(0)\n            .toRightSlot(int128(int256(Math.mulDiv128(feeGrowthInside0LastX128, liquidity))))\n            .toLeftSlot(int128(int256(Math.mulDiv128(feeGrowthInside1LastX128, liquidity))));\n    }"
}