{
    "Function": "_getLeverageRemaining",
    "File": "contracts/routers/FullRouter.sol",
    "Parent Contracts": [
        "contracts/routers/StrategyRouter.sol",
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IStrategyRouter.sol"
    ],
    "High-Level Calls": [
        "SignedSafeMath",
        "SignedSafeMath",
        "IERC20",
        "IOracle",
        "StrategyLibrary"
    ],
    "Internal Calls": [
        "_setTempEstimate"
    ],
    "Library Calls": [
        "sub",
        "sub",
        "getExpectedTokenValue"
    ],
    "Low-Level Calls": [],
    "Code": "function _getLeverageRemaining(\n        IOracle oracle,\n        address strategy,\n        address leverageItem,\n        uint256 total,\n        bool isLeveraging\n    ) internal returns (uint256) {\n        int256 expected = StrategyLibrary.getExpectedTokenValue(total, strategy, leverageItem);\n        int256 estimate = oracle.estimateItem(\n            IERC20(leverageItem).balanceOf(strategy),\n            leverageItem\n        );\n        if (isLeveraging) {\n            if (expected > estimate) return uint256(expected.sub(estimate));\n        } else {\n            _setTempEstimate(strategy, leverageItem, estimate); // Store this value for _deleverage()\n            if (estimate > expected) return uint256(estimate.sub(expected));\n        }\n        return 0;\n    }"
}