{
    "Function": "getTakerExpectedMFAndLiquidationPrice",
    "File": "contracts/HubbleViewer.sol",
    "Parent Contracts": [
        "contracts/Interfaces.sol"
    ],
    "High-Level Calls": [
        "IAMM",
        "SafeCast",
        "IClearingHouse",
        "IAMM",
        "IAMM",
        "IClearingHouse"
    ],
    "Internal Calls": [
        "_calculateTradeFee",
        "_getMarginFraction",
        "getQuote",
        "_getLiquidationPrice"
    ],
    "Library Calls": [
        "toInt256"
    ],
    "Low-Level Calls": [],
    "Code": "function getTakerExpectedMFAndLiquidationPrice(address trader, uint idx, int256 baseAssetQuantity)\n        external\n        view\n        returns (int256 expectedMarginFraction, uint256 quoteAssetQuantity, uint256 liquidationPrice)\n    {\n        IAMM amm = clearingHouse.amms(idx);\n        // get quoteAsset required to swap baseAssetQuantity\n        quoteAssetQuantity = getQuote(baseAssetQuantity, idx);\n\n        // get total notionalPosition and margin (including unrealizedPnL and funding)\n        (uint256 notionalPosition, int256 margin) = clearingHouse.getNotionalPositionAndMargin(trader, true /* includeFundingPayments */);\n\n        // get market specific position info\n        (int256 takerPosSize,,) = amm.positions(trader);\n        uint takerNowNotional = amm.getCloseQuote(takerPosSize);\n        uint takerUpdatedNotional = amm.getCloseQuote(takerPosSize + baseAssetQuantity);\n        // Calculate new total notionalPosition\n        notionalPosition = notionalPosition + takerUpdatedNotional - takerNowNotional;\n\n        margin -= _calculateTradeFee(quoteAssetQuantity).toInt256();\n        expectedMarginFraction = _getMarginFraction(margin, notionalPosition);\n        liquidationPrice = _getLiquidationPrice(trader, amm, notionalPosition, margin, baseAssetQuantity, quoteAssetQuantity);\n    }"
}