{
    "Function": "slitherConstructorConstantVariables",
    "File": "src/contracts/middleware/VoteWeigherBase.sol",
    "Parent Contracts": [
        "src/contracts/middleware/VoteWeigherBaseStorage.sol",
        "src/contracts/interfaces/IVoteWeigher.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "abstract contract VoteWeigherBase is VoteWeigherBaseStorage {\n    /// @notice emitted when `strategy` has been added to the array at `strategiesConsideredAndMultipliers[quorumNumber]`\n    event StrategyAddedToQuorum(uint256 indexed quorumNumber, IStrategy strategy);\n    /// @notice emitted when `strategy` has removed from the array at `strategiesConsideredAndMultipliers[quorumNumber]`\n    event StrategyRemovedFromQuorum(uint256 indexed quorumNumber, IStrategy strategy);\n\n    /// @notice when applied to a function, ensures that the function is only callable by the current `owner` of the `serviceManager`\n    modifier onlyServiceManagerOwner() {\n        require(msg.sender == serviceManager.owner(), \"onlyServiceManagerOwner\");\n        _;\n    }\n\n    /// @notice Sets the (immutable) `strategyManager` and `serviceManager` addresses, as well as the (immutable) `NUMBER_OF_QUORUMS` variable\n    constructor(\n        IStrategyManager _strategyManager,\n        IServiceManager _serviceManager,\n        uint8 _NUMBER_OF_QUORUMS\n    ) VoteWeigherBaseStorage(_strategyManager, _serviceManager, _NUMBER_OF_QUORUMS) \n    // solhint-disable-next-line no-empty-blocks\n    {}\n\n    /// @notice Set the split in earnings between the different quorums.\n    function _initialize(uint256[] memory _quorumBips) internal virtual onlyInitializing {\n        // verify that the provided `_quorumBips` is of the correct length\n        require(\n            _quorumBips.length == NUMBER_OF_QUORUMS,\n            \"VoteWeigherBase._initialize: _quorumBips.length != NUMBER_OF_QUORUMS\"\n        );\n        uint256 totalQuorumBips;\n        for (uint256 i; i < NUMBER_OF_QUORUMS; ++i) {\n            totalQuorumBips += _quorumBips[i];\n            quorumBips[i] = _quorumBips[i];\n        }\n        // verify that the provided `_quorumBips` do indeed sum to 10,000!\n        require(totalQuorumBips == MAX_BIPS, \"VoteWeigherBase._initialize: totalQuorumBips != MAX_BIPS\");\n    }\n\n    /**\n     * @notice This function computes the total weight of the @param operator in the quorum @param quorumNumber.\n     * @dev returns zero in the case that `quorumNumber` is greater than or equal to `NUMBER_OF_QUORUMS`\n     */\n    function weightOfOperator(address operator, uint256 quorumNumber) public virtual returns (uint96) {\n        uint96 weight;\n\n        if (quorumNumber < NUMBER_OF_QUORUMS) {\n            uint256 stratsLength = strategiesConsideredAndMultipliersLength(quorumNumber);\n\n            StrategyAndWeightingMultiplier memory strategyAndMultiplier;\n\n            for (uint256 i = 0; i < stratsLength;) {\n                // accessing i^th StrategyAndWeightingMultiplier struct for the quorumNumber\n                strategyAndMultiplier = strategiesConsideredAndMultipliers[quorumNumber][i];\n\n                // shares of the operator in the strategy\n                uint256 sharesAmount = delegation.operatorShares(operator, strategyAndMultiplier.strategy);\n\n                // add the weight from the shares for this strategy to the total weight\n                if (sharesAmount > 0) {\n                    weight += uint96(\n                        (\n                            (strategyAndMultiplier.strategy).sharesToUnderlying(sharesAmount)\n                                * strategyAndMultiplier.multiplier\n                        ) / WEIGHTING_DIVISOR\n                    );\n                }\n\n                unchecked {\n                    ++i;\n                }\n            }\n        }\n\n        return weight;\n    }\n\n    /// @notice Adds new strategies and the associated multipliers to the @param quorumNumber.\n    function addStrategiesConsideredAndMultipliers(\n        uint256 quorumNumber,\n        StrategyAndWeightingMultiplier[] memory _newStrategiesConsideredAndMultipliers\n    ) external virtual onlyServiceManagerOwner {\n        _addStrategiesConsideredAndMultipliers(quorumNumber, _newStrategiesConsideredAndMultipliers);\n    }\n\n    /**\n     * @notice This function is used for removing strategies and their associated weights from the\n     * mapping strategiesConsideredAndMultipliers for a specific @param quorumNumber.\n     * @dev higher indices should be *first* in the list of @param indicesToRemove, since otherwise\n     * the removal of lower index entries will cause a shift in the indices of the other strategiesToRemove\n     */\n    function removeStrategiesConsideredAndMultipliers(\n        uint256 quorumNumber,\n        IStrategy[] calldata _strategiesToRemove,\n        uint256[] calldata indicesToRemove\n    ) external virtual onlyServiceManagerOwner {\n        uint256 numStrats = _strategiesToRemove.length;\n        // sanity check on input lengths\n        require(indicesToRemove.length == numStrats, \"VoteWeigherBase.removeStrategiesConsideredAndWeights: input length mismatch\");\n\n        for (uint256 i = 0; i < numStrats;) {\n            // check that the provided index is correct\n            require(\n                strategiesConsideredAndMultipliers[quorumNumber][indicesToRemove[i]].strategy == _strategiesToRemove[i],\n                \"VoteWeigherBase.removeStrategiesConsideredAndWeights: index incorrect\"\n            );\n\n            // remove strategy and its associated multiplier\n            strategiesConsideredAndMultipliers[quorumNumber][indicesToRemove[i]] = strategiesConsideredAndMultipliers[quorumNumber][strategiesConsideredAndMultipliers[quorumNumber]\n                .length - 1];\n            strategiesConsideredAndMultipliers[quorumNumber].pop();\n            emit StrategyRemovedFromQuorum(quorumNumber, _strategiesToRemove[i]);\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @notice This function is used for modifying the weights of strategies that are already in the\n     * mapping strategiesConsideredAndMultipliers for a specific @param quorumNumber.\n     * @param strategyIndices is a correctness-check input -- the supplied values must match the indices of the\n     * strategiesToModifyWeightsOf in strategiesConsideredAndMultipliers[quorumNumber]\n     */\n    function modifyStrategyWeights(\n        uint256 quorumNumber,\n        uint256[] calldata strategyIndices,\n        uint96[] calldata newMultipliers\n    ) external virtual onlyServiceManagerOwner {\n        uint256 numStrats = strategyIndices.length;\n        // sanity check on input lengths\n        require(newMultipliers.length == numStrats,\n            \"VoteWeigherBase.modifyStrategyWeights: input length mismatch\");\n\n        for (uint256 i = 0; i < numStrats;) {\n            // change the strategy's associated multiplier\n            strategiesConsideredAndMultipliers[quorumNumber][strategyIndices[i]].multiplier = newMultipliers[i];\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @notice Returns the length of the dynamic array stored in `strategiesConsideredAndMultipliers[quorumNumber]`.\n     * @dev Reverts if `quorumNumber` < `NUMBER_OF_QUORUMS`, i.e. the input is out of bounds.\n     */\n    function strategiesConsideredAndMultipliersLength(uint256 quorumNumber) public view returns (uint256) {\n        require(\n            quorumNumber < NUMBER_OF_QUORUMS,\n            \"VoteWeigherBase.strategiesConsideredAndMultipliersLength: quorumNumber input exceeds NUMBER_OF_QUORUMS\"\n        );\n        return strategiesConsideredAndMultipliers[quorumNumber].length;\n    }\n\n    /** \n     * @notice Adds `_newStrategiesConsideredAndMultipliers` to the `quorumNumber`-th quorum.\n     * @dev Checks to make sure that the *same* strategy cannot be added multiple times (checks against both against existing and new strategies).\n     * @dev This function has no check to make sure that the strategies for a single quorum have the same underlying asset. This is a concious choice,\n     * since a middleware may want, e.g., a stablecoin quorum that accepts USDC, USDT, DAI, etc. as underlying assets and trades them as \"equivalent\".\n     */\n    function _addStrategiesConsideredAndMultipliers(\n        uint256 quorumNumber,\n        StrategyAndWeightingMultiplier[] memory _newStrategiesConsideredAndMultipliers\n    ) internal {\n        uint256 numStratsToAdd = _newStrategiesConsideredAndMultipliers.length;\n        uint256 numStratsExisting = strategiesConsideredAndMultipliers[quorumNumber].length;\n        require(\n            numStratsExisting + numStratsToAdd <= MAX_WEIGHING_FUNCTION_LENGTH,\n            \"VoteWeigherBase._addStrategiesConsideredAndMultipliers: exceed MAX_WEIGHING_FUNCTION_LENGTH\"\n        );\n        for (uint256 i = 0; i < numStratsToAdd;) {\n            // fairly gas-expensive internal loop to make sure that the *same* strategy cannot be added multiple times\n            for (uint256 j = 0; j < (numStratsExisting + i);) {\n                require(\n                    strategiesConsideredAndMultipliers[quorumNumber][j].strategy\n                        != _newStrategiesConsideredAndMultipliers[i].strategy,\n                    \"VoteWeigherBase._addStrategiesConsideredAndMultipliers: cannot add same strategy 2x\"\n                );\n                unchecked {\n                    ++j;\n                }\n            }\n            strategiesConsideredAndMultipliers[quorumNumber].push(_newStrategiesConsideredAndMultipliers[i]);\n            emit StrategyAddedToQuorum(quorumNumber, _newStrategiesConsideredAndMultipliers[i].strategy);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n}"
}