{
    "Function": "slitherConstructorConstantVariables",
    "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": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract StrategyBase is Initializable, Pausable, IStrategy {\n    using SafeERC20 for IERC20;\n\n    uint8 internal constant PAUSED_DEPOSITS = 0;\n    uint8 internal constant PAUSED_WITHDRAWALS = 1;\n    /*\n     * as long as at least *some* shares exist, this is the minimum number.\n     * i.e. `totalShares` must exist in the set {0, [MIN_NONZERO_TOTAL_SHARES, type(uint256).max]}\n    */\n    uint96 internal constant MIN_NONZERO_TOTAL_SHARES = 1e9;\n\n    /// @notice EigenLayer's StrategyManager contract\n    IStrategyManager public immutable strategyManager;\n\n    /// @notice The underyling token for shares in this Strategy\n    IERC20 public underlyingToken;\n\n    /// @notice The total number of extant shares in thie Strategy\n    uint256 public totalShares;\n\n    /// @notice Simply checks that the `msg.sender` is the `strategyManager`, which is an address stored immutably at construction.\n    modifier onlyStrategyManager() {\n        require(msg.sender == address(strategyManager), \"StrategyBase.onlyStrategyManager\");\n        _;\n    }\n\n    /// @notice Since this contract is designed to be initializable, the constructor simply sets `strategyManager`, the only immutable variable.\n    constructor(IStrategyManager _strategyManager) {\n        strategyManager = _strategyManager;\n        _disableInitializers();\n    }\n\n    function initialize(IERC20 _underlyingToken, IPauserRegistry _pauserRegistry) public virtual initializer {\n        _initializeStrategyBase(_underlyingToken, _pauserRegistry);\n    }\n\n    /// @notice Sets the `underlyingToken` and `pauserRegistry` for the strategy.\n    function _initializeStrategyBase(IERC20 _underlyingToken, IPauserRegistry _pauserRegistry) internal onlyInitializing {\n        underlyingToken = _underlyingToken;\n        _initializePauser(_pauserRegistry, UNPAUSE_ALL);\n    }\n\n    /**\n     * @notice Used to deposit tokens into this Strategy\n     * @param token is the ERC20 token being deposited\n     * @param amount is the amount of token being deposited\n     * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's\n     * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.\n     * @dev Note that the assumption is made that `amount` of `token` has already been transferred directly to this contract\n     * (as performed in the StrategyManager's deposit functions). In particular, setting the `underlyingToken` of this contract\n     * to be a fee-on-transfer token will break the assumption that the amount this contract *received* of the token is equal to\n     * the amount that was input when the transfer was performed (i.e. the amount transferred 'out' of the depositor's balance).\n     * \n     * WARNING: In order to mitigate against inflation/donation attacks in the context of ERC_4626, this contract requires the \n     *          minimum amount of shares be either 0 or 1e9. A consequence of this is that in the worst case a user will not \n     *          be able to withdraw for 1e9-1 or less shares. \n     * \n     * @return newShares is the number of new shares issued at the current exchange ratio.\n     */\n    function deposit(IERC20 token, uint256 amount)\n        external\n        virtual\n        override\n        onlyWhenNotPaused(PAUSED_DEPOSITS)\n        onlyStrategyManager\n        returns (uint256 newShares)\n    {\n        require(token == underlyingToken, \"StrategyBase.deposit: Can only deposit underlyingToken\");\n\n        /**\n         * @notice calculation of newShares *mirrors* `underlyingToShares(amount)`, but is different since the balance of `underlyingToken`\n         * has already been increased due to the `strategyManager` transferring tokens to this strategy prior to calling this function\n         */\n        if (totalShares == 0) {\n            newShares = amount;\n        } else {\n            uint256 priorTokenBalance = _tokenBalance() - amount;\n            if (priorTokenBalance == 0) {\n                newShares = amount;\n            } else {\n                newShares = (amount * totalShares) / priorTokenBalance;\n            }\n        }\n\n        // checks to ensure correctness / avoid edge case where share rate can be massively inflated as a 'griefing' sort of attack\n        require(newShares != 0, \"StrategyBase.deposit: newShares cannot be zero\");\n        uint256 updatedTotalShares = totalShares + newShares;\n        require(updatedTotalShares >= MIN_NONZERO_TOTAL_SHARES,\n            \"StrategyBase.deposit: updated totalShares amount would be nonzero but below MIN_NONZERO_TOTAL_SHARES\");\n\n        // update total share amount\n        totalShares = updatedTotalShares;\n        return newShares;\n    }\n\n    /**\n     * @notice Used to withdraw tokens from this Strategy, to the `depositor`'s address\n     * @param token is the ERC20 token being transferred out\n     * @param amountShares is the amount of shares being withdrawn\n     * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's\n     * other functions, and individual share balances are recorded in the strategyManager as well.\n     */\n    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    }\n\n    /**\n     * @notice Currently returns a brief string explaining the strategy's goal & purpose, but for more complex\n     * strategies, may be a link to metadata that explains in more detail.\n     */\n    function explanation() external pure virtual override returns (string memory) {\n        return \"Base Strategy implementation to inherit from for more complex implementations\";\n    }\n\n    /**\n     * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.\n     * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications\n     * @param amountShares is the amount of shares to calculate its conversion into the underlying token\n     * @dev Implementation for these functions in particular may vary signifcantly for different strategies\n     */\n    function sharesToUnderlyingView(uint256 amountShares) public view virtual override returns (uint256) {\n        if (totalShares == 0) {\n            return amountShares;\n        } else {\n            return (_tokenBalance() * amountShares) / totalShares;\n        }\n    }\n\n    /**\n     * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.\n     * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications\n     * @param amountShares is the amount of shares to calculate its conversion into the underlying token\n     * @dev Implementation for these functions in particular may vary signifcantly for different strategies\n     */\n    function sharesToUnderlying(uint256 amountShares) public view virtual override returns (uint256) {\n        return sharesToUnderlyingView(amountShares);\n    }\n\n    /**\n     * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.\n     * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications\n     * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares\n     * @dev Implementation for these functions in particular may vary signifcantly for different strategies\n     */\n    function underlyingToSharesView(uint256 amountUnderlying) public view virtual returns (uint256) {\n        uint256 tokenBalance = _tokenBalance();\n        if (tokenBalance == 0 || totalShares == 0) {\n            return amountUnderlying;\n        } else {\n            return (amountUnderlying * totalShares) / tokenBalance;\n        }\n    }\n\n    /**\n     * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.\n     * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications\n     * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares\n     * @dev Implementation for these functions in particular may vary signifcantly for different strategies\n     */\n    function underlyingToShares(uint256 amountUnderlying) external view virtual returns (uint256) {\n        return underlyingToSharesView(amountUnderlying);\n    }\n\n    /**\n     * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in\n     * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications\n     */\n    function userUnderlyingView(address user) external view virtual returns (uint256) {\n        return sharesToUnderlyingView(shares(user));\n    }\n\n    /**\n     * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in\n     * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications\n     */\n    function userUnderlying(address user) external virtual returns (uint256) {\n        return sharesToUnderlying(shares(user));\n    }\n\n    /**\n     * @notice convenience function for fetching the current total shares of `user` in this strategy, by\n     * querying the `strategyManager` contract\n     */\n    function shares(address user) public view virtual returns (uint256) {\n        return strategyManager.stakerStrategyShares(user, IStrategy(address(this)));\n    }\n\n    /// @notice Internal function used to fetch this contract's current balance of `underlyingToken`.\n    // slither-disable-next-line dead-code\n    function _tokenBalance() internal view virtual returns (uint256) {\n        return underlyingToken.balanceOf(address(this));\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[48] private __gap;\n}"
}