{
    "Function": "estimateStrategy",
    "File": "contracts/oracles/EnsoOracle.sol",
    "Parent Contracts": [
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IOracle.sol"
    ],
    "High-Level Calls": [
        "IERC20",
        "SignedSafeMath",
        "IEstimator",
        "ITokenRegistry",
        "IEstimator",
        "IStrategy",
        "IERC20",
        "SignedSafeMath",
        "SignedSafeMath",
        "SignedSafeMath",
        "IStrategy",
        "IStrategy",
        "SignedSafeMath"
    ],
    "Internal Calls": [
        "estimateItem",
        "estimateItem",
        "require(bool,string)"
    ],
    "Library Calls": [
        "add",
        "add",
        "add",
        "add",
        "add"
    ],
    "Low-Level Calls": [],
    "Code": "function estimateStrategy(IStrategy strategy) public view override returns (uint256, int256[] memory) {\n        address[] memory strategyItems = strategy.items();\n        address[] memory strategyDebt = strategy.debt();\n        int256 total = int256(IERC20(weth).balanceOf(address(strategy))); //WETH is never part of items array but always included in total value\n        int256[] memory estimates = new int256[](strategyItems.length + strategyDebt.length + 1); // +1 for virtual item\n        for (uint256 i = 0; i < strategyItems.length; i++) {\n            int256 estimate = estimateItem(\n                address(strategy),\n                strategyItems[i]\n            );\n            total = total.add(estimate);\n            estimates[i] = estimate;\n        }\n        for (uint256 i = 0; i < strategyDebt.length; i++) {\n            int256 estimate = estimateItem(\n                address(strategy),\n                strategyDebt[i]\n            );\n            total = total.add(estimate);\n            estimates[i + strategyItems.length] = estimate;\n        }\n        address[] memory strategySynths = strategy.synths();\n        if (strategySynths.length > 0) {\n            // All synths rely on the chainlink oracle\n            IEstimator chainlinkEstimator = tokenRegistry.estimators(uint256(EstimatorCategory.CHAINLINK_ORACLE));\n            int256 estimate = 0;\n            for (uint256 i = 0; i < strategySynths.length; i++) {\n                estimate = estimate.add(chainlinkEstimator.estimateItem(\n                    address(strategy),\n                    strategySynths[i]\n                ));\n            }\n            estimate = estimate.add(chainlinkEstimator.estimateItem(\n                IERC20(susd).balanceOf(address(strategy)),\n                susd\n            )); //SUSD is never part of synths array but always included in total value\n            total = total.add(estimate);\n            estimates[estimates.length - 1] = estimate; //Synths' estimates are pooled together in the virtual item address\n        }\n        require(total >= 0, \"Negative total\");\n        return (uint256(total), estimates);\n    }"
}