{
    "Function": "_deleverageForWithdraw",
    "File": "contracts/routers/FullRouter.sol",
    "Parent Contracts": [
        "contracts/routers/StrategyRouter.sol",
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IStrategyRouter.sol"
    ],
    "High-Level Calls": [
        "IStrategy",
        "SignedSafeMath",
        "StrategyLibrary",
        "IStrategy"
    ],
    "Internal Calls": [
        "_repayPath"
    ],
    "Library Calls": [
        "sub",
        "getExpectedTokenValue"
    ],
    "Low-Level Calls": [],
    "Code": "function _deleverageForWithdraw(address strategy, address[] memory strategyItems, int256[] memory estimates, uint256 total) private {\n        address[] memory strategyDebt = IStrategy(strategy).debt();\n        // Deleverage debt\n        for (uint256 i = 0; i < strategyDebt.length; i++) {\n            int256 estimatedValue = estimates[strategyItems.length + i];\n            int256 expectedValue = StrategyLibrary.getExpectedTokenValue(total, strategy, strategyDebt[i]);\n            if (estimatedValue < expectedValue) {\n                _repayPath(\n                    IStrategy(strategy).getTradeData(strategyDebt[i]),\n                    uint256(-estimatedValue.sub(expectedValue)),\n                    total,\n                    strategy\n                );\n            }\n        }\n    }"
}