{
    "Function": "_liquidateMaker",
    "File": "contracts/ClearingHouse.sol",
    "Parent Contracts": [
        "contracts/legos/HubbleBase.sol",
        "node_modules/@openzeppelin/contracts/metatx/ERC2771Context.sol",
        "node_modules/@openzeppelin/contracts/security/Pausable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol",
        "contracts/legos/Governable.sol",
        "node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol",
        "contracts/legos/Governable.sol",
        "contracts/Interfaces.sol"
    ],
    "High-Level Calls": [
        "IAMM",
        "IAMM"
    ],
    "Internal Calls": [
        "_disperseLiquidationFee",
        "_chargeFeeAndRealizePnL",
        "_calcMarginFraction",
        "require(bool,string)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _liquidateMaker(address maker) internal {\n        require(\n            _calcMarginFraction(maker, false) < maintenanceMargin,\n            \"CH: Above Maintenance Margin\"\n        );\n        int256 realizedPnl;\n        uint quoteAsset;\n        for (uint i = 0; i < amms.length; i++) {\n            (,, uint dToken,,,,) = amms[i].makers(maker);\n            // @todo put checks on slippage\n            (int256 _realizedPnl, uint _quote) = amms[i].removeLiquidity(maker, dToken, 0, 0);\n            realizedPnl += _realizedPnl;\n            quoteAsset += _quote;\n        }\n\n        _disperseLiquidationFee(\n            _chargeFeeAndRealizePnL(\n                maker,\n                realizedPnl,\n                2 * quoteAsset,  // total liquidity value = 2 * quote value\n                true // isLiquidation\n            )\n        );\n    }"
}