{
    "Function": "slitherConstructorConstantVariables",
    "File": "src/contracts/core/DelegationManager.sol",
    "Parent Contracts": [
        "src/contracts/core/DelegationManagerStorage.sol",
        "src/contracts/interfaces/IDelegationManager.sol",
        "src/contracts/permissions/Pausable.sol",
        "src/contracts/interfaces/IPausable.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol",
        "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [
        "keccak256(bytes)",
        "keccak256(bytes)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, DelegationManagerStorage {\n    // index for flag that pauses new delegations when set\n    uint8 internal constant PAUSED_NEW_DELEGATION = 0;\n    // bytes4(keccak256(\"isValidSignature(bytes32,bytes)\")\n    bytes4 constant internal ERC1271_MAGICVALUE = 0x1626ba7e;\n\n    // chain id at the time of contract deployment\n    uint256 immutable ORIGINAL_CHAIN_ID;\n\n\n    /// @notice Simple permission for functions that are only callable by the StrategyManager contract.\n    modifier onlyStrategyManager() {\n        require(msg.sender == address(strategyManager), \"onlyStrategyManager\");\n        _;\n    }\n\n    // INITIALIZING FUNCTIONS\n    constructor(IStrategyManager _strategyManager, ISlasher _slasher) \n        DelegationManagerStorage(_strategyManager, _slasher)\n    {\n        _disableInitializers();\n        ORIGINAL_CHAIN_ID = block.chainid;\n    }\n\n    /// @dev Emitted when a low-level call to `delegationTerms.onDelegationReceived` fails, returning `returnData`\n    event OnDelegationReceivedCallFailure(IDelegationTerms indexed delegationTerms, bytes32 returnData);\n\n    /// @dev Emitted when a low-level call to `delegationTerms.onDelegationWithdrawn` fails, returning `returnData`\n    event OnDelegationWithdrawnCallFailure(IDelegationTerms indexed delegationTerms, bytes32 returnData);\n\n    function initialize(address initialOwner, IPauserRegistry _pauserRegistry, uint256 initialPausedStatus)\n        external\n        initializer\n    {\n        _initializePauser(_pauserRegistry, initialPausedStatus);\n        DOMAIN_SEPARATOR = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\"EigenLayer\")), ORIGINAL_CHAIN_ID, address(this)));\n        _transferOwnership(initialOwner);\n    }\n\n    // EXTERNAL FUNCTIONS\n    /**\n     * @notice This will be called by an operator to register itself as an operator that stakers can choose to delegate to.\n     * @param dt is the `DelegationTerms` contract that the operator has for those who delegate to them.\n     * @dev An operator can set `dt` equal to their own address (or another EOA address), in the event that they want to split payments\n     * in a more 'trustful' manner.\n     * @dev In the present design, once set, there is no way for an operator to ever modify the address of their DelegationTerms contract.\n     */\n    function registerAsOperator(IDelegationTerms dt) external {\n        require(\n            address(delegationTerms[msg.sender]) == address(0),\n            \"DelegationManager.registerAsOperator: operator has already registered\"\n        );\n        // store the address of the delegation contract that the operator is providing.\n        delegationTerms[msg.sender] = dt;\n        _delegate(msg.sender, msg.sender);\n    }\n\n    /**\n     *  @notice This will be called by a staker to delegate its assets to some operator.\n     *  @param operator is the operator to whom staker (msg.sender) is delegating its assets\n     */\n    function delegateTo(address operator) external {\n        _delegate(msg.sender, operator);\n    }\n\n    /**\n     * @notice Delegates from `staker` to `operator`.\n     * @dev requires that:\n     * 1) if `staker` is an EOA, then `signature` is valid ECSDA signature from `staker`, indicating their intention for this action\n     * 2) if `staker` is a contract, then `signature` must will be checked according to EIP-1271\n     */\n    function delegateToBySignature(address staker, address operator, uint256 expiry, bytes memory signature)\n        external\n    {\n        require(expiry >= block.timestamp, \"DelegationManager.delegateToBySignature: delegation signature expired\");\n\n        // calculate struct hash, then increment `staker`'s nonce\n        uint256 nonce = nonces[staker];\n        bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, staker, operator, nonce, expiry));\n        unchecked {\n            nonces[staker] = nonce + 1;\n        }\n\n        bytes32 digestHash;\n        if (block.chainid != ORIGINAL_CHAIN_ID) {\n            bytes32 domain_separator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(\"EigenLayer\")), block.chainid, address(this)));\n            digestHash = keccak256(abi.encodePacked(\"\\x19\\x01\", domain_separator, structHash));\n        } else{\n            digestHash = keccak256(abi.encodePacked(\"\\x19\\x01\", DOMAIN_SEPARATOR, structHash));\n        }\n\n        /**\n         * check validity of signature:\n         * 1) if `staker` is an EOA, then `signature` must be a valid ECSDA signature from `staker`,\n         * indicating their intention for this action\n         * 2) if `staker` is a contract, then `signature` must will be checked according to EIP-1271\n         */\n        if (Address.isContract(staker)) {\n            require(IERC1271(staker).isValidSignature(digestHash, signature) == ERC1271_MAGICVALUE,\n                \"DelegationManager.delegateToBySignature: ERC1271 signature verification failed\");\n        } else {\n            require(ECDSA.recover(digestHash, signature) == staker,\n                \"DelegationManager.delegateToBySignature: sig not from staker\");\n        }\n\n        _delegate(staker, operator);\n    }\n\n    /**\n     * @notice Undelegates `staker` from the operator who they are delegated to.\n     * @notice Callable only by the StrategyManager\n     * @dev Should only ever be called in the event that the `staker` has no active deposits in EigenLayer.\n     */\n    function undelegate(address staker) external onlyStrategyManager {\n        require(!isOperator(staker), \"DelegationManager.undelegate: operators cannot undelegate from themselves\");\n        delegatedTo[staker] = address(0);\n    }\n\n    /**\n     * @notice Increases the `staker`'s delegated shares in `strategy` by `shares, typically called when the staker has further deposits into EigenLayer\n     * @dev Callable only by the StrategyManager\n     */\n    function increaseDelegatedShares(address staker, IStrategy strategy, uint256 shares)\n        external\n        onlyStrategyManager\n    {\n        //if the staker is delegated to an operator\n        if (isDelegated(staker)) {\n            address operator = delegatedTo[staker];\n\n            // add strategy shares to delegate's shares\n            operatorShares[operator][strategy] += shares;\n\n            //Calls into operator's delegationTerms contract to update weights of individual staker\n            IStrategy[] memory stakerStrategyList = new IStrategy[](1);\n            uint256[] memory stakerShares = new uint[](1);\n            stakerStrategyList[0] = strategy;\n            stakerShares[0] = shares;\n\n            // call into hook in delegationTerms contract\n            IDelegationTerms dt = delegationTerms[operator];\n            _delegationReceivedHook(dt, staker, stakerStrategyList, stakerShares);\n        }\n    }\n\n    /**\n     * @notice Decreases the `staker`'s delegated shares in each entry of `strategies` by its respective `shares[i]`, typically called when the staker withdraws from EigenLayer\n     * @dev Callable only by the StrategyManager\n     */\n    function decreaseDelegatedShares(\n        address staker,\n        IStrategy[] calldata strategies,\n        uint256[] calldata shares\n    )\n        external\n        onlyStrategyManager\n    {\n        if (isDelegated(staker)) {\n            address operator = delegatedTo[staker];\n\n            // subtract strategy shares from delegate's shares\n            uint256 stratsLength = strategies.length;\n            for (uint256 i = 0; i < stratsLength;) {\n                operatorShares[operator][strategies[i]] -= shares[i];\n                unchecked {\n                    ++i;\n                }\n            }\n\n            // call into hook in delegationTerms contract\n            IDelegationTerms dt = delegationTerms[operator];\n            _delegationWithdrawnHook(dt, staker, strategies, shares);\n        }\n    }\n\n    // INTERNAL FUNCTIONS\n\n    /** \n     * @notice Makes a low-level call to `dt.onDelegationReceived(staker, strategies, shares)`, ignoring reverts and with a gas budget \n     * equal to `LOW_LEVEL_GAS_BUDGET` (a constant defined in this contract).\n     * @dev *If* the low-level call fails, then this function emits the event `OnDelegationReceivedCallFailure(dt, returnData)`, where\n     * `returnData` is *only the first 32 bytes* returned by the call to `dt`.\n     */\n    function _delegationReceivedHook(\n        IDelegationTerms dt,\n        address staker,\n        IStrategy[] memory strategies,\n        uint256[] memory shares\n    )\n        internal\n    {\n        /**\n         * We use low-level call functionality here to ensure that an operator cannot maliciously make this function fail in order to prevent undelegation.\n         * In particular, in-line assembly is also used to prevent the copying of uncapped return data which is also a potential DoS vector.\n         */\n        // format calldata\n        bytes memory lowLevelCalldata = abi.encodeWithSelector(IDelegationTerms.onDelegationReceived.selector, staker, strategies, shares);\n        // Prepare memory for low-level call return data. We accept a max return data length of 32 bytes\n        bool success;\n        bytes32[1] memory returnData;\n        // actually make the call\n        assembly {\n            success := call(\n                // gas provided to this context\n                LOW_LEVEL_GAS_BUDGET,\n                // address to call\n                dt,\n                // value in wei for call\n                0,\n                // memory location to copy for calldata\n                add(lowLevelCalldata, 32),\n                // length of memory to copy for calldata\n                mload(lowLevelCalldata),\n                // memory location to copy return data\n                returnData,\n                // byte size of return data to copy to memory\n                32\n            )\n        }\n        // if the call fails, we emit a special event rather than reverting\n        if (!success) {\n            emit OnDelegationReceivedCallFailure(dt, returnData[0]);\n        }\n    }\n\n    /** \n     * @notice Makes a low-level call to `dt.onDelegationWithdrawn(staker, strategies, shares)`, ignoring reverts and with a gas budget \n     * equal to `LOW_LEVEL_GAS_BUDGET` (a constant defined in this contract).\n     * @dev *If* the low-level call fails, then this function emits the event `OnDelegationReceivedCallFailure(dt, returnData)`, where\n     * `returnData` is *only the first 32 bytes* returned by the call to `dt`.\n     */\n    function _delegationWithdrawnHook(\n        IDelegationTerms dt,\n        address staker,\n        IStrategy[] memory strategies,\n        uint256[] memory shares\n    )\n        internal\n    {\n        /**\n         * We use low-level call functionality here to ensure that an operator cannot maliciously make this function fail in order to prevent undelegation.\n         * In particular, in-line assembly is also used to prevent the copying of uncapped return data which is also a potential DoS vector.\n         */\n        // format calldata\n        bytes memory lowLevelCalldata = abi.encodeWithSelector(IDelegationTerms.onDelegationWithdrawn.selector, staker, strategies, shares);\n        // Prepare memory for low-level call return data. We accept a max return data length of 32 bytes\n        bool success;\n        bytes32[1] memory returnData;\n        // actually make the call\n        assembly {\n            success := call(\n                // gas provided to this context\n                LOW_LEVEL_GAS_BUDGET,\n                // address to call\n                dt,\n                // value in wei for call\n                0,\n                // memory location to copy for calldata\n                add(lowLevelCalldata, 32),\n                // length of memory to copy for calldata\n                mload(lowLevelCalldata),\n                // memory location to copy return data\n                returnData,\n                // byte size of return data to copy to memory\n                32\n            )\n        }\n        // if the call fails, we emit a special event rather than reverting\n        if (!success) {\n            emit OnDelegationWithdrawnCallFailure(dt, returnData[0]);\n        }\n    }\n\n    /**\n     * @notice Internal function implementing the delegation *from* `staker` *to* `operator`.\n     * @param staker The address to delegate *from* -- this address is delegating control of its own assets.\n     * @param operator The address to delegate *to* -- this address is being given power to place the `staker`'s assets at risk on services\n     * @dev Ensures that the operator has registered as a delegate (`address(dt) != address(0)`), verifies that `staker` is not already\n     * delegated, and records the new delegation.\n     */ \n    function _delegate(address staker, address operator) internal onlyWhenNotPaused(PAUSED_NEW_DELEGATION) {\n        IDelegationTerms dt = delegationTerms[operator];\n        require(\n            address(dt) != address(0), \"DelegationManager._delegate: operator has not yet registered as a delegate\"\n        );\n\n        require(isNotDelegated(staker), \"DelegationManager._delegate: staker has existing delegation\");\n        // checks that operator has not been frozen\n        require(!slasher.isFrozen(operator), \"DelegationManager._delegate: cannot delegate to a frozen operator\");\n\n        // record delegation relation between the staker and operator\n        delegatedTo[staker] = operator;\n\n        // retrieve list of strategies and their shares from strategy manager\n        (IStrategy[] memory strategies, uint256[] memory shares) = strategyManager.getDeposits(staker);\n\n        // add strategy shares to delegate's shares\n        uint256 stratsLength = strategies.length;\n        for (uint256 i = 0; i < stratsLength;) {\n            // update the share amounts for each of the operator's strategies\n            operatorShares[operator][strategies[i]] += shares[i];\n            unchecked {\n                ++i;\n            }\n        }\n\n        // call into hook in delegationTerms contract\n        _delegationReceivedHook(dt, staker, strategies, shares);\n    }\n\n    // VIEW FUNCTIONS\n\n    /// @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise.\n    function isDelegated(address staker) public view returns (bool) {\n        return (delegatedTo[staker] != address(0));\n    }\n\n    /// @notice Returns 'true' if `staker` is *not* actively delegated, and 'false' otherwise.\n    function isNotDelegated(address staker) public view returns (bool) {\n        return (delegatedTo[staker] == address(0));\n    }\n\n    /// @notice Returns if an operator can be delegated to, i.e. it has called `registerAsOperator`.\n    function isOperator(address operator) public view returns (bool) {\n        return (address(delegationTerms[operator]) != address(0));\n    }\n}"
}