{
    "Function": "liquidateAccount",
    "File": "contracts/LendingPair.sol",
    "Parent Contracts": [
        "contracts/TransferHelper.sol"
    ],
    "High-Level Calls": [
        "IController",
        "Math",
        "IController",
        "IController"
    ],
    "Internal Calls": [
        "feeRecipient",
        "feeRecipient",
        "_burnDebt",
        "_convertTokenValues",
        "require(bool,string)",
        "_safeTransferFrom",
        "_burnSupply",
        "accountHealth",
        "_validateToken",
        "require(bool,string)",
        "_accrueAccountInterest",
        "_safeTransfer",
        "_accrueAccountInterest",
        "_mintSupply"
    ],
    "Library Calls": [
        "min"
    ],
    "Low-Level Calls": [],
    "Code": "function liquidateAccount(\n    address _account,\n    address _repayToken,\n    uint    _repayAmount,\n    uint    _minSupplyOutput\n  ) external {\n\n    // Input validation and adjustments\n\n    _validateToken(_repayToken);\n    address supplyToken = _repayToken == tokenA ? tokenB : tokenA;\n\n    // Check account is underwater after interest\n\n    _accrueAccountInterest(_account);\n    _accrueAccountInterest(feeRecipient());\n    uint health = accountHealth(_account);\n    require(health < controller.LIQ_MIN_HEALTH(), \"LendingPair: account health > LIQ_MIN_HEALTH\");\n\n    // Calculate balance adjustments\n\n    _repayAmount = Math.min(_repayAmount, debtOf[_repayToken][_account]);\n\n    uint supplyDebt   = _convertTokenValues(_repayToken, supplyToken, _repayAmount);\n    uint callerFee    = supplyDebt * controller.liqFeeCaller(_repayToken) / 100e18;\n    uint systemFee    = supplyDebt * controller.liqFeeSystem(_repayToken) / 100e18;\n    uint supplyBurn   = supplyDebt + callerFee + systemFee;\n    uint supplyOutput = supplyDebt + callerFee;\n\n    require(supplyOutput >= _minSupplyOutput, \"LendingPair: supplyOutput >= _minSupplyOutput\");\n\n    // Adjust balances\n\n    _burnSupply(supplyToken, _account, supplyBurn);\n    _mintSupply(supplyToken, feeRecipient(), systemFee);\n    _burnDebt(_repayToken, _account, _repayAmount);\n\n    // Settle token transfers\n\n    _safeTransferFrom(_repayToken, msg.sender, _repayAmount);\n    _safeTransfer(IERC20(supplyToken), msg.sender, supplyOutput);\n\n    emit Liquidation(_account, _repayToken, supplyToken, _repayAmount, supplyOutput);\n  }"
}