{
    "Function": "getMakerExpectedMFAndLiquidationPrice",
    "File": "contracts/HubbleViewer.sol",
    "Parent Contracts": [
        "contracts/Interfaces.sol"
    ],
    "High-Level Calls": [
        "IAMM",
        "IClearingHouse",
        "IAMM",
        "IAMM",
        "IAMM",
        "IClearingHouse",
        "IAMM"
    ],
    "Internal Calls": [
        "getMakerPositionAndUnrealizedPnl",
        "_getLiquidationPrice",
        "_max",
        "_getMarginFraction"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function getMakerExpectedMFAndLiquidationPrice(address trader, uint idx, uint vUSD, bool isRemove)\n        external\n        view\n        returns (int256 expectedMarginFraction, uint256 liquidationPrice)\n    {\n        // get total notionalPosition and margin (including unrealizedPnL and funding)\n        (uint256 notionalPosition, int256 margin) = clearingHouse.getNotionalPositionAndMargin(trader, true /* includeFundingPayments */);\n\n        IAMM amm = clearingHouse.amms(idx);\n\n        // get taker info\n        (int256 takerPosSize,,) = amm.positions(trader);\n        uint takerNotional = amm.getCloseQuote(takerPosSize);\n        // get maker info\n        (uint makerDebt,,,,,,) = amm.makers(trader);\n        // calculate total value of deposited liquidity after the tx\n        if (isRemove) {\n            makerDebt = 2 * (makerDebt - vUSD);\n        } else {\n            makerDebt = 2 * (makerDebt + vUSD);\n        }\n\n        {\n            // calculate effective notionalPosition\n            (int256 makerPosSize,,) = getMakerPositionAndUnrealizedPnl(trader, idx);\n            uint totalPosNotional = amm.getCloseQuote(makerPosSize + takerPosSize);\n            notionalPosition += _max(makerDebt + takerNotional, totalPosNotional);\n        }\n\n        {\n            (uint nowNotional,,,) = amm.getNotionalPositionAndUnrealizedPnl(trader);\n            notionalPosition -= nowNotional;\n        }\n\n        expectedMarginFraction = _getMarginFraction(margin, notionalPosition);\n        liquidationPrice = _getLiquidationPrice(trader, amm, notionalPosition, margin, 0, 0);\n    }"
}