{
    "Function": "flashLoanHelper",
    "File": "src/libraries/FeeDistributionHelper.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "SafeCast",
        "TokenHelper"
    ],
    "Internal Calls": [
        "revert FeeDistributionHelper__FlashLoanUnderflow(uint256,uint256)"
    ],
    "Library Calls": [
        "received",
        "safe128"
    ],
    "Low-Level Calls": [],
    "Code": "function flashLoanHelper(\n        FeeHelper.FeesDistribution memory _fees,\n        FeeHelper.FeesDistribution storage _pairFees,\n        IERC20 _token,\n        uint256 _reserve\n    ) internal {\n        uint128 _totalFees = _pairFees.total;\n        uint256 _amountReceived = _token.received(_reserve, _totalFees);\n\n        if (_fees.total > _amountReceived)\n            revert FeeDistributionHelper__FlashLoanUnderflow(_fees.total, _amountReceived);\n\n        _fees.total = _amountReceived.safe128();\n\n        _pairFees.total = _totalFees + _fees.total;\n        // unsafe math is fine because total >= protocol\n        unchecked {\n            _pairFees.protocol += _fees.protocol;\n        }\n    }"
}