```\nFile: FlatcoinVault.sol\n    function settleFundingFees() public returns (int256 _fundingFees) {\n..SNIP..\n        // Calculate the funding fees accrued to the longs.\n        // This will be used to adjust the global margin and collateral amounts.\n        _fundingFees = PerpMath._accruedFundingTotalByLongs(_globalPositions, unrecordedFunding);\n\n        // In the worst case scenario that the last position which remained open is underwater,\n        // we set the margin deposited total to 0. We don't want to have a negative margin deposited total.\n        _globalPositions.marginDepositedTotal = (int256(_globalPositions.marginDepositedTotal) > _fundingFees)\n            ? uint256(int256(_globalPositions.marginDepositedTotal) + _fundingFees)\n            : 0;\n\n        _updateStableCollateralTotal(-_fundingFees);\n```\n