{
    "Function": "withdraw",
    "File": "src/contracts/strategies/StrategyBase.sol",
    "Parent Contracts": [
        "src/contracts/interfaces/IStrategy.sol",
        "src/contracts/permissions/Pausable.sol",
        "src/contracts/interfaces/IPausable.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [
        "SafeERC20"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "onlyStrategyManager",
        "_tokenBalance",
        "require(bool,string)",
        "_tokenBalance",
        "require(bool,string)",
        "onlyWhenNotPaused"
    ],
    "Library Calls": [
        "safeTransfer"
    ],
    "Low-Level Calls": [],
    "Code": "function withdraw(address depositor, IERC20 token, uint256 amountShares)\n        external\n        virtual\n        override\n        onlyWhenNotPaused(PAUSED_WITHDRAWALS)\n        onlyStrategyManager\n    {\n        require(token == underlyingToken, \"StrategyBase.withdraw: Can only withdraw the strategy token\");\n        // copy `totalShares` value to memory, prior to any decrease\n        uint256 priorTotalShares = totalShares;\n        require(\n            amountShares <= priorTotalShares,\n            \"StrategyBase.withdraw: amountShares must be less than or equal to totalShares\"\n        );\n\n        // Calculate the value that `totalShares` will decrease to as a result of the withdrawal\n        uint256 updatedTotalShares = priorTotalShares - amountShares;\n        // check to avoid edge case where share rate can be massively inflated as a 'griefing' sort of attack\n        require(updatedTotalShares >= MIN_NONZERO_TOTAL_SHARES || updatedTotalShares == 0,\n            \"StrategyBase.withdraw: updated totalShares amount would be nonzero but below MIN_NONZERO_TOTAL_SHARES\");\n        // Actually decrease the `totalShares` value\n        totalShares = updatedTotalShares;\n\n        /**\n         * @notice calculation of amountToSend *mirrors* `sharesToUnderlying(amountShares)`, but is different since the `totalShares` has already\n         * been decremented. Specifically, notice how we use `priorTotalShares` here instead of `totalShares`.\n         */\n        uint256 amountToSend;\n        if (priorTotalShares == amountShares) {\n            amountToSend = _tokenBalance();\n        } else {\n            amountToSend = (_tokenBalance() * amountShares) / priorTotalShares;\n        }\n\n        underlyingToken.safeTransfer(depositor, amountToSend);\n    }"
}