{
    "Function": "_delegate",
    "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": [
        "ISlasher",
        "IStrategyManager"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "isNotDelegated",
        "require(bool,string)",
        "onlyWhenNotPaused",
        "_delegationReceivedHook",
        "require(bool,string)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "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    }"
}