ETH Price: $2,522.95 (-3.70%)
Gas: 0.89 Gwei

Transaction Decoder

Block:
20229825 at Jul-04-2024 01:19:59 AM +UTC
Transaction Fee:
0.001245764632967476 ETH $3.14
Gas Used:
295,388 Gas / 4.217384027 Gwei

Account State Difference:

  Address   Before After State Difference Code
0x6AF2B84a...3184C60Ad
0.365755982151271908 Eth
Nonce: 2
0.364510217518304432 Eth
Nonce: 3
0.001245764632967476
(beaverbuild)
19.673832594395859244 Eth19.673945949212978564 Eth0.00011335481711932

Execution Trace

TransparentUpgradeableProxy.CALL( )
  • EigenPodManager.DELEGATECALL( )
    • 0x770df1f3ba4bfca32436ec8f16ae7dd7c050c4bf.60806040( )
      • UpgradeableBeacon.STATICCALL( )
      • 0x770df1f3ba4bfca32436ec8f16ae7dd7c050c4bf.c4d66de8( )
        • UpgradeableBeacon.STATICCALL( )
        • EigenPod.initialize( _podOwner=0x6AF2B84aaFE5e9c5C7c90B71D02F78D3184C60Ad )
          File 1 of 4: TransparentUpgradeableProxy
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
          pragma solidity ^0.8.0;
          import "../ERC1967/ERC1967Proxy.sol";
          /**
           * @dev This contract implements a proxy that is upgradeable by an admin.
           *
           * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
           * clashing], which can potentially be used in an attack, this contract uses the
           * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
           * things that go hand in hand:
           *
           * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
           * that call matches one of the admin functions exposed by the proxy itself.
           * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
           * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
           * "admin cannot fallback to proxy target".
           *
           * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
           * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
           * to sudden errors when trying to call a function from the proxy implementation.
           *
           * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
           * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
           */
          contract TransparentUpgradeableProxy is ERC1967Proxy {
              /**
               * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
               * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
               */
              constructor(
                  address _logic,
                  address admin_,
                  bytes memory _data
              ) payable ERC1967Proxy(_logic, _data) {
                  _changeAdmin(admin_);
              }
              /**
               * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
               */
              modifier ifAdmin() {
                  if (msg.sender == _getAdmin()) {
                      _;
                  } else {
                      _fallback();
                  }
              }
              /**
               * @dev Returns the current admin.
               *
               * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
               *
               * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
               * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
               * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
               */
              function admin() external ifAdmin returns (address admin_) {
                  admin_ = _getAdmin();
              }
              /**
               * @dev Returns the current implementation.
               *
               * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
               *
               * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
               * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
               * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
               */
              function implementation() external ifAdmin returns (address implementation_) {
                  implementation_ = _implementation();
              }
              /**
               * @dev Changes the admin of the proxy.
               *
               * Emits an {AdminChanged} event.
               *
               * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
               */
              function changeAdmin(address newAdmin) external virtual ifAdmin {
                  _changeAdmin(newAdmin);
              }
              /**
               * @dev Upgrade the implementation of the proxy.
               *
               * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
               */
              function upgradeTo(address newImplementation) external ifAdmin {
                  _upgradeToAndCall(newImplementation, bytes(""), false);
              }
              /**
               * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
               * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
               * proxied contract.
               *
               * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
               */
              function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                  _upgradeToAndCall(newImplementation, data, true);
              }
              /**
               * @dev Returns the current admin.
               */
              function _admin() internal view virtual returns (address) {
                  return _getAdmin();
              }
              /**
               * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
               */
              function _beforeFallback() internal virtual override {
                  require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                  super._beforeFallback();
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
          pragma solidity ^0.8.0;
          import "../Proxy.sol";
          import "./ERC1967Upgrade.sol";
          /**
           * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
           * implementation address that can be changed. This address is stored in storage in the location specified by
           * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
           * implementation behind the proxy.
           */
          contract ERC1967Proxy is Proxy, ERC1967Upgrade {
              /**
               * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
               *
               * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
               * function call, and allows initializing the storage of the proxy like a Solidity constructor.
               */
              constructor(address _logic, bytes memory _data) payable {
                  _upgradeToAndCall(_logic, _data, false);
              }
              /**
               * @dev Returns the current implementation address.
               */
              function _implementation() internal view virtual override returns (address impl) {
                  return ERC1967Upgrade._getImplementation();
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
           * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
           * be specified by overriding the virtual {_implementation} function.
           *
           * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
           * different contract through the {_delegate} function.
           *
           * The success and return data of the delegated call will be returned back to the caller of the proxy.
           */
          abstract contract Proxy {
              /**
               * @dev Delegates the current call to `implementation`.
               *
               * This function does not return to its internal call site, it will return directly to the external caller.
               */
              function _delegate(address implementation) internal virtual {
                  assembly {
                      // Copy msg.data. We take full control of memory in this inline assembly
                      // block because it will not return to Solidity code. We overwrite the
                      // Solidity scratch pad at memory position 0.
                      calldatacopy(0, 0, calldatasize())
                      // Call the implementation.
                      // out and outsize are 0 because we don't know the size yet.
                      let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                      // Copy the returned data.
                      returndatacopy(0, 0, returndatasize())
                      switch result
                      // delegatecall returns 0 on error.
                      case 0 {
                          revert(0, returndatasize())
                      }
                      default {
                          return(0, returndatasize())
                      }
                  }
              }
              /**
               * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
               * and {_fallback} should delegate.
               */
              function _implementation() internal view virtual returns (address);
              /**
               * @dev Delegates the current call to the address returned by `_implementation()`.
               *
               * This function does not return to its internal call site, it will return directly to the external caller.
               */
              function _fallback() internal virtual {
                  _beforeFallback();
                  _delegate(_implementation());
              }
              /**
               * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
               * function in the contract matches the call data.
               */
              fallback() external payable virtual {
                  _fallback();
              }
              /**
               * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
               * is empty.
               */
              receive() external payable virtual {
                  _fallback();
              }
              /**
               * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
               * call, or as part of the Solidity `fallback` or `receive` functions.
               *
               * If overridden should call `super._beforeFallback()`.
               */
              function _beforeFallback() internal virtual {}
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
          pragma solidity ^0.8.2;
          import "../beacon/IBeacon.sol";
          import "../../interfaces/draft-IERC1822.sol";
          import "../../utils/Address.sol";
          import "../../utils/StorageSlot.sol";
          /**
           * @dev This abstract contract provides getters and event emitting update functions for
           * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
           *
           * _Available since v4.1._
           *
           * @custom:oz-upgrades-unsafe-allow delegatecall
           */
          abstract contract ERC1967Upgrade {
              // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
              bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
              /**
               * @dev Storage slot with the address of the current implementation.
               * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
               * validated in the constructor.
               */
              bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
              /**
               * @dev Emitted when the implementation is upgraded.
               */
              event Upgraded(address indexed implementation);
              /**
               * @dev Returns the current implementation address.
               */
              function _getImplementation() internal view returns (address) {
                  return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
              }
              /**
               * @dev Stores a new address in the EIP1967 implementation slot.
               */
              function _setImplementation(address newImplementation) private {
                  require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                  StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
              }
              /**
               * @dev Perform implementation upgrade
               *
               * Emits an {Upgraded} event.
               */
              function _upgradeTo(address newImplementation) internal {
                  _setImplementation(newImplementation);
                  emit Upgraded(newImplementation);
              }
              /**
               * @dev Perform implementation upgrade with additional setup call.
               *
               * Emits an {Upgraded} event.
               */
              function _upgradeToAndCall(
                  address newImplementation,
                  bytes memory data,
                  bool forceCall
              ) internal {
                  _upgradeTo(newImplementation);
                  if (data.length > 0 || forceCall) {
                      Address.functionDelegateCall(newImplementation, data);
                  }
              }
              /**
               * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
               *
               * Emits an {Upgraded} event.
               */
              function _upgradeToAndCallUUPS(
                  address newImplementation,
                  bytes memory data,
                  bool forceCall
              ) internal {
                  // Upgrades from old implementations will perform a rollback test. This test requires the new
                  // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
                  // this special case will break upgrade paths from old UUPS implementation to new ones.
                  if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
                      _setImplementation(newImplementation);
                  } else {
                      try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                          require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
                      } catch {
                          revert("ERC1967Upgrade: new implementation is not UUPS");
                      }
                      _upgradeToAndCall(newImplementation, data, forceCall);
                  }
              }
              /**
               * @dev Storage slot with the admin of the contract.
               * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
               * validated in the constructor.
               */
              bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
              /**
               * @dev Emitted when the admin account has changed.
               */
              event AdminChanged(address previousAdmin, address newAdmin);
              /**
               * @dev Returns the current admin.
               */
              function _getAdmin() internal view returns (address) {
                  return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
              }
              /**
               * @dev Stores a new address in the EIP1967 admin slot.
               */
              function _setAdmin(address newAdmin) private {
                  require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                  StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
              }
              /**
               * @dev Changes the admin of the proxy.
               *
               * Emits an {AdminChanged} event.
               */
              function _changeAdmin(address newAdmin) internal {
                  emit AdminChanged(_getAdmin(), newAdmin);
                  _setAdmin(newAdmin);
              }
              /**
               * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
               * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
               */
              bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
              /**
               * @dev Emitted when the beacon is upgraded.
               */
              event BeaconUpgraded(address indexed beacon);
              /**
               * @dev Returns the current beacon.
               */
              function _getBeacon() internal view returns (address) {
                  return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
              }
              /**
               * @dev Stores a new beacon in the EIP1967 beacon slot.
               */
              function _setBeacon(address newBeacon) private {
                  require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
                  require(
                      Address.isContract(IBeacon(newBeacon).implementation()),
                      "ERC1967: beacon implementation is not a contract"
                  );
                  StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
              }
              /**
               * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
               * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
               *
               * Emits a {BeaconUpgraded} event.
               */
              function _upgradeBeaconToAndCall(
                  address newBeacon,
                  bytes memory data,
                  bool forceCall
              ) internal {
                  _setBeacon(newBeacon);
                  emit BeaconUpgraded(newBeacon);
                  if (data.length > 0 || forceCall) {
                      Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev This is the interface that {BeaconProxy} expects of its beacon.
           */
          interface IBeacon {
              /**
               * @dev Must return an address that can be used as a delegate call target.
               *
               * {BeaconProxy} will check that this address is a contract.
               */
              function implementation() external view returns (address);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
           * proxy whose upgrades are fully controlled by the current implementation.
           */
          interface IERC1822Proxiable {
              /**
               * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
               * address.
               *
               * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
               * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
               * function revert if invoked through a proxy.
               */
              function proxiableUUID() external view returns (bytes32);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
          pragma solidity ^0.8.1;
          /**
           * @dev Collection of functions related to the address type
           */
          library Address {
              /**
               * @dev Returns true if `account` is a contract.
               *
               * [IMPORTANT]
               * ====
               * It is unsafe to assume that an address for which this function returns
               * false is an externally-owned account (EOA) and not a contract.
               *
               * Among others, `isContract` will return false for the following
               * types of addresses:
               *
               *  - an externally-owned account
               *  - a contract in construction
               *  - an address where a contract will be created
               *  - an address where a contract lived, but was destroyed
               * ====
               *
               * [IMPORTANT]
               * ====
               * You shouldn't rely on `isContract` to protect against flash loan attacks!
               *
               * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
               * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
               * constructor.
               * ====
               */
              function isContract(address account) internal view returns (bool) {
                  // This method relies on extcodesize/address.code.length, which returns 0
                  // for contracts in construction, since the code is only stored at the end
                  // of the constructor execution.
                  return account.code.length > 0;
              }
              /**
               * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
               * `recipient`, forwarding all available gas and reverting on errors.
               *
               * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
               * of certain opcodes, possibly making contracts go over the 2300 gas limit
               * imposed by `transfer`, making them unable to receive funds via
               * `transfer`. {sendValue} removes this limitation.
               *
               * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
               *
               * IMPORTANT: because control is transferred to `recipient`, care must be
               * taken to not create reentrancy vulnerabilities. Consider using
               * {ReentrancyGuard} or the
               * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
               */
              function sendValue(address payable recipient, uint256 amount) internal {
                  require(address(this).balance >= amount, "Address: insufficient balance");
                  (bool success, ) = recipient.call{value: amount}("");
                  require(success, "Address: unable to send value, recipient may have reverted");
              }
              /**
               * @dev Performs a Solidity function call using a low level `call`. A
               * plain `call` is an unsafe replacement for a function call: use this
               * function instead.
               *
               * If `target` reverts with a revert reason, it is bubbled up by this
               * function (like regular Solidity function calls).
               *
               * Returns the raw returned data. To convert to the expected return value,
               * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
               *
               * Requirements:
               *
               * - `target` must be a contract.
               * - calling `target` with `data` must not revert.
               *
               * _Available since v3.1._
               */
              function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionCall(target, data, "Address: low-level call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
               * `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, 0, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but also transferring `value` wei to `target`.
               *
               * Requirements:
               *
               * - the calling contract must have an ETH balance of at least `value`.
               * - the called Solidity function must be `payable`.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
              }
              /**
               * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
               * with `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(address(this).balance >= value, "Address: insufficient balance for call");
                  require(isContract(target), "Address: call to non-contract");
                  (bool success, bytes memory returndata) = target.call{value: value}(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                  return functionStaticCall(target, data, "Address: low-level static call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal view returns (bytes memory) {
                  require(isContract(target), "Address: static call to non-contract");
                  (bool success, bytes memory returndata) = target.staticcall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionDelegateCall(target, data, "Address: low-level delegate call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(isContract(target), "Address: delegate call to non-contract");
                  (bool success, bytes memory returndata) = target.delegatecall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
               * revert reason using the provided one.
               *
               * _Available since v4.3._
               */
              function verifyCallResult(
                  bool success,
                  bytes memory returndata,
                  string memory errorMessage
              ) internal pure returns (bytes memory) {
                  if (success) {
                      return returndata;
                  } else {
                      // Look for revert reason and bubble it up if present
                      if (returndata.length > 0) {
                          // The easiest way to bubble the revert reason is using memory via assembly
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Library for reading and writing primitive types to specific storage slots.
           *
           * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
           * This library helps with reading and writing to such slots without the need for inline assembly.
           *
           * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
           *
           * Example usage to set ERC1967 implementation slot:
           * ```
           * contract ERC1967 {
           *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
           *
           *     function _getImplementation() internal view returns (address) {
           *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
           *     }
           *
           *     function _setImplementation(address newImplementation) internal {
           *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
           *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
           *     }
           * }
           * ```
           *
           * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
           */
          library StorageSlot {
              struct AddressSlot {
                  address value;
              }
              struct BooleanSlot {
                  bool value;
              }
              struct Bytes32Slot {
                  bytes32 value;
              }
              struct Uint256Slot {
                  uint256 value;
              }
              /**
               * @dev Returns an `AddressSlot` with member `value` located at `slot`.
               */
              function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                  /// @solidity memory-safe-assembly
                  assembly {
                      r.slot := slot
                  }
              }
              /**
               * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
               */
              function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                  /// @solidity memory-safe-assembly
                  assembly {
                      r.slot := slot
                  }
              }
              /**
               * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
               */
              function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                  /// @solidity memory-safe-assembly
                  assembly {
                      r.slot := slot
                  }
              }
              /**
               * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
               */
              function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                  /// @solidity memory-safe-assembly
                  assembly {
                      r.slot := slot
                  }
              }
          }
          

          File 2 of 4: EigenPodManager
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity =0.8.12;
          import "@openzeppelin/contracts/utils/Create2.sol";
          import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
          import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
          import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol";
          import "../interfaces/IBeaconChainOracle.sol";
          import "../permissions/Pausable.sol";
          import "./EigenPodPausingConstants.sol";
          import "./EigenPodManagerStorage.sol";
          /**
           * @title The contract used for creating and managing EigenPods
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice The main functionalities are:
           * - creating EigenPods
           * - staking for new validators on EigenPods
           * - keeping track of the restaked balances of all EigenPod owners
           * - withdrawing eth when withdrawals are completed
           */
          contract EigenPodManager is
              Initializable,
              OwnableUpgradeable,
              Pausable,
              EigenPodPausingConstants,
              EigenPodManagerStorage,
              ReentrancyGuardUpgradeable
          {
              
              modifier onlyEigenPod(address podOwner) {
                  require(address(ownerToPod[podOwner]) == msg.sender, "EigenPodManager.onlyEigenPod: not a pod");
                  _;
              }
              modifier onlyDelegationManager() {
                  require(
                      msg.sender == address(delegationManager),
                      "EigenPodManager.onlyDelegationManager: not the DelegationManager"
                  );
                  _;
              }
              constructor(
                  IETHPOSDeposit _ethPOS,
                  IBeacon _eigenPodBeacon,
                  IStrategyManager _strategyManager,
                  ISlasher _slasher,
                  IDelegationManager _delegationManager
              ) EigenPodManagerStorage(_ethPOS, _eigenPodBeacon, _strategyManager, _slasher, _delegationManager) {
                  _disableInitializers();
              }
              function initialize(
                  IBeaconChainOracle _beaconChainOracle,
                  address initialOwner,
                  IPauserRegistry _pauserRegistry,
                  uint256 _initPausedStatus
              ) external initializer {
                  _updateBeaconChainOracle(_beaconChainOracle);
                  _transferOwnership(initialOwner);
                  _initializePauser(_pauserRegistry, _initPausedStatus);
              }
              /**
               * @notice Creates an EigenPod for the sender.
               * @dev Function will revert if the `msg.sender` already has an EigenPod.
               * @dev Returns EigenPod address 
               */
              function createPod() external onlyWhenNotPaused(PAUSED_NEW_EIGENPODS) returns (address) {
                  require(!hasPod(msg.sender), "EigenPodManager.createPod: Sender already has a pod");
                  // deploy a pod if the sender doesn't have one already
                  IEigenPod pod = _deployPod();
                  return address(pod);
              }
              /**
               * @notice Stakes for a new beacon chain validator on the sender's EigenPod.
               * Also creates an EigenPod for the sender if they don't have one already.
               * @param pubkey The 48 bytes public key of the beacon chain validator.
               * @param signature The validator's signature of the deposit data.
               * @param depositDataRoot The root/hash of the deposit data for the validator's deposit.
               */
              function stake(
                  bytes calldata pubkey, 
                  bytes calldata signature, 
                  bytes32 depositDataRoot
              ) external payable onlyWhenNotPaused(PAUSED_NEW_EIGENPODS) {
                  IEigenPod pod = ownerToPod[msg.sender];
                  if (address(pod) == address(0)) {
                      //deploy a pod if the sender doesn't have one already
                      pod = _deployPod();
                  }
                  pod.stake{value: msg.value}(pubkey, signature, depositDataRoot);
              }
              /**
               * @notice Changes the `podOwner`'s shares by `sharesDelta` and performs a call to the DelegationManager
               * to ensure that delegated shares are also tracked correctly
               * @param podOwner is the pod owner whose balance is being updated.
               * @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares
               * @dev Callable only by the podOwner's EigenPod contract.
               * @dev Reverts if `sharesDelta` is not a whole Gwei amount
               */
              function recordBeaconChainETHBalanceUpdate(
                  address podOwner,
                  int256 sharesDelta
              ) external onlyEigenPod(podOwner) nonReentrant {
                  require(podOwner != address(0), "EigenPodManager.recordBeaconChainETHBalanceUpdate: podOwner cannot be zero address");
                  require(sharesDelta % int256(GWEI_TO_WEI) == 0,
                      "EigenPodManager.recordBeaconChainETHBalanceUpdate: sharesDelta must be a whole Gwei amount");
                  int256 currentPodOwnerShares = podOwnerShares[podOwner];
                  int256 updatedPodOwnerShares = currentPodOwnerShares + sharesDelta;
                  podOwnerShares[podOwner] = updatedPodOwnerShares;
                  // inform the DelegationManager of the change in delegateable shares
                  int256 changeInDelegatableShares = _calculateChangeInDelegatableShares({
                      sharesBefore: currentPodOwnerShares,
                      sharesAfter: updatedPodOwnerShares
                  });
                  // skip making a call to the DelegationManager if there is no change in delegateable shares
                  if (changeInDelegatableShares != 0) {
                      if (changeInDelegatableShares < 0) {
                          delegationManager.decreaseDelegatedShares({
                              staker: podOwner,
                              strategy: beaconChainETHStrategy,
                              shares: uint256(-changeInDelegatableShares)
                          });
                      } else {
                          delegationManager.increaseDelegatedShares({
                              staker: podOwner,
                              strategy: beaconChainETHStrategy,
                              shares: uint256(changeInDelegatableShares)
                          });
                      }
                  }
                  emit PodSharesUpdated(podOwner, sharesDelta);
              }
              /**
               * @notice Used by the DelegationManager to remove a pod owner's shares while they're in the withdrawal queue.
               * Simply decreases the `podOwner`'s shares by `shares`, down to a minimum of zero.
               * @dev This function reverts if it would result in `podOwnerShares[podOwner]` being less than zero, i.e. it is forbidden for this function to
               * result in the `podOwner` incurring a "share deficit". This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive
               * shares from the operator to whom the staker is delegated.
               * @dev Reverts if `shares` is not a whole Gwei amount
               * @dev The delegation manager validates that the podOwner is not address(0)
               */
              function removeShares(
                  address podOwner, 
                  uint256 shares
              ) external onlyDelegationManager {
                  require(int256(shares) >= 0, "EigenPodManager.removeShares: shares cannot be negative");
                  require(shares % GWEI_TO_WEI == 0, "EigenPodManager.removeShares: shares must be a whole Gwei amount");
                  int256 updatedPodOwnerShares = podOwnerShares[podOwner] - int256(shares);
                  require(updatedPodOwnerShares >= 0, "EigenPodManager.removeShares: cannot result in pod owner having negative shares");
                  podOwnerShares[podOwner] = updatedPodOwnerShares;
              }
              /**
               * @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible.
               * Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue
               * @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input
               * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero)
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function addShares(
                  address podOwner,
                  uint256 shares
              ) external onlyDelegationManager returns (uint256) {
                  require(podOwner != address(0), "EigenPodManager.addShares: podOwner cannot be zero address");
                  require(int256(shares) >= 0, "EigenPodManager.addShares: shares cannot be negative");
                  require(shares % GWEI_TO_WEI == 0, "EigenPodManager.addShares: shares must be a whole Gwei amount");
                  int256 currentPodOwnerShares = podOwnerShares[podOwner];
                  int256 updatedPodOwnerShares = currentPodOwnerShares + int256(shares);
                  podOwnerShares[podOwner] = updatedPodOwnerShares;
                  emit PodSharesUpdated(podOwner, int256(shares));
                  return uint256(_calculateChangeInDelegatableShares({sharesBefore: currentPodOwnerShares, sharesAfter: updatedPodOwnerShares}));
              }
              /**
               * @notice Used by the DelegationManager to complete a withdrawal, sending tokens to some destination address
               * @dev Prioritizes decreasing the podOwner's share deficit, if they have one
               * @dev Reverts if `shares` is not a whole Gwei amount
               * @dev This function assumes that `removeShares` has already been called by the delegationManager, hence why
               *      we do not need to update the podOwnerShares if `currentPodOwnerShares` is positive
               */
              function withdrawSharesAsTokens(
                  address podOwner, 
                  address destination, 
                  uint256 shares
              ) external onlyDelegationManager {
                  require(podOwner != address(0), "EigenPodManager.withdrawSharesAsTokens: podOwner cannot be zero address");
                  require(destination != address(0), "EigenPodManager.withdrawSharesAsTokens: destination cannot be zero address");
                  require(int256(shares) >= 0, "EigenPodManager.withdrawSharesAsTokens: shares cannot be negative");
                  require(shares % GWEI_TO_WEI == 0, "EigenPodManager.withdrawSharesAsTokens: shares must be a whole Gwei amount");
                  int256 currentPodOwnerShares = podOwnerShares[podOwner];
                  // if there is an existing shares deficit, prioritize decreasing the deficit first
                  if (currentPodOwnerShares < 0) {
                      uint256 currentShareDeficit = uint256(-currentPodOwnerShares);
                      // get rid of the whole deficit if possible, and pass any remaining shares onto destination
                      if (shares > currentShareDeficit) {
                          podOwnerShares[podOwner] = 0;
                          shares -= currentShareDeficit;
                          emit PodSharesUpdated(podOwner, int256(currentShareDeficit));
                      // otherwise get rid of as much deficit as possible, and return early, since there is nothing left over to forward on
                      } else {
                          podOwnerShares[podOwner] += int256(shares);
                          emit PodSharesUpdated(podOwner, int256(shares));
                          return;
                      }
                  }
                  // Actually withdraw to the destination
                  ownerToPod[podOwner].withdrawRestakedBeaconChainETH(destination, shares);
              }
              /**
               * @notice Updates the oracle contract that provides the beacon chain state root
               * @param newBeaconChainOracle is the new oracle contract being pointed to
               * @dev Callable only by the owner of this contract (i.e. governance)
               */
              function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external onlyOwner {
                  _updateBeaconChainOracle(newBeaconChainOracle);
              }
              /**
               * @notice Sets the timestamp of the Deneb fork.
               * @param newDenebForkTimestamp is the new timestamp of the Deneb fork
               */
              function setDenebForkTimestamp(uint64 newDenebForkTimestamp) external onlyOwner {
                  require(newDenebForkTimestamp != 0, "EigenPodManager.setDenebForkTimestamp: cannot set newDenebForkTimestamp to 0");
                  require(_denebForkTimestamp == 0, "EigenPodManager.setDenebForkTimestamp: cannot set denebForkTimestamp more than once");
                  
                  _denebForkTimestamp = newDenebForkTimestamp;
                  emit DenebForkTimestampUpdated(newDenebForkTimestamp);
              }
              // INTERNAL FUNCTIONS
              function _deployPod() internal returns (IEigenPod) {
                  ++numPods;
                  // create the pod
                  IEigenPod pod = IEigenPod(
                      Create2.deploy(
                          0,
                          bytes32(uint256(uint160(msg.sender))),
                          // set the beacon address to the eigenPodBeacon and initialize it
                          abi.encodePacked(beaconProxyBytecode, abi.encode(eigenPodBeacon, ""))
                      )
                  );
                  pod.initialize(msg.sender);
                  // store the pod in the mapping
                  ownerToPod[msg.sender] = pod;
                  emit PodDeployed(address(pod), msg.sender);
                  return pod;
              }
              /// @notice Internal setter for `beaconChainOracle` that also emits an event
              function _updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) internal {
                  beaconChainOracle = newBeaconChainOracle;
                  emit BeaconOracleUpdated(address(newBeaconChainOracle));
              }
              /**
               * @notice Calculates the change in a pod owner's delegateable shares as a result of their beacon chain ETH shares changing
               * from `sharesBefore` to `sharesAfter`. The key concept here is that negative/"deficit" shares are not delegateable.
               */
              function _calculateChangeInDelegatableShares(int256 sharesBefore, int256 sharesAfter) internal pure returns (int256) {
                  if (sharesBefore <= 0) {
                      // if the shares started negative and stayed negative, then there cannot have been an increase in delegateable shares
                      if (sharesAfter <= 0) {
                          return 0;
                      // if the shares started negative and became positive, then the increase in delegateable shares is the ending share amount
                      } else {
                          return sharesAfter;
                      }
                  } else {
                      // if the shares started positive and became negative, then the decrease in delegateable shares is the starting share amount
                      if (sharesAfter <= 0) {
                          return (-sharesBefore);
                      // if the shares started positive and stayed positive, then the change in delegateable shares
                      // is the difference between starting and ending amounts
                      } else {
                          return (sharesAfter - sharesBefore);
                      }
                  }
              }
              // VIEW FUNCTIONS
              /// @notice Returns the address of the `podOwner`'s EigenPod (whether it is deployed yet or not).
              function getPod(address podOwner) public view returns (IEigenPod) {
                  IEigenPod pod = ownerToPod[podOwner];
                  // if pod does not exist already, calculate what its address *will be* once it is deployed
                  if (address(pod) == address(0)) {
                      pod = IEigenPod(
                          Create2.computeAddress(
                              bytes32(uint256(uint160(podOwner))), //salt
                              keccak256(abi.encodePacked(beaconProxyBytecode, abi.encode(eigenPodBeacon, ""))) //bytecode
                          )
                      );
                  }
                  return pod;
              }
              /// @notice Returns 'true' if the `podOwner` has created an EigenPod, and 'false' otherwise.
              function hasPod(address podOwner) public view returns (bool) {
                  return address(ownerToPod[podOwner]) != address(0);
              }
              /// @notice Returns the Beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized.
              function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32) {
                  bytes32 stateRoot = beaconChainOracle.timestampToBlockRoot(timestamp);
                  require(
                      stateRoot != bytes32(0),
                      "EigenPodManager.getBlockRootAtTimestamp: state root at timestamp not yet finalized"
                  );
                  return stateRoot;
              }
              /**
               * @notice Wrapper around the `_denebForkTimestamp` storage variable that returns type(uint64).max if the storage variable is unset.
               * @dev This allows restricting the storage variable to be set once and only once.
               */
              function denebForkTimestamp() public view returns (uint64) {
                  uint64 timestamp = _denebForkTimestamp;
                  if (timestamp == 0) {
                      return type(uint64).max;
                  } else {
                      return timestamp;
                  }
              }
          }// SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
           * `CREATE2` can be used to compute in advance the address where a smart
           * contract will be deployed, which allows for interesting new mechanisms known
           * as 'counterfactual interactions'.
           *
           * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
           * information.
           */
          library Create2 {
              /**
               * @dev Deploys a contract using `CREATE2`. The address where the contract
               * will be deployed can be known in advance via {computeAddress}.
               *
               * The bytecode for a contract can be obtained from Solidity with
               * `type(contractName).creationCode`.
               *
               * Requirements:
               *
               * - `bytecode` must not be empty.
               * - `salt` must have not been used for `bytecode` already.
               * - the factory must have a balance of at least `amount`.
               * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
               */
              function deploy(
                  uint256 amount,
                  bytes32 salt,
                  bytes memory bytecode
              ) internal returns (address) {
                  address addr;
                  require(address(this).balance >= amount, "Create2: insufficient balance");
                  require(bytecode.length != 0, "Create2: bytecode length is zero");
                  /// @solidity memory-safe-assembly
                  assembly {
                      addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
                  }
                  require(addr != address(0), "Create2: Failed on deploy");
                  return addr;
              }
              /**
               * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
               * `bytecodeHash` or `salt` will result in a new destination address.
               */
              function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
                  return computeAddress(salt, bytecodeHash, address(this));
              }
              /**
               * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
               * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
               */
              function computeAddress(
                  bytes32 salt,
                  bytes32 bytecodeHash,
                  address deployer
              ) internal pure returns (address) {
                  bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
                  return address(uint160(uint256(_data)));
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
          pragma solidity ^0.8.2;
          import "../../utils/AddressUpgradeable.sol";
          /**
           * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
           * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
           * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
           * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
           *
           * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
           * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
           * case an upgrade adds a module that needs to be initialized.
           *
           * For example:
           *
           * [.hljs-theme-light.nopadding]
           * ```
           * contract MyToken is ERC20Upgradeable {
           *     function initialize() initializer public {
           *         __ERC20_init("MyToken", "MTK");
           *     }
           * }
           * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
           *     function initializeV2() reinitializer(2) public {
           *         __ERC20Permit_init("MyToken");
           *     }
           * }
           * ```
           *
           * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
           * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
           *
           * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
           * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
           *
           * [CAUTION]
           * ====
           * Avoid leaving a contract uninitialized.
           *
           * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
           * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
           * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
           *
           * [.hljs-theme-light.nopadding]
           * ```
           * /// @custom:oz-upgrades-unsafe-allow constructor
           * constructor() {
           *     _disableInitializers();
           * }
           * ```
           * ====
           */
          abstract contract Initializable {
              /**
               * @dev Indicates that the contract has been initialized.
               * @custom:oz-retyped-from bool
               */
              uint8 private _initialized;
              /**
               * @dev Indicates that the contract is in the process of being initialized.
               */
              bool private _initializing;
              /**
               * @dev Triggered when the contract has been initialized or reinitialized.
               */
              event Initialized(uint8 version);
              /**
               * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
               * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
               */
              modifier initializer() {
                  bool isTopLevelCall = !_initializing;
                  require(
                      (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                      "Initializable: contract is already initialized"
                  );
                  _initialized = 1;
                  if (isTopLevelCall) {
                      _initializing = true;
                  }
                  _;
                  if (isTopLevelCall) {
                      _initializing = false;
                      emit Initialized(1);
                  }
              }
              /**
               * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
               * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
               * used to initialize parent contracts.
               *
               * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
               * initialization step. This is essential to configure modules that are added through upgrades and that require
               * initialization.
               *
               * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
               * a contract, executing them in the right order is up to the developer or operator.
               */
              modifier reinitializer(uint8 version) {
                  require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                  _initialized = version;
                  _initializing = true;
                  _;
                  _initializing = false;
                  emit Initialized(version);
              }
              /**
               * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
               * {initializer} and {reinitializer} modifiers, directly or indirectly.
               */
              modifier onlyInitializing() {
                  require(_initializing, "Initializable: contract is not initializing");
                  _;
              }
              /**
               * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
               * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
               * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
               * through proxies.
               */
              function _disableInitializers() internal virtual {
                  require(!_initializing, "Initializable: contract is initializing");
                  if (_initialized < type(uint8).max) {
                      _initialized = type(uint8).max;
                      emit Initialized(type(uint8).max);
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
          pragma solidity ^0.8.0;
          import "../utils/ContextUpgradeable.sol";
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Contract module which provides a basic access control mechanism, where
           * there is an account (an owner) that can be granted exclusive access to
           * specific functions.
           *
           * By default, the owner account will be the one that deploys the contract. This
           * can later be changed with {transferOwnership}.
           *
           * This module is used through inheritance. It will make available the modifier
           * `onlyOwner`, which can be applied to your functions to restrict their use to
           * the owner.
           */
          abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
              address private _owner;
              event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
              /**
               * @dev Initializes the contract setting the deployer as the initial owner.
               */
              function __Ownable_init() internal onlyInitializing {
                  __Ownable_init_unchained();
              }
              function __Ownable_init_unchained() internal onlyInitializing {
                  _transferOwnership(_msgSender());
              }
              /**
               * @dev Throws if called by any account other than the owner.
               */
              modifier onlyOwner() {
                  _checkOwner();
                  _;
              }
              /**
               * @dev Returns the address of the current owner.
               */
              function owner() public view virtual returns (address) {
                  return _owner;
              }
              /**
               * @dev Throws if the sender is not the owner.
               */
              function _checkOwner() internal view virtual {
                  require(owner() == _msgSender(), "Ownable: caller is not the owner");
              }
              /**
               * @dev Leaves the contract without owner. It will not be possible to call
               * `onlyOwner` functions anymore. Can only be called by the current owner.
               *
               * NOTE: Renouncing ownership will leave the contract without an owner,
               * thereby removing any functionality that is only available to the owner.
               */
              function renounceOwnership() public virtual onlyOwner {
                  _transferOwnership(address(0));
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Can only be called by the current owner.
               */
              function transferOwnership(address newOwner) public virtual onlyOwner {
                  require(newOwner != address(0), "Ownable: new owner is the zero address");
                  _transferOwnership(newOwner);
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Internal function without access restriction.
               */
              function _transferOwnership(address newOwner) internal virtual {
                  address oldOwner = _owner;
                  _owner = newOwner;
                  emit OwnershipTransferred(oldOwner, newOwner);
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[49] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
          pragma solidity ^0.8.0;
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Contract module that helps prevent reentrant calls to a function.
           *
           * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
           * available, which can be applied to functions to make sure there are no nested
           * (reentrant) calls to them.
           *
           * Note that because there is a single `nonReentrant` guard, functions marked as
           * `nonReentrant` may not call one another. This can be worked around by making
           * those functions `private`, and then adding `external` `nonReentrant` entry
           * points to them.
           *
           * TIP: If you would like to learn more about reentrancy and alternative ways
           * to protect against it, check out our blog post
           * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
           */
          abstract contract ReentrancyGuardUpgradeable is Initializable {
              // Booleans are more expensive than uint256 or any type that takes up a full
              // word because each write operation emits an extra SLOAD to first read the
              // slot's contents, replace the bits taken up by the boolean, and then write
              // back. This is the compiler's defense against contract upgrades and
              // pointer aliasing, and it cannot be disabled.
              // The values being non-zero value makes deployment a bit more expensive,
              // but in exchange the refund on every call to nonReentrant will be lower in
              // amount. Since refunds are capped to a percentage of the total
              // transaction's gas, it is best to keep them low in cases like this one, to
              // increase the likelihood of the full refund coming into effect.
              uint256 private constant _NOT_ENTERED = 1;
              uint256 private constant _ENTERED = 2;
              uint256 private _status;
              function __ReentrancyGuard_init() internal onlyInitializing {
                  __ReentrancyGuard_init_unchained();
              }
              function __ReentrancyGuard_init_unchained() internal onlyInitializing {
                  _status = _NOT_ENTERED;
              }
              /**
               * @dev Prevents a contract from calling itself, directly or indirectly.
               * Calling a `nonReentrant` function from another `nonReentrant`
               * function is not supported. It is possible to prevent this from happening
               * by making the `nonReentrant` function external, and making it call a
               * `private` function that does the actual work.
               */
              modifier nonReentrant() {
                  // On the first call to nonReentrant, _notEntered will be true
                  require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                  // Any calls to nonReentrant after this point will fail
                  _status = _ENTERED;
                  _;
                  // By storing the original value once again, a refund is triggered (see
                  // https://eips.ethereum.org/EIPS/eip-2200)
                  _status = _NOT_ENTERED;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[49] private __gap;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title Interface for the BeaconStateOracle contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IBeaconChainOracle {
              /// @notice The block number to state root mapping.
              function timestampToBlockRoot(uint256 timestamp) external view returns (bytes32);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity =0.8.12;
          import "../interfaces/IPausable.sol";
          /**
           * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
           * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
           * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
           * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
           * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
           * you can only flip (any number of) switches to off/0 (aka "paused").
           * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
           * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
           * 2) update the paused state to this new value
           * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
           * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
           */
          contract Pausable is IPausable {
              /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
              IPauserRegistry public pauserRegistry;
              /// @dev whether or not the contract is currently paused
              uint256 private _paused;
              uint256 internal constant UNPAUSE_ALL = 0;
              uint256 internal constant PAUSE_ALL = type(uint256).max;
              /// @notice
              modifier onlyPauser() {
                  require(pauserRegistry.isPauser(msg.sender), "msg.sender is not permissioned as pauser");
                  _;
              }
              modifier onlyUnpauser() {
                  require(msg.sender == pauserRegistry.unpauser(), "msg.sender is not permissioned as unpauser");
                  _;
              }
              /// @notice Throws if the contract is paused, i.e. if any of the bits in `_paused` is flipped to 1.
              modifier whenNotPaused() {
                  require(_paused == 0, "Pausable: contract is paused");
                  _;
              }
              /// @notice Throws if the `indexed`th bit of `_paused` is 1, i.e. if the `index`th pause switch is flipped.
              modifier onlyWhenNotPaused(uint8 index) {
                  require(!paused(index), "Pausable: index is paused");
                  _;
              }
              /// @notice One-time function for setting the `pauserRegistry` and initializing the value of `_paused`.
              function _initializePauser(IPauserRegistry _pauserRegistry, uint256 initPausedStatus) internal {
                  require(
                      address(pauserRegistry) == address(0) && address(_pauserRegistry) != address(0),
                      "Pausable._initializePauser: _initializePauser() can only be called once"
                  );
                  _paused = initPausedStatus;
                  emit Paused(msg.sender, initPausedStatus);
                  _setPauserRegistry(_pauserRegistry);
              }
              /**
               * @notice This function is used to pause an EigenLayer contract's functionality.
               * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
               */
              function pause(uint256 newPausedStatus) external onlyPauser {
                  // verify that the `newPausedStatus` does not *unflip* any bits (i.e. doesn't unpause anything, all 1 bits remain)
                  require((_paused & newPausedStatus) == _paused, "Pausable.pause: invalid attempt to unpause functionality");
                  _paused = newPausedStatus;
                  emit Paused(msg.sender, newPausedStatus);
              }
              /**
               * @notice Alias for `pause(type(uint256).max)`.
               */
              function pauseAll() external onlyPauser {
                  _paused = type(uint256).max;
                  emit Paused(msg.sender, type(uint256).max);
              }
              /**
               * @notice This function is used to unpause an EigenLayer contract's functionality.
               * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
               */
              function unpause(uint256 newPausedStatus) external onlyUnpauser {
                  // verify that the `newPausedStatus` does not *flip* any bits (i.e. doesn't pause anything, all 0 bits remain)
                  require(
                      ((~_paused) & (~newPausedStatus)) == (~_paused),
                      "Pausable.unpause: invalid attempt to pause functionality"
                  );
                  _paused = newPausedStatus;
                  emit Unpaused(msg.sender, newPausedStatus);
              }
              /// @notice Returns the current paused status as a uint256.
              function paused() public view virtual returns (uint256) {
                  return _paused;
              }
              /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
              function paused(uint8 index) public view virtual returns (bool) {
                  uint256 mask = 1 << index;
                  return ((_paused & mask) == mask);
              }
              /// @notice Allows the unpauser to set a new pauser registry
              function setPauserRegistry(IPauserRegistry newPauserRegistry) external onlyUnpauser {
                  _setPauserRegistry(newPauserRegistry);
              }
              /// internal function for setting pauser registry
              function _setPauserRegistry(IPauserRegistry newPauserRegistry) internal {
                  require(
                      address(newPauserRegistry) != address(0),
                      "Pausable._setPauserRegistry: newPauserRegistry cannot be the zero address"
                  );
                  emit PauserRegistrySet(pauserRegistry, newPauserRegistry);
                  pauserRegistry = newPauserRegistry;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[48] private __gap;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity =0.8.12;
          /**
           * @title Constants shared between 'EigenPod' and 'EigenPodManager' contracts.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          abstract contract EigenPodPausingConstants {
              /// @notice Index for flag that pauses creation of new EigenPods when set. See EigenPodManager code for details.
              uint8 internal constant PAUSED_NEW_EIGENPODS = 0;
              /**
               * @notice Index for flag that pauses all withdrawal-of-restaked ETH related functionality `
               * function *of the EigenPodManager* when set. See EigenPodManager code for details.
               */
              uint8 internal constant PAUSED_WITHDRAW_RESTAKED_ETH = 1;
              /// @notice Index for flag that pauses the deposit related functions *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_CREDENTIALS = 2;
              /// @notice Index for flag that pauses the `verifyBalanceUpdate` function *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_BALANCE_UPDATE = 3;
              /// @notice Index for flag that pauses the `verifyBeaconChainFullWithdrawal` function *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_WITHDRAWAL = 4;
              /// @notice Pausability for EigenPod's "accidental transfer" withdrawal methods
              uint8 internal constant PAUSED_NON_PROOF_WITHDRAWALS = 5;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity =0.8.12;
          import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
          import "../interfaces/IStrategy.sol";
          import "../interfaces/IEigenPodManager.sol";
          import "../interfaces/IStrategyManager.sol";
          import "../interfaces/IDelegationManager.sol";
          import "../interfaces/IETHPOSDeposit.sol";
          import "../interfaces/IEigenPod.sol";
          abstract contract EigenPodManagerStorage is IEigenPodManager {
              /// @notice The ETH2 Deposit Contract
              IETHPOSDeposit public immutable ethPOS;
              /// @notice Beacon proxy to which the EigenPods point
              IBeacon public immutable eigenPodBeacon;
              /// @notice EigenLayer's StrategyManager contract
              IStrategyManager public immutable strategyManager;
              /// @notice EigenLayer's Slasher contract
              ISlasher public immutable slasher;
              /// @notice EigenLayer's DelegationManager contract
              IDelegationManager public immutable delegationManager;
              /**
               * @notice Stored code of type(BeaconProxy).creationCode
               * @dev Maintained as a constant to solve an edge case - changes to OpenZeppelin's BeaconProxy code should not cause
               * addresses of EigenPods that are pre-computed with Create2 to change, even upon upgrading this contract, changing compiler version, etc.
               */
              bytes internal constant beaconProxyBytecode =
                  hex"608060405260405161090e38038061090e83398101604081905261002291610460565b61002e82826000610035565b505061058a565b61003e83610100565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a260008251118061007f5750805b156100fb576100f9836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e99190610520565b836102a360201b6100291760201c565b505b505050565b610113816102cf60201b6100551760201c565b6101725760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6101e6816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d79190610520565b6102cf60201b6100551760201c565b61024b5760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610169565b806102827fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5060001b6102de60201b6100641760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606102c883836040518060600160405280602781526020016108e7602791396102e1565b9392505050565b6001600160a01b03163b151590565b90565b6060600080856001600160a01b0316856040516102fe919061053b565b600060405180830381855af49150503d8060008114610339576040519150601f19603f3d011682016040523d82523d6000602084013e61033e565b606091505b5090925090506103508683838761035a565b9695505050505050565b606083156103c65782516103bf576001600160a01b0385163b6103bf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610169565b50816103d0565b6103d083836103d8565b949350505050565b8151156103e85781518083602001fd5b8060405162461bcd60e51b81526004016101699190610557565b80516001600160a01b038116811461041957600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561044f578181015183820152602001610437565b838111156100f95750506000910152565b6000806040838503121561047357600080fd5b61047c83610402565b60208401519092506001600160401b038082111561049957600080fd5b818501915085601f8301126104ad57600080fd5b8151818111156104bf576104bf61041e565b604051601f8201601f19908116603f011681019083821181831017156104e7576104e761041e565b8160405282815288602084870101111561050057600080fd5b610511836020830160208801610434565b80955050505050509250929050565b60006020828403121561053257600080fd5b6102c882610402565b6000825161054d818460208701610434565b9190910192915050565b6020815260008251806020840152610576816040850160208701610434565b601f01601f19169190910160400192915050565b61034e806105996000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610067565b610100565b565b606061004e83836040518060600160405280602781526020016102f260279139610124565b9392505050565b6001600160a01b03163b151590565b90565b600061009a7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50546001600160a01b031690565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100fb9190610249565b905090565b3660008037600080366000845af43d6000803e80801561011f573d6000f35b3d6000fd5b6060600080856001600160a01b03168560405161014191906102a2565b600060405180830381855af49150503d806000811461017c576040519150601f19603f3d011682016040523d82523d6000602084013e610181565b606091505b50915091506101928683838761019c565b9695505050505050565b6060831561020d578251610206576001600160a01b0385163b6102065760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610217565b610217838361021f565b949350505050565b81511561022f5781518083602001fd5b8060405162461bcd60e51b81526004016101fd91906102be565b60006020828403121561025b57600080fd5b81516001600160a01b038116811461004e57600080fd5b60005b8381101561028d578181015183820152602001610275565b8381111561029c576000848401525b50505050565b600082516102b4818460208701610272565b9190910192915050565b60208152600082518060208401526102dd816040850160208701610272565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d51e81d3bc5ed20a26aeb05dce7e825c503b2061aa78628027300c8d65b9d89a64736f6c634300080c0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564";
              // @notice Internal constant used in calculations, since the beacon chain stores balances in Gwei rather than wei
              uint256 internal constant GWEI_TO_WEI = 1e9;
              /// @notice Canonical, virtual beacon chain ETH strategy
              IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0);
              /// @notice Oracle contract that provides updates to the beacon chain's state
              IBeaconChainOracle public beaconChainOracle;
              /// @notice Pod owner to deployed EigenPod address
              mapping(address => IEigenPod) public ownerToPod;
              // BEGIN STORAGE VARIABLES ADDED AFTER FIRST TESTNET DEPLOYMENT -- DO NOT SUGGEST REORDERING TO CONVENTIONAL ORDER
              /// @notice The number of EigenPods that have been deployed
              uint256 public numPods;
              /// @notice Deprecated from old mainnet release. Was initially used to limit growth early on but there is no longer
              /// a maximum number of EigenPods that can be deployed.
              uint256 private __deprecated_maxPods;
              // BEGIN STORAGE VARIABLES ADDED AFTER MAINNET DEPLOYMENT -- DO NOT SUGGEST REORDERING TO CONVENTIONAL ORDER
              /**
               * @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy.
               * @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can
               * decrease between the pod owner queuing and completing a withdrawal.
               * When the pod owner's shares would otherwise increase, this "deficit" is decreased first _instead_.
               * Likewise, when a withdrawal is completed, this "deficit" is decreased and the withdrawal amount is decreased; We can think of this
               * as the withdrawal "paying off the deficit".
               */
              mapping(address => int256) public podOwnerShares;
              uint64 internal _denebForkTimestamp;
              constructor(
                  IETHPOSDeposit _ethPOS,
                  IBeacon _eigenPodBeacon,
                  IStrategyManager _strategyManager,
                  ISlasher _slasher,
                  IDelegationManager _delegationManager
              ) {
                  ethPOS = _ethPOS;
                  eigenPodBeacon = _eigenPodBeacon;
                  strategyManager = _strategyManager;
                  slasher = _slasher;
                  delegationManager = _delegationManager;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[44] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
          pragma solidity ^0.8.1;
          /**
           * @dev Collection of functions related to the address type
           */
          library AddressUpgradeable {
              /**
               * @dev Returns true if `account` is a contract.
               *
               * [IMPORTANT]
               * ====
               * It is unsafe to assume that an address for which this function returns
               * false is an externally-owned account (EOA) and not a contract.
               *
               * Among others, `isContract` will return false for the following
               * types of addresses:
               *
               *  - an externally-owned account
               *  - a contract in construction
               *  - an address where a contract will be created
               *  - an address where a contract lived, but was destroyed
               * ====
               *
               * [IMPORTANT]
               * ====
               * You shouldn't rely on `isContract` to protect against flash loan attacks!
               *
               * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
               * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
               * constructor.
               * ====
               */
              function isContract(address account) internal view returns (bool) {
                  // This method relies on extcodesize/address.code.length, which returns 0
                  // for contracts in construction, since the code is only stored at the end
                  // of the constructor execution.
                  return account.code.length > 0;
              }
              /**
               * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
               * `recipient`, forwarding all available gas and reverting on errors.
               *
               * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
               * of certain opcodes, possibly making contracts go over the 2300 gas limit
               * imposed by `transfer`, making them unable to receive funds via
               * `transfer`. {sendValue} removes this limitation.
               *
               * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
               *
               * IMPORTANT: because control is transferred to `recipient`, care must be
               * taken to not create reentrancy vulnerabilities. Consider using
               * {ReentrancyGuard} or the
               * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
               */
              function sendValue(address payable recipient, uint256 amount) internal {
                  require(address(this).balance >= amount, "Address: insufficient balance");
                  (bool success, ) = recipient.call{value: amount}("");
                  require(success, "Address: unable to send value, recipient may have reverted");
              }
              /**
               * @dev Performs a Solidity function call using a low level `call`. A
               * plain `call` is an unsafe replacement for a function call: use this
               * function instead.
               *
               * If `target` reverts with a revert reason, it is bubbled up by this
               * function (like regular Solidity function calls).
               *
               * Returns the raw returned data. To convert to the expected return value,
               * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
               *
               * Requirements:
               *
               * - `target` must be a contract.
               * - calling `target` with `data` must not revert.
               *
               * _Available since v3.1._
               */
              function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionCall(target, data, "Address: low-level call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
               * `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, 0, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but also transferring `value` wei to `target`.
               *
               * Requirements:
               *
               * - the calling contract must have an ETH balance of at least `value`.
               * - the called Solidity function must be `payable`.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
              }
              /**
               * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
               * with `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(address(this).balance >= value, "Address: insufficient balance for call");
                  require(isContract(target), "Address: call to non-contract");
                  (bool success, bytes memory returndata) = target.call{value: value}(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                  return functionStaticCall(target, data, "Address: low-level static call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal view returns (bytes memory) {
                  require(isContract(target), "Address: static call to non-contract");
                  (bool success, bytes memory returndata) = target.staticcall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
               * revert reason using the provided one.
               *
               * _Available since v4.3._
               */
              function verifyCallResult(
                  bool success,
                  bytes memory returndata,
                  string memory errorMessage
              ) internal pure returns (bytes memory) {
                  if (success) {
                      return returndata;
                  } else {
                      // Look for revert reason and bubble it up if present
                      if (returndata.length > 0) {
                          // The easiest way to bubble the revert reason is using memory via assembly
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
          pragma solidity ^0.8.0;
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Provides information about the current execution context, including the
           * sender of the transaction and its data. While these are generally available
           * via msg.sender and msg.data, they should not be accessed in such a direct
           * manner, since when dealing with meta-transactions the account sending and
           * paying for execution may not be the actual sender (as far as an application
           * is concerned).
           *
           * This contract is only required for intermediate, library-like contracts.
           */
          abstract contract ContextUpgradeable is Initializable {
              function __Context_init() internal onlyInitializing {
              }
              function __Context_init_unchained() internal onlyInitializing {
              }
              function _msgSender() internal view virtual returns (address) {
                  return msg.sender;
              }
              function _msgData() internal view virtual returns (bytes calldata) {
                  return msg.data;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[50] private __gap;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "../interfaces/IPauserRegistry.sol";
          /**
           * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
           * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
           * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
           * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
           * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
           * you can only flip (any number of) switches to off/0 (aka "paused").
           * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
           * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
           * 2) update the paused state to this new value
           * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
           * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
           */
          interface IPausable {
              /// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`.
              event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry);
              /// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`.
              event Paused(address indexed account, uint256 newPausedStatus);
              /// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`.
              event Unpaused(address indexed account, uint256 newPausedStatus);
              
              /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
              function pauserRegistry() external view returns (IPauserRegistry);
              /**
               * @notice This function is used to pause an EigenLayer contract's functionality.
               * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
               */
              function pause(uint256 newPausedStatus) external;
              /**
               * @notice Alias for `pause(type(uint256).max)`.
               */
              function pauseAll() external;
              /**
               * @notice This function is used to unpause an EigenLayer contract's functionality.
               * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
               */
              function unpause(uint256 newPausedStatus) external;
              /// @notice Returns the current paused status as a uint256.
              function paused() external view returns (uint256);
              /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
              function paused(uint8 index) external view returns (bool);
              /// @notice Allows the unpauser to set a new pauser registry
              function setPauserRegistry(IPauserRegistry newPauserRegistry) external;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev This is the interface that {BeaconProxy} expects of its beacon.
           */
          interface IBeacon {
              /**
               * @dev Must return an address that can be used as a delegate call target.
               *
               * {BeaconProxy} will check that this address is a contract.
               */
              function implementation() external view returns (address);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
          /**
           * @title Minimal interface for an `Strategy` contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice Custom `Strategy` implementations may expand extensively on this interface.
           */
          interface IStrategy {
              /**
               * @notice Used to deposit tokens into this Strategy
               * @param token is the ERC20 token being deposited
               * @param amount is the amount of token being deposited
               * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
               * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.
               * @return newShares is the number of new shares issued at the current exchange ratio.
               */
              function deposit(IERC20 token, uint256 amount) external returns (uint256);
              /**
               * @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address
               * @param recipient is the address to receive the withdrawn funds
               * @param token is the ERC20 token being transferred out
               * @param amountShares is the amount of shares being withdrawn
               * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
               * other functions, and individual share balances are recorded in the strategyManager as well.
               */
              function withdraw(address recipient, IERC20 token, uint256 amountShares) external;
              /**
               * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
               * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications
               * @param amountShares is the amount of shares to calculate its conversion into the underlying token
               * @return The amount of underlying tokens corresponding to the input `amountShares`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function sharesToUnderlying(uint256 amountShares) external returns (uint256);
              /**
               * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
               * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications
               * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
               * @return The amount of underlying tokens corresponding to the input `amountShares`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function underlyingToShares(uint256 amountUnderlying) external returns (uint256);
              /**
               * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
               * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications
               */
              function userUnderlying(address user) external returns (uint256);
              /**
               * @notice convenience function for fetching the current total shares of `user` in this strategy, by
               * querying the `strategyManager` contract
               */
              function shares(address user) external view returns (uint256);
              /**
               * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
               * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications
               * @param amountShares is the amount of shares to calculate its conversion into the underlying token
               * @return The amount of shares corresponding to the input `amountUnderlying`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256);
              /**
               * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
               * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications
               * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
               * @return The amount of shares corresponding to the input `amountUnderlying`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256);
              /**
               * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
               * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications
               */
              function userUnderlyingView(address user) external view returns (uint256);
              /// @notice The underlying token for shares in this Strategy
              function underlyingToken() external view returns (IERC20);
              /// @notice The total number of extant shares in this Strategy
              function totalShares() external view returns (uint256);
              /// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that explains in more detail.
              function explanation() external view returns (string memory);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
          import "./IETHPOSDeposit.sol";
          import "./IStrategyManager.sol";
          import "./IEigenPod.sol";
          import "./IBeaconChainOracle.sol";
          import "./IPausable.sol";
          import "./ISlasher.sol";
          import "./IStrategy.sol";
          /**
           * @title Interface for factory that creates and manages solo staking pods that have their withdrawal credentials pointed to EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IEigenPodManager is IPausable {
              /// @notice Emitted to notify the update of the beaconChainOracle address
              event BeaconOracleUpdated(address indexed newOracleAddress);
              /// @notice Emitted to notify the deployment of an EigenPod
              event PodDeployed(address indexed eigenPod, address indexed podOwner);
              /// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager
              event BeaconChainETHDeposited(address indexed podOwner, uint256 amount);
              /// @notice Emitted when the balance of an EigenPod is updated
              event PodSharesUpdated(address indexed podOwner, int256 sharesDelta);
              /// @notice Emitted when a withdrawal of beacon chain ETH is completed
              event BeaconChainETHWithdrawalCompleted(
                  address indexed podOwner,
                  uint256 shares,
                  uint96 nonce,
                  address delegatedAddress,
                  address withdrawer,
                  bytes32 withdrawalRoot
              );
              event DenebForkTimestampUpdated(uint64 newValue);
              /**
               * @notice Creates an EigenPod for the sender.
               * @dev Function will revert if the `msg.sender` already has an EigenPod.
               * @dev Returns EigenPod address 
               */
              function createPod() external returns (address);
              /**
               * @notice Stakes for a new beacon chain validator on the sender's EigenPod.
               * Also creates an EigenPod for the sender if they don't have one already.
               * @param pubkey The 48 bytes public key of the beacon chain validator.
               * @param signature The validator's signature of the deposit data.
               * @param depositDataRoot The root/hash of the deposit data for the validator's deposit.
               */
              function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
              /**
               * @notice Changes the `podOwner`'s shares by `sharesDelta` and performs a call to the DelegationManager
               * to ensure that delegated shares are also tracked correctly
               * @param podOwner is the pod owner whose balance is being updated.
               * @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares
               * @dev Callable only by the podOwner's EigenPod contract.
               * @dev Reverts if `sharesDelta` is not a whole Gwei amount
               */
              function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external;
              /**
               * @notice Updates the oracle contract that provides the beacon chain state root
               * @param newBeaconChainOracle is the new oracle contract being pointed to
               * @dev Callable only by the owner of this contract (i.e. governance)
               */
              function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external;
              /// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed.
              function ownerToPod(address podOwner) external view returns (IEigenPod);
              /// @notice Returns the address of the `podOwner`'s EigenPod (whether it is deployed yet or not).
              function getPod(address podOwner) external view returns (IEigenPod);
              /// @notice The ETH2 Deposit Contract
              function ethPOS() external view returns (IETHPOSDeposit);
              /// @notice Beacon proxy to which the EigenPods point
              function eigenPodBeacon() external view returns (IBeacon);
              /// @notice Oracle contract that provides updates to the beacon chain's state
              function beaconChainOracle() external view returns (IBeaconChainOracle);
              /// @notice Returns the beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized.
              function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32);
              /// @notice EigenLayer's StrategyManager contract
              function strategyManager() external view returns (IStrategyManager);
              /// @notice EigenLayer's Slasher contract
              function slasher() external view returns (ISlasher);
              /// @notice Returns 'true' if the `podOwner` has created an EigenPod, and 'false' otherwise.
              function hasPod(address podOwner) external view returns (bool);
              /// @notice Returns the number of EigenPods that have been created
              function numPods() external view returns (uint256);
              /**
               * @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy.
               * @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can
               * decrease between the pod owner queuing and completing a withdrawal.
               * When the pod owner's shares would otherwise increase, this "deficit" is decreased first _instead_.
               * Likewise, when a withdrawal is completed, this "deficit" is decreased and the withdrawal amount is decreased; We can think of this
               * as the withdrawal "paying off the deficit".
               */
              function podOwnerShares(address podOwner) external view returns (int256);
              /// @notice returns canonical, virtual beaconChainETH strategy
              function beaconChainETHStrategy() external view returns (IStrategy);
              /**
               * @notice Used by the DelegationManager to remove a pod owner's shares while they're in the withdrawal queue.
               * Simply decreases the `podOwner`'s shares by `shares`, down to a minimum of zero.
               * @dev This function reverts if it would result in `podOwnerShares[podOwner]` being less than zero, i.e. it is forbidden for this function to
               * result in the `podOwner` incurring a "share deficit". This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive
               * shares from the operator to whom the staker is delegated.
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function removeShares(address podOwner, uint256 shares) external;
              /**
               * @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible.
               * Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue
               * @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input
               * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero)
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function addShares(address podOwner, uint256 shares) external returns (uint256);
              /**
               * @notice Used by the DelegationManager to complete a withdrawal, sending tokens to some destination address
               * @dev Prioritizes decreasing the podOwner's share deficit, if they have one
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external;
              /**
               * @notice the deneb hard fork timestamp used to determine which proof path to use for proving a withdrawal
               */
              function denebForkTimestamp() external view returns (uint64);
               /**
               * setting the deneb hard fork timestamp by the eigenPodManager owner
               * @dev this function is designed to be called twice.  Once, it is set to type(uint64).max 
               * prior to the actual deneb fork timestamp being set, and then the second time it is set 
               * to the actual deneb fork timestamp.
               */
              function setDenebForkTimestamp(uint64 newDenebForkTimestamp) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategy.sol";
          import "./ISlasher.sol";
          import "./IDelegationManager.sol";
          import "./IEigenPodManager.sol";
          /**
           * @title Interface for the primary entrypoint for funds into EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice See the `StrategyManager` contract itself for implementation details.
           */
          interface IStrategyManager {
              /**
               * @notice Emitted when a new deposit occurs on behalf of `staker`.
               * @param staker Is the staker who is depositing funds into EigenLayer.
               * @param strategy Is the strategy that `staker` has deposited into.
               * @param token Is the token that `staker` deposited.
               * @param shares Is the number of new shares `staker` has been granted in `strategy`.
               */
              event Deposit(address staker, IERC20 token, IStrategy strategy, uint256 shares);
              /// @notice Emitted when `thirdPartyTransfersForbidden` is updated for a strategy and value by the owner
              event UpdatedThirdPartyTransfersForbidden(IStrategy strategy, bool value);
              /// @notice Emitted when the `strategyWhitelister` is changed
              event StrategyWhitelisterChanged(address previousAddress, address newAddress);
              /// @notice Emitted when a strategy is added to the approved list of strategies for deposit
              event StrategyAddedToDepositWhitelist(IStrategy strategy);
              /// @notice Emitted when a strategy is removed from the approved list of strategies for deposit
              event StrategyRemovedFromDepositWhitelist(IStrategy strategy);
              /**
               * @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender`
               * @param strategy is the specified strategy where deposit is to be made,
               * @param token is the denomination in which the deposit is to be made,
               * @param amount is the amount of token to be deposited in the strategy by the staker
               * @return shares The amount of new shares in the `strategy` created as part of the action.
               * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
               * @dev Cannot be called by an address that is 'frozen' (this function will revert if the `msg.sender` is frozen).
               *
               * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
               *          where the token balance and corresponding strategy shares are not in sync upon reentrancy.
               */
              function depositIntoStrategy(IStrategy strategy, IERC20 token, uint256 amount) external returns (uint256 shares);
              /**
               * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`,
               * who must sign off on the action.
               * Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed
               * purely to help one address deposit 'for' another.
               * @param strategy is the specified strategy where deposit is to be made,
               * @param token is the denomination in which the deposit is to be made,
               * @param amount is the amount of token to be deposited in the strategy by the staker
               * @param staker the staker that the deposited assets will be credited to
               * @param expiry the timestamp at which the signature expires
               * @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward
               * following EIP-1271 if the `staker` is a contract
               * @return shares The amount of new shares in the `strategy` created as part of the action.
               * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
               * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those
               * targeting stakers who may be attempting to undelegate.
               * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy
               *
               *  WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
               *          where the token balance and corresponding strategy shares are not in sync upon reentrancy
               */
              function depositIntoStrategyWithSignature(
                  IStrategy strategy,
                  IERC20 token,
                  uint256 amount,
                  address staker,
                  uint256 expiry,
                  bytes memory signature
              ) external returns (uint256 shares);
              /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue
              function removeShares(address staker, IStrategy strategy, uint256 shares) external;
              /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue
              function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external;
              
              /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient
              function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external;
              /// @notice Returns the current shares of `user` in `strategy`
              function stakerStrategyShares(address user, IStrategy strategy) external view returns (uint256 shares);
              /**
               * @notice Get all details on the staker's deposits and corresponding shares
               * @return (staker's strategies, shares in these strategies)
               */
              function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory);
              /// @notice Simple getter function that returns `stakerStrategyList[staker].length`.
              function stakerStrategyListLength(address staker) external view returns (uint256);
              /**
               * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into
               * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already)
               * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy
               */
              function addStrategiesToDepositWhitelist(
                  IStrategy[] calldata strategiesToWhitelist,
                  bool[] calldata thirdPartyTransfersForbiddenValues
              ) external;
              /**
               * @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into
               * @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it)
               */
              function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) external;
              /// @notice Returns the single, central Delegation contract of EigenLayer
              function delegation() external view returns (IDelegationManager);
              /// @notice Returns the single, central Slasher contract of EigenLayer
              function slasher() external view returns (ISlasher);
              /// @notice Returns the EigenPodManager contract of EigenLayer
              function eigenPodManager() external view returns (IEigenPodManager);
              /// @notice Returns the address of the `strategyWhitelister`
              function strategyWhitelister() external view returns (address);
              /**
               * @notice Returns bool for whether or not `strategy` enables credit transfers. i.e enabling
               * depositIntoStrategyWithSignature calls or queueing withdrawals to a different address than the staker.
               */
              function thirdPartyTransfersForbidden(IStrategy strategy) external view returns (bool);
          // LIMITED BACKWARDS-COMPATIBILITY FOR DEPRECATED FUNCTIONALITY
              // packed struct for queued withdrawals; helps deal with stack-too-deep errors
              struct DeprecatedStruct_WithdrawerAndNonce {
                  address withdrawer;
                  uint96 nonce;
              }
              /**
               * Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
               * In functions that operate on existing queued withdrawals -- e.g. `startQueuedWithdrawalWaitingPeriod` or `completeQueuedWithdrawal`,
               * the data is resubmitted and the hash of the submitted data is computed by `calculateWithdrawalRoot` and checked against the
               * stored hash in order to confirm the integrity of the submitted data.
               */
              struct DeprecatedStruct_QueuedWithdrawal {
                  IStrategy[] strategies;
                  uint256[] shares;
                  address staker;
                  DeprecatedStruct_WithdrawerAndNonce withdrawerAndNonce;
                  uint32 withdrawalStartBlock;
                  address delegatedAddress;
              }
              function migrateQueuedWithdrawal(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external returns (bool, bytes32);
              function calculateWithdrawalRoot(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external pure returns (bytes32);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategy.sol";
          import "./ISignatureUtils.sol";
          import "./IStrategyManager.sol";
          /**
           * @title DelegationManager
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice  This is the contract for delegation in EigenLayer. The main functionalities of this contract are
           * - enabling anyone to register as an operator in EigenLayer
           * - allowing operators to specify parameters related to stakers who delegate to them
           * - enabling any staker to delegate its stake to the operator of its choice (a given staker can only delegate to a single operator at a time)
           * - enabling a staker to undelegate its assets from the operator it is delegated to (performed as part of the withdrawal process, initiated through the StrategyManager)
           */
          interface IDelegationManager is ISignatureUtils {
              // @notice Struct used for storing information about a single operator who has registered with EigenLayer
              struct OperatorDetails {
                  // @notice address to receive the rewards that the operator earns via serving applications built on EigenLayer.
                  address earningsReceiver;
                  /**
                   * @notice Address to verify signatures when a staker wishes to delegate to the operator, as well as controlling "forced undelegations".
                   * @dev Signature verification follows these rules:
                   * 1) If this address is left as address(0), then any staker will be free to delegate to the operator, i.e. no signature verification will be performed.
                   * 2) If this address is an EOA (i.e. it has no code), then we follow standard ECDSA signature verification for delegations to the operator.
                   * 3) If this address is a contract (i.e. it has code) then we forward a call to the contract and verify that it returns the correct EIP-1271 "magic value".
                   */
                  address delegationApprover;
                  /**
                   * @notice A minimum delay -- measured in blocks -- enforced between:
                   * 1) the operator signalling their intent to register for a service, via calling `Slasher.optIntoSlashing`
                   * and
                   * 2) the operator completing registration for the service, via the service ultimately calling `Slasher.recordFirstStakeUpdate`
                   * @dev note that for a specific operator, this value *cannot decrease*, i.e. if the operator wishes to modify their OperatorDetails,
                   * then they are only allowed to either increase this value or keep it the same.
                   */
                  uint32 stakerOptOutWindowBlocks;
              }
              /**
               * @notice Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator.
               * @dev Used in computing the `STAKER_DELEGATION_TYPEHASH` and as a reference in the computation of the stakerDigestHash in the `delegateToBySignature` function.
               */
              struct StakerDelegation {
                  // the staker who is delegating
                  address staker;
                  // the operator being delegated to
                  address operator;
                  // the staker's nonce
                  uint256 nonce;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              /**
               * @notice Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator.
               * @dev Used in computing the `DELEGATION_APPROVAL_TYPEHASH` and as a reference in the computation of the approverDigestHash in the `_delegate` function.
               */
              struct DelegationApproval {
                  // the staker who is delegating
                  address staker;
                  // the operator being delegated to
                  address operator;
                  // the operator's provided salt
                  bytes32 salt;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              /**
               * Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
               * In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal`, the data is resubmitted and the hash of the submitted
               * data is computed by `calculateWithdrawalRoot` and checked against the stored hash in order to confirm the integrity of the submitted data.
               */
              struct Withdrawal {
                  // The address that originated the Withdrawal
                  address staker;
                  // The address that the staker was delegated to at the time that the Withdrawal was created
                  address delegatedTo;
                  // The address that can complete the Withdrawal + will receive funds when completing the withdrawal
                  address withdrawer;
                  // Nonce used to guarantee that otherwise identical withdrawals have unique hashes
                  uint256 nonce;
                  // Block number when the Withdrawal was created
                  uint32 startBlock;
                  // Array of strategies that the Withdrawal contains
                  IStrategy[] strategies;
                  // Array containing the amount of shares in each Strategy in the `strategies` array
                  uint256[] shares;
              }
              struct QueuedWithdrawalParams {
                  // Array of strategies that the QueuedWithdrawal contains
                  IStrategy[] strategies;
                  // Array containing the amount of shares in each Strategy in the `strategies` array
                  uint256[] shares;
                  // The address of the withdrawer
                  address withdrawer;
              }
              // @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails.
              event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails);
              /// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails
              event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails);
              /**
               * @notice Emitted when @param operator indicates that they are updating their MetadataURI string
               * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
               */
              event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);
              /// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
              event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
              /// @notice Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares.
              event OperatorSharesDecreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
              /// @notice Emitted when @param staker delegates to @param operator.
              event StakerDelegated(address indexed staker, address indexed operator);
              /// @notice Emitted when @param staker undelegates from @param operator.
              event StakerUndelegated(address indexed staker, address indexed operator);
              /// @notice Emitted when @param staker is undelegated via a call not originating from the staker themself
              event StakerForceUndelegated(address indexed staker, address indexed operator);
              /**
               * @notice Emitted when a new withdrawal is queued.
               * @param withdrawalRoot Is the hash of the `withdrawal`.
               * @param withdrawal Is the withdrawal itself.
               */
              event WithdrawalQueued(bytes32 withdrawalRoot, Withdrawal withdrawal);
              /// @notice Emitted when a queued withdrawal is completed
              event WithdrawalCompleted(bytes32 withdrawalRoot);
              /// @notice Emitted when a queued withdrawal is *migrated* from the StrategyManager to the DelegationManager
              event WithdrawalMigrated(bytes32 oldWithdrawalRoot, bytes32 newWithdrawalRoot);
              
              /// @notice Emitted when the `minWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
              event MinWithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);
              /// @notice Emitted when the `strategyWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
              event StrategyWithdrawalDelayBlocksSet(IStrategy strategy, uint256 previousValue, uint256 newValue);
              /**
               * @notice Registers the caller as an operator in EigenLayer.
               * @param registeringOperatorDetails is the `OperatorDetails` for the operator.
               * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator.
               *
               * @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself".
               * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
               * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
               */
              function registerAsOperator(
                  OperatorDetails calldata registeringOperatorDetails,
                  string calldata metadataURI
              ) external;
              /**
               * @notice Updates an operator's stored `OperatorDetails`.
               * @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`.
               *
               * @dev The caller must have previously registered as an operator in EigenLayer.
               * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
               */
              function modifyOperatorDetails(OperatorDetails calldata newOperatorDetails) external;
              /**
               * @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated.
               * @param metadataURI The URI for metadata associated with an operator
               * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
               */
              function updateOperatorMetadataURI(string calldata metadataURI) external;
              /**
               * @notice Caller delegates their stake to an operator.
               * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer.
               * @param approverSignatureAndExpiry Verifies the operator approves of this delegation
               * @param approverSalt A unique single use value tied to an individual signature.
               * @dev The approverSignatureAndExpiry is used in the event that:
               *          1) the operator's `delegationApprover` address is set to a non-zero value.
               *                  AND
               *          2) neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator
               *             or their delegationApprover is the `msg.sender`, then approval is assumed.
               * @dev In the event that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
               * in this case to save on complexity + gas costs
               */
              function delegateTo(
                  address operator,
                  SignatureWithExpiry memory approverSignatureAndExpiry,
                  bytes32 approverSalt
              ) external;
              /**
               * @notice Caller delegates a staker's stake to an operator with valid signatures from both parties.
               * @param staker The account delegating stake to an `operator` account
               * @param operator The account (`staker`) is delegating its assets to for use in serving applications built on EigenLayer.
               * @param stakerSignatureAndExpiry Signed data from the staker authorizing delegating stake to an operator
               * @param approverSignatureAndExpiry is a parameter that will be used for verifying that the operator approves of this delegation action in the event that:
               * @param approverSalt Is a salt used to help guarantee signature uniqueness. Each salt can only be used once by a given approver.
               *
               * @dev If `staker` is an EOA, then `stakerSignature` is verified to be a valid ECDSA stakerSignature from `staker`, indicating their intention for this action.
               * @dev If `staker` is a contract, then `stakerSignature` will be checked according to EIP-1271.
               * @dev the operator's `delegationApprover` address is set to a non-zero value.
               * @dev neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator or their delegationApprover
               * is the `msg.sender`, then approval is assumed.
               * @dev This function will revert if the current `block.timestamp` is equal to or exceeds the expiry
               * @dev In the case that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
               * in this case to save on complexity + gas costs
               */
              function delegateToBySignature(
                  address staker,
                  address operator,
                  SignatureWithExpiry memory stakerSignatureAndExpiry,
                  SignatureWithExpiry memory approverSignatureAndExpiry,
                  bytes32 approverSalt
              ) external;
              /**
               * @notice Undelegates the staker from the operator who they are delegated to. Puts the staker into the "undelegation limbo" mode of the EigenPodManager
               * and queues a withdrawal of all of the staker's shares in the StrategyManager (to the staker), if necessary.
               * @param staker The account to be undelegated.
               * @return withdrawalRoot The root of the newly queued withdrawal, if a withdrawal was queued. Otherwise just bytes32(0).
               *
               * @dev Reverts if the `staker` is also an operator, since operators are not allowed to undelegate from themselves.
               * @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
               * @dev Reverts if the `staker` is already undelegated.
               */
              function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot);
              /**
               * Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed
               * from the staker. If the staker is delegated, withdrawn shares/strategies are also removed from
               * their operator.
               *
               * All withdrawn shares/strategies are placed in a queue and can be fully withdrawn after a delay.
               */
              function queueWithdrawals(
                  QueuedWithdrawalParams[] calldata queuedWithdrawalParams
              ) external returns (bytes32[] memory);
              /**
               * @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer`
               * @param withdrawal The Withdrawal to complete.
               * @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array.
               * This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused)
               * @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array
               * @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves
               * and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies
               * will simply be transferred to the caller directly.
               * @dev middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies `slasher.canWithdraw`
               * @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that
               * any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in
               * any other strategies, which will be transferred to the withdrawer.
               */
              function completeQueuedWithdrawal(
                  Withdrawal calldata withdrawal,
                  IERC20[] calldata tokens,
                  uint256 middlewareTimesIndex,
                  bool receiveAsTokens
              ) external;
              /**
               * @notice Array-ified version of `completeQueuedWithdrawal`.
               * Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer`
               * @param withdrawals The Withdrawals to complete.
               * @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array.
               * @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index.
               * @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean.
               * @dev See `completeQueuedWithdrawal` for relevant dev tags
               */
              function completeQueuedWithdrawals(
                  Withdrawal[] calldata withdrawals,
                  IERC20[][] calldata tokens,
                  uint256[] calldata middlewareTimesIndexes,
                  bool[] calldata receiveAsTokens
              ) external;
              /**
               * @notice Increases a staker's delegated share balance in a strategy.
               * @param staker The address to increase the delegated shares for their operator.
               * @param strategy The strategy in which to increase the delegated shares.
               * @param shares The number of shares to increase.
               *
               * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
               * @dev Callable only by the StrategyManager or EigenPodManager.
               */
              function increaseDelegatedShares(
                  address staker,
                  IStrategy strategy,
                  uint256 shares
              ) external;
              /**
               * @notice Decreases a staker's delegated share balance in a strategy.
               * @param staker The address to increase the delegated shares for their operator.
               * @param strategy The strategy in which to decrease the delegated shares.
               * @param shares The number of shares to decrease.
               *
               * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
               * @dev Callable only by the StrategyManager or EigenPodManager.
               */
              function decreaseDelegatedShares(
                  address staker,
                  IStrategy strategy,
                  uint256 shares
              ) external;
              /**
               * @notice returns the address of the operator that `staker` is delegated to.
               * @notice Mapping: staker => operator whom the staker is currently delegated to.
               * @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator.
               */
              function delegatedTo(address staker) external view returns (address);
              /**
               * @notice Returns the OperatorDetails struct associated with an `operator`.
               */
              function operatorDetails(address operator) external view returns (OperatorDetails memory);
              /*
               * @notice Returns the earnings receiver address for an operator
               */
              function earningsReceiver(address operator) external view returns (address);
              /**
               * @notice Returns the delegationApprover account for an operator
               */
              function delegationApprover(address operator) external view returns (address);
              /**
               * @notice Returns the stakerOptOutWindowBlocks for an operator
               */
              function stakerOptOutWindowBlocks(address operator) external view returns (uint256);
              /**
               * @notice Given array of strategies, returns array of shares for the operator
               */
              function getOperatorShares(
                  address operator,
                  IStrategy[] memory strategies
              ) external view returns (uint256[] memory);
              /**
               * @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw
               * from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay.
               * @param strategies The strategies to check withdrawal delays for
               */
              function getWithdrawalDelay(IStrategy[] calldata strategies) external view returns (uint256);
              /**
               * @notice returns the total number of shares in `strategy` that are delegated to `operator`.
               * @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator.
               * @dev By design, the following invariant should hold for each Strategy:
               * (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator)
               * = sum (delegateable shares of all stakers delegated to the operator)
               */
              function operatorShares(address operator, IStrategy strategy) external view returns (uint256);
              /**
               * @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise.
               */
              function isDelegated(address staker) external view returns (bool);
              /**
               * @notice Returns true is an operator has previously registered for delegation.
               */
              function isOperator(address operator) external view returns (bool);
              /// @notice Mapping: staker => number of signed delegation nonces (used in `delegateToBySignature`) from the staker that the contract has already checked
              function stakerNonce(address staker) external view returns (uint256);
              /**
               * @notice Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover.
               * @dev Salts are used in the `delegateTo` and `delegateToBySignature` functions. Note that these functions only process the delegationApprover's
               * signature + the provided salt if the operator being delegated to has specified a nonzero address as their `delegationApprover`.
               */
              function delegationApproverSaltIsSpent(address _delegationApprover, bytes32 salt) external view returns (bool);
              /**
               * @notice Minimum delay enforced by this contract for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
               * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
               * Note that strategies each have a separate withdrawal delay, which can be greater than this value. So the minimum number of blocks that must pass
               * to withdraw a strategy is MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy])
               */
              function minWithdrawalDelayBlocks() external view returns (uint256);
              /**
               * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
               * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
               */
              function strategyWithdrawalDelayBlocks(IStrategy strategy) external view returns (uint256);
              /**
               * @notice Calculates the digestHash for a `staker` to sign to delegate to an `operator`
               * @param staker The signing staker
               * @param operator The operator who is being delegated to
               * @param expiry The desired expiry time of the staker's signature
               */
              function calculateCurrentStakerDelegationDigestHash(
                  address staker,
                  address operator,
                  uint256 expiry
              ) external view returns (bytes32);
              /**
               * @notice Calculates the digest hash to be signed and used in the `delegateToBySignature` function
               * @param staker The signing staker
               * @param _stakerNonce The nonce of the staker. In practice we use the staker's current nonce, stored at `stakerNonce[staker]`
               * @param operator The operator who is being delegated to
               * @param expiry The desired expiry time of the staker's signature
               */
              function calculateStakerDelegationDigestHash(
                  address staker,
                  uint256 _stakerNonce,
                  address operator,
                  uint256 expiry
              ) external view returns (bytes32);
              /**
               * @notice Calculates the digest hash to be signed by the operator's delegationApprove and used in the `delegateTo` and `delegateToBySignature` functions.
               * @param staker The account delegating their stake
               * @param operator The account receiving delegated stake
               * @param _delegationApprover the operator's `delegationApprover` who will be signing the delegationHash (in general)
               * @param approverSalt A unique and single use value associated with the approver signature.
               * @param expiry Time after which the approver's signature becomes invalid
               */
              function calculateDelegationApprovalDigestHash(
                  address staker,
                  address operator,
                  address _delegationApprover,
                  bytes32 approverSalt,
                  uint256 expiry
              ) external view returns (bytes32);
              /// @notice The EIP-712 typehash for the contract's domain
              function DOMAIN_TYPEHASH() external view returns (bytes32);
              /// @notice The EIP-712 typehash for the StakerDelegation struct used by the contract
              function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32);
              /// @notice The EIP-712 typehash for the DelegationApproval struct used by the contract
              function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32);
              /**
               * @notice Getter function for the current EIP-712 domain separator for this contract.
               *
               * @dev The domain separator will change in the event of a fork that changes the ChainID.
               * @dev By introducing a domain separator the DApp developers are guaranteed that there can be no signature collision.
               * for more detailed information please read EIP-712.
               */
              function domainSeparator() external view returns (bytes32);
              
              /// @notice Mapping: staker => cumulative number of queued withdrawals they have ever initiated.
              /// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
              function cumulativeWithdrawalsQueued(address staker) external view returns (uint256);
              /// @notice Returns the keccak256 hash of `withdrawal`.
              function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32);
              function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external;
          }
          // ┏━━━┓━┏┓━┏┓━━┏━━━┓━━┏━━━┓━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━┏┓━━━━━┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━━┏┓━
          // ┃┏━━┛┏┛┗┓┃┃━━┃┏━┓┃━━┃┏━┓┃━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━┏┛┗┓━━━━┃┏━┓┃━━━━━━━━┏┛┗┓━━━━━━━━━━━━┏┛┗┓
          // ┃┗━━┓┗┓┏┛┃┗━┓┗┛┏┛┃━━┃┃━┃┃━━━━━┃┃┃┃┏━━┓┏━━┓┏━━┓┏━━┓┏┓┗┓┏┛━━━━┃┃━┗┛┏━━┓┏━┓━┗┓┏┛┏━┓┏━━┓━┏━━┓┗┓┏┛
          // ┃┏━━┛━┃┃━┃┏┓┃┏━┛┏┛━━┃┃━┃┃━━━━━┃┃┃┃┃┏┓┃┃┏┓┃┃┏┓┃┃━━┫┣┫━┃┃━━━━━┃┃━┏┓┃┏┓┃┃┏┓┓━┃┃━┃┏┛┗━┓┃━┃┏━┛━┃┃━
          // ┃┗━━┓━┃┗┓┃┃┃┃┃┃┗━┓┏┓┃┗━┛┃━━━━┏┛┗┛┃┃┃━┫┃┗┛┃┃┗┛┃┣━━┃┃┃━┃┗┓━━━━┃┗━┛┃┃┗┛┃┃┃┃┃━┃┗┓┃┃━┃┗┛┗┓┃┗━┓━┃┗┓
          // ┗━━━┛━┗━┛┗┛┗┛┗━━━┛┗┛┗━━━┛━━━━┗━━━┛┗━━┛┃┏━┛┗━━┛┗━━┛┗┛━┗━┛━━━━┗━━━┛┗━━┛┗┛┗┛━┗━┛┗┛━┗━━━┛┗━━┛━┗━┛
          // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
          // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
          // SPDX-License-Identifier: CC0-1.0
          pragma solidity >=0.5.0;
          // This interface is designed to be compatible with the Vyper version.
          /// @notice This is the Ethereum 2.0 deposit contract interface.
          /// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs
          interface IETHPOSDeposit {
              /// @notice A processed deposit event.
              event DepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index);
              /// @notice Submit a Phase 0 DepositData object.
              /// @param pubkey A BLS12-381 public key.
              /// @param withdrawal_credentials Commitment to a public key for withdrawals.
              /// @param signature A BLS12-381 signature.
              /// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object.
              /// Used as a protection against malformed input.
              function deposit(
                  bytes calldata pubkey,
                  bytes calldata withdrawal_credentials,
                  bytes calldata signature,
                  bytes32 deposit_data_root
              ) external payable;
              /// @notice Query the current deposit root hash.
              /// @return The deposit root hash.
              function get_deposit_root() external view returns (bytes32);
              /// @notice Query the current deposit count.
              /// @return The deposit count encoded as a little endian 64-bit number.
              function get_deposit_count() external view returns (bytes memory);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "../libraries/BeaconChainProofs.sol";
          import "./IEigenPodManager.sol";
          import "./IBeaconChainOracle.sol";
          import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
          /**
           * @title The implementation contract used for restaking beacon chain ETH on EigenLayer
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice The main functionalities are:
           * - creating new ETH validators with their withdrawal credentials pointed to this contract
           * - proving from beacon chain state roots that withdrawal credentials are pointed to this contract
           * - proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials
           *   pointed to this contract
           * - updating aggregate balances in the EigenPodManager
           * - withdrawing eth when withdrawals are initiated
           * @dev Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose
           *   to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts
           */
          interface IEigenPod {
              enum VALIDATOR_STATUS {
                  INACTIVE, // doesnt exist
                  ACTIVE, // staked on ethpos and withdrawal credentials are pointed to the EigenPod
                  WITHDRAWN // withdrawn from the Beacon Chain
              }
              struct ValidatorInfo {
                  // index of the validator in the beacon chain
                  uint64 validatorIndex;
                  // amount of beacon chain ETH restaked on EigenLayer in gwei
                  uint64 restakedBalanceGwei;
                  //timestamp of the validator's most recent balance update
                  uint64 mostRecentBalanceUpdateTimestamp;
                  // status of the validator
                  VALIDATOR_STATUS status;
              }
              /**
               * @notice struct used to store amounts related to proven withdrawals in memory. Used to help
               * manage stack depth and optimize the number of external calls, when batching withdrawal operations.
               */
              struct VerifiedWithdrawal {
                  // amount to send to a podOwner from a proven withdrawal
                  uint256 amountToSendGwei;
                  // difference in shares to be recorded in the eigenPodManager, as a result of the withdrawal
                  int256 sharesDeltaGwei;
              }
              enum PARTIAL_WITHDRAWAL_CLAIM_STATUS {
                  REDEEMED,
                  PENDING,
                  FAILED
              }
              /// @notice Emitted when an ETH validator stakes via this eigenPod
              event EigenPodStaked(bytes pubkey);
              /// @notice Emitted when an ETH validator's withdrawal credentials are successfully verified to be pointed to this eigenPod
              event ValidatorRestaked(uint40 validatorIndex);
              /// @notice Emitted when an ETH validator's  balance is proven to be updated.  Here newValidatorBalanceGwei
              //  is the validator's balance that is credited on EigenLayer.
              event ValidatorBalanceUpdated(uint40 validatorIndex, uint64 balanceTimestamp, uint64 newValidatorBalanceGwei);
              /// @notice Emitted when an ETH validator is prove to have withdrawn from the beacon chain
              event FullWithdrawalRedeemed(
                  uint40 validatorIndex,
                  uint64 withdrawalTimestamp,
                  address indexed recipient,
                  uint64 withdrawalAmountGwei
              );
              /// @notice Emitted when a partial withdrawal claim is successfully redeemed
              event PartialWithdrawalRedeemed(
                  uint40 validatorIndex,
                  uint64 withdrawalTimestamp,
                  address indexed recipient,
                  uint64 partialWithdrawalAmountGwei
              );
              /// @notice Emitted when restaked beacon chain ETH is withdrawn from the eigenPod.
              event RestakedBeaconChainETHWithdrawn(address indexed recipient, uint256 amount);
              /// @notice Emitted when podOwner enables restaking
              event RestakingActivated(address indexed podOwner);
              /// @notice Emitted when ETH is received via the `receive` fallback
              event NonBeaconChainETHReceived(uint256 amountReceived);
              /// @notice Emitted when ETH that was previously received via the `receive` fallback is withdrawn
              event NonBeaconChainETHWithdrawn(address indexed recipient, uint256 amountWithdrawn);
              /// @notice The max amount of eth, in gwei, that can be restaked per validator
              function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns (uint64);
              /// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer),
              function withdrawableRestakedExecutionLayerGwei() external view returns (uint64);
              /// @notice any ETH deposited into the EigenPod contract via the `receive` fallback function
              function nonBeaconChainETHBalanceWei() external view returns (uint256);
              /// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager
              function initialize(address owner) external;
              /// @notice Called by EigenPodManager when the owner wants to create another ETH validator.
              function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
              /**
               * @notice Transfers `amountWei` in ether from this contract to the specified `recipient` address
               * @notice Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain.
               * @dev The podOwner must have already proved sufficient withdrawals, so that this pod's `withdrawableRestakedExecutionLayerGwei` exceeds the
               * `amountWei` input (when converted to GWEI).
               * @dev Reverts if `amountWei` is not a whole Gwei amount
               */
              function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external;
              /// @notice The single EigenPodManager for EigenLayer
              function eigenPodManager() external view returns (IEigenPodManager);
              /// @notice The owner of this EigenPod
              function podOwner() external view returns (address);
              /// @notice an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling `verifyCorrectWithdrawalCredentials`.
              function hasRestaked() external view returns (bool);
              /**
               * @notice The latest timestamp at which the pod owner withdrew the balance of the pod, via calling `withdrawBeforeRestaking`.
               * @dev This variable is only updated when the `withdrawBeforeRestaking` function is called, which can only occur before `hasRestaked` is set to true for this pod.
               * Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored `mostRecentWithdrawalTimestamp`.
               */
              function mostRecentWithdrawalTimestamp() external view returns (uint64);
              /// @notice Returns the validatorInfo struct for the provided pubkeyHash
              function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory);
              /// @notice Returns the validatorInfo struct for the provided pubkey
              function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory);
              ///@notice mapping that tracks proven withdrawals
              function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool);
              /// @notice This returns the status of a given validator
              function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS);
              /// @notice This returns the status of a given validator pubkey
              function validatorStatus(bytes calldata validatorPubkey) external view returns (VALIDATOR_STATUS);
              /**
               * @notice This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to
               * this contract. It also verifies the effective balance  of the validator.  It verifies the provided proof of the ETH validator against the beacon chain state
               * root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer.
               * @param oracleTimestamp is the Beacon Chain timestamp whose state root the `proof` will be proven against.
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs
               * @param withdrawalCredentialProofs is an array of proofs, where each proof proves each ETH validator's balance and withdrawal credentials
               * against a beacon chain state root
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyWithdrawalCredentials(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  uint40[] calldata validatorIndices,
                  bytes[] calldata withdrawalCredentialProofs,
                  bytes32[][] calldata validatorFields
              )
                  external;
              /**
               * @notice This function records an update (either increase or decrease) in the pod's balance in the StrategyManager.  
                         It also verifies a merkle proof of the validator's current beacon chain balance.  
               * @param oracleTimestamp The oracleTimestamp whose state root the `proof` will be proven against.
               *        Must be within `VERIFY_BALANCE_UPDATE_WINDOW_SECONDS` of the current block.
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs 
               * @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields`
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * @dev For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyBalanceUpdates(
                  uint64 oracleTimestamp,
                  uint40[] calldata validatorIndices,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields
              ) external;
              /**
               * @notice This function records full and partial withdrawals on behalf of one of the Ethereum validators for this EigenPod
               * @param oracleTimestamp is the timestamp of the oracle slot that the withdrawal is being proven against
               * @param withdrawalProofs is the information needed to check the veracity of the block numbers and withdrawals being proven
               * @param validatorFieldsProofs is the proof of the validator's fields' in the validator tree
               * @param withdrawalFields are the fields of the withdrawals being proven
               * @param validatorFields are the fields of the validators being proven
               */
              function verifyAndProcessWithdrawals(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  BeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields,
                  bytes32[][] calldata withdrawalFields
              ) external;
              /**
               * @notice Called by the pod owner to activate restaking by withdrawing
               * all existing ETH from the pod and preventing further withdrawals via
               * "withdrawBeforeRestaking()"
               */
              function activateRestaking() external;
              /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false
              function withdrawBeforeRestaking() external;
              /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei
              function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external;
              /// @notice called by owner of a pod to remove any ERC20s deposited in the pod
              function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title Interface for the `PauserRegistry` contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IPauserRegistry {
              event PauserStatusChanged(address pauser, bool canPause);
              event UnpauserChanged(address previousUnpauser, address newUnpauser);
              
              /// @notice Mapping of addresses to whether they hold the pauser role.
              function isPauser(address pauser) external view returns (bool);
              /// @notice Unique address that holds the unpauser role. Capable of changing *both* the pauser and unpauser addresses.
              function unpauser() external view returns (address);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Interface of the ERC20 standard as defined in the EIP.
           */
          interface IERC20 {
              /**
               * @dev Emitted when `value` tokens are moved from one account (`from`) to
               * another (`to`).
               *
               * Note that `value` may be zero.
               */
              event Transfer(address indexed from, address indexed to, uint256 value);
              /**
               * @dev Emitted when the allowance of a `spender` for an `owner` is set by
               * a call to {approve}. `value` is the new allowance.
               */
              event Approval(address indexed owner, address indexed spender, uint256 value);
              /**
               * @dev Returns the amount of tokens in existence.
               */
              function totalSupply() external view returns (uint256);
              /**
               * @dev Returns the amount of tokens owned by `account`.
               */
              function balanceOf(address account) external view returns (uint256);
              /**
               * @dev Moves `amount` tokens from the caller's account to `to`.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * Emits a {Transfer} event.
               */
              function transfer(address to, uint256 amount) external returns (bool);
              /**
               * @dev Returns the remaining number of tokens that `spender` will be
               * allowed to spend on behalf of `owner` through {transferFrom}. This is
               * zero by default.
               *
               * This value changes when {approve} or {transferFrom} are called.
               */
              function allowance(address owner, address spender) external view returns (uint256);
              /**
               * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * IMPORTANT: Beware that changing an allowance with this method brings the risk
               * that someone may use both the old and the new allowance by unfortunate
               * transaction ordering. One possible solution to mitigate this race
               * condition is to first reduce the spender's allowance to 0 and set the
               * desired value afterwards:
               * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
               *
               * Emits an {Approval} event.
               */
              function approve(address spender, uint256 amount) external returns (bool);
              /**
               * @dev Moves `amount` tokens from `from` to `to` using the
               * allowance mechanism. `amount` is then deducted from the caller's
               * allowance.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * Emits a {Transfer} event.
               */
              function transferFrom(
                  address from,
                  address to,
                  uint256 amount
              ) external returns (bool);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategyManager.sol";
          import "./IDelegationManager.sol";
          /**
           * @title Interface for the primary 'slashing' contract for EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice See the `Slasher` contract itself for implementation details.
           */
          interface ISlasher {
              // struct used to store information about the current state of an operator's obligations to middlewares they are serving
              struct MiddlewareTimes {
                  // The update block for the middleware whose most recent update was earliest, i.e. the 'stalest' update out of all middlewares the operator is serving
                  uint32 stalestUpdateBlock;
                  // The latest 'serveUntilBlock' from all of the middleware that the operator is serving
                  uint32 latestServeUntilBlock;
              }
              // struct used to store details relevant to a single middleware that an operator has opted-in to serving
              struct MiddlewareDetails {
                  // the block at which the contract begins being able to finalize the operator's registration with the service via calling `recordFirstStakeUpdate`
                  uint32 registrationMayBeginAtBlock;
                  // the block before which the contract is allowed to slash the user
                  uint32 contractCanSlashOperatorUntilBlock;
                  // the block at which the middleware's view of the operator's stake was most recently updated
                  uint32 latestUpdateBlock;
              }
              /// @notice Emitted when a middleware times is added to `operator`'s array.
              event MiddlewareTimesAdded(
                  address operator,
                  uint256 index,
                  uint32 stalestUpdateBlock,
                  uint32 latestServeUntilBlock
              );
              /// @notice Emitted when `operator` begins to allow `contractAddress` to slash them.
              event OptedIntoSlashing(address indexed operator, address indexed contractAddress);
              /// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilBlock`.
              event SlashingAbilityRevoked(
                  address indexed operator,
                  address indexed contractAddress,
                  uint32 contractCanSlashOperatorUntilBlock
              );
              /**
               * @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`.
               * @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'.
               */
              event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract);
              /// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within EigenLayer.
              event FrozenStatusReset(address indexed previouslySlashedAddress);
              /**
               * @notice Gives the `contractAddress` permission to slash the funds of the caller.
               * @dev Typically, this function must be called prior to registering for a middleware.
               */
              function optIntoSlashing(address contractAddress) external;
              /**
               * @notice Used for 'slashing' a certain operator.
               * @param toBeFrozen The operator to be frozen.
               * @dev Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop.
               * @dev The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to `optIntoSlashing`.
               */
              function freezeOperator(address toBeFrozen) external;
              /**
               * @notice Removes the 'frozen' status from each of the `frozenAddresses`
               * @dev Callable only by the contract owner (i.e. governance).
               */
              function resetFrozenStatus(address[] calldata frozenAddresses) external;
              /**
               * @notice this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration
               *         is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at the current block is slashable
               * @dev adds the middleware's slashing contract to the operator's linked list
               */
              function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external;
              /**
               * @notice this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals)
               *         to make sure the operator's stake at updateBlock is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param updateBlock the block for which the stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at updateBlock is slashable
               * @param insertAfter the element of the operators linked list that the currently updating middleware should be inserted after
               * @dev insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions,
               *      but it is anticipated to be rare and not detrimental.
               */
              function recordStakeUpdate(
                  address operator,
                  uint32 updateBlock,
                  uint32 serveUntilBlock,
                  uint256 insertAfter
              ) external;
              /**
               * @notice this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration
               *         is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at the current block is slashable
               * @dev removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to
               * slash `operator` once `serveUntil` is reached
               */
              function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external;
              /// @notice The StrategyManager contract of EigenLayer
              function strategyManager() external view returns (IStrategyManager);
              /// @notice The DelegationManager contract of EigenLayer
              function delegation() external view returns (IDelegationManager);
              /**
               * @notice Used to determine whether `staker` is actively 'frozen'. If a staker is frozen, then they are potentially subject to
               * slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed
               * and the staker's status is reset (to 'unfrozen').
               * @param staker The staker of interest.
               * @return Returns 'true' if `staker` themselves has their status set to frozen, OR if the staker is delegated
               * to an operator who has their status set to frozen. Otherwise returns 'false'.
               */
              function isFrozen(address staker) external view returns (bool);
              /// @notice Returns true if `slashingContract` is currently allowed to slash `toBeSlashed`.
              function canSlash(address toBeSlashed, address slashingContract) external view returns (bool);
              /// @notice Returns the block until which `serviceContract` is allowed to slash the `operator`.
              function contractCanSlashOperatorUntilBlock(
                  address operator,
                  address serviceContract
              ) external view returns (uint32);
              /// @notice Returns the block at which the `serviceContract` last updated its view of the `operator`'s stake
              function latestUpdateBlock(address operator, address serviceContract) external view returns (uint32);
              /// @notice A search routine for finding the correct input value of `insertAfter` to `recordStakeUpdate` / `_updateMiddlewareList`.
              function getCorrectValueForInsertAfter(address operator, uint32 updateBlock) external view returns (uint256);
              /**
               * @notice Returns 'true' if `operator` can currently complete a withdrawal started at the `withdrawalStartBlock`, with `middlewareTimesIndex` used
               * to specify the index of a `MiddlewareTimes` struct in the operator's list (i.e. an index in `operatorToMiddlewareTimes[operator]`). The specified
               * struct is consulted as proof of the `operator`'s ability (or lack thereof) to complete the withdrawal.
               * This function will return 'false' if the operator cannot currently complete a withdrawal started at the `withdrawalStartBlock`, *or* in the event
               * that an incorrect `middlewareTimesIndex` is supplied, even if one or more correct inputs exist.
               * @param operator Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator,
               * this address is the operator *who the staker was delegated to* at the time of the `withdrawalStartBlock`.
               * @param withdrawalStartBlock The block number at which the withdrawal was initiated.
               * @param middlewareTimesIndex Indicates an index in `operatorToMiddlewareTimes[operator]` to consult as proof of the `operator`'s ability to withdraw
               * @dev The correct `middlewareTimesIndex` input should be computable off-chain.
               */
              function canWithdraw(
                  address operator,
                  uint32 withdrawalStartBlock,
                  uint256 middlewareTimesIndex
              ) external returns (bool);
              /**
               * operator =>
               *  [
               *      (
               *          the least recent update block of all of the middlewares it's serving/served,
               *          latest time that the stake bonded at that update needed to serve until
               *      )
               *  ]
               */
              function operatorToMiddlewareTimes(
                  address operator,
                  uint256 arrayIndex
              ) external view returns (MiddlewareTimes memory);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator].length`
              function middlewareTimesLength(address operator) external view returns (uint256);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].stalestUpdateBlock`.
              function getMiddlewareTimesIndexStalestUpdateBlock(address operator, uint32 index) external view returns (uint32);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].latestServeUntil`.
              function getMiddlewareTimesIndexServeUntilBlock(address operator, uint32 index) external view returns (uint32);
              /// @notice Getter function for fetching `_operatorToWhitelistedContractsByUpdate[operator].size`.
              function operatorWhitelistedContractsLinkedListSize(address operator) external view returns (uint256);
              /// @notice Getter function for fetching a single node in the operator's linked list (`_operatorToWhitelistedContractsByUpdate[operator]`).
              function operatorWhitelistedContractsLinkedListEntry(
                  address operator,
                  address node
              ) external view returns (bool, uint256, uint256);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title The interface for common signature utilities.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface ISignatureUtils {
              // @notice Struct that bundles together a signature and an expiration time for the signature. Used primarily for stack management.
              struct SignatureWithExpiry {
                  // the signature itself, formatted as a single bytes object
                  bytes signature;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              // @notice Struct that bundles together a signature, a salt for uniqueness, and an expiration time for the signature. Used primarily for stack management.
              struct SignatureWithSaltAndExpiry {
                  // the signature itself, formatted as a single bytes object
                  bytes signature;
                  // the salt used to generate the signature
                  bytes32 salt;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
          }// SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.0;
          import "./Merkle.sol";
          import "../libraries/Endian.sol";
          //Utility library for parsing and PHASE0 beacon chain block headers
          //SSZ Spec: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization
          //BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
          //BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate
          library BeaconChainProofs {
              // constants are the number of fields and the heights of the different merkle trees used in merkleizing beacon chain containers
              uint256 internal constant BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT = 3;
              uint256 internal constant BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT = 4;
              uint256 internal constant BEACON_STATE_FIELD_TREE_HEIGHT = 5;
              uint256 internal constant VALIDATOR_FIELD_TREE_HEIGHT = 3;
              //Note: changed in the deneb hard fork from 4->5
              uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB = 5;
              uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA = 4;
              // SLOTS_PER_HISTORICAL_ROOT = 2**13, so tree height is 13
              uint256 internal constant BLOCK_ROOTS_TREE_HEIGHT = 13;
              //HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
              uint256 internal constant HISTORICAL_SUMMARIES_TREE_HEIGHT = 24;
              //Index of block_summary_root in historical_summary container
              uint256 internal constant BLOCK_SUMMARY_ROOT_INDEX = 0;
              // tree height for hash tree of an individual withdrawal container
              uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2;
              uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;
              // MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4
              uint256 internal constant WITHDRAWALS_TREE_HEIGHT = 4;
              //in beacon block body https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconblockbody
              uint256 internal constant EXECUTION_PAYLOAD_INDEX = 9;
              // in beacon block header https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
              uint256 internal constant SLOT_INDEX = 0;
              uint256 internal constant STATE_ROOT_INDEX = 3;
              uint256 internal constant BODY_ROOT_INDEX = 4;
              // in beacon state https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate
              uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11;
              uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27;
              // in validator https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
              uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
              uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
              uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
              uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7;
              // in execution payload header
              uint256 internal constant TIMESTAMP_INDEX = 9;
              //in execution payload
              uint256 internal constant WITHDRAWALS_INDEX = 14;
              // in withdrawal
              uint256 internal constant WITHDRAWAL_VALIDATOR_INDEX_INDEX = 1;
              uint256 internal constant WITHDRAWAL_VALIDATOR_AMOUNT_INDEX = 3;
              //Misc Constants
              /// @notice The number of slots each epoch in the beacon chain
              uint64 internal constant SLOTS_PER_EPOCH = 32;
              /// @notice The number of seconds in a slot in the beacon chain
              uint64 internal constant SECONDS_PER_SLOT = 12;
              /// @notice Number of seconds per epoch: 384 == 32 slots/epoch * 12 seconds/slot 
              uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT;
              bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;
              /// @notice This struct contains the merkle proofs and leaves needed to verify a partial/full withdrawal
              struct WithdrawalProof {
                  bytes withdrawalProof;
                  bytes slotProof;
                  bytes executionPayloadProof;
                  bytes timestampProof;
                  bytes historicalSummaryBlockRootProof;
                  uint64 blockRootIndex;
                  uint64 historicalSummaryIndex;
                  uint64 withdrawalIndex;
                  bytes32 blockRoot;
                  bytes32 slotRoot;
                  bytes32 timestampRoot;
                  bytes32 executionPayloadRoot;
              }
              /// @notice This struct contains the root and proof for verifying the state root against the oracle block root
              struct StateRootProof {
                  bytes32 beaconStateRoot;
                  bytes proof;
              }
              /**
               * @notice This function verifies merkle proofs of the fields of a certain validator against a beacon chain state root
               * @param validatorIndex the index of the proven validator
               * @param beaconStateRoot is the beacon chain state root to be proven against.
               * @param validatorFieldsProof is the data used in proving the validator's fields
               * @param validatorFields the claimed fields of the validator
               */
              function verifyValidatorFields(
                  bytes32 beaconStateRoot,
                  bytes32[] calldata validatorFields,
                  bytes calldata validatorFieldsProof,
                  uint40 validatorIndex
              ) internal view {
                  require(
                      validatorFields.length == 2 ** VALIDATOR_FIELD_TREE_HEIGHT,
                      "BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"
                  );
                  /**
                   * Note: the length of the validator merkle proof is BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1.
                   * There is an additional layer added by hashing the root with the length of the validator list
                   */
                  require(
                      validatorFieldsProof.length == 32 * ((VALIDATOR_TREE_HEIGHT + 1) + BEACON_STATE_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"
                  );
                  uint256 index = (VALIDATOR_TREE_ROOT_INDEX << (VALIDATOR_TREE_HEIGHT + 1)) | uint256(validatorIndex);
                  // merkleize the validatorFields to get the leaf to prove
                  bytes32 validatorRoot = Merkle.merkleizeSha256(validatorFields);
                  // verify the proof of the validatorRoot against the beaconStateRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: validatorFieldsProof,
                          root: beaconStateRoot,
                          leaf: validatorRoot,
                          index: index
                      }),
                      "BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"
                  );
              }
              /**
               * @notice This function verifies the latestBlockHeader against the state root. the latestBlockHeader is
               * a tracked in the beacon state.
               * @param beaconStateRoot is the beacon chain state root to be proven against.
               * @param stateRootProof is the provided merkle proof
               * @param latestBlockRoot is hashtree root of the latest block header in the beacon state
               */
              function verifyStateRootAgainstLatestBlockRoot(
                  bytes32 latestBlockRoot,
                  bytes32 beaconStateRoot,
                  bytes calldata stateRootProof
              ) internal view {
                  require(
                      stateRootProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Proof has incorrect length"
                  );
                  //Next we verify the slot against the blockRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: stateRootProof,
                          root: latestBlockRoot,
                          leaf: beaconStateRoot,
                          index: STATE_ROOT_INDEX
                      }),
                      "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Invalid latest block header root merkle proof"
                  );
              }
              /**
               * @notice This function verifies the slot and the withdrawal fields for a given withdrawal
               * @param withdrawalProof is the provided set of merkle proofs
               * @param withdrawalFields is the serialized withdrawal container to be proven
               */
              function verifyWithdrawal(
                  bytes32 beaconStateRoot,
                  bytes32[] calldata withdrawalFields,
                  WithdrawalProof calldata withdrawalProof,
                  uint64 denebForkTimestamp
              ) internal view {
                  require(
                      withdrawalFields.length == 2 ** WITHDRAWAL_FIELD_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: withdrawalFields has incorrect length"
                  );
                  require(
                      withdrawalProof.blockRootIndex < 2 ** BLOCK_ROOTS_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: blockRootIndex is too large"
                  );
                  require(
                      withdrawalProof.withdrawalIndex < 2 ** WITHDRAWALS_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: withdrawalIndex is too large"
                  );
                  require(
                      withdrawalProof.historicalSummaryIndex < 2 ** HISTORICAL_SUMMARIES_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: historicalSummaryIndex is too large"
                  );
                  //Note: post deneb hard fork, the number of exection payload header fields increased from 15->17, adding an extra level to the tree height
                  uint256 executionPayloadHeaderFieldTreeHeight = (getWithdrawalTimestamp(withdrawalProof) < denebForkTimestamp) ? EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA : EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB;
                  require(
                      withdrawalProof.withdrawalProof.length ==
                          32 * (executionPayloadHeaderFieldTreeHeight + WITHDRAWALS_TREE_HEIGHT + 1),
                      "BeaconChainProofs.verifyWithdrawal: withdrawalProof has incorrect length"
                  );
                  require(
                      withdrawalProof.executionPayloadProof.length ==
                          32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT + BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyWithdrawal: executionPayloadProof has incorrect length"
                  );
                  require(
                      withdrawalProof.slotProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyWithdrawal: slotProof has incorrect length"
                  );
                  require(
                      withdrawalProof.timestampProof.length == 32 * (executionPayloadHeaderFieldTreeHeight),
                      "BeaconChainProofs.verifyWithdrawal: timestampProof has incorrect length"
                  );
                  require(
                      withdrawalProof.historicalSummaryBlockRootProof.length ==
                          32 *
                              (BEACON_STATE_FIELD_TREE_HEIGHT +
                                  (HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) +
                                  1 +
                                  (BLOCK_ROOTS_TREE_HEIGHT)),
                      "BeaconChainProofs.verifyWithdrawal: historicalSummaryBlockRootProof has incorrect length"
                  );
                  /**
                   * Note: Here, the "1" in "1 + (BLOCK_ROOTS_TREE_HEIGHT)" signifies that extra step of choosing the "block_root_summary" within the individual
                   * "historical_summary". Everywhere else it signifies merkelize_with_mixin, where the length of an array is hashed with the root of the array,
                   * but not here.
                   */
                  uint256 historicalBlockHeaderIndex = (HISTORICAL_SUMMARIES_INDEX <<
                      ((HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) + 1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
                      (uint256(withdrawalProof.historicalSummaryIndex) << (1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
                      (BLOCK_SUMMARY_ROOT_INDEX << (BLOCK_ROOTS_TREE_HEIGHT)) |
                      uint256(withdrawalProof.blockRootIndex);
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.historicalSummaryBlockRootProof,
                          root: beaconStateRoot,
                          leaf: withdrawalProof.blockRoot,
                          index: historicalBlockHeaderIndex
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid historicalsummary merkle proof"
                  );
                  //Next we verify the slot against the blockRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.slotProof,
                          root: withdrawalProof.blockRoot,
                          leaf: withdrawalProof.slotRoot,
                          index: SLOT_INDEX
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid slot merkle proof"
                  );
                  {
                      // Next we verify the executionPayloadRoot against the blockRoot
                      uint256 executionPayloadIndex = (BODY_ROOT_INDEX << (BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT)) |
                          EXECUTION_PAYLOAD_INDEX;
                      require(
                          Merkle.verifyInclusionSha256({
                              proof: withdrawalProof.executionPayloadProof,
                              root: withdrawalProof.blockRoot,
                              leaf: withdrawalProof.executionPayloadRoot,
                              index: executionPayloadIndex
                          }),
                          "BeaconChainProofs.verifyWithdrawal: Invalid executionPayload merkle proof"
                      );
                  }
                  // Next we verify the timestampRoot against the executionPayload root
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.timestampProof,
                          root: withdrawalProof.executionPayloadRoot,
                          leaf: withdrawalProof.timestampRoot,
                          index: TIMESTAMP_INDEX
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid timestamp merkle proof"
                  );
                  {
                      /**
                       * Next we verify the withdrawal fields against the executionPayloadRoot:
                       * First we compute the withdrawal_index, then we merkleize the 
                       * withdrawalFields container to calculate the withdrawalRoot.
                       *
                       * Note: Merkleization of the withdrawals root tree uses MerkleizeWithMixin, i.e., the length of the array is hashed with the root of
                       * the array.  Thus we shift the WITHDRAWALS_INDEX over by WITHDRAWALS_TREE_HEIGHT + 1 and not just WITHDRAWALS_TREE_HEIGHT.
                       */
                      uint256 withdrawalIndex = (WITHDRAWALS_INDEX << (WITHDRAWALS_TREE_HEIGHT + 1)) |
                          uint256(withdrawalProof.withdrawalIndex);
                      bytes32 withdrawalRoot = Merkle.merkleizeSha256(withdrawalFields);
                      require(
                          Merkle.verifyInclusionSha256({
                              proof: withdrawalProof.withdrawalProof,
                              root: withdrawalProof.executionPayloadRoot,
                              leaf: withdrawalRoot,
                              index: withdrawalIndex
                          }),
                          "BeaconChainProofs.verifyWithdrawal: Invalid withdrawal merkle proof"
                      );
                  }
              }
              /**
               * @notice This function replicates the ssz hashing of a validator's pubkey, outlined below:
               *  hh := ssz.NewHasher()
               *  hh.PutBytes(validatorPubkey[:])
               *  validatorPubkeyHash := hh.Hash()
               *  hh.Reset()
               */
              function hashValidatorBLSPubkey(bytes memory validatorPubkey) internal pure returns (bytes32 pubkeyHash) {
                  require(validatorPubkey.length == 48, "Input should be 48 bytes in length");
                  return sha256(abi.encodePacked(validatorPubkey, bytes16(0)));
              }
              /**
               * @dev Retrieve the withdrawal timestamp
               */
              function getWithdrawalTimestamp(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalProof.timestampRoot);
              }
              /**
               * @dev Converts the withdrawal's slot to an epoch
               */
              function getWithdrawalEpoch(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalProof.slotRoot) / SLOTS_PER_EPOCH;
              }
              /**
               * Indices for validator fields (refer to consensus specs):
               * 0: pubkey
               * 1: withdrawal credentials
               * 2: effective balance
               * 3: slashed?
               * 4: activation elligibility epoch
               * 5: activation epoch
               * 6: exit epoch
               * 7: withdrawable epoch
               */
              /**
               * @dev Retrieves a validator's pubkey hash
               */
              function getPubkeyHash(bytes32[] memory validatorFields) internal pure returns (bytes32) {
                  return 
                      validatorFields[VALIDATOR_PUBKEY_INDEX];
              }
              function getWithdrawalCredentials(bytes32[] memory validatorFields) internal pure returns (bytes32) {
                  return
                      validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX];
              }
              /**
               * @dev Retrieves a validator's effective balance (in gwei)
               */
              function getEffectiveBalanceGwei(bytes32[] memory validatorFields) internal pure returns (uint64) {
                  return 
                      Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_BALANCE_INDEX]);
              }
              /**
               * @dev Retrieves a validator's withdrawable epoch
               */
              function getWithdrawableEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
                  return 
                      Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_WITHDRAWABLE_EPOCH_INDEX]);
              }
              /**
               * Indices for withdrawal fields (refer to consensus specs):
               * 0: withdrawal index
               * 1: validator index
               * 2: execution address
               * 3: withdrawal amount
               */
              /**
               * @dev Retrieves a withdrawal's validator index
               */
              function getValidatorIndex(bytes32[] memory withdrawalFields) internal pure returns (uint40) {
                  return 
                      uint40(Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_INDEX_INDEX]));
              }
              /**
               * @dev Retrieves a withdrawal's withdrawal amount (in gwei)
               */
              function getWithdrawalAmountGwei(bytes32[] memory withdrawalFields) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_AMOUNT_INDEX]);
              }
          }
          // SPDX-License-Identifier: MIT
          // Adapted from OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev These functions deal with verification of Merkle Tree proofs.
           *
           * The tree and the proofs can be generated using our
           * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
           * You will find a quickstart guide in the readme.
           *
           * WARNING: You should avoid using leaf values that are 64 bytes long prior to
           * hashing, or use a hash function other than keccak256 for hashing leaves.
           * This is because the concatenation of a sorted pair of internal nodes in
           * the merkle tree could be reinterpreted as a leaf value.
           * OpenZeppelin's JavaScript library generates merkle trees that are safe
           * against this attack out of the box.
           */
          library Merkle {
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * Note this is for a Merkle tree using the keccak/sha3 hash function
               */
              function verifyInclusionKeccak(
                  bytes memory proof,
                  bytes32 root,
                  bytes32 leaf,
                  uint256 index
              ) internal pure returns (bool) {
                  return processInclusionProofKeccak(proof, leaf, index) == root;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * _Available since v4.4._
               *
               * Note this is for a Merkle tree using the keccak/sha3 hash function
               */
              function processInclusionProofKeccak(
                  bytes memory proof,
                  bytes32 leaf,
                  uint256 index
              ) internal pure returns (bytes32) {
                  require(
                      proof.length != 0 && proof.length % 32 == 0,
                      "Merkle.processInclusionProofKeccak: proof length should be a non-zero multiple of 32"
                  );
                  bytes32 computedHash = leaf;
                  for (uint256 i = 32; i <= proof.length; i += 32) {
                      if (index % 2 == 0) {
                          // if ith bit of index is 0, then computedHash is a left sibling
                          assembly {
                              mstore(0x00, computedHash)
                              mstore(0x20, mload(add(proof, i)))
                              computedHash := keccak256(0x00, 0x40)
                              index := div(index, 2)
                          }
                      } else {
                          // if ith bit of index is 1, then computedHash is a right sibling
                          assembly {
                              mstore(0x00, mload(add(proof, i)))
                              mstore(0x20, computedHash)
                              computedHash := keccak256(0x00, 0x40)
                              index := div(index, 2)
                          }
                      }
                  }
                  return computedHash;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * Note this is for a Merkle tree using the sha256 hash function
               */
              function verifyInclusionSha256(
                  bytes memory proof,
                  bytes32 root,
                  bytes32 leaf,
                  uint256 index
              ) internal view returns (bool) {
                  return processInclusionProofSha256(proof, leaf, index) == root;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * _Available since v4.4._
               *
               * Note this is for a Merkle tree using the sha256 hash function
               */
              function processInclusionProofSha256(
                  bytes memory proof,
                  bytes32 leaf,
                  uint256 index
              ) internal view returns (bytes32) {
                  require(
                      proof.length != 0 && proof.length % 32 == 0,
                      "Merkle.processInclusionProofSha256: proof length should be a non-zero multiple of 32"
                  );
                  bytes32[1] memory computedHash = [leaf];
                  for (uint256 i = 32; i <= proof.length; i += 32) {
                      if (index % 2 == 0) {
                          // if ith bit of index is 0, then computedHash is a left sibling
                          assembly {
                              mstore(0x00, mload(computedHash))
                              mstore(0x20, mload(add(proof, i)))
                              if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
                                  revert(0, 0)
                              }
                              index := div(index, 2)
                          }
                      } else {
                          // if ith bit of index is 1, then computedHash is a right sibling
                          assembly {
                              mstore(0x00, mload(add(proof, i)))
                              mstore(0x20, mload(computedHash))
                              if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
                                  revert(0, 0)
                              }
                              index := div(index, 2)
                          }
                      }
                  }
                  return computedHash[0];
              }
              /**
               @notice this function returns the merkle root of a tree created from a set of leaves using sha256 as its hash function
               @param leaves the leaves of the merkle tree
               @return The computed Merkle root of the tree.
               @dev A pre-condition to this function is that leaves.length is a power of two.  If not, the function will merkleize the inputs incorrectly.
               */
              function merkleizeSha256(bytes32[] memory leaves) internal pure returns (bytes32) {
                  //there are half as many nodes in the layer above the leaves
                  uint256 numNodesInLayer = leaves.length / 2;
                  //create a layer to store the internal nodes
                  bytes32[] memory layer = new bytes32[](numNodesInLayer);
                  //fill the layer with the pairwise hashes of the leaves
                  for (uint256 i = 0; i < numNodesInLayer; i++) {
                      layer[i] = sha256(abi.encodePacked(leaves[2 * i], leaves[2 * i + 1]));
                  }
                  //the next layer above has half as many nodes
                  numNodesInLayer /= 2;
                  //while we haven't computed the root
                  while (numNodesInLayer != 0) {
                      //overwrite the first numNodesInLayer nodes in layer with the pairwise hashes of their children
                      for (uint256 i = 0; i < numNodesInLayer; i++) {
                          layer[i] = sha256(abi.encodePacked(layer[2 * i], layer[2 * i + 1]));
                      }
                      //the next layer above has half as many nodes
                      numNodesInLayer /= 2;
                  }
                  //the first node in the layer is the root
                  return layer[0];
              }
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.0;
          library Endian {
              /**
               * @notice Converts a little endian-formatted uint64 to a big endian-formatted uint64
               * @param lenum little endian-formatted uint64 input, provided as 'bytes32' type
               * @return n The big endian-formatted uint64
               * @dev Note that the input is formatted as a 'bytes32' type (i.e. 256 bits), but it is immediately truncated to a uint64 (i.e. 64 bits)
               * through a right-shift/shr operation.
               */
              function fromLittleEndianUint64(bytes32 lenum) internal pure returns (uint64 n) {
                  // the number needs to be stored in little-endian encoding (ie in bytes 0-8)
                  n = uint64(uint256(lenum >> 192));
                  return
                      (n >> 56) |
                      ((0x00FF000000000000 & n) >> 40) |
                      ((0x0000FF0000000000 & n) >> 24) |
                      ((0x000000FF00000000 & n) >> 8) |
                      ((0x00000000FF000000 & n) << 8) |
                      ((0x0000000000FF0000 & n) << 24) |
                      ((0x000000000000FF00 & n) << 40) |
                      ((0x00000000000000FF & n) << 56);
              }
          }
          

          File 3 of 4: UpgradeableBeacon
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)
          pragma solidity ^0.8.0;
          import "./IBeacon.sol";
          import "../../access/Ownable.sol";
          import "../../utils/Address.sol";
          /**
           * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
           * implementation contract, which is where they will delegate all function calls.
           *
           * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
           */
          contract UpgradeableBeacon is IBeacon, Ownable {
              address private _implementation;
              /**
               * @dev Emitted when the implementation returned by the beacon is changed.
               */
              event Upgraded(address indexed implementation);
              /**
               * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the
               * beacon.
               */
              constructor(address implementation_) {
                  _setImplementation(implementation_);
              }
              /**
               * @dev Returns the current implementation address.
               */
              function implementation() public view virtual override returns (address) {
                  return _implementation;
              }
              /**
               * @dev Upgrades the beacon to a new implementation.
               *
               * Emits an {Upgraded} event.
               *
               * Requirements:
               *
               * - msg.sender must be the owner of the contract.
               * - `newImplementation` must be a contract.
               */
              function upgradeTo(address newImplementation) public virtual onlyOwner {
                  _setImplementation(newImplementation);
                  emit Upgraded(newImplementation);
              }
              /**
               * @dev Sets the implementation contract address for this beacon
               *
               * Requirements:
               *
               * - `newImplementation` must be a contract.
               */
              function _setImplementation(address newImplementation) private {
                  require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract");
                  _implementation = newImplementation;
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev This is the interface that {BeaconProxy} expects of its beacon.
           */
          interface IBeacon {
              /**
               * @dev Must return an address that can be used as a delegate call target.
               *
               * {BeaconProxy} will check that this address is a contract.
               */
              function implementation() external view returns (address);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
          pragma solidity ^0.8.0;
          import "../utils/Context.sol";
          /**
           * @dev Contract module which provides a basic access control mechanism, where
           * there is an account (an owner) that can be granted exclusive access to
           * specific functions.
           *
           * By default, the owner account will be the one that deploys the contract. This
           * can later be changed with {transferOwnership}.
           *
           * This module is used through inheritance. It will make available the modifier
           * `onlyOwner`, which can be applied to your functions to restrict their use to
           * the owner.
           */
          abstract contract Ownable is Context {
              address private _owner;
              event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
              /**
               * @dev Initializes the contract setting the deployer as the initial owner.
               */
              constructor() {
                  _transferOwnership(_msgSender());
              }
              /**
               * @dev Throws if called by any account other than the owner.
               */
              modifier onlyOwner() {
                  _checkOwner();
                  _;
              }
              /**
               * @dev Returns the address of the current owner.
               */
              function owner() public view virtual returns (address) {
                  return _owner;
              }
              /**
               * @dev Throws if the sender is not the owner.
               */
              function _checkOwner() internal view virtual {
                  require(owner() == _msgSender(), "Ownable: caller is not the owner");
              }
              /**
               * @dev Leaves the contract without owner. It will not be possible to call
               * `onlyOwner` functions anymore. Can only be called by the current owner.
               *
               * NOTE: Renouncing ownership will leave the contract without an owner,
               * thereby removing any functionality that is only available to the owner.
               */
              function renounceOwnership() public virtual onlyOwner {
                  _transferOwnership(address(0));
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Can only be called by the current owner.
               */
              function transferOwnership(address newOwner) public virtual onlyOwner {
                  require(newOwner != address(0), "Ownable: new owner is the zero address");
                  _transferOwnership(newOwner);
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Internal function without access restriction.
               */
              function _transferOwnership(address newOwner) internal virtual {
                  address oldOwner = _owner;
                  _owner = newOwner;
                  emit OwnershipTransferred(oldOwner, newOwner);
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
          pragma solidity ^0.8.1;
          /**
           * @dev Collection of functions related to the address type
           */
          library Address {
              /**
               * @dev Returns true if `account` is a contract.
               *
               * [IMPORTANT]
               * ====
               * It is unsafe to assume that an address for which this function returns
               * false is an externally-owned account (EOA) and not a contract.
               *
               * Among others, `isContract` will return false for the following
               * types of addresses:
               *
               *  - an externally-owned account
               *  - a contract in construction
               *  - an address where a contract will be created
               *  - an address where a contract lived, but was destroyed
               * ====
               *
               * [IMPORTANT]
               * ====
               * You shouldn't rely on `isContract` to protect against flash loan attacks!
               *
               * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
               * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
               * constructor.
               * ====
               */
              function isContract(address account) internal view returns (bool) {
                  // This method relies on extcodesize/address.code.length, which returns 0
                  // for contracts in construction, since the code is only stored at the end
                  // of the constructor execution.
                  return account.code.length > 0;
              }
              /**
               * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
               * `recipient`, forwarding all available gas and reverting on errors.
               *
               * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
               * of certain opcodes, possibly making contracts go over the 2300 gas limit
               * imposed by `transfer`, making them unable to receive funds via
               * `transfer`. {sendValue} removes this limitation.
               *
               * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
               *
               * IMPORTANT: because control is transferred to `recipient`, care must be
               * taken to not create reentrancy vulnerabilities. Consider using
               * {ReentrancyGuard} or the
               * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
               */
              function sendValue(address payable recipient, uint256 amount) internal {
                  require(address(this).balance >= amount, "Address: insufficient balance");
                  (bool success, ) = recipient.call{value: amount}("");
                  require(success, "Address: unable to send value, recipient may have reverted");
              }
              /**
               * @dev Performs a Solidity function call using a low level `call`. A
               * plain `call` is an unsafe replacement for a function call: use this
               * function instead.
               *
               * If `target` reverts with a revert reason, it is bubbled up by this
               * function (like regular Solidity function calls).
               *
               * Returns the raw returned data. To convert to the expected return value,
               * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
               *
               * Requirements:
               *
               * - `target` must be a contract.
               * - calling `target` with `data` must not revert.
               *
               * _Available since v3.1._
               */
              function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionCall(target, data, "Address: low-level call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
               * `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, 0, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but also transferring `value` wei to `target`.
               *
               * Requirements:
               *
               * - the calling contract must have an ETH balance of at least `value`.
               * - the called Solidity function must be `payable`.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
              }
              /**
               * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
               * with `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(address(this).balance >= value, "Address: insufficient balance for call");
                  require(isContract(target), "Address: call to non-contract");
                  (bool success, bytes memory returndata) = target.call{value: value}(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                  return functionStaticCall(target, data, "Address: low-level static call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal view returns (bytes memory) {
                  require(isContract(target), "Address: static call to non-contract");
                  (bool success, bytes memory returndata) = target.staticcall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionDelegateCall(target, data, "Address: low-level delegate call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(isContract(target), "Address: delegate call to non-contract");
                  (bool success, bytes memory returndata) = target.delegatecall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
               * revert reason using the provided one.
               *
               * _Available since v4.3._
               */
              function verifyCallResult(
                  bool success,
                  bytes memory returndata,
                  string memory errorMessage
              ) internal pure returns (bytes memory) {
                  if (success) {
                      return returndata;
                  } else {
                      // Look for revert reason and bubble it up if present
                      if (returndata.length > 0) {
                          // The easiest way to bubble the revert reason is using memory via assembly
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Provides information about the current execution context, including the
           * sender of the transaction and its data. While these are generally available
           * via msg.sender and msg.data, they should not be accessed in such a direct
           * manner, since when dealing with meta-transactions the account sending and
           * paying for execution may not be the actual sender (as far as an application
           * is concerned).
           *
           * This contract is only required for intermediate, library-like contracts.
           */
          abstract contract Context {
              function _msgSender() internal view virtual returns (address) {
                  return msg.sender;
              }
              function _msgData() internal view virtual returns (bytes calldata) {
                  return msg.data;
              }
          }
          

          File 4 of 4: EigenPod
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.12;
          import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
          import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
          import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol";
          import "@openzeppelin-upgrades/contracts/utils/AddressUpgradeable.sol";
          import "@openzeppelin-upgrades/contracts/utils/math/MathUpgradeable.sol";
          import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
          import "../libraries/BeaconChainProofs.sol";
          import "../libraries/BytesLib.sol";
          import "../libraries/Endian.sol";
          import "../interfaces/IETHPOSDeposit.sol";
          import "../interfaces/IEigenPodManager.sol";
          import "../interfaces/IEigenPod.sol";
          import "../interfaces/IDelayedWithdrawalRouter.sol";
          import "../interfaces/IPausable.sol";
          import "./EigenPodPausingConstants.sol";
          /**
           * @title The implementation contract used for restaking beacon chain ETH on EigenLayer
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice The main functionalities are:
           * - creating new ETH validators with their withdrawal credentials pointed to this contract
           * - proving from beacon chain state roots that withdrawal credentials are pointed to this contract
           * - proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials
           *   pointed to this contract
           * - updating aggregate balances in the EigenPodManager
           * - withdrawing eth when withdrawals are initiated
           * @notice This EigenPod Beacon Proxy implementation adheres to the current Capella consensus specs
           * @dev Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose
           *   to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts
           */
          contract EigenPod is IEigenPod, Initializable, ReentrancyGuardUpgradeable, EigenPodPausingConstants {
              using BytesLib for bytes;
              using SafeERC20 for IERC20;
              using BeaconChainProofs for *;
              // CONSTANTS + IMMUTABLES
              // @notice Internal constant used in calculations, since the beacon chain stores balances in Gwei rather than wei
              uint256 internal constant GWEI_TO_WEI = 1e9;
              /**
               * @notice Maximum "staleness" of a Beacon Chain state root against which `verifyBalanceUpdate` or `verifyWithdrawalCredentials` may be proven.
               * We can't allow "stale" roots to be used for restaking as the validator may have been slashed in a more updated beacon state root. 
               */
              uint256 internal constant VERIFY_BALANCE_UPDATE_WINDOW_SECONDS = 4.5 hours;
              /// @notice This is the beacon chain deposit contract
              IETHPOSDeposit public immutable ethPOS;
              /// @notice Contract used for withdrawal routing, to provide an extra "safety net" mechanism
              IDelayedWithdrawalRouter public immutable delayedWithdrawalRouter;
              /// @notice The single EigenPodManager for EigenLayer
              IEigenPodManager public immutable eigenPodManager;
              ///@notice The maximum amount of ETH, in gwei, a validator can have restaked in the eigenlayer
              uint64 public immutable MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
              /// @notice This is the genesis time of the beacon state, to help us calculate conversions between slot and timestamp
              uint64 public immutable GENESIS_TIME;
              // STORAGE VARIABLES
              /// @notice The owner of this EigenPod
              address public podOwner;
              /**
               * @notice The latest timestamp at which the pod owner withdrew the balance of the pod, via calling `withdrawBeforeRestaking`.
               * @dev This variable is only updated when the `withdrawBeforeRestaking` function is called, which can only occur before `hasRestaked` is set to true for this pod.
               * Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored `mostRecentWithdrawalTimestamp`.
               */
              uint64 public mostRecentWithdrawalTimestamp;
              /// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from the Beacon Chain but not from EigenLayer),
              uint64 public withdrawableRestakedExecutionLayerGwei;
              /// @notice an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling `verifyCorrectWithdrawalCredentials`.
              bool public hasRestaked;
              /// @notice This is a mapping of validatorPubkeyHash to timestamp to whether or not they have proven a withdrawal for that timestamp
              mapping(bytes32 => mapping(uint64 => bool)) public provenWithdrawal;
              /// @notice This is a mapping that tracks a validator's information by their pubkey hash
              mapping(bytes32 => ValidatorInfo) internal _validatorPubkeyHashToInfo;
              /// @notice This variable tracks any ETH deposited into this contract via the `receive` fallback function
              uint256 public nonBeaconChainETHBalanceWei;
              /// @notice This variable tracks the total amount of partial withdrawals claimed via merkle proofs prior to a switch to ZK proofs for claiming partial withdrawals
              uint64 public sumOfPartialWithdrawalsClaimedGwei;
              /// @notice Number of validators with proven withdrawal credentials, who do not have proven full withdrawals
              uint256 activeValidatorCount;
              modifier onlyEigenPodManager() {
                  require(msg.sender == address(eigenPodManager), "EigenPod.onlyEigenPodManager: not eigenPodManager");
                  _;
              }
              modifier onlyEigenPodOwner() {
                  require(msg.sender == podOwner, "EigenPod.onlyEigenPodOwner: not podOwner");
                  _;
              }
              modifier hasNeverRestaked() {
                  require(!hasRestaked, "EigenPod.hasNeverRestaked: restaking is enabled");
                  _;
              }
              /// @notice checks that hasRestaked is set to true by calling activateRestaking()
              modifier hasEnabledRestaking() {
                  require(hasRestaked, "EigenPod.hasEnabledRestaking: restaking is not enabled");
                  _;
              }
              /// @notice Checks that `timestamp` is greater than or equal to the value stored in `mostRecentWithdrawalTimestamp`
              modifier proofIsForValidTimestamp(uint64 timestamp) {
                  require(
                      timestamp >= mostRecentWithdrawalTimestamp,
                      "EigenPod.proofIsForValidTimestamp: beacon chain proof must be at or after mostRecentWithdrawalTimestamp"
                  );
                  _;
              }
              /**
               * @notice Based on 'Pausable' code, but uses the storage of the EigenPodManager instead of this contract. This construction
               * is necessary for enabling pausing all EigenPods at the same time (due to EigenPods being Beacon Proxies).
               * Modifier throws if the `indexed`th bit of `_paused` in the EigenPodManager is 1, i.e. if the `index`th pause switch is flipped.
               */
              modifier onlyWhenNotPaused(uint8 index) {
                  require(
                      !IPausable(address(eigenPodManager)).paused(index),
                      "EigenPod.onlyWhenNotPaused: index is paused in EigenPodManager"
                  );
                  _;
              }
              constructor(
                  IETHPOSDeposit _ethPOS,
                  IDelayedWithdrawalRouter _delayedWithdrawalRouter,
                  IEigenPodManager _eigenPodManager,
                  uint64 _MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR,
                  uint64 _GENESIS_TIME
              ) {
                  ethPOS = _ethPOS;
                  delayedWithdrawalRouter = _delayedWithdrawalRouter;
                  eigenPodManager = _eigenPodManager;
                  MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR = _MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
                  GENESIS_TIME = _GENESIS_TIME;
                  _disableInitializers();
              }
              /// @notice Used to initialize the pointers to addresses crucial to the pod's functionality. Called on construction by the EigenPodManager.
              function initialize(address _podOwner) external initializer {
                  require(_podOwner != address(0), "EigenPod.initialize: podOwner cannot be zero address");
                  podOwner = _podOwner;
                  /**
                   * From the M2 deployment onwards, we are requiring that pods deployed are by default enabled with restaking
                   * In prior deployments without proofs, EigenPods could be deployed with restaking disabled so as to allow
                   * simple (proof-free) withdrawals.  However, this is no longer the case.  Thus going forward, all pods are
                   * initialized with hasRestaked set to true.
                   */
                  hasRestaked = true;
                  emit RestakingActivated(podOwner);
              }
              /// @notice payable fallback function that receives ether deposited to the eigenpods contract
              receive() external payable {
                  nonBeaconChainETHBalanceWei += msg.value;
                  emit NonBeaconChainETHReceived(msg.value);
              }
              /**
               * @notice This function records an update (either increase or decrease) in a validator's balance.
               * @param oracleTimestamp The oracleTimestamp whose state root the proof will be proven against.
               *        Must be within `VERIFY_BALANCE_UPDATE_WINDOW_SECONDS` of the current block.
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs 
               * @param stateRootProof proves a `beaconStateRoot` against a block root fetched from the oracle
               * @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields`
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * @dev For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyBalanceUpdates(
                  uint64 oracleTimestamp,
                  uint40[] calldata validatorIndices,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields
              ) external onlyWhenNotPaused(PAUSED_EIGENPODS_VERIFY_BALANCE_UPDATE) {
                  require(
                      (validatorIndices.length == validatorFieldsProofs.length) && (validatorFieldsProofs.length == validatorFields.length),
                      "EigenPod.verifyBalanceUpdates: validatorIndices and proofs must be same length"
                  );
                  // Balance updates should not be "stale" (older than VERIFY_BALANCE_UPDATE_WINDOW_SECONDS)
                  require(
                      oracleTimestamp + VERIFY_BALANCE_UPDATE_WINDOW_SECONDS >= block.timestamp,
                      "EigenPod.verifyBalanceUpdates: specified timestamp is too far in past"
                  );
                  // Verify passed-in beaconStateRoot against oracle-provided block root:
                  BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot({
                      latestBlockRoot: eigenPodManager.getBlockRootAtTimestamp(oracleTimestamp),
                      beaconStateRoot: stateRootProof.beaconStateRoot,
                      stateRootProof: stateRootProof.proof
                  });
                  int256 sharesDeltaGwei;
                  for (uint256 i = 0; i < validatorIndices.length; i++) {
                      sharesDeltaGwei += _verifyBalanceUpdate(
                          oracleTimestamp,
                          validatorIndices[i],
                          stateRootProof.beaconStateRoot,
                          validatorFieldsProofs[i], // Use validator fields proof because contains the effective balance
                          validatorFields[i]
                      );
                  }
                  eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, sharesDeltaGwei * int256(GWEI_TO_WEI));
              }
              /**
               * @notice This function records full and partial withdrawals on behalf of one or more of this EigenPod's validators
               * @param oracleTimestamp is the timestamp of the oracle slot that the withdrawal is being proven against
               * @param stateRootProof proves a `beaconStateRoot` against a block root fetched from the oracle
               * @param withdrawalProofs proves several withdrawal-related values against the `beaconStateRoot`
               * @param validatorFieldsProofs proves `validatorFields` against the `beaconStateRoot`
               * @param withdrawalFields are the fields of the withdrawals being proven
               * @param validatorFields are the fields of the validators being proven
               */
              function verifyAndProcessWithdrawals(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  BeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields,
                  bytes32[][] calldata withdrawalFields
              ) external onlyWhenNotPaused(PAUSED_EIGENPODS_VERIFY_WITHDRAWAL) {
                  require(
                      (validatorFields.length == validatorFieldsProofs.length) &&
                          (validatorFieldsProofs.length == withdrawalProofs.length) &&
                          (withdrawalProofs.length == withdrawalFields.length),
                      "EigenPod.verifyAndProcessWithdrawals: inputs must be same length"
                  );
                  // Verify passed-in beaconStateRoot against oracle-provided block root:
                  BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot({
                      latestBlockRoot: eigenPodManager.getBlockRootAtTimestamp(oracleTimestamp),
                      beaconStateRoot: stateRootProof.beaconStateRoot,
                      stateRootProof: stateRootProof.proof
                  });
                  VerifiedWithdrawal memory withdrawalSummary;
                  for (uint256 i = 0; i < withdrawalFields.length; i++) {
                      VerifiedWithdrawal memory verifiedWithdrawal = _verifyAndProcessWithdrawal(
                          stateRootProof.beaconStateRoot,
                          withdrawalProofs[i],
                          validatorFieldsProofs[i],
                          validatorFields[i],
                          withdrawalFields[i]
                      );
                      withdrawalSummary.amountToSendGwei += verifiedWithdrawal.amountToSendGwei;
                      withdrawalSummary.sharesDeltaGwei += verifiedWithdrawal.sharesDeltaGwei;
                  }
                  // If any withdrawals are eligible for immediate redemption, send to the pod owner via
                  // DelayedWithdrawalRouter
                  if (withdrawalSummary.amountToSendGwei != 0) {
                      _sendETH_AsDelayedWithdrawal(podOwner, withdrawalSummary.amountToSendGwei * GWEI_TO_WEI);
                  }
                  // If any withdrawals resulted in a change in the pod's shares, update the EigenPodManager
                  if (withdrawalSummary.sharesDeltaGwei != 0) {
                      eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, withdrawalSummary.sharesDeltaGwei * int256(GWEI_TO_WEI));
                  }
              }
              /*******************************************************************************
                              EXTERNAL FUNCTIONS CALLABLE BY EIGENPOD OWNER
              *******************************************************************************/
              /**
               * @notice This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to
               * this contract. It also verifies the effective balance  of the validator.  It verifies the provided proof of the ETH validator against the beacon chain state
               * root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer.
               * @param oracleTimestamp is the Beacon Chain timestamp whose state root the `proof` will be proven against.
               * @param stateRootProof proves a `beaconStateRoot` against a block root fetched from the oracle
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs
               * @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields`
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyWithdrawalCredentials(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  uint40[] calldata validatorIndices,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields
              )
                  external
                  onlyEigenPodOwner
                  onlyWhenNotPaused(PAUSED_EIGENPODS_VERIFY_CREDENTIALS)
                  // ensure that caller has previously enabled restaking by calling `activateRestaking()`
                  hasEnabledRestaking
              {        
                  require(
                      (validatorIndices.length == validatorFieldsProofs.length) &&
                          (validatorFieldsProofs.length == validatorFields.length),
                      "EigenPod.verifyWithdrawalCredentials: validatorIndices and proofs must be same length"
                  );
                  // `mostRecentWithdrawalTimestamp` will be 0 for any pods deployed after M2
                  // If this is non-zero, ensure `oracleTimestamp` is from the epoch AFTER `activateRestaking`
                  // was called.
                  require(
                      mostRecentWithdrawalTimestamp == 0 ||
                      oracleTimestamp >= _nextEpochStartTimestamp(_timestampToEpoch(mostRecentWithdrawalTimestamp)),
                      "EigenPod.verifyWithdrawalCredentials: proof must be in the epoch after activation"
                  );
                  /**
                   * Withdrawal credential proof should not be "stale" (older than VERIFY_BALANCE_UPDATE_WINDOW_SECONDS) as we are doing a balance check here
                   * The validator container persists as the state evolves and even after the validator exits. So we can use a more "fresh" credential proof within
                   * the VERIFY_BALANCE_UPDATE_WINDOW_SECONDS window, not just the first proof where the validator container is registered in the state.
                   */
                  require(
                      oracleTimestamp + VERIFY_BALANCE_UPDATE_WINDOW_SECONDS >= block.timestamp,
                      "EigenPod.verifyWithdrawalCredentials: specified timestamp is too far in past"
                  );
                  // Verify passed-in beaconStateRoot against oracle-provided block root:
                  BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot({
                      latestBlockRoot: eigenPodManager.getBlockRootAtTimestamp(oracleTimestamp),
                      beaconStateRoot: stateRootProof.beaconStateRoot,
                      stateRootProof: stateRootProof.proof
                  });
                  uint256 totalAmountToBeRestakedWei;
                  for (uint256 i = 0; i < validatorIndices.length; i++) {
                      totalAmountToBeRestakedWei += _verifyWithdrawalCredentials(
                          oracleTimestamp,
                          stateRootProof.beaconStateRoot,
                          validatorIndices[i],
                          validatorFieldsProofs[i],
                          validatorFields[i]
                      );
                  }
                  // Update the EigenPodManager on this pod's new balance
                  eigenPodManager.recordBeaconChainETHBalanceUpdate(podOwner, int256(totalAmountToBeRestakedWei));
              }
              /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei
              function withdrawNonBeaconChainETHBalanceWei(
                  address recipient,
                  uint256 amountToWithdraw
              ) external onlyEigenPodOwner onlyWhenNotPaused(PAUSED_NON_PROOF_WITHDRAWALS) {
                  require(
                      amountToWithdraw <= nonBeaconChainETHBalanceWei,
                      "EigenPod.withdrawnonBeaconChainETHBalanceWei: amountToWithdraw is greater than nonBeaconChainETHBalanceWei"
                  );
                  nonBeaconChainETHBalanceWei -= amountToWithdraw;
                  emit NonBeaconChainETHWithdrawn(recipient, amountToWithdraw);
                  _sendETH_AsDelayedWithdrawal(recipient, amountToWithdraw);
              }
              /// @notice called by owner of a pod to remove any ERC20s deposited in the pod
              function recoverTokens(
                  IERC20[] memory tokenList,
                  uint256[] memory amountsToWithdraw,
                  address recipient
              ) external onlyEigenPodOwner onlyWhenNotPaused(PAUSED_NON_PROOF_WITHDRAWALS) {
                  require(
                      tokenList.length == amountsToWithdraw.length,
                      "EigenPod.recoverTokens: tokenList and amountsToWithdraw must be same length"
                  );
                  for (uint256 i = 0; i < tokenList.length; i++) {
                      tokenList[i].safeTransfer(recipient, amountsToWithdraw[i]);
                  }
              }
              /**
               * @notice Called by the pod owner to activate restaking by withdrawing
               * all existing ETH from the pod and preventing further withdrawals via
               * "withdrawBeforeRestaking()"
               */
              function activateRestaking()
                  external
                  onlyWhenNotPaused(PAUSED_EIGENPODS_VERIFY_CREDENTIALS)
                  onlyEigenPodOwner
                  hasNeverRestaked
              {
                  hasRestaked = true;
                  _processWithdrawalBeforeRestaking(podOwner);
                  emit RestakingActivated(podOwner);
              }
              /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false
              function withdrawBeforeRestaking() external onlyEigenPodOwner hasNeverRestaked {
                  _processWithdrawalBeforeRestaking(podOwner);
              }
              /*******************************************************************************
                              EXTERNAL FUNCTIONS CALLABLE BY EIGENPODMANAGER
              *******************************************************************************/
              /// @notice Called by EigenPodManager when the owner wants to create another ETH validator.
              function stake(
                  bytes calldata pubkey,
                  bytes calldata signature,
                  bytes32 depositDataRoot
              ) external payable onlyEigenPodManager {
                  // stake on ethpos
                  require(msg.value == 32 ether, "EigenPod.stake: must initially stake for any validator with 32 ether");
                  ethPOS.deposit{value: 32 ether}(pubkey, _podWithdrawalCredentials(), signature, depositDataRoot);
                  emit EigenPodStaked(pubkey);
              }
              /**
               * @notice Transfers `amountWei` in ether from this contract to the specified `recipient` address
               * @notice Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain.
               * @dev The podOwner must have already proved sufficient withdrawals, so that this pod's `withdrawableRestakedExecutionLayerGwei` exceeds the
               * `amountWei` input (when converted to GWEI).
               * @dev Reverts if `amountWei` is not a whole Gwei amount
               */
              function withdrawRestakedBeaconChainETH(address recipient, uint256 amountWei) external onlyEigenPodManager {
                  require(amountWei % GWEI_TO_WEI == 0, "EigenPod.withdrawRestakedBeaconChainETH: amountWei must be a whole Gwei amount");
                  uint64 amountGwei = uint64(amountWei / GWEI_TO_WEI);
                  require(amountGwei <= withdrawableRestakedExecutionLayerGwei, "EigenPod.withdrawRestakedBeaconChainETH: amountGwei exceeds withdrawableRestakedExecutionLayerGwei");
                  withdrawableRestakedExecutionLayerGwei -= amountGwei;
                  emit RestakedBeaconChainETHWithdrawn(recipient, amountWei);
                  // transfer ETH from pod to `recipient` directly
                  _sendETH(recipient, amountWei);
              }
              /*******************************************************************************
                                          INTERNAL FUNCTIONS
              *******************************************************************************/
              /**
               * @notice internal function that proves an individual validator's withdrawal credentials
               * @param oracleTimestamp is the timestamp whose state root the `proof` will be proven against.
               * @param validatorIndex is the index of the validator being proven
               * @param validatorFieldsProof is the bytes that prove the ETH validator's  withdrawal credentials against a beacon chain state root
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               */
              function _verifyWithdrawalCredentials(
                  uint64 oracleTimestamp,
                  bytes32 beaconStateRoot,
                  uint40 validatorIndex,
                  bytes calldata validatorFieldsProof,
                  bytes32[] calldata validatorFields
              ) internal returns (uint256) {
                  bytes32 validatorPubkeyHash = validatorFields.getPubkeyHash();
                  ValidatorInfo memory validatorInfo = _validatorPubkeyHashToInfo[validatorPubkeyHash];
                  // Withdrawal credential proofs should only be processed for "INACTIVE" validators
                  require(
                      validatorInfo.status == VALIDATOR_STATUS.INACTIVE,
                      "EigenPod.verifyCorrectWithdrawalCredentials: Validator must be inactive to prove withdrawal credentials"
                  );
                  // Ensure the `validatorFields` we're proving have the correct withdrawal credentials
                  require(
                      validatorFields.getWithdrawalCredentials() == bytes32(_podWithdrawalCredentials()),
                      "EigenPod.verifyCorrectWithdrawalCredentials: Proof is not for this EigenPod"
                  );
                  /**
                   * Deserialize the balance field from the Validator struct.  Note that this is the "effective" balance of the validator
                   * rather than the current balance.  Effective balance is generated via a hystersis function such that an effective
                   * balance, always a multiple of 1 ETH, will only lower to the next multiple of 1 ETH if the current balance is less
                   * than 0.25 ETH below their current effective balance.  For example, if the effective balance is 31ETH, it only falls to
                   * 30ETH when the true balance falls below 30.75ETH.  Thus in the worst case, the effective balance is overestimating the
                   * actual validator balance by 0.25 ETH. 
                   */
                  uint64 validatorEffectiveBalanceGwei = validatorFields.getEffectiveBalanceGwei();
                  // Verify passed-in validatorFields against verified beaconStateRoot:
                  BeaconChainProofs.verifyValidatorFields({
                      beaconStateRoot: beaconStateRoot,
                      validatorFields: validatorFields,
                      validatorFieldsProof: validatorFieldsProof,
                      validatorIndex: validatorIndex
                  });
                  // Proofs complete - update this validator's status, record its proven balance, and save in state:
                  activeValidatorCount++;
                  validatorInfo.status = VALIDATOR_STATUS.ACTIVE;
                  validatorInfo.validatorIndex = validatorIndex;
                  validatorInfo.mostRecentBalanceUpdateTimestamp = oracleTimestamp;
                  if (validatorEffectiveBalanceGwei > MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR) {
                      validatorInfo.restakedBalanceGwei = MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
                  } else {
                      validatorInfo.restakedBalanceGwei = validatorEffectiveBalanceGwei;
                  }
                  _validatorPubkeyHashToInfo[validatorPubkeyHash] = validatorInfo;
                  emit ValidatorRestaked(validatorIndex);
                  emit ValidatorBalanceUpdated(validatorIndex, oracleTimestamp, validatorInfo.restakedBalanceGwei);
                  return validatorInfo.restakedBalanceGwei * GWEI_TO_WEI;
              }
              function _verifyBalanceUpdate(
                  uint64 oracleTimestamp,
                  uint40 validatorIndex,
                  bytes32 beaconStateRoot,
                  bytes calldata validatorFieldsProof,
                  bytes32[] calldata validatorFields
              ) internal returns(int256 sharesDeltaGwei){
                  uint64 validatorEffectiveBalanceGwei = validatorFields.getEffectiveBalanceGwei();
                  bytes32 validatorPubkeyHash = validatorFields.getPubkeyHash();
                  ValidatorInfo memory validatorInfo = _validatorPubkeyHashToInfo[validatorPubkeyHash];
                  // 1. Balance updates should be more recent than the most recent update
                  require(
                      validatorInfo.mostRecentBalanceUpdateTimestamp < oracleTimestamp,
                      "EigenPod.verifyBalanceUpdate: Validators balance has already been updated for this timestamp"
                  );
                  // 2. Balance updates should only be performed on "ACTIVE" validators
                  require(
                      validatorInfo.status == VALIDATOR_STATUS.ACTIVE, 
                      "EigenPod.verifyBalanceUpdate: Validator not active"
                  );
                  // 3. Balance updates should only be made before a validator is fully withdrawn. 
                  // -- A withdrawable validator may not have withdrawn yet, so we require their balance is nonzero
                  // -- A fully withdrawn validator should withdraw via verifyAndProcessWithdrawals
                  if (validatorFields.getWithdrawableEpoch() <= _timestampToEpoch(oracleTimestamp)) {
                      require(
                          validatorEffectiveBalanceGwei > 0,
                          "EigenPod.verifyBalanceUpdate: validator is withdrawable but has not withdrawn"
                      );
                  }
                  // Verify passed-in validatorFields against verified beaconStateRoot:
                  BeaconChainProofs.verifyValidatorFields({
                      beaconStateRoot: beaconStateRoot,
                      validatorFields: validatorFields,
                      validatorFieldsProof: validatorFieldsProof,
                      validatorIndex: validatorIndex
                  });
                  // Done with proofs! Now update the validator's balance and send to the EigenPodManager if needed
                  uint64 currentRestakedBalanceGwei = validatorInfo.restakedBalanceGwei;
                  uint64 newRestakedBalanceGwei;
                  if (validatorEffectiveBalanceGwei > MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR) {
                      newRestakedBalanceGwei = MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
                  } else {
                      newRestakedBalanceGwei = validatorEffectiveBalanceGwei;
                  }
                  
                  // Update validator balance and timestamp, and save to state:
                  validatorInfo.restakedBalanceGwei = newRestakedBalanceGwei;
                  validatorInfo.mostRecentBalanceUpdateTimestamp = oracleTimestamp;
                  _validatorPubkeyHashToInfo[validatorPubkeyHash] = validatorInfo;
                  // If our new and old balances differ, calculate the delta and send to the EigenPodManager
                  if (newRestakedBalanceGwei != currentRestakedBalanceGwei) {
                      emit ValidatorBalanceUpdated(validatorIndex, oracleTimestamp, newRestakedBalanceGwei);
                      sharesDeltaGwei = _calculateSharesDelta({
                          newAmountGwei: newRestakedBalanceGwei,
                          previousAmountGwei: currentRestakedBalanceGwei
                      });
                  }
              }
              function _verifyAndProcessWithdrawal(
                  bytes32 beaconStateRoot,
                  BeaconChainProofs.WithdrawalProof calldata withdrawalProof,
                  bytes calldata validatorFieldsProof,
                  bytes32[] calldata validatorFields,
                  bytes32[] calldata withdrawalFields
              )
                  internal
                  /**
                   * Check that the provided timestamp being proven against is after the `mostRecentWithdrawalTimestamp`.
                   * Without this check, there is an edge case where a user proves a past withdrawal for a validator whose funds they already withdrew,
                   * as a way to "withdraw the same funds twice" without providing adequate proof.
                   * Note that this check is not made using the oracleTimestamp as in the `verifyWithdrawalCredentials` proof; instead this proof
                   * proof is made for the timestamp of the withdrawal, which may be within SLOTS_PER_HISTORICAL_ROOT slots of the oracleTimestamp.
                   * This difference in modifier usage is OK, since it is still not possible to `verifyAndProcessWithdrawal` against a slot that occurred
                   * *prior* to the proof provided in the `verifyWithdrawalCredentials` function.
                   */
                  proofIsForValidTimestamp(withdrawalProof.getWithdrawalTimestamp())
                  returns (VerifiedWithdrawal memory)
              {
                  uint64 withdrawalTimestamp = withdrawalProof.getWithdrawalTimestamp();
                  bytes32 validatorPubkeyHash = validatorFields.getPubkeyHash();
                  /**
                   * Withdrawal processing should only be performed for "ACTIVE" or "WITHDRAWN" validators.
                   * (WITHDRAWN is allowed because technically you can deposit to a validator even after it exits)
                   */
                  require(
                      _validatorPubkeyHashToInfo[validatorPubkeyHash].status != VALIDATOR_STATUS.INACTIVE,
                      "EigenPod._verifyAndProcessWithdrawal: Validator never proven to have withdrawal credentials pointed to this contract"
                  );
                  // Ensure we don't process the same withdrawal twice
                  require(
                      !provenWithdrawal[validatorPubkeyHash][withdrawalTimestamp],
                      "EigenPod._verifyAndProcessWithdrawal: withdrawal has already been proven for this timestamp"
                  );
                  provenWithdrawal[validatorPubkeyHash][withdrawalTimestamp] = true;
                  // Verifying the withdrawal against verified beaconStateRoot:
                  BeaconChainProofs.verifyWithdrawal({
                      beaconStateRoot: beaconStateRoot, 
                      withdrawalFields: withdrawalFields, 
                      withdrawalProof: withdrawalProof,
                      denebForkTimestamp: eigenPodManager.denebForkTimestamp()
                  });
                  uint40 validatorIndex = withdrawalFields.getValidatorIndex();
                  // Verify passed-in validatorFields against verified beaconStateRoot:
                  BeaconChainProofs.verifyValidatorFields({
                      beaconStateRoot: beaconStateRoot,
                      validatorFields: validatorFields,
                      validatorFieldsProof: validatorFieldsProof,
                      validatorIndex: validatorIndex
                  });
                  uint64 withdrawalAmountGwei = withdrawalFields.getWithdrawalAmountGwei();
                  
                  /**
                   * If the withdrawal's epoch comes after the validator's "withdrawable epoch," we know the validator
                   * has fully withdrawn, and we process this as a full withdrawal.
                   */
                  if (withdrawalProof.getWithdrawalEpoch() >= validatorFields.getWithdrawableEpoch()) {
                      return
                          _processFullWithdrawal(
                              validatorIndex,
                              validatorPubkeyHash,
                              withdrawalTimestamp,
                              podOwner,
                              withdrawalAmountGwei,
                              _validatorPubkeyHashToInfo[validatorPubkeyHash]
                          );
                  } else {
                      return
                          _processPartialWithdrawal(
                              validatorIndex,
                              withdrawalTimestamp,
                              podOwner,
                              withdrawalAmountGwei
                          );
                  }
              }
              function _processFullWithdrawal(
                  uint40 validatorIndex,
                  bytes32 validatorPubkeyHash,
                  uint64 withdrawalTimestamp,
                  address recipient,
                  uint64 withdrawalAmountGwei,
                  ValidatorInfo memory validatorInfo
              ) internal returns (VerifiedWithdrawal memory) {
                  /**
                   * First, determine withdrawal amounts. We need to know:
                   * 1. How much can be withdrawn immediately
                   * 2. How much needs to be withdrawn via the EigenLayer withdrawal queue
                   */
                  uint64 amountToQueueGwei;
                  if (withdrawalAmountGwei > MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR) {
                      amountToQueueGwei = MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR;
                  } else {
                      amountToQueueGwei = withdrawalAmountGwei;
                  }
                  /**
                   * If the withdrawal is for more than the max per-validator balance, we mark 
                   * the max as "withdrawable" via the queue, and withdraw the excess immediately
                   */
                  VerifiedWithdrawal memory verifiedWithdrawal;
                  verifiedWithdrawal.amountToSendGwei = uint256(withdrawalAmountGwei - amountToQueueGwei);
                  withdrawableRestakedExecutionLayerGwei += amountToQueueGwei;
                  
                  /**
                   * Next, calculate the change in number of shares this validator is "backing":
                   * - Anything that needs to go through the withdrawal queue IS backed
                   * - Anything immediately withdrawn IS NOT backed
                   *
                   * This means that this validator is currently backing `amountToQueueGwei` shares.
                   */
                  verifiedWithdrawal.sharesDeltaGwei = _calculateSharesDelta({
                      newAmountGwei: amountToQueueGwei,
                      previousAmountGwei: validatorInfo.restakedBalanceGwei
                  });
                  /**
                   * Finally, the validator is fully withdrawn. Update their status and place in state:
                   */
                  if (validatorInfo.status != VALIDATOR_STATUS.WITHDRAWN) {
                      activeValidatorCount--;
                      validatorInfo.status = VALIDATOR_STATUS.WITHDRAWN;
                  }
                  validatorInfo.restakedBalanceGwei = 0;        
                  _validatorPubkeyHashToInfo[validatorPubkeyHash] = validatorInfo;
                  emit FullWithdrawalRedeemed(validatorIndex, withdrawalTimestamp, recipient, withdrawalAmountGwei);
                  return verifiedWithdrawal;
              }
              function _processPartialWithdrawal(
                  uint40 validatorIndex,
                  uint64 withdrawalTimestamp,
                  address recipient,
                  uint64 partialWithdrawalAmountGwei
              ) internal returns (VerifiedWithdrawal memory) {
                  emit PartialWithdrawalRedeemed(
                      validatorIndex,
                      withdrawalTimestamp,
                      recipient,
                      partialWithdrawalAmountGwei
                  );
                  sumOfPartialWithdrawalsClaimedGwei += partialWithdrawalAmountGwei;
                  // For partial withdrawals, the withdrawal amount is immediately sent to the pod owner
                  return
                      VerifiedWithdrawal({
                          amountToSendGwei: uint256(partialWithdrawalAmountGwei),
                          sharesDeltaGwei: 0
                      });
              }
              function _processWithdrawalBeforeRestaking(address _podOwner) internal {
                  mostRecentWithdrawalTimestamp = uint32(block.timestamp);
                  nonBeaconChainETHBalanceWei = 0;
                  _sendETH_AsDelayedWithdrawal(_podOwner, address(this).balance);
              }
              function _sendETH(address recipient, uint256 amountWei) internal {
                  Address.sendValue(payable(recipient), amountWei);
              }
              function _sendETH_AsDelayedWithdrawal(address recipient, uint256 amountWei) internal {
                  delayedWithdrawalRouter.createDelayedWithdrawal{value: amountWei}(podOwner, recipient);
              }
              function _podWithdrawalCredentials() internal view returns (bytes memory) {
                  return abi.encodePacked(bytes1(uint8(1)), bytes11(0), address(this));
              }
              ///@notice Calculates the pubkey hash of a validator's pubkey as per SSZ spec
              function _calculateValidatorPubkeyHash(bytes memory validatorPubkey) internal pure returns (bytes32){
                  require(validatorPubkey.length == 48, "EigenPod._calculateValidatorPubkeyHash must be a 48-byte BLS public key");
                  return sha256(abi.encodePacked(validatorPubkey, bytes16(0)));
              }
              /**
               * Calculates delta between two share amounts and returns as an int256
               */
              function _calculateSharesDelta(uint64 newAmountGwei, uint64 previousAmountGwei) internal pure returns (int256) {
                  return
                      int256(uint256(newAmountGwei)) - int256(uint256(previousAmountGwei));
              }
              /**
               * @dev Converts a timestamp to a beacon chain epoch by calculating the number of
               * seconds since genesis, and dividing by seconds per epoch.
               * reference: https://github.com/ethereum/consensus-specs/blob/ce240ca795e257fc83059c4adfd591328c7a7f21/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot
               */
              function _timestampToEpoch(uint64 timestamp) internal view returns (uint64) {
                  require(timestamp >= GENESIS_TIME, "EigenPod._timestampToEpoch: timestamp is before genesis");
                  return (timestamp - GENESIS_TIME) / BeaconChainProofs.SECONDS_PER_EPOCH;
              }
              /**
               * @dev Given an epoch number, calculates the timestamp of the first slot in the following epoch
               */
              function _nextEpochStartTimestamp(uint64 epoch) internal view returns (uint64) {
                  return  
                      GENESIS_TIME + ((1 + epoch) * BeaconChainProofs.SECONDS_PER_EPOCH);
              }
              /*******************************************************************************
                                      VIEW FUNCTIONS
              *******************************************************************************/
              function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory) {
                  return _validatorPubkeyHashToInfo[validatorPubkeyHash];
              }
              /// @notice Returns the validatorInfo for a given validatorPubkey
              function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory) {
                  return _validatorPubkeyHashToInfo[_calculateValidatorPubkeyHash(validatorPubkey)];
              }
              function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS) {
                  return _validatorPubkeyHashToInfo[pubkeyHash].status;
              }
                  /// @notice Returns the validator status for a given validatorPubkey
              function validatorStatus(bytes calldata validatorPubkey) external view returns (VALIDATOR_STATUS) {
                  bytes32 validatorPubkeyHash = _calculateValidatorPubkeyHash(validatorPubkey);
                  return _validatorPubkeyHashToInfo[validatorPubkeyHash].status;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[44] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
          pragma solidity ^0.8.2;
          import "../../utils/AddressUpgradeable.sol";
          /**
           * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
           * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
           * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
           * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
           *
           * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
           * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
           * case an upgrade adds a module that needs to be initialized.
           *
           * For example:
           *
           * [.hljs-theme-light.nopadding]
           * ```
           * contract MyToken is ERC20Upgradeable {
           *     function initialize() initializer public {
           *         __ERC20_init("MyToken", "MTK");
           *     }
           * }
           * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
           *     function initializeV2() reinitializer(2) public {
           *         __ERC20Permit_init("MyToken");
           *     }
           * }
           * ```
           *
           * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
           * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
           *
           * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
           * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
           *
           * [CAUTION]
           * ====
           * Avoid leaving a contract uninitialized.
           *
           * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
           * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
           * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
           *
           * [.hljs-theme-light.nopadding]
           * ```
           * /// @custom:oz-upgrades-unsafe-allow constructor
           * constructor() {
           *     _disableInitializers();
           * }
           * ```
           * ====
           */
          abstract contract Initializable {
              /**
               * @dev Indicates that the contract has been initialized.
               * @custom:oz-retyped-from bool
               */
              uint8 private _initialized;
              /**
               * @dev Indicates that the contract is in the process of being initialized.
               */
              bool private _initializing;
              /**
               * @dev Triggered when the contract has been initialized or reinitialized.
               */
              event Initialized(uint8 version);
              /**
               * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
               * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
               */
              modifier initializer() {
                  bool isTopLevelCall = !_initializing;
                  require(
                      (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                      "Initializable: contract is already initialized"
                  );
                  _initialized = 1;
                  if (isTopLevelCall) {
                      _initializing = true;
                  }
                  _;
                  if (isTopLevelCall) {
                      _initializing = false;
                      emit Initialized(1);
                  }
              }
              /**
               * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
               * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
               * used to initialize parent contracts.
               *
               * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
               * initialization step. This is essential to configure modules that are added through upgrades and that require
               * initialization.
               *
               * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
               * a contract, executing them in the right order is up to the developer or operator.
               */
              modifier reinitializer(uint8 version) {
                  require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                  _initialized = version;
                  _initializing = true;
                  _;
                  _initializing = false;
                  emit Initialized(version);
              }
              /**
               * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
               * {initializer} and {reinitializer} modifiers, directly or indirectly.
               */
              modifier onlyInitializing() {
                  require(_initializing, "Initializable: contract is not initializing");
                  _;
              }
              /**
               * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
               * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
               * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
               * through proxies.
               */
              function _disableInitializers() internal virtual {
                  require(!_initializing, "Initializable: contract is initializing");
                  if (_initialized < type(uint8).max) {
                      _initialized = type(uint8).max;
                      emit Initialized(type(uint8).max);
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
          pragma solidity ^0.8.0;
          import "../utils/ContextUpgradeable.sol";
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Contract module which provides a basic access control mechanism, where
           * there is an account (an owner) that can be granted exclusive access to
           * specific functions.
           *
           * By default, the owner account will be the one that deploys the contract. This
           * can later be changed with {transferOwnership}.
           *
           * This module is used through inheritance. It will make available the modifier
           * `onlyOwner`, which can be applied to your functions to restrict their use to
           * the owner.
           */
          abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
              address private _owner;
              event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
              /**
               * @dev Initializes the contract setting the deployer as the initial owner.
               */
              function __Ownable_init() internal onlyInitializing {
                  __Ownable_init_unchained();
              }
              function __Ownable_init_unchained() internal onlyInitializing {
                  _transferOwnership(_msgSender());
              }
              /**
               * @dev Throws if called by any account other than the owner.
               */
              modifier onlyOwner() {
                  _checkOwner();
                  _;
              }
              /**
               * @dev Returns the address of the current owner.
               */
              function owner() public view virtual returns (address) {
                  return _owner;
              }
              /**
               * @dev Throws if the sender is not the owner.
               */
              function _checkOwner() internal view virtual {
                  require(owner() == _msgSender(), "Ownable: caller is not the owner");
              }
              /**
               * @dev Leaves the contract without owner. It will not be possible to call
               * `onlyOwner` functions anymore. Can only be called by the current owner.
               *
               * NOTE: Renouncing ownership will leave the contract without an owner,
               * thereby removing any functionality that is only available to the owner.
               */
              function renounceOwnership() public virtual onlyOwner {
                  _transferOwnership(address(0));
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Can only be called by the current owner.
               */
              function transferOwnership(address newOwner) public virtual onlyOwner {
                  require(newOwner != address(0), "Ownable: new owner is the zero address");
                  _transferOwnership(newOwner);
              }
              /**
               * @dev Transfers ownership of the contract to a new account (`newOwner`).
               * Internal function without access restriction.
               */
              function _transferOwnership(address newOwner) internal virtual {
                  address oldOwner = _owner;
                  _owner = newOwner;
                  emit OwnershipTransferred(oldOwner, newOwner);
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[49] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
          pragma solidity ^0.8.0;
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Contract module that helps prevent reentrant calls to a function.
           *
           * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
           * available, which can be applied to functions to make sure there are no nested
           * (reentrant) calls to them.
           *
           * Note that because there is a single `nonReentrant` guard, functions marked as
           * `nonReentrant` may not call one another. This can be worked around by making
           * those functions `private`, and then adding `external` `nonReentrant` entry
           * points to them.
           *
           * TIP: If you would like to learn more about reentrancy and alternative ways
           * to protect against it, check out our blog post
           * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
           */
          abstract contract ReentrancyGuardUpgradeable is Initializable {
              // Booleans are more expensive than uint256 or any type that takes up a full
              // word because each write operation emits an extra SLOAD to first read the
              // slot's contents, replace the bits taken up by the boolean, and then write
              // back. This is the compiler's defense against contract upgrades and
              // pointer aliasing, and it cannot be disabled.
              // The values being non-zero value makes deployment a bit more expensive,
              // but in exchange the refund on every call to nonReentrant will be lower in
              // amount. Since refunds are capped to a percentage of the total
              // transaction's gas, it is best to keep them low in cases like this one, to
              // increase the likelihood of the full refund coming into effect.
              uint256 private constant _NOT_ENTERED = 1;
              uint256 private constant _ENTERED = 2;
              uint256 private _status;
              function __ReentrancyGuard_init() internal onlyInitializing {
                  __ReentrancyGuard_init_unchained();
              }
              function __ReentrancyGuard_init_unchained() internal onlyInitializing {
                  _status = _NOT_ENTERED;
              }
              /**
               * @dev Prevents a contract from calling itself, directly or indirectly.
               * Calling a `nonReentrant` function from another `nonReentrant`
               * function is not supported. It is possible to prevent this from happening
               * by making the `nonReentrant` function external, and making it call a
               * `private` function that does the actual work.
               */
              modifier nonReentrant() {
                  // On the first call to nonReentrant, _notEntered will be true
                  require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                  // Any calls to nonReentrant after this point will fail
                  _status = _ENTERED;
                  _;
                  // By storing the original value once again, a refund is triggered (see
                  // https://eips.ethereum.org/EIPS/eip-2200)
                  _status = _NOT_ENTERED;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[49] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
          pragma solidity ^0.8.1;
          /**
           * @dev Collection of functions related to the address type
           */
          library AddressUpgradeable {
              /**
               * @dev Returns true if `account` is a contract.
               *
               * [IMPORTANT]
               * ====
               * It is unsafe to assume that an address for which this function returns
               * false is an externally-owned account (EOA) and not a contract.
               *
               * Among others, `isContract` will return false for the following
               * types of addresses:
               *
               *  - an externally-owned account
               *  - a contract in construction
               *  - an address where a contract will be created
               *  - an address where a contract lived, but was destroyed
               * ====
               *
               * [IMPORTANT]
               * ====
               * You shouldn't rely on `isContract` to protect against flash loan attacks!
               *
               * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
               * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
               * constructor.
               * ====
               */
              function isContract(address account) internal view returns (bool) {
                  // This method relies on extcodesize/address.code.length, which returns 0
                  // for contracts in construction, since the code is only stored at the end
                  // of the constructor execution.
                  return account.code.length > 0;
              }
              /**
               * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
               * `recipient`, forwarding all available gas and reverting on errors.
               *
               * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
               * of certain opcodes, possibly making contracts go over the 2300 gas limit
               * imposed by `transfer`, making them unable to receive funds via
               * `transfer`. {sendValue} removes this limitation.
               *
               * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
               *
               * IMPORTANT: because control is transferred to `recipient`, care must be
               * taken to not create reentrancy vulnerabilities. Consider using
               * {ReentrancyGuard} or the
               * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
               */
              function sendValue(address payable recipient, uint256 amount) internal {
                  require(address(this).balance >= amount, "Address: insufficient balance");
                  (bool success, ) = recipient.call{value: amount}("");
                  require(success, "Address: unable to send value, recipient may have reverted");
              }
              /**
               * @dev Performs a Solidity function call using a low level `call`. A
               * plain `call` is an unsafe replacement for a function call: use this
               * function instead.
               *
               * If `target` reverts with a revert reason, it is bubbled up by this
               * function (like regular Solidity function calls).
               *
               * Returns the raw returned data. To convert to the expected return value,
               * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
               *
               * Requirements:
               *
               * - `target` must be a contract.
               * - calling `target` with `data` must not revert.
               *
               * _Available since v3.1._
               */
              function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionCall(target, data, "Address: low-level call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
               * `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, 0, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but also transferring `value` wei to `target`.
               *
               * Requirements:
               *
               * - the calling contract must have an ETH balance of at least `value`.
               * - the called Solidity function must be `payable`.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
              }
              /**
               * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
               * with `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(address(this).balance >= value, "Address: insufficient balance for call");
                  require(isContract(target), "Address: call to non-contract");
                  (bool success, bytes memory returndata) = target.call{value: value}(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                  return functionStaticCall(target, data, "Address: low-level static call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal view returns (bytes memory) {
                  require(isContract(target), "Address: static call to non-contract");
                  (bool success, bytes memory returndata) = target.staticcall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
               * revert reason using the provided one.
               *
               * _Available since v4.3._
               */
              function verifyCallResult(
                  bool success,
                  bytes memory returndata,
                  string memory errorMessage
              ) internal pure returns (bytes memory) {
                  if (success) {
                      return returndata;
                  } else {
                      // Look for revert reason and bubble it up if present
                      if (returndata.length > 0) {
                          // The easiest way to bubble the revert reason is using memory via assembly
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Standard math utilities missing in the Solidity language.
           */
          library MathUpgradeable {
              enum Rounding {
                  Down, // Toward negative infinity
                  Up, // Toward infinity
                  Zero // Toward zero
              }
              /**
               * @dev Returns the largest of two numbers.
               */
              function max(uint256 a, uint256 b) internal pure returns (uint256) {
                  return a >= b ? a : b;
              }
              /**
               * @dev Returns the smallest of two numbers.
               */
              function min(uint256 a, uint256 b) internal pure returns (uint256) {
                  return a < b ? a : b;
              }
              /**
               * @dev Returns the average of two numbers. The result is rounded towards
               * zero.
               */
              function average(uint256 a, uint256 b) internal pure returns (uint256) {
                  // (a + b) / 2 can overflow.
                  return (a & b) + (a ^ b) / 2;
              }
              /**
               * @dev Returns the ceiling of the division of two numbers.
               *
               * This differs from standard division with `/` in that it rounds up instead
               * of rounding down.
               */
              function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
                  // (a + b - 1) / b can overflow on addition, so we distribute.
                  return a == 0 ? 0 : (a - 1) / b + 1;
              }
              /**
               * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
               * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
               * with further edits by Uniswap Labs also under MIT license.
               */
              function mulDiv(
                  uint256 x,
                  uint256 y,
                  uint256 denominator
              ) internal pure returns (uint256 result) {
                  unchecked {
                      // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
                      // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
                      // variables such that product = prod1 * 2^256 + prod0.
                      uint256 prod0; // Least significant 256 bits of the product
                      uint256 prod1; // Most significant 256 bits of the product
                      assembly {
                          let mm := mulmod(x, y, not(0))
                          prod0 := mul(x, y)
                          prod1 := sub(sub(mm, prod0), lt(mm, prod0))
                      }
                      // Handle non-overflow cases, 256 by 256 division.
                      if (prod1 == 0) {
                          return prod0 / denominator;
                      }
                      // Make sure the result is less than 2^256. Also prevents denominator == 0.
                      require(denominator > prod1);
                      ///////////////////////////////////////////////
                      // 512 by 256 division.
                      ///////////////////////////////////////////////
                      // Make division exact by subtracting the remainder from [prod1 prod0].
                      uint256 remainder;
                      assembly {
                          // Compute remainder using mulmod.
                          remainder := mulmod(x, y, denominator)
                          // Subtract 256 bit number from 512 bit number.
                          prod1 := sub(prod1, gt(remainder, prod0))
                          prod0 := sub(prod0, remainder)
                      }
                      // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
                      // See https://cs.stackexchange.com/q/138556/92363.
                      // Does not overflow because the denominator cannot be zero at this stage in the function.
                      uint256 twos = denominator & (~denominator + 1);
                      assembly {
                          // Divide denominator by twos.
                          denominator := div(denominator, twos)
                          // Divide [prod1 prod0] by twos.
                          prod0 := div(prod0, twos)
                          // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                          twos := add(div(sub(0, twos), twos), 1)
                      }
                      // Shift in bits from prod1 into prod0.
                      prod0 |= prod1 * twos;
                      // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
                      // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
                      // four bits. That is, denominator * inv = 1 mod 2^4.
                      uint256 inverse = (3 * denominator) ^ 2;
                      // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
                      // in modular arithmetic, doubling the correct bits in each step.
                      inverse *= 2 - denominator * inverse; // inverse mod 2^8
                      inverse *= 2 - denominator * inverse; // inverse mod 2^16
                      inverse *= 2 - denominator * inverse; // inverse mod 2^32
                      inverse *= 2 - denominator * inverse; // inverse mod 2^64
                      inverse *= 2 - denominator * inverse; // inverse mod 2^128
                      inverse *= 2 - denominator * inverse; // inverse mod 2^256
                      // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
                      // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
                      // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
                      // is no longer required.
                      result = prod0 * inverse;
                      return result;
                  }
              }
              /**
               * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
               */
              function mulDiv(
                  uint256 x,
                  uint256 y,
                  uint256 denominator,
                  Rounding rounding
              ) internal pure returns (uint256) {
                  uint256 result = mulDiv(x, y, denominator);
                  if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
                      result += 1;
                  }
                  return result;
              }
              /**
               * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
               *
               * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
               */
              function sqrt(uint256 a) internal pure returns (uint256) {
                  if (a == 0) {
                      return 0;
                  }
                  // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
                  // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
                  // `msb(a) <= a < 2*msb(a)`.
                  // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
                  // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
                  // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
                  // good first aproximation of `sqrt(a)` with at least 1 correct bit.
                  uint256 result = 1;
                  uint256 x = a;
                  if (x >> 128 > 0) {
                      x >>= 128;
                      result <<= 64;
                  }
                  if (x >> 64 > 0) {
                      x >>= 64;
                      result <<= 32;
                  }
                  if (x >> 32 > 0) {
                      x >>= 32;
                      result <<= 16;
                  }
                  if (x >> 16 > 0) {
                      x >>= 16;
                      result <<= 8;
                  }
                  if (x >> 8 > 0) {
                      x >>= 8;
                      result <<= 4;
                  }
                  if (x >> 4 > 0) {
                      x >>= 4;
                      result <<= 2;
                  }
                  if (x >> 2 > 0) {
                      result <<= 1;
                  }
                  // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
                  // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
                  // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
                  // into the expected uint128 result.
                  unchecked {
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      result = (result + a / result) >> 1;
                      return min(result, a / result);
                  }
              }
              /**
               * @notice Calculates sqrt(a), following the selected rounding direction.
               */
              function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
                  uint256 result = sqrt(a);
                  if (rounding == Rounding.Up && result * result < a) {
                      result += 1;
                  }
                  return result;
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
          pragma solidity ^0.8.0;
          import "../IERC20.sol";
          import "../extensions/draft-IERC20Permit.sol";
          import "../../../utils/Address.sol";
          /**
           * @title SafeERC20
           * @dev Wrappers around ERC20 operations that throw on failure (when the token
           * contract returns false). Tokens that return no value (and instead revert or
           * throw on failure) are also supported, non-reverting calls are assumed to be
           * successful.
           * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
           * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
           */
          library SafeERC20 {
              using Address for address;
              function safeTransfer(
                  IERC20 token,
                  address to,
                  uint256 value
              ) internal {
                  _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
              }
              function safeTransferFrom(
                  IERC20 token,
                  address from,
                  address to,
                  uint256 value
              ) internal {
                  _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
              }
              /**
               * @dev Deprecated. This function has issues similar to the ones found in
               * {IERC20-approve}, and its usage is discouraged.
               *
               * Whenever possible, use {safeIncreaseAllowance} and
               * {safeDecreaseAllowance} instead.
               */
              function safeApprove(
                  IERC20 token,
                  address spender,
                  uint256 value
              ) internal {
                  // safeApprove should only be called when setting an initial allowance,
                  // or when resetting it to zero. To increase and decrease it, use
                  // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                  require(
                      (value == 0) || (token.allowance(address(this), spender) == 0),
                      "SafeERC20: approve from non-zero to non-zero allowance"
                  );
                  _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
              }
              function safeIncreaseAllowance(
                  IERC20 token,
                  address spender,
                  uint256 value
              ) internal {
                  uint256 newAllowance = token.allowance(address(this), spender) + value;
                  _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
              }
              function safeDecreaseAllowance(
                  IERC20 token,
                  address spender,
                  uint256 value
              ) internal {
                  unchecked {
                      uint256 oldAllowance = token.allowance(address(this), spender);
                      require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                      uint256 newAllowance = oldAllowance - value;
                      _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                  }
              }
              function safePermit(
                  IERC20Permit token,
                  address owner,
                  address spender,
                  uint256 value,
                  uint256 deadline,
                  uint8 v,
                  bytes32 r,
                  bytes32 s
              ) internal {
                  uint256 nonceBefore = token.nonces(owner);
                  token.permit(owner, spender, value, deadline, v, r, s);
                  uint256 nonceAfter = token.nonces(owner);
                  require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
              }
              /**
               * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
               * on the return value: the return value is optional (but if data is returned, it must not be false).
               * @param token The token targeted by the call.
               * @param data The call data (encoded using abi.encode or one of its variants).
               */
              function _callOptionalReturn(IERC20 token, bytes memory data) private {
                  // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                  // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                  // the target address contains contract code and also asserts for success in the low-level call.
                  bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                  if (returndata.length > 0) {
                      // Return data is optional
                      require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                  }
              }
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.0;
          import "./Merkle.sol";
          import "../libraries/Endian.sol";
          //Utility library for parsing and PHASE0 beacon chain block headers
          //SSZ Spec: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization
          //BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
          //BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate
          library BeaconChainProofs {
              // constants are the number of fields and the heights of the different merkle trees used in merkleizing beacon chain containers
              uint256 internal constant BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT = 3;
              uint256 internal constant BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT = 4;
              uint256 internal constant BEACON_STATE_FIELD_TREE_HEIGHT = 5;
              uint256 internal constant VALIDATOR_FIELD_TREE_HEIGHT = 3;
              //Note: changed in the deneb hard fork from 4->5
              uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB = 5;
              uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA = 4;
              // SLOTS_PER_HISTORICAL_ROOT = 2**13, so tree height is 13
              uint256 internal constant BLOCK_ROOTS_TREE_HEIGHT = 13;
              //HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
              uint256 internal constant HISTORICAL_SUMMARIES_TREE_HEIGHT = 24;
              //Index of block_summary_root in historical_summary container
              uint256 internal constant BLOCK_SUMMARY_ROOT_INDEX = 0;
              // tree height for hash tree of an individual withdrawal container
              uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2;
              uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;
              // MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4
              uint256 internal constant WITHDRAWALS_TREE_HEIGHT = 4;
              //in beacon block body https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconblockbody
              uint256 internal constant EXECUTION_PAYLOAD_INDEX = 9;
              // in beacon block header https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
              uint256 internal constant SLOT_INDEX = 0;
              uint256 internal constant STATE_ROOT_INDEX = 3;
              uint256 internal constant BODY_ROOT_INDEX = 4;
              // in beacon state https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate
              uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11;
              uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27;
              // in validator https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
              uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
              uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
              uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
              uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7;
              // in execution payload header
              uint256 internal constant TIMESTAMP_INDEX = 9;
              //in execution payload
              uint256 internal constant WITHDRAWALS_INDEX = 14;
              // in withdrawal
              uint256 internal constant WITHDRAWAL_VALIDATOR_INDEX_INDEX = 1;
              uint256 internal constant WITHDRAWAL_VALIDATOR_AMOUNT_INDEX = 3;
              //Misc Constants
              /// @notice The number of slots each epoch in the beacon chain
              uint64 internal constant SLOTS_PER_EPOCH = 32;
              /// @notice The number of seconds in a slot in the beacon chain
              uint64 internal constant SECONDS_PER_SLOT = 12;
              /// @notice Number of seconds per epoch: 384 == 32 slots/epoch * 12 seconds/slot 
              uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT;
              bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;
              /// @notice This struct contains the merkle proofs and leaves needed to verify a partial/full withdrawal
              struct WithdrawalProof {
                  bytes withdrawalProof;
                  bytes slotProof;
                  bytes executionPayloadProof;
                  bytes timestampProof;
                  bytes historicalSummaryBlockRootProof;
                  uint64 blockRootIndex;
                  uint64 historicalSummaryIndex;
                  uint64 withdrawalIndex;
                  bytes32 blockRoot;
                  bytes32 slotRoot;
                  bytes32 timestampRoot;
                  bytes32 executionPayloadRoot;
              }
              /// @notice This struct contains the root and proof for verifying the state root against the oracle block root
              struct StateRootProof {
                  bytes32 beaconStateRoot;
                  bytes proof;
              }
              /**
               * @notice This function verifies merkle proofs of the fields of a certain validator against a beacon chain state root
               * @param validatorIndex the index of the proven validator
               * @param beaconStateRoot is the beacon chain state root to be proven against.
               * @param validatorFieldsProof is the data used in proving the validator's fields
               * @param validatorFields the claimed fields of the validator
               */
              function verifyValidatorFields(
                  bytes32 beaconStateRoot,
                  bytes32[] calldata validatorFields,
                  bytes calldata validatorFieldsProof,
                  uint40 validatorIndex
              ) internal view {
                  require(
                      validatorFields.length == 2 ** VALIDATOR_FIELD_TREE_HEIGHT,
                      "BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"
                  );
                  /**
                   * Note: the length of the validator merkle proof is BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1.
                   * There is an additional layer added by hashing the root with the length of the validator list
                   */
                  require(
                      validatorFieldsProof.length == 32 * ((VALIDATOR_TREE_HEIGHT + 1) + BEACON_STATE_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"
                  );
                  uint256 index = (VALIDATOR_TREE_ROOT_INDEX << (VALIDATOR_TREE_HEIGHT + 1)) | uint256(validatorIndex);
                  // merkleize the validatorFields to get the leaf to prove
                  bytes32 validatorRoot = Merkle.merkleizeSha256(validatorFields);
                  // verify the proof of the validatorRoot against the beaconStateRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: validatorFieldsProof,
                          root: beaconStateRoot,
                          leaf: validatorRoot,
                          index: index
                      }),
                      "BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"
                  );
              }
              /**
               * @notice This function verifies the latestBlockHeader against the state root. the latestBlockHeader is
               * a tracked in the beacon state.
               * @param beaconStateRoot is the beacon chain state root to be proven against.
               * @param stateRootProof is the provided merkle proof
               * @param latestBlockRoot is hashtree root of the latest block header in the beacon state
               */
              function verifyStateRootAgainstLatestBlockRoot(
                  bytes32 latestBlockRoot,
                  bytes32 beaconStateRoot,
                  bytes calldata stateRootProof
              ) internal view {
                  require(
                      stateRootProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Proof has incorrect length"
                  );
                  //Next we verify the slot against the blockRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: stateRootProof,
                          root: latestBlockRoot,
                          leaf: beaconStateRoot,
                          index: STATE_ROOT_INDEX
                      }),
                      "BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Invalid latest block header root merkle proof"
                  );
              }
              /**
               * @notice This function verifies the slot and the withdrawal fields for a given withdrawal
               * @param withdrawalProof is the provided set of merkle proofs
               * @param withdrawalFields is the serialized withdrawal container to be proven
               */
              function verifyWithdrawal(
                  bytes32 beaconStateRoot,
                  bytes32[] calldata withdrawalFields,
                  WithdrawalProof calldata withdrawalProof,
                  uint64 denebForkTimestamp
              ) internal view {
                  require(
                      withdrawalFields.length == 2 ** WITHDRAWAL_FIELD_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: withdrawalFields has incorrect length"
                  );
                  require(
                      withdrawalProof.blockRootIndex < 2 ** BLOCK_ROOTS_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: blockRootIndex is too large"
                  );
                  require(
                      withdrawalProof.withdrawalIndex < 2 ** WITHDRAWALS_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: withdrawalIndex is too large"
                  );
                  require(
                      withdrawalProof.historicalSummaryIndex < 2 ** HISTORICAL_SUMMARIES_TREE_HEIGHT,
                      "BeaconChainProofs.verifyWithdrawal: historicalSummaryIndex is too large"
                  );
                  //Note: post deneb hard fork, the number of exection payload header fields increased from 15->17, adding an extra level to the tree height
                  uint256 executionPayloadHeaderFieldTreeHeight = (getWithdrawalTimestamp(withdrawalProof) < denebForkTimestamp) ? EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_CAPELLA : EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT_DENEB;
                  require(
                      withdrawalProof.withdrawalProof.length ==
                          32 * (executionPayloadHeaderFieldTreeHeight + WITHDRAWALS_TREE_HEIGHT + 1),
                      "BeaconChainProofs.verifyWithdrawal: withdrawalProof has incorrect length"
                  );
                  require(
                      withdrawalProof.executionPayloadProof.length ==
                          32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT + BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyWithdrawal: executionPayloadProof has incorrect length"
                  );
                  require(
                      withdrawalProof.slotProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
                      "BeaconChainProofs.verifyWithdrawal: slotProof has incorrect length"
                  );
                  require(
                      withdrawalProof.timestampProof.length == 32 * (executionPayloadHeaderFieldTreeHeight),
                      "BeaconChainProofs.verifyWithdrawal: timestampProof has incorrect length"
                  );
                  require(
                      withdrawalProof.historicalSummaryBlockRootProof.length ==
                          32 *
                              (BEACON_STATE_FIELD_TREE_HEIGHT +
                                  (HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) +
                                  1 +
                                  (BLOCK_ROOTS_TREE_HEIGHT)),
                      "BeaconChainProofs.verifyWithdrawal: historicalSummaryBlockRootProof has incorrect length"
                  );
                  /**
                   * Note: Here, the "1" in "1 + (BLOCK_ROOTS_TREE_HEIGHT)" signifies that extra step of choosing the "block_root_summary" within the individual
                   * "historical_summary". Everywhere else it signifies merkelize_with_mixin, where the length of an array is hashed with the root of the array,
                   * but not here.
                   */
                  uint256 historicalBlockHeaderIndex = (HISTORICAL_SUMMARIES_INDEX <<
                      ((HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) + 1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
                      (uint256(withdrawalProof.historicalSummaryIndex) << (1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
                      (BLOCK_SUMMARY_ROOT_INDEX << (BLOCK_ROOTS_TREE_HEIGHT)) |
                      uint256(withdrawalProof.blockRootIndex);
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.historicalSummaryBlockRootProof,
                          root: beaconStateRoot,
                          leaf: withdrawalProof.blockRoot,
                          index: historicalBlockHeaderIndex
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid historicalsummary merkle proof"
                  );
                  //Next we verify the slot against the blockRoot
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.slotProof,
                          root: withdrawalProof.blockRoot,
                          leaf: withdrawalProof.slotRoot,
                          index: SLOT_INDEX
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid slot merkle proof"
                  );
                  {
                      // Next we verify the executionPayloadRoot against the blockRoot
                      uint256 executionPayloadIndex = (BODY_ROOT_INDEX << (BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT)) |
                          EXECUTION_PAYLOAD_INDEX;
                      require(
                          Merkle.verifyInclusionSha256({
                              proof: withdrawalProof.executionPayloadProof,
                              root: withdrawalProof.blockRoot,
                              leaf: withdrawalProof.executionPayloadRoot,
                              index: executionPayloadIndex
                          }),
                          "BeaconChainProofs.verifyWithdrawal: Invalid executionPayload merkle proof"
                      );
                  }
                  // Next we verify the timestampRoot against the executionPayload root
                  require(
                      Merkle.verifyInclusionSha256({
                          proof: withdrawalProof.timestampProof,
                          root: withdrawalProof.executionPayloadRoot,
                          leaf: withdrawalProof.timestampRoot,
                          index: TIMESTAMP_INDEX
                      }),
                      "BeaconChainProofs.verifyWithdrawal: Invalid timestamp merkle proof"
                  );
                  {
                      /**
                       * Next we verify the withdrawal fields against the executionPayloadRoot:
                       * First we compute the withdrawal_index, then we merkleize the 
                       * withdrawalFields container to calculate the withdrawalRoot.
                       *
                       * Note: Merkleization of the withdrawals root tree uses MerkleizeWithMixin, i.e., the length of the array is hashed with the root of
                       * the array.  Thus we shift the WITHDRAWALS_INDEX over by WITHDRAWALS_TREE_HEIGHT + 1 and not just WITHDRAWALS_TREE_HEIGHT.
                       */
                      uint256 withdrawalIndex = (WITHDRAWALS_INDEX << (WITHDRAWALS_TREE_HEIGHT + 1)) |
                          uint256(withdrawalProof.withdrawalIndex);
                      bytes32 withdrawalRoot = Merkle.merkleizeSha256(withdrawalFields);
                      require(
                          Merkle.verifyInclusionSha256({
                              proof: withdrawalProof.withdrawalProof,
                              root: withdrawalProof.executionPayloadRoot,
                              leaf: withdrawalRoot,
                              index: withdrawalIndex
                          }),
                          "BeaconChainProofs.verifyWithdrawal: Invalid withdrawal merkle proof"
                      );
                  }
              }
              /**
               * @notice This function replicates the ssz hashing of a validator's pubkey, outlined below:
               *  hh := ssz.NewHasher()
               *  hh.PutBytes(validatorPubkey[:])
               *  validatorPubkeyHash := hh.Hash()
               *  hh.Reset()
               */
              function hashValidatorBLSPubkey(bytes memory validatorPubkey) internal pure returns (bytes32 pubkeyHash) {
                  require(validatorPubkey.length == 48, "Input should be 48 bytes in length");
                  return sha256(abi.encodePacked(validatorPubkey, bytes16(0)));
              }
              /**
               * @dev Retrieve the withdrawal timestamp
               */
              function getWithdrawalTimestamp(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalProof.timestampRoot);
              }
              /**
               * @dev Converts the withdrawal's slot to an epoch
               */
              function getWithdrawalEpoch(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalProof.slotRoot) / SLOTS_PER_EPOCH;
              }
              /**
               * Indices for validator fields (refer to consensus specs):
               * 0: pubkey
               * 1: withdrawal credentials
               * 2: effective balance
               * 3: slashed?
               * 4: activation elligibility epoch
               * 5: activation epoch
               * 6: exit epoch
               * 7: withdrawable epoch
               */
              /**
               * @dev Retrieves a validator's pubkey hash
               */
              function getPubkeyHash(bytes32[] memory validatorFields) internal pure returns (bytes32) {
                  return 
                      validatorFields[VALIDATOR_PUBKEY_INDEX];
              }
              function getWithdrawalCredentials(bytes32[] memory validatorFields) internal pure returns (bytes32) {
                  return
                      validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX];
              }
              /**
               * @dev Retrieves a validator's effective balance (in gwei)
               */
              function getEffectiveBalanceGwei(bytes32[] memory validatorFields) internal pure returns (uint64) {
                  return 
                      Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_BALANCE_INDEX]);
              }
              /**
               * @dev Retrieves a validator's withdrawable epoch
               */
              function getWithdrawableEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
                  return 
                      Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_WITHDRAWABLE_EPOCH_INDEX]);
              }
              /**
               * Indices for withdrawal fields (refer to consensus specs):
               * 0: withdrawal index
               * 1: validator index
               * 2: execution address
               * 3: withdrawal amount
               */
              /**
               * @dev Retrieves a withdrawal's validator index
               */
              function getValidatorIndex(bytes32[] memory withdrawalFields) internal pure returns (uint40) {
                  return 
                      uint40(Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_INDEX_INDEX]));
              }
              /**
               * @dev Retrieves a withdrawal's withdrawal amount (in gwei)
               */
              function getWithdrawalAmountGwei(bytes32[] memory withdrawalFields) internal pure returns (uint64) {
                  return
                      Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_AMOUNT_INDEX]);
              }
          }
          // SPDX-License-Identifier: Unlicense
          /*
           * @title Solidity Bytes Arrays Utils
           * @author Gonçalo Sá <[email protected]>
           *
           * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
           *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
           */
          pragma solidity >=0.8.0 <0.9.0;
          library BytesLib {
              function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {
                  bytes memory tempBytes;
                  assembly {
                      // Get a location of some free memory and store it in tempBytes as
                      // Solidity does for memory variables.
                      tempBytes := mload(0x40)
                      // Store the length of the first bytes array at the beginning of
                      // the memory for tempBytes.
                      let length := mload(_preBytes)
                      mstore(tempBytes, length)
                      // Maintain a memory counter for the current write location in the
                      // temp bytes array by adding the 32 bytes for the array length to
                      // the starting location.
                      let mc := add(tempBytes, 0x20)
                      // Stop copying when the memory counter reaches the length of the
                      // first bytes array.
                      let end := add(mc, length)
                      for {
                          // Initialize a copy counter to the start of the _preBytes data,
                          // 32 bytes into its memory.
                          let cc := add(_preBytes, 0x20)
                      } lt(mc, end) {
                          // Increase both counters by 32 bytes each iteration.
                          mc := add(mc, 0x20)
                          cc := add(cc, 0x20)
                      } {
                          // Write the _preBytes data into the tempBytes memory 32 bytes
                          // at a time.
                          mstore(mc, mload(cc))
                      }
                      // Add the length of _postBytes to the current length of tempBytes
                      // and store it as the new length in the first 32 bytes of the
                      // tempBytes memory.
                      length := mload(_postBytes)
                      mstore(tempBytes, add(length, mload(tempBytes)))
                      // Move the memory counter back from a multiple of 0x20 to the
                      // actual end of the _preBytes data.
                      mc := end
                      // Stop copying when the memory counter reaches the new combined
                      // length of the arrays.
                      end := add(mc, length)
                      for {
                          let cc := add(_postBytes, 0x20)
                      } lt(mc, end) {
                          mc := add(mc, 0x20)
                          cc := add(cc, 0x20)
                      } {
                          mstore(mc, mload(cc))
                      }
                      // Update the free-memory pointer by padding our last write location
                      // to 32 bytes: add 31 bytes to the end of tempBytes to move to the
                      // next 32 byte block, then round down to the nearest multiple of
                      // 32. If the sum of the length of the two arrays is zero then add
                      // one before rounding down to leave a blank 32 bytes (the length block with 0).
                      mstore(
                          0x40,
                          and(
                              add(add(end, iszero(add(length, mload(_preBytes)))), 31),
                              not(31) // Round down to the nearest 32 bytes.
                          )
                      )
                  }
                  return tempBytes;
              }
              function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
                  assembly {
                      // Read the first 32 bytes of _preBytes storage, which is the length
                      // of the array. (We don't need to use the offset into the slot
                      // because arrays use the entire slot.)
                      let fslot := sload(_preBytes.slot)
                      // Arrays of 31 bytes or less have an even value in their slot,
                      // while longer arrays have an odd value. The actual length is
                      // the slot divided by two for odd values, and the lowest order
                      // byte divided by two for even values.
                      // If the slot is even, bitwise and the slot with 255 and divide by
                      // two to get the length. If the slot is odd, bitwise and the slot
                      // with -1 and divide by two.
                      let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
                      let mlength := mload(_postBytes)
                      let newlength := add(slength, mlength)
                      // slength can contain both the length and contents of the array
                      // if length < 32 bytes so let's prepare for that
                      // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                      switch add(lt(slength, 32), lt(newlength, 32))
                      case 2 {
                          // Since the new array still fits in the slot, we just need to
                          // update the contents of the slot.
                          // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
                          sstore(
                              _preBytes.slot,
                              // all the modifications to the slot are inside this
                              // next block
                              add(
                                  // we can just add to the slot contents because the
                                  // bytes we want to change are the LSBs
                                  fslot,
                                  add(
                                      mul(
                                          div(
                                              // load the bytes from memory
                                              mload(add(_postBytes, 0x20)),
                                              // zero all bytes to the right
                                              exp(0x100, sub(32, mlength))
                                          ),
                                          // and now shift left the number of bytes to
                                          // leave space for the length in the slot
                                          exp(0x100, sub(32, newlength))
                                      ),
                                      // increase length by the double of the memory
                                      // bytes length
                                      mul(mlength, 2)
                                  )
                              )
                          )
                      }
                      case 1 {
                          // The stored value fits in the slot, but the combined value
                          // will exceed it.
                          // get the keccak hash to get the contents of the array
                          mstore(0x0, _preBytes.slot)
                          let sc := add(keccak256(0x0, 0x20), div(slength, 32))
                          // save new length
                          sstore(_preBytes.slot, add(mul(newlength, 2), 1))
                          // The contents of the _postBytes array start 32 bytes into
                          // the structure. Our first read should obtain the `submod`
                          // bytes that can fit into the unused space in the last word
                          // of the stored array. To get this, we read 32 bytes starting
                          // from `submod`, so the data we read overlaps with the array
                          // contents by `submod` bytes. Masking the lowest-order
                          // `submod` bytes allows us to add that value directly to the
                          // stored value.
                          let submod := sub(32, slength)
                          let mc := add(_postBytes, submod)
                          let end := add(_postBytes, mlength)
                          let mask := sub(exp(0x100, submod), 1)
                          sstore(
                              sc,
                              add(
                                  and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00),
                                  and(mload(mc), mask)
                              )
                          )
                          for {
                              mc := add(mc, 0x20)
                              sc := add(sc, 1)
                          } lt(mc, end) {
                              sc := add(sc, 1)
                              mc := add(mc, 0x20)
                          } {
                              sstore(sc, mload(mc))
                          }
                          mask := exp(0x100, sub(mc, end))
                          sstore(sc, mul(div(mload(mc), mask), mask))
                      }
                      default {
                          // get the keccak hash to get the contents of the array
                          mstore(0x0, _preBytes.slot)
                          // Start copying to the last used word of the stored array.
                          let sc := add(keccak256(0x0, 0x20), div(slength, 32))
                          // save new length
                          sstore(_preBytes.slot, add(mul(newlength, 2), 1))
                          // Copy over the first `submod` bytes of the new data as in
                          // case 1 above.
                          let slengthmod := mod(slength, 32)
                          // solhint-disable-next-line no-unused-vars
                          let mlengthmod := mod(mlength, 32)
                          let submod := sub(32, slengthmod)
                          let mc := add(_postBytes, submod)
                          let end := add(_postBytes, mlength)
                          let mask := sub(exp(0x100, submod), 1)
                          sstore(sc, add(sload(sc), and(mload(mc), mask)))
                          for {
                              sc := add(sc, 1)
                              mc := add(mc, 0x20)
                          } lt(mc, end) {
                              sc := add(sc, 1)
                              mc := add(mc, 0x20)
                          } {
                              sstore(sc, mload(mc))
                          }
                          mask := exp(0x100, sub(mc, end))
                          sstore(sc, mul(div(mload(mc), mask), mask))
                      }
                  }
              }
              function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {
                  require(_length + 31 >= _length, "slice_overflow");
                  require(_bytes.length >= _start + _length, "slice_outOfBounds");
                  bytes memory tempBytes;
                  assembly {
                      switch iszero(_length)
                      case 0 {
                          // Get a location of some free memory and store it in tempBytes as
                          // Solidity does for memory variables.
                          tempBytes := mload(0x40)
                          // The first word of the slice result is potentially a partial
                          // word read from the original array. To read it, we calculate
                          // the length of that partial word and start copying that many
                          // bytes into the array. The first word we copy will start with
                          // data we don't care about, but the last `lengthmod` bytes will
                          // land at the beginning of the contents of the new array. When
                          // we're done copying, we overwrite the full first word with
                          // the actual length of the slice.
                          let lengthmod := and(_length, 31)
                          // The multiplication in the next line is necessary
                          // because when slicing multiples of 32 bytes (lengthmod == 0)
                          // the following copy loop was copying the origin's length
                          // and then ending prematurely not copying everything it should.
                          let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                          let end := add(mc, _length)
                          for {
                              // The multiplication in the next line has the same exact purpose
                              // as the one above.
                              let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                          } lt(mc, end) {
                              mc := add(mc, 0x20)
                              cc := add(cc, 0x20)
                          } {
                              mstore(mc, mload(cc))
                          }
                          mstore(tempBytes, _length)
                          //update free-memory pointer
                          //allocating the array padded to 32 bytes like the compiler does now
                          mstore(0x40, and(add(mc, 31), not(31)))
                      }
                      //if we want a zero-length slice let's just return a zero-length array
                      default {
                          tempBytes := mload(0x40)
                          //zero out the 32 bytes slice we are about to return
                          //we need to do it because Solidity does not garbage collect
                          mstore(tempBytes, 0)
                          mstore(0x40, add(tempBytes, 0x20))
                      }
                  }
                  return tempBytes;
              }
              function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
                  require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
                  address tempAddress;
                  assembly {
                      tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
                  }
                  return tempAddress;
              }
              function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
                  require(_bytes.length >= _start + 1, "toUint8_outOfBounds");
                  uint8 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x1), _start))
                  }
                  return tempUint;
              }
              function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
                  require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
                  uint16 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x2), _start))
                  }
                  return tempUint;
              }
              function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
                  require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
                  uint32 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x4), _start))
                  }
                  return tempUint;
              }
              function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
                  require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
                  uint64 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x8), _start))
                  }
                  return tempUint;
              }
              function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
                  require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
                  uint96 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0xc), _start))
                  }
                  return tempUint;
              }
              function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
                  require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
                  uint128 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x10), _start))
                  }
                  return tempUint;
              }
              function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
                  require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
                  uint256 tempUint;
                  assembly {
                      tempUint := mload(add(add(_bytes, 0x20), _start))
                  }
                  return tempUint;
              }
              function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
                  require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
                  bytes32 tempBytes32;
                  assembly {
                      tempBytes32 := mload(add(add(_bytes, 0x20), _start))
                  }
                  return tempBytes32;
              }
              function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
                  bool success = true;
                  assembly {
                      let length := mload(_preBytes)
                      // if lengths don't match the arrays are not equal
                      switch eq(length, mload(_postBytes))
                      case 1 {
                          // cb is a circuit breaker in the for loop since there's
                          //  no said feature for inline assembly loops
                          // cb = 1 - don't breaker
                          // cb = 0 - break
                          let cb := 1
                          let mc := add(_preBytes, 0x20)
                          let end := add(mc, length)
                          for {
                              let cc := add(_postBytes, 0x20)
                          } // while(uint256(mc < end) + cb == 2) // the next line is the loop condition:
                          eq(add(lt(mc, end), cb), 2) {
                              mc := add(mc, 0x20)
                              cc := add(cc, 0x20)
                          } {
                              // if any of these checks fails then arrays are not equal
                              if iszero(eq(mload(mc), mload(cc))) {
                                  // unsuccess:
                                  success := 0
                                  cb := 0
                              }
                          }
                      }
                      default {
                          // unsuccess:
                          success := 0
                      }
                  }
                  return success;
              }
              function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {
                  bool success = true;
                  assembly {
                      // we know _preBytes_offset is 0
                      let fslot := sload(_preBytes.slot)
                      // Decode the length of the stored array like in concatStorage().
                      let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
                      let mlength := mload(_postBytes)
                      // if lengths don't match the arrays are not equal
                      switch eq(slength, mlength)
                      case 1 {
                          // slength can contain both the length and contents of the array
                          // if length < 32 bytes so let's prepare for that
                          // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                          if iszero(iszero(slength)) {
                              switch lt(slength, 32)
                              case 1 {
                                  // blank the last byte which is the length
                                  fslot := mul(div(fslot, 0x100), 0x100)
                                  if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                                      // unsuccess:
                                      success := 0
                                  }
                              }
                              default {
                                  // cb is a circuit breaker in the for loop since there's
                                  //  no said feature for inline assembly loops
                                  // cb = 1 - don't breaker
                                  // cb = 0 - break
                                  let cb := 1
                                  // get the keccak hash to get the contents of the array
                                  mstore(0x0, _preBytes.slot)
                                  let sc := keccak256(0x0, 0x20)
                                  let mc := add(_postBytes, 0x20)
                                  let end := add(mc, mlength)
                                  // the next line is the loop condition:
                                  // while(uint256(mc < end) + cb == 2)
                                  // solhint-disable-next-line no-empty-blocks
                                  for {
                                  } eq(add(lt(mc, end), cb), 2) {
                                      sc := add(sc, 1)
                                      mc := add(mc, 0x20)
                                  } {
                                      if iszero(eq(sload(sc), mload(mc))) {
                                          // unsuccess:
                                          success := 0
                                          cb := 0
                                      }
                                  }
                              }
                          }
                      }
                      default {
                          // unsuccess:
                          success := 0
                      }
                  }
                  return success;
              }
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.0;
          library Endian {
              /**
               * @notice Converts a little endian-formatted uint64 to a big endian-formatted uint64
               * @param lenum little endian-formatted uint64 input, provided as 'bytes32' type
               * @return n The big endian-formatted uint64
               * @dev Note that the input is formatted as a 'bytes32' type (i.e. 256 bits), but it is immediately truncated to a uint64 (i.e. 64 bits)
               * through a right-shift/shr operation.
               */
              function fromLittleEndianUint64(bytes32 lenum) internal pure returns (uint64 n) {
                  // the number needs to be stored in little-endian encoding (ie in bytes 0-8)
                  n = uint64(uint256(lenum >> 192));
                  return
                      (n >> 56) |
                      ((0x00FF000000000000 & n) >> 40) |
                      ((0x0000FF0000000000 & n) >> 24) |
                      ((0x000000FF00000000 & n) >> 8) |
                      ((0x00000000FF000000 & n) << 8) |
                      ((0x0000000000FF0000 & n) << 24) |
                      ((0x000000000000FF00 & n) << 40) |
                      ((0x00000000000000FF & n) << 56);
              }
          }
          // ┏━━━┓━┏┓━┏┓━━┏━━━┓━━┏━━━┓━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━┏┓━━━━━┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━━┏┓━
          // ┃┏━━┛┏┛┗┓┃┃━━┃┏━┓┃━━┃┏━┓┃━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━┏┛┗┓━━━━┃┏━┓┃━━━━━━━━┏┛┗┓━━━━━━━━━━━━┏┛┗┓
          // ┃┗━━┓┗┓┏┛┃┗━┓┗┛┏┛┃━━┃┃━┃┃━━━━━┃┃┃┃┏━━┓┏━━┓┏━━┓┏━━┓┏┓┗┓┏┛━━━━┃┃━┗┛┏━━┓┏━┓━┗┓┏┛┏━┓┏━━┓━┏━━┓┗┓┏┛
          // ┃┏━━┛━┃┃━┃┏┓┃┏━┛┏┛━━┃┃━┃┃━━━━━┃┃┃┃┃┏┓┃┃┏┓┃┃┏┓┃┃━━┫┣┫━┃┃━━━━━┃┃━┏┓┃┏┓┃┃┏┓┓━┃┃━┃┏┛┗━┓┃━┃┏━┛━┃┃━
          // ┃┗━━┓━┃┗┓┃┃┃┃┃┃┗━┓┏┓┃┗━┛┃━━━━┏┛┗┛┃┃┃━┫┃┗┛┃┃┗┛┃┣━━┃┃┃━┃┗┓━━━━┃┗━┛┃┃┗┛┃┃┃┃┃━┃┗┓┃┃━┃┗┛┗┓┃┗━┓━┃┗┓
          // ┗━━━┛━┗━┛┗┛┗┛┗━━━┛┗┛┗━━━┛━━━━┗━━━┛┗━━┛┃┏━┛┗━━┛┗━━┛┗┛━┗━┛━━━━┗━━━┛┗━━┛┗┛┗┛━┗━┛┗┛━┗━━━┛┗━━┛━┗━┛
          // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
          // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
          // SPDX-License-Identifier: CC0-1.0
          pragma solidity >=0.5.0;
          // This interface is designed to be compatible with the Vyper version.
          /// @notice This is the Ethereum 2.0 deposit contract interface.
          /// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs
          interface IETHPOSDeposit {
              /// @notice A processed deposit event.
              event DepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index);
              /// @notice Submit a Phase 0 DepositData object.
              /// @param pubkey A BLS12-381 public key.
              /// @param withdrawal_credentials Commitment to a public key for withdrawals.
              /// @param signature A BLS12-381 signature.
              /// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object.
              /// Used as a protection against malformed input.
              function deposit(
                  bytes calldata pubkey,
                  bytes calldata withdrawal_credentials,
                  bytes calldata signature,
                  bytes32 deposit_data_root
              ) external payable;
              /// @notice Query the current deposit root hash.
              /// @return The deposit root hash.
              function get_deposit_root() external view returns (bytes32);
              /// @notice Query the current deposit count.
              /// @return The deposit count encoded as a little endian 64-bit number.
              function get_deposit_count() external view returns (bytes memory);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
          import "./IETHPOSDeposit.sol";
          import "./IStrategyManager.sol";
          import "./IEigenPod.sol";
          import "./IBeaconChainOracle.sol";
          import "./IPausable.sol";
          import "./ISlasher.sol";
          import "./IStrategy.sol";
          /**
           * @title Interface for factory that creates and manages solo staking pods that have their withdrawal credentials pointed to EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IEigenPodManager is IPausable {
              /// @notice Emitted to notify the update of the beaconChainOracle address
              event BeaconOracleUpdated(address indexed newOracleAddress);
              /// @notice Emitted to notify the deployment of an EigenPod
              event PodDeployed(address indexed eigenPod, address indexed podOwner);
              /// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager
              event BeaconChainETHDeposited(address indexed podOwner, uint256 amount);
              /// @notice Emitted when the balance of an EigenPod is updated
              event PodSharesUpdated(address indexed podOwner, int256 sharesDelta);
              /// @notice Emitted when a withdrawal of beacon chain ETH is completed
              event BeaconChainETHWithdrawalCompleted(
                  address indexed podOwner,
                  uint256 shares,
                  uint96 nonce,
                  address delegatedAddress,
                  address withdrawer,
                  bytes32 withdrawalRoot
              );
              event DenebForkTimestampUpdated(uint64 newValue);
              /**
               * @notice Creates an EigenPod for the sender.
               * @dev Function will revert if the `msg.sender` already has an EigenPod.
               * @dev Returns EigenPod address 
               */
              function createPod() external returns (address);
              /**
               * @notice Stakes for a new beacon chain validator on the sender's EigenPod.
               * Also creates an EigenPod for the sender if they don't have one already.
               * @param pubkey The 48 bytes public key of the beacon chain validator.
               * @param signature The validator's signature of the deposit data.
               * @param depositDataRoot The root/hash of the deposit data for the validator's deposit.
               */
              function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
              /**
               * @notice Changes the `podOwner`'s shares by `sharesDelta` and performs a call to the DelegationManager
               * to ensure that delegated shares are also tracked correctly
               * @param podOwner is the pod owner whose balance is being updated.
               * @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares
               * @dev Callable only by the podOwner's EigenPod contract.
               * @dev Reverts if `sharesDelta` is not a whole Gwei amount
               */
              function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external;
              /**
               * @notice Updates the oracle contract that provides the beacon chain state root
               * @param newBeaconChainOracle is the new oracle contract being pointed to
               * @dev Callable only by the owner of this contract (i.e. governance)
               */
              function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external;
              /// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed.
              function ownerToPod(address podOwner) external view returns (IEigenPod);
              /// @notice Returns the address of the `podOwner`'s EigenPod (whether it is deployed yet or not).
              function getPod(address podOwner) external view returns (IEigenPod);
              /// @notice The ETH2 Deposit Contract
              function ethPOS() external view returns (IETHPOSDeposit);
              /// @notice Beacon proxy to which the EigenPods point
              function eigenPodBeacon() external view returns (IBeacon);
              /// @notice Oracle contract that provides updates to the beacon chain's state
              function beaconChainOracle() external view returns (IBeaconChainOracle);
              /// @notice Returns the beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized.
              function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32);
              /// @notice EigenLayer's StrategyManager contract
              function strategyManager() external view returns (IStrategyManager);
              /// @notice EigenLayer's Slasher contract
              function slasher() external view returns (ISlasher);
              /// @notice Returns 'true' if the `podOwner` has created an EigenPod, and 'false' otherwise.
              function hasPod(address podOwner) external view returns (bool);
              /// @notice Returns the number of EigenPods that have been created
              function numPods() external view returns (uint256);
              /**
               * @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy.
               * @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can
               * decrease between the pod owner queuing and completing a withdrawal.
               * When the pod owner's shares would otherwise increase, this "deficit" is decreased first _instead_.
               * Likewise, when a withdrawal is completed, this "deficit" is decreased and the withdrawal amount is decreased; We can think of this
               * as the withdrawal "paying off the deficit".
               */
              function podOwnerShares(address podOwner) external view returns (int256);
              /// @notice returns canonical, virtual beaconChainETH strategy
              function beaconChainETHStrategy() external view returns (IStrategy);
              /**
               * @notice Used by the DelegationManager to remove a pod owner's shares while they're in the withdrawal queue.
               * Simply decreases the `podOwner`'s shares by `shares`, down to a minimum of zero.
               * @dev This function reverts if it would result in `podOwnerShares[podOwner]` being less than zero, i.e. it is forbidden for this function to
               * result in the `podOwner` incurring a "share deficit". This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive
               * shares from the operator to whom the staker is delegated.
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function removeShares(address podOwner, uint256 shares) external;
              /**
               * @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible.
               * Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue
               * @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input
               * in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero)
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function addShares(address podOwner, uint256 shares) external returns (uint256);
              /**
               * @notice Used by the DelegationManager to complete a withdrawal, sending tokens to some destination address
               * @dev Prioritizes decreasing the podOwner's share deficit, if they have one
               * @dev Reverts if `shares` is not a whole Gwei amount
               */
              function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external;
              /**
               * @notice the deneb hard fork timestamp used to determine which proof path to use for proving a withdrawal
               */
              function denebForkTimestamp() external view returns (uint64);
               /**
               * setting the deneb hard fork timestamp by the eigenPodManager owner
               * @dev this function is designed to be called twice.  Once, it is set to type(uint64).max 
               * prior to the actual deneb fork timestamp being set, and then the second time it is set 
               * to the actual deneb fork timestamp.
               */
              function setDenebForkTimestamp(uint64 newDenebForkTimestamp) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "../libraries/BeaconChainProofs.sol";
          import "./IEigenPodManager.sol";
          import "./IBeaconChainOracle.sol";
          import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
          /**
           * @title The implementation contract used for restaking beacon chain ETH on EigenLayer
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice The main functionalities are:
           * - creating new ETH validators with their withdrawal credentials pointed to this contract
           * - proving from beacon chain state roots that withdrawal credentials are pointed to this contract
           * - proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials
           *   pointed to this contract
           * - updating aggregate balances in the EigenPodManager
           * - withdrawing eth when withdrawals are initiated
           * @dev Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose
           *   to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts
           */
          interface IEigenPod {
              enum VALIDATOR_STATUS {
                  INACTIVE, // doesnt exist
                  ACTIVE, // staked on ethpos and withdrawal credentials are pointed to the EigenPod
                  WITHDRAWN // withdrawn from the Beacon Chain
              }
              struct ValidatorInfo {
                  // index of the validator in the beacon chain
                  uint64 validatorIndex;
                  // amount of beacon chain ETH restaked on EigenLayer in gwei
                  uint64 restakedBalanceGwei;
                  //timestamp of the validator's most recent balance update
                  uint64 mostRecentBalanceUpdateTimestamp;
                  // status of the validator
                  VALIDATOR_STATUS status;
              }
              /**
               * @notice struct used to store amounts related to proven withdrawals in memory. Used to help
               * manage stack depth and optimize the number of external calls, when batching withdrawal operations.
               */
              struct VerifiedWithdrawal {
                  // amount to send to a podOwner from a proven withdrawal
                  uint256 amountToSendGwei;
                  // difference in shares to be recorded in the eigenPodManager, as a result of the withdrawal
                  int256 sharesDeltaGwei;
              }
              enum PARTIAL_WITHDRAWAL_CLAIM_STATUS {
                  REDEEMED,
                  PENDING,
                  FAILED
              }
              /// @notice Emitted when an ETH validator stakes via this eigenPod
              event EigenPodStaked(bytes pubkey);
              /// @notice Emitted when an ETH validator's withdrawal credentials are successfully verified to be pointed to this eigenPod
              event ValidatorRestaked(uint40 validatorIndex);
              /// @notice Emitted when an ETH validator's  balance is proven to be updated.  Here newValidatorBalanceGwei
              //  is the validator's balance that is credited on EigenLayer.
              event ValidatorBalanceUpdated(uint40 validatorIndex, uint64 balanceTimestamp, uint64 newValidatorBalanceGwei);
              /// @notice Emitted when an ETH validator is prove to have withdrawn from the beacon chain
              event FullWithdrawalRedeemed(
                  uint40 validatorIndex,
                  uint64 withdrawalTimestamp,
                  address indexed recipient,
                  uint64 withdrawalAmountGwei
              );
              /// @notice Emitted when a partial withdrawal claim is successfully redeemed
              event PartialWithdrawalRedeemed(
                  uint40 validatorIndex,
                  uint64 withdrawalTimestamp,
                  address indexed recipient,
                  uint64 partialWithdrawalAmountGwei
              );
              /// @notice Emitted when restaked beacon chain ETH is withdrawn from the eigenPod.
              event RestakedBeaconChainETHWithdrawn(address indexed recipient, uint256 amount);
              /// @notice Emitted when podOwner enables restaking
              event RestakingActivated(address indexed podOwner);
              /// @notice Emitted when ETH is received via the `receive` fallback
              event NonBeaconChainETHReceived(uint256 amountReceived);
              /// @notice Emitted when ETH that was previously received via the `receive` fallback is withdrawn
              event NonBeaconChainETHWithdrawn(address indexed recipient, uint256 amountWithdrawn);
              /// @notice The max amount of eth, in gwei, that can be restaked per validator
              function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns (uint64);
              /// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer),
              function withdrawableRestakedExecutionLayerGwei() external view returns (uint64);
              /// @notice any ETH deposited into the EigenPod contract via the `receive` fallback function
              function nonBeaconChainETHBalanceWei() external view returns (uint256);
              /// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager
              function initialize(address owner) external;
              /// @notice Called by EigenPodManager when the owner wants to create another ETH validator.
              function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
              /**
               * @notice Transfers `amountWei` in ether from this contract to the specified `recipient` address
               * @notice Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain.
               * @dev The podOwner must have already proved sufficient withdrawals, so that this pod's `withdrawableRestakedExecutionLayerGwei` exceeds the
               * `amountWei` input (when converted to GWEI).
               * @dev Reverts if `amountWei` is not a whole Gwei amount
               */
              function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external;
              /// @notice The single EigenPodManager for EigenLayer
              function eigenPodManager() external view returns (IEigenPodManager);
              /// @notice The owner of this EigenPod
              function podOwner() external view returns (address);
              /// @notice an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling `verifyCorrectWithdrawalCredentials`.
              function hasRestaked() external view returns (bool);
              /**
               * @notice The latest timestamp at which the pod owner withdrew the balance of the pod, via calling `withdrawBeforeRestaking`.
               * @dev This variable is only updated when the `withdrawBeforeRestaking` function is called, which can only occur before `hasRestaked` is set to true for this pod.
               * Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored `mostRecentWithdrawalTimestamp`.
               */
              function mostRecentWithdrawalTimestamp() external view returns (uint64);
              /// @notice Returns the validatorInfo struct for the provided pubkeyHash
              function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory);
              /// @notice Returns the validatorInfo struct for the provided pubkey
              function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory);
              ///@notice mapping that tracks proven withdrawals
              function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool);
              /// @notice This returns the status of a given validator
              function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS);
              /// @notice This returns the status of a given validator pubkey
              function validatorStatus(bytes calldata validatorPubkey) external view returns (VALIDATOR_STATUS);
              /**
               * @notice This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to
               * this contract. It also verifies the effective balance  of the validator.  It verifies the provided proof of the ETH validator against the beacon chain state
               * root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer.
               * @param oracleTimestamp is the Beacon Chain timestamp whose state root the `proof` will be proven against.
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs
               * @param withdrawalCredentialProofs is an array of proofs, where each proof proves each ETH validator's balance and withdrawal credentials
               * against a beacon chain state root
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyWithdrawalCredentials(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  uint40[] calldata validatorIndices,
                  bytes[] calldata withdrawalCredentialProofs,
                  bytes32[][] calldata validatorFields
              )
                  external;
              /**
               * @notice This function records an update (either increase or decrease) in the pod's balance in the StrategyManager.  
                         It also verifies a merkle proof of the validator's current beacon chain balance.  
               * @param oracleTimestamp The oracleTimestamp whose state root the `proof` will be proven against.
               *        Must be within `VERIFY_BALANCE_UPDATE_WINDOW_SECONDS` of the current block.
               * @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs 
               * @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields`
               * @param validatorFields are the fields of the "Validator Container", refer to consensus specs
               * @dev For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
               */
              function verifyBalanceUpdates(
                  uint64 oracleTimestamp,
                  uint40[] calldata validatorIndices,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields
              ) external;
              /**
               * @notice This function records full and partial withdrawals on behalf of one of the Ethereum validators for this EigenPod
               * @param oracleTimestamp is the timestamp of the oracle slot that the withdrawal is being proven against
               * @param withdrawalProofs is the information needed to check the veracity of the block numbers and withdrawals being proven
               * @param validatorFieldsProofs is the proof of the validator's fields' in the validator tree
               * @param withdrawalFields are the fields of the withdrawals being proven
               * @param validatorFields are the fields of the validators being proven
               */
              function verifyAndProcessWithdrawals(
                  uint64 oracleTimestamp,
                  BeaconChainProofs.StateRootProof calldata stateRootProof,
                  BeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
                  bytes[] calldata validatorFieldsProofs,
                  bytes32[][] calldata validatorFields,
                  bytes32[][] calldata withdrawalFields
              ) external;
              /**
               * @notice Called by the pod owner to activate restaking by withdrawing
               * all existing ETH from the pod and preventing further withdrawals via
               * "withdrawBeforeRestaking()"
               */
              function activateRestaking() external;
              /// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false
              function withdrawBeforeRestaking() external;
              /// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei
              function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external;
              /// @notice called by owner of a pod to remove any ERC20s deposited in the pod
              function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          interface IDelayedWithdrawalRouter {
              // struct used to pack data into a single storage slot
              struct DelayedWithdrawal {
                  uint224 amount;
                  uint32 blockCreated;
              }
              // struct used to store a single users delayedWithdrawal data
              struct UserDelayedWithdrawals {
                  uint256 delayedWithdrawalsCompleted;
                  DelayedWithdrawal[] delayedWithdrawals;
              }
               /// @notice event for delayedWithdrawal creation
              event DelayedWithdrawalCreated(address podOwner, address recipient, uint256 amount, uint256 index);
              /// @notice event for the claiming of delayedWithdrawals
              event DelayedWithdrawalsClaimed(address recipient, uint256 amountClaimed, uint256 delayedWithdrawalsCompleted);
              /// @notice Emitted when the `withdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
              event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);
              /**
               * @notice Creates an delayed withdrawal for `msg.value` to the `recipient`.
               * @dev Only callable by the `podOwner`'s EigenPod contract.
               */
              function createDelayedWithdrawal(address podOwner, address recipient) external payable;
              /**
               * @notice Called in order to withdraw delayed withdrawals made to the `recipient` that have passed the `withdrawalDelayBlocks` period.
               * @param recipient The address to claim delayedWithdrawals for.
               * @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
               */
              function claimDelayedWithdrawals(address recipient, uint256 maxNumberOfWithdrawalsToClaim) external;
              /**
               * @notice Called in order to withdraw delayed withdrawals made to the caller that have passed the `withdrawalDelayBlocks` period.
               * @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
               */
              function claimDelayedWithdrawals(uint256 maxNumberOfWithdrawalsToClaim) external;
              /// @notice Owner-only function for modifying the value of the `withdrawalDelayBlocks` variable.
              function setWithdrawalDelayBlocks(uint256 newValue) external;
              /// @notice Getter function for the mapping `_userWithdrawals`
              function userWithdrawals(address user) external view returns (UserDelayedWithdrawals memory);
              /// @notice Getter function to get all delayedWithdrawals of the `user`
              function getUserDelayedWithdrawals(address user) external view returns (DelayedWithdrawal[] memory);
              /// @notice Getter function to get all delayedWithdrawals that are currently claimable by the `user`
              function getClaimableUserDelayedWithdrawals(address user) external view returns (DelayedWithdrawal[] memory);
              /// @notice Getter function for fetching the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array
              function userDelayedWithdrawalByIndex(address user, uint256 index) external view returns (DelayedWithdrawal memory);
              /// @notice Getter function for fetching the length of the delayedWithdrawals array of a specific user
              function userWithdrawalsLength(address user) external view returns (uint256);
              /// @notice Convenience function for checking whether or not the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array is currently claimable
              function canClaimDelayedWithdrawal(address user, uint256 index) external view returns (bool);
              /**
               * @notice Delay enforced by this contract for completing any delayedWithdrawal. Measured in blocks, and adjustable by this contract's owner,
               * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
               */
              function withdrawalDelayBlocks() external view returns (uint256);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "../interfaces/IPauserRegistry.sol";
          /**
           * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
           * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
           * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
           * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
           * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
           * you can only flip (any number of) switches to off/0 (aka "paused").
           * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
           * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
           * 2) update the paused state to this new value
           * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
           * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
           */
          interface IPausable {
              /// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`.
              event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry);
              /// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`.
              event Paused(address indexed account, uint256 newPausedStatus);
              /// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`.
              event Unpaused(address indexed account, uint256 newPausedStatus);
              
              /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
              function pauserRegistry() external view returns (IPauserRegistry);
              /**
               * @notice This function is used to pause an EigenLayer contract's functionality.
               * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
               */
              function pause(uint256 newPausedStatus) external;
              /**
               * @notice Alias for `pause(type(uint256).max)`.
               */
              function pauseAll() external;
              /**
               * @notice This function is used to unpause an EigenLayer contract's functionality.
               * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
               * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
               * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
               */
              function unpause(uint256 newPausedStatus) external;
              /// @notice Returns the current paused status as a uint256.
              function paused() external view returns (uint256);
              /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
              function paused(uint8 index) external view returns (bool);
              /// @notice Allows the unpauser to set a new pauser registry
              function setPauserRegistry(IPauserRegistry newPauserRegistry) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity ^0.8.12;
          /**
           * @title Constants shared between 'EigenPod' and 'EigenPodManager' contracts.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          abstract contract EigenPodPausingConstants {
              /// @notice Index for flag that pauses creation of new EigenPods when set. See EigenPodManager code for details.
              uint8 internal constant PAUSED_NEW_EIGENPODS = 0;
              /**
               * @notice Index for flag that pauses all withdrawal-of-restaked ETH related functionality `
               * function *of the EigenPodManager* when set. See EigenPodManager code for details.
               */
              uint8 internal constant PAUSED_WITHDRAW_RESTAKED_ETH = 1;
              /// @notice Index for flag that pauses the deposit related functions *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_CREDENTIALS = 2;
              /// @notice Index for flag that pauses the `verifyBalanceUpdate` function *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_BALANCE_UPDATE = 3;
              /// @notice Index for flag that pauses the `verifyBeaconChainFullWithdrawal` function *of the EigenPods* when set. see EigenPod code for details.
              uint8 internal constant PAUSED_EIGENPODS_VERIFY_WITHDRAWAL = 4;
              /// @notice Pausability for EigenPod's "accidental transfer" withdrawal methods
              uint8 internal constant PAUSED_NON_PROOF_WITHDRAWALS = 5;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
          pragma solidity ^0.8.0;
          import "../proxy/utils/Initializable.sol";
          /**
           * @dev Provides information about the current execution context, including the
           * sender of the transaction and its data. While these are generally available
           * via msg.sender and msg.data, they should not be accessed in such a direct
           * manner, since when dealing with meta-transactions the account sending and
           * paying for execution may not be the actual sender (as far as an application
           * is concerned).
           *
           * This contract is only required for intermediate, library-like contracts.
           */
          abstract contract ContextUpgradeable is Initializable {
              function __Context_init() internal onlyInitializing {
              }
              function __Context_init_unchained() internal onlyInitializing {
              }
              function _msgSender() internal view virtual returns (address) {
                  return msg.sender;
              }
              function _msgData() internal view virtual returns (bytes calldata) {
                  return msg.data;
              }
              /**
               * @dev This empty reserved space is put in place to allow future versions to add new
               * variables without shifting down storage in the inheritance chain.
               * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
               */
              uint256[50] private __gap;
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Interface of the ERC20 standard as defined in the EIP.
           */
          interface IERC20 {
              /**
               * @dev Emitted when `value` tokens are moved from one account (`from`) to
               * another (`to`).
               *
               * Note that `value` may be zero.
               */
              event Transfer(address indexed from, address indexed to, uint256 value);
              /**
               * @dev Emitted when the allowance of a `spender` for an `owner` is set by
               * a call to {approve}. `value` is the new allowance.
               */
              event Approval(address indexed owner, address indexed spender, uint256 value);
              /**
               * @dev Returns the amount of tokens in existence.
               */
              function totalSupply() external view returns (uint256);
              /**
               * @dev Returns the amount of tokens owned by `account`.
               */
              function balanceOf(address account) external view returns (uint256);
              /**
               * @dev Moves `amount` tokens from the caller's account to `to`.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * Emits a {Transfer} event.
               */
              function transfer(address to, uint256 amount) external returns (bool);
              /**
               * @dev Returns the remaining number of tokens that `spender` will be
               * allowed to spend on behalf of `owner` through {transferFrom}. This is
               * zero by default.
               *
               * This value changes when {approve} or {transferFrom} are called.
               */
              function allowance(address owner, address spender) external view returns (uint256);
              /**
               * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * IMPORTANT: Beware that changing an allowance with this method brings the risk
               * that someone may use both the old and the new allowance by unfortunate
               * transaction ordering. One possible solution to mitigate this race
               * condition is to first reduce the spender's allowance to 0 and set the
               * desired value afterwards:
               * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
               *
               * Emits an {Approval} event.
               */
              function approve(address spender, uint256 amount) external returns (bool);
              /**
               * @dev Moves `amount` tokens from `from` to `to` using the
               * allowance mechanism. `amount` is then deducted from the caller's
               * allowance.
               *
               * Returns a boolean value indicating whether the operation succeeded.
               *
               * Emits a {Transfer} event.
               */
              function transferFrom(
                  address from,
                  address to,
                  uint256 amount
              ) external returns (bool);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
           * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
           *
           * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
           * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
           * need to send a transaction, and thus is not required to hold Ether at all.
           */
          interface IERC20Permit {
              /**
               * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
               * given ``owner``'s signed approval.
               *
               * IMPORTANT: The same issues {IERC20-approve} has related to transaction
               * ordering also apply here.
               *
               * Emits an {Approval} event.
               *
               * Requirements:
               *
               * - `spender` cannot be the zero address.
               * - `deadline` must be a timestamp in the future.
               * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
               * over the EIP712-formatted function arguments.
               * - the signature must use ``owner``'s current nonce (see {nonces}).
               *
               * For more information on the signature format, see the
               * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
               * section].
               */
              function permit(
                  address owner,
                  address spender,
                  uint256 value,
                  uint256 deadline,
                  uint8 v,
                  bytes32 r,
                  bytes32 s
              ) external;
              /**
               * @dev Returns the current nonce for `owner`. This value must be
               * included whenever a signature is generated for {permit}.
               *
               * Every successful call to {permit} increases ``owner``'s nonce by one. This
               * prevents a signature from being used multiple times.
               */
              function nonces(address owner) external view returns (uint256);
              /**
               * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
               */
              // solhint-disable-next-line func-name-mixedcase
              function DOMAIN_SEPARATOR() external view returns (bytes32);
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
          pragma solidity ^0.8.1;
          /**
           * @dev Collection of functions related to the address type
           */
          library Address {
              /**
               * @dev Returns true if `account` is a contract.
               *
               * [IMPORTANT]
               * ====
               * It is unsafe to assume that an address for which this function returns
               * false is an externally-owned account (EOA) and not a contract.
               *
               * Among others, `isContract` will return false for the following
               * types of addresses:
               *
               *  - an externally-owned account
               *  - a contract in construction
               *  - an address where a contract will be created
               *  - an address where a contract lived, but was destroyed
               * ====
               *
               * [IMPORTANT]
               * ====
               * You shouldn't rely on `isContract` to protect against flash loan attacks!
               *
               * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
               * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
               * constructor.
               * ====
               */
              function isContract(address account) internal view returns (bool) {
                  // This method relies on extcodesize/address.code.length, which returns 0
                  // for contracts in construction, since the code is only stored at the end
                  // of the constructor execution.
                  return account.code.length > 0;
              }
              /**
               * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
               * `recipient`, forwarding all available gas and reverting on errors.
               *
               * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
               * of certain opcodes, possibly making contracts go over the 2300 gas limit
               * imposed by `transfer`, making them unable to receive funds via
               * `transfer`. {sendValue} removes this limitation.
               *
               * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
               *
               * IMPORTANT: because control is transferred to `recipient`, care must be
               * taken to not create reentrancy vulnerabilities. Consider using
               * {ReentrancyGuard} or the
               * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
               */
              function sendValue(address payable recipient, uint256 amount) internal {
                  require(address(this).balance >= amount, "Address: insufficient balance");
                  (bool success, ) = recipient.call{value: amount}("");
                  require(success, "Address: unable to send value, recipient may have reverted");
              }
              /**
               * @dev Performs a Solidity function call using a low level `call`. A
               * plain `call` is an unsafe replacement for a function call: use this
               * function instead.
               *
               * If `target` reverts with a revert reason, it is bubbled up by this
               * function (like regular Solidity function calls).
               *
               * Returns the raw returned data. To convert to the expected return value,
               * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
               *
               * Requirements:
               *
               * - `target` must be a contract.
               * - calling `target` with `data` must not revert.
               *
               * _Available since v3.1._
               */
              function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionCall(target, data, "Address: low-level call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
               * `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, 0, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but also transferring `value` wei to `target`.
               *
               * Requirements:
               *
               * - the calling contract must have an ETH balance of at least `value`.
               * - the called Solidity function must be `payable`.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value
              ) internal returns (bytes memory) {
                  return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
              }
              /**
               * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
               * with `errorMessage` as a fallback revert reason when `target` reverts.
               *
               * _Available since v3.1._
               */
              function functionCallWithValue(
                  address target,
                  bytes memory data,
                  uint256 value,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(address(this).balance >= value, "Address: insufficient balance for call");
                  require(isContract(target), "Address: call to non-contract");
                  (bool success, bytes memory returndata) = target.call{value: value}(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                  return functionStaticCall(target, data, "Address: low-level static call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a static call.
               *
               * _Available since v3.3._
               */
              function functionStaticCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal view returns (bytes memory) {
                  require(isContract(target), "Address: static call to non-contract");
                  (bool success, bytes memory returndata) = target.staticcall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                  return functionDelegateCall(target, data, "Address: low-level delegate call failed");
              }
              /**
               * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
               * but performing a delegate call.
               *
               * _Available since v3.4._
               */
              function functionDelegateCall(
                  address target,
                  bytes memory data,
                  string memory errorMessage
              ) internal returns (bytes memory) {
                  require(isContract(target), "Address: delegate call to non-contract");
                  (bool success, bytes memory returndata) = target.delegatecall(data);
                  return verifyCallResult(success, returndata, errorMessage);
              }
              /**
               * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
               * revert reason using the provided one.
               *
               * _Available since v4.3._
               */
              function verifyCallResult(
                  bool success,
                  bytes memory returndata,
                  string memory errorMessage
              ) internal pure returns (bytes memory) {
                  if (success) {
                      return returndata;
                  } else {
                      // Look for revert reason and bubble it up if present
                      if (returndata.length > 0) {
                          // The easiest way to bubble the revert reason is using memory via assembly
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
          }
          // SPDX-License-Identifier: MIT
          // Adapted from OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev These functions deal with verification of Merkle Tree proofs.
           *
           * The tree and the proofs can be generated using our
           * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
           * You will find a quickstart guide in the readme.
           *
           * WARNING: You should avoid using leaf values that are 64 bytes long prior to
           * hashing, or use a hash function other than keccak256 for hashing leaves.
           * This is because the concatenation of a sorted pair of internal nodes in
           * the merkle tree could be reinterpreted as a leaf value.
           * OpenZeppelin's JavaScript library generates merkle trees that are safe
           * against this attack out of the box.
           */
          library Merkle {
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * Note this is for a Merkle tree using the keccak/sha3 hash function
               */
              function verifyInclusionKeccak(
                  bytes memory proof,
                  bytes32 root,
                  bytes32 leaf,
                  uint256 index
              ) internal pure returns (bool) {
                  return processInclusionProofKeccak(proof, leaf, index) == root;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * _Available since v4.4._
               *
               * Note this is for a Merkle tree using the keccak/sha3 hash function
               */
              function processInclusionProofKeccak(
                  bytes memory proof,
                  bytes32 leaf,
                  uint256 index
              ) internal pure returns (bytes32) {
                  require(
                      proof.length != 0 && proof.length % 32 == 0,
                      "Merkle.processInclusionProofKeccak: proof length should be a non-zero multiple of 32"
                  );
                  bytes32 computedHash = leaf;
                  for (uint256 i = 32; i <= proof.length; i += 32) {
                      if (index % 2 == 0) {
                          // if ith bit of index is 0, then computedHash is a left sibling
                          assembly {
                              mstore(0x00, computedHash)
                              mstore(0x20, mload(add(proof, i)))
                              computedHash := keccak256(0x00, 0x40)
                              index := div(index, 2)
                          }
                      } else {
                          // if ith bit of index is 1, then computedHash is a right sibling
                          assembly {
                              mstore(0x00, mload(add(proof, i)))
                              mstore(0x20, computedHash)
                              computedHash := keccak256(0x00, 0x40)
                              index := div(index, 2)
                          }
                      }
                  }
                  return computedHash;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * Note this is for a Merkle tree using the sha256 hash function
               */
              function verifyInclusionSha256(
                  bytes memory proof,
                  bytes32 root,
                  bytes32 leaf,
                  uint256 index
              ) internal view returns (bool) {
                  return processInclusionProofSha256(proof, leaf, index) == root;
              }
              /**
               * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
               * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
               * hash matches the root of the tree. The tree is built assuming `leaf` is
               * the 0 indexed `index`'th leaf from the bottom left of the tree.
               *
               * _Available since v4.4._
               *
               * Note this is for a Merkle tree using the sha256 hash function
               */
              function processInclusionProofSha256(
                  bytes memory proof,
                  bytes32 leaf,
                  uint256 index
              ) internal view returns (bytes32) {
                  require(
                      proof.length != 0 && proof.length % 32 == 0,
                      "Merkle.processInclusionProofSha256: proof length should be a non-zero multiple of 32"
                  );
                  bytes32[1] memory computedHash = [leaf];
                  for (uint256 i = 32; i <= proof.length; i += 32) {
                      if (index % 2 == 0) {
                          // if ith bit of index is 0, then computedHash is a left sibling
                          assembly {
                              mstore(0x00, mload(computedHash))
                              mstore(0x20, mload(add(proof, i)))
                              if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
                                  revert(0, 0)
                              }
                              index := div(index, 2)
                          }
                      } else {
                          // if ith bit of index is 1, then computedHash is a right sibling
                          assembly {
                              mstore(0x00, mload(add(proof, i)))
                              mstore(0x20, mload(computedHash))
                              if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
                                  revert(0, 0)
                              }
                              index := div(index, 2)
                          }
                      }
                  }
                  return computedHash[0];
              }
              /**
               @notice this function returns the merkle root of a tree created from a set of leaves using sha256 as its hash function
               @param leaves the leaves of the merkle tree
               @return The computed Merkle root of the tree.
               @dev A pre-condition to this function is that leaves.length is a power of two.  If not, the function will merkleize the inputs incorrectly.
               */
              function merkleizeSha256(bytes32[] memory leaves) internal pure returns (bytes32) {
                  //there are half as many nodes in the layer above the leaves
                  uint256 numNodesInLayer = leaves.length / 2;
                  //create a layer to store the internal nodes
                  bytes32[] memory layer = new bytes32[](numNodesInLayer);
                  //fill the layer with the pairwise hashes of the leaves
                  for (uint256 i = 0; i < numNodesInLayer; i++) {
                      layer[i] = sha256(abi.encodePacked(leaves[2 * i], leaves[2 * i + 1]));
                  }
                  //the next layer above has half as many nodes
                  numNodesInLayer /= 2;
                  //while we haven't computed the root
                  while (numNodesInLayer != 0) {
                      //overwrite the first numNodesInLayer nodes in layer with the pairwise hashes of their children
                      for (uint256 i = 0; i < numNodesInLayer; i++) {
                          layer[i] = sha256(abi.encodePacked(layer[2 * i], layer[2 * i + 1]));
                      }
                      //the next layer above has half as many nodes
                      numNodesInLayer /= 2;
                  }
                  //the first node in the layer is the root
                  return layer[0];
              }
          }
          // SPDX-License-Identifier: MIT
          // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
          pragma solidity ^0.8.0;
          /**
           * @dev This is the interface that {BeaconProxy} expects of its beacon.
           */
          interface IBeacon {
              /**
               * @dev Must return an address that can be used as a delegate call target.
               *
               * {BeaconProxy} will check that this address is a contract.
               */
              function implementation() external view returns (address);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategy.sol";
          import "./ISlasher.sol";
          import "./IDelegationManager.sol";
          import "./IEigenPodManager.sol";
          /**
           * @title Interface for the primary entrypoint for funds into EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice See the `StrategyManager` contract itself for implementation details.
           */
          interface IStrategyManager {
              /**
               * @notice Emitted when a new deposit occurs on behalf of `staker`.
               * @param staker Is the staker who is depositing funds into EigenLayer.
               * @param strategy Is the strategy that `staker` has deposited into.
               * @param token Is the token that `staker` deposited.
               * @param shares Is the number of new shares `staker` has been granted in `strategy`.
               */
              event Deposit(address staker, IERC20 token, IStrategy strategy, uint256 shares);
              /// @notice Emitted when `thirdPartyTransfersForbidden` is updated for a strategy and value by the owner
              event UpdatedThirdPartyTransfersForbidden(IStrategy strategy, bool value);
              /// @notice Emitted when the `strategyWhitelister` is changed
              event StrategyWhitelisterChanged(address previousAddress, address newAddress);
              /// @notice Emitted when a strategy is added to the approved list of strategies for deposit
              event StrategyAddedToDepositWhitelist(IStrategy strategy);
              /// @notice Emitted when a strategy is removed from the approved list of strategies for deposit
              event StrategyRemovedFromDepositWhitelist(IStrategy strategy);
              /**
               * @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender`
               * @param strategy is the specified strategy where deposit is to be made,
               * @param token is the denomination in which the deposit is to be made,
               * @param amount is the amount of token to be deposited in the strategy by the staker
               * @return shares The amount of new shares in the `strategy` created as part of the action.
               * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
               * @dev Cannot be called by an address that is 'frozen' (this function will revert if the `msg.sender` is frozen).
               *
               * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
               *          where the token balance and corresponding strategy shares are not in sync upon reentrancy.
               */
              function depositIntoStrategy(IStrategy strategy, IERC20 token, uint256 amount) external returns (uint256 shares);
              /**
               * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`,
               * who must sign off on the action.
               * Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed
               * purely to help one address deposit 'for' another.
               * @param strategy is the specified strategy where deposit is to be made,
               * @param token is the denomination in which the deposit is to be made,
               * @param amount is the amount of token to be deposited in the strategy by the staker
               * @param staker the staker that the deposited assets will be credited to
               * @param expiry the timestamp at which the signature expires
               * @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward
               * following EIP-1271 if the `staker` is a contract
               * @return shares The amount of new shares in the `strategy` created as part of the action.
               * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
               * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those
               * targeting stakers who may be attempting to undelegate.
               * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy
               *
               *  WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
               *          where the token balance and corresponding strategy shares are not in sync upon reentrancy
               */
              function depositIntoStrategyWithSignature(
                  IStrategy strategy,
                  IERC20 token,
                  uint256 amount,
                  address staker,
                  uint256 expiry,
                  bytes memory signature
              ) external returns (uint256 shares);
              /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue
              function removeShares(address staker, IStrategy strategy, uint256 shares) external;
              /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue
              function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external;
              
              /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient
              function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external;
              /// @notice Returns the current shares of `user` in `strategy`
              function stakerStrategyShares(address user, IStrategy strategy) external view returns (uint256 shares);
              /**
               * @notice Get all details on the staker's deposits and corresponding shares
               * @return (staker's strategies, shares in these strategies)
               */
              function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory);
              /// @notice Simple getter function that returns `stakerStrategyList[staker].length`.
              function stakerStrategyListLength(address staker) external view returns (uint256);
              /**
               * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into
               * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already)
               * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy
               */
              function addStrategiesToDepositWhitelist(
                  IStrategy[] calldata strategiesToWhitelist,
                  bool[] calldata thirdPartyTransfersForbiddenValues
              ) external;
              /**
               * @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into
               * @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it)
               */
              function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) external;
              /// @notice Returns the single, central Delegation contract of EigenLayer
              function delegation() external view returns (IDelegationManager);
              /// @notice Returns the single, central Slasher contract of EigenLayer
              function slasher() external view returns (ISlasher);
              /// @notice Returns the EigenPodManager contract of EigenLayer
              function eigenPodManager() external view returns (IEigenPodManager);
              /// @notice Returns the address of the `strategyWhitelister`
              function strategyWhitelister() external view returns (address);
              /**
               * @notice Returns bool for whether or not `strategy` enables credit transfers. i.e enabling
               * depositIntoStrategyWithSignature calls or queueing withdrawals to a different address than the staker.
               */
              function thirdPartyTransfersForbidden(IStrategy strategy) external view returns (bool);
          // LIMITED BACKWARDS-COMPATIBILITY FOR DEPRECATED FUNCTIONALITY
              // packed struct for queued withdrawals; helps deal with stack-too-deep errors
              struct DeprecatedStruct_WithdrawerAndNonce {
                  address withdrawer;
                  uint96 nonce;
              }
              /**
               * Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
               * In functions that operate on existing queued withdrawals -- e.g. `startQueuedWithdrawalWaitingPeriod` or `completeQueuedWithdrawal`,
               * the data is resubmitted and the hash of the submitted data is computed by `calculateWithdrawalRoot` and checked against the
               * stored hash in order to confirm the integrity of the submitted data.
               */
              struct DeprecatedStruct_QueuedWithdrawal {
                  IStrategy[] strategies;
                  uint256[] shares;
                  address staker;
                  DeprecatedStruct_WithdrawerAndNonce withdrawerAndNonce;
                  uint32 withdrawalStartBlock;
                  address delegatedAddress;
              }
              function migrateQueuedWithdrawal(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external returns (bool, bytes32);
              function calculateWithdrawalRoot(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external pure returns (bytes32);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title Interface for the BeaconStateOracle contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IBeaconChainOracle {
              /// @notice The block number to state root mapping.
              function timestampToBlockRoot(uint256 timestamp) external view returns (bytes32);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategyManager.sol";
          import "./IDelegationManager.sol";
          /**
           * @title Interface for the primary 'slashing' contract for EigenLayer.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice See the `Slasher` contract itself for implementation details.
           */
          interface ISlasher {
              // struct used to store information about the current state of an operator's obligations to middlewares they are serving
              struct MiddlewareTimes {
                  // The update block for the middleware whose most recent update was earliest, i.e. the 'stalest' update out of all middlewares the operator is serving
                  uint32 stalestUpdateBlock;
                  // The latest 'serveUntilBlock' from all of the middleware that the operator is serving
                  uint32 latestServeUntilBlock;
              }
              // struct used to store details relevant to a single middleware that an operator has opted-in to serving
              struct MiddlewareDetails {
                  // the block at which the contract begins being able to finalize the operator's registration with the service via calling `recordFirstStakeUpdate`
                  uint32 registrationMayBeginAtBlock;
                  // the block before which the contract is allowed to slash the user
                  uint32 contractCanSlashOperatorUntilBlock;
                  // the block at which the middleware's view of the operator's stake was most recently updated
                  uint32 latestUpdateBlock;
              }
              /// @notice Emitted when a middleware times is added to `operator`'s array.
              event MiddlewareTimesAdded(
                  address operator,
                  uint256 index,
                  uint32 stalestUpdateBlock,
                  uint32 latestServeUntilBlock
              );
              /// @notice Emitted when `operator` begins to allow `contractAddress` to slash them.
              event OptedIntoSlashing(address indexed operator, address indexed contractAddress);
              /// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilBlock`.
              event SlashingAbilityRevoked(
                  address indexed operator,
                  address indexed contractAddress,
                  uint32 contractCanSlashOperatorUntilBlock
              );
              /**
               * @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`.
               * @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'.
               */
              event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract);
              /// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within EigenLayer.
              event FrozenStatusReset(address indexed previouslySlashedAddress);
              /**
               * @notice Gives the `contractAddress` permission to slash the funds of the caller.
               * @dev Typically, this function must be called prior to registering for a middleware.
               */
              function optIntoSlashing(address contractAddress) external;
              /**
               * @notice Used for 'slashing' a certain operator.
               * @param toBeFrozen The operator to be frozen.
               * @dev Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop.
               * @dev The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to `optIntoSlashing`.
               */
              function freezeOperator(address toBeFrozen) external;
              /**
               * @notice Removes the 'frozen' status from each of the `frozenAddresses`
               * @dev Callable only by the contract owner (i.e. governance).
               */
              function resetFrozenStatus(address[] calldata frozenAddresses) external;
              /**
               * @notice this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration
               *         is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at the current block is slashable
               * @dev adds the middleware's slashing contract to the operator's linked list
               */
              function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external;
              /**
               * @notice this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals)
               *         to make sure the operator's stake at updateBlock is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param updateBlock the block for which the stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at updateBlock is slashable
               * @param insertAfter the element of the operators linked list that the currently updating middleware should be inserted after
               * @dev insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions,
               *      but it is anticipated to be rare and not detrimental.
               */
              function recordStakeUpdate(
                  address operator,
                  uint32 updateBlock,
                  uint32 serveUntilBlock,
                  uint256 insertAfter
              ) external;
              /**
               * @notice this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration
               *         is slashable until serveUntil
               * @param operator the operator whose stake update is being recorded
               * @param serveUntilBlock the block until which the operator's stake at the current block is slashable
               * @dev removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to
               * slash `operator` once `serveUntil` is reached
               */
              function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external;
              /// @notice The StrategyManager contract of EigenLayer
              function strategyManager() external view returns (IStrategyManager);
              /// @notice The DelegationManager contract of EigenLayer
              function delegation() external view returns (IDelegationManager);
              /**
               * @notice Used to determine whether `staker` is actively 'frozen'. If a staker is frozen, then they are potentially subject to
               * slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed
               * and the staker's status is reset (to 'unfrozen').
               * @param staker The staker of interest.
               * @return Returns 'true' if `staker` themselves has their status set to frozen, OR if the staker is delegated
               * to an operator who has their status set to frozen. Otherwise returns 'false'.
               */
              function isFrozen(address staker) external view returns (bool);
              /// @notice Returns true if `slashingContract` is currently allowed to slash `toBeSlashed`.
              function canSlash(address toBeSlashed, address slashingContract) external view returns (bool);
              /// @notice Returns the block until which `serviceContract` is allowed to slash the `operator`.
              function contractCanSlashOperatorUntilBlock(
                  address operator,
                  address serviceContract
              ) external view returns (uint32);
              /// @notice Returns the block at which the `serviceContract` last updated its view of the `operator`'s stake
              function latestUpdateBlock(address operator, address serviceContract) external view returns (uint32);
              /// @notice A search routine for finding the correct input value of `insertAfter` to `recordStakeUpdate` / `_updateMiddlewareList`.
              function getCorrectValueForInsertAfter(address operator, uint32 updateBlock) external view returns (uint256);
              /**
               * @notice Returns 'true' if `operator` can currently complete a withdrawal started at the `withdrawalStartBlock`, with `middlewareTimesIndex` used
               * to specify the index of a `MiddlewareTimes` struct in the operator's list (i.e. an index in `operatorToMiddlewareTimes[operator]`). The specified
               * struct is consulted as proof of the `operator`'s ability (or lack thereof) to complete the withdrawal.
               * This function will return 'false' if the operator cannot currently complete a withdrawal started at the `withdrawalStartBlock`, *or* in the event
               * that an incorrect `middlewareTimesIndex` is supplied, even if one or more correct inputs exist.
               * @param operator Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator,
               * this address is the operator *who the staker was delegated to* at the time of the `withdrawalStartBlock`.
               * @param withdrawalStartBlock The block number at which the withdrawal was initiated.
               * @param middlewareTimesIndex Indicates an index in `operatorToMiddlewareTimes[operator]` to consult as proof of the `operator`'s ability to withdraw
               * @dev The correct `middlewareTimesIndex` input should be computable off-chain.
               */
              function canWithdraw(
                  address operator,
                  uint32 withdrawalStartBlock,
                  uint256 middlewareTimesIndex
              ) external returns (bool);
              /**
               * operator =>
               *  [
               *      (
               *          the least recent update block of all of the middlewares it's serving/served,
               *          latest time that the stake bonded at that update needed to serve until
               *      )
               *  ]
               */
              function operatorToMiddlewareTimes(
                  address operator,
                  uint256 arrayIndex
              ) external view returns (MiddlewareTimes memory);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator].length`
              function middlewareTimesLength(address operator) external view returns (uint256);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].stalestUpdateBlock`.
              function getMiddlewareTimesIndexStalestUpdateBlock(address operator, uint32 index) external view returns (uint32);
              /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].latestServeUntil`.
              function getMiddlewareTimesIndexServeUntilBlock(address operator, uint32 index) external view returns (uint32);
              /// @notice Getter function for fetching `_operatorToWhitelistedContractsByUpdate[operator].size`.
              function operatorWhitelistedContractsLinkedListSize(address operator) external view returns (uint256);
              /// @notice Getter function for fetching a single node in the operator's linked list (`_operatorToWhitelistedContractsByUpdate[operator]`).
              function operatorWhitelistedContractsLinkedListEntry(
                  address operator,
                  address node
              ) external view returns (bool, uint256, uint256);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
          /**
           * @title Minimal interface for an `Strategy` contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice Custom `Strategy` implementations may expand extensively on this interface.
           */
          interface IStrategy {
              /**
               * @notice Used to deposit tokens into this Strategy
               * @param token is the ERC20 token being deposited
               * @param amount is the amount of token being deposited
               * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
               * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.
               * @return newShares is the number of new shares issued at the current exchange ratio.
               */
              function deposit(IERC20 token, uint256 amount) external returns (uint256);
              /**
               * @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address
               * @param recipient is the address to receive the withdrawn funds
               * @param token is the ERC20 token being transferred out
               * @param amountShares is the amount of shares being withdrawn
               * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
               * other functions, and individual share balances are recorded in the strategyManager as well.
               */
              function withdraw(address recipient, IERC20 token, uint256 amountShares) external;
              /**
               * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
               * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications
               * @param amountShares is the amount of shares to calculate its conversion into the underlying token
               * @return The amount of underlying tokens corresponding to the input `amountShares`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function sharesToUnderlying(uint256 amountShares) external returns (uint256);
              /**
               * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
               * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications
               * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
               * @return The amount of underlying tokens corresponding to the input `amountShares`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function underlyingToShares(uint256 amountUnderlying) external returns (uint256);
              /**
               * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
               * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications
               */
              function userUnderlying(address user) external returns (uint256);
              /**
               * @notice convenience function for fetching the current total shares of `user` in this strategy, by
               * querying the `strategyManager` contract
               */
              function shares(address user) external view returns (uint256);
              /**
               * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
               * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications
               * @param amountShares is the amount of shares to calculate its conversion into the underlying token
               * @return The amount of shares corresponding to the input `amountUnderlying`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256);
              /**
               * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
               * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications
               * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
               * @return The amount of shares corresponding to the input `amountUnderlying`
               * @dev Implementation for these functions in particular may vary significantly for different strategies
               */
              function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256);
              /**
               * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
               * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications
               */
              function userUnderlyingView(address user) external view returns (uint256);
              /// @notice The underlying token for shares in this Strategy
              function underlyingToken() external view returns (IERC20);
              /// @notice The total number of extant shares in this Strategy
              function totalShares() external view returns (uint256);
              /// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that explains in more detail.
              function explanation() external view returns (string memory);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title Interface for the `PauserRegistry` contract.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface IPauserRegistry {
              event PauserStatusChanged(address pauser, bool canPause);
              event UnpauserChanged(address previousUnpauser, address newUnpauser);
              
              /// @notice Mapping of addresses to whether they hold the pauser role.
              function isPauser(address pauser) external view returns (bool);
              /// @notice Unique address that holds the unpauser role. Capable of changing *both* the pauser and unpauser addresses.
              function unpauser() external view returns (address);
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          import "./IStrategy.sol";
          import "./ISignatureUtils.sol";
          import "./IStrategyManager.sol";
          /**
           * @title DelegationManager
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           * @notice  This is the contract for delegation in EigenLayer. The main functionalities of this contract are
           * - enabling anyone to register as an operator in EigenLayer
           * - allowing operators to specify parameters related to stakers who delegate to them
           * - enabling any staker to delegate its stake to the operator of its choice (a given staker can only delegate to a single operator at a time)
           * - enabling a staker to undelegate its assets from the operator it is delegated to (performed as part of the withdrawal process, initiated through the StrategyManager)
           */
          interface IDelegationManager is ISignatureUtils {
              // @notice Struct used for storing information about a single operator who has registered with EigenLayer
              struct OperatorDetails {
                  // @notice address to receive the rewards that the operator earns via serving applications built on EigenLayer.
                  address earningsReceiver;
                  /**
                   * @notice Address to verify signatures when a staker wishes to delegate to the operator, as well as controlling "forced undelegations".
                   * @dev Signature verification follows these rules:
                   * 1) If this address is left as address(0), then any staker will be free to delegate to the operator, i.e. no signature verification will be performed.
                   * 2) If this address is an EOA (i.e. it has no code), then we follow standard ECDSA signature verification for delegations to the operator.
                   * 3) If this address is a contract (i.e. it has code) then we forward a call to the contract and verify that it returns the correct EIP-1271 "magic value".
                   */
                  address delegationApprover;
                  /**
                   * @notice A minimum delay -- measured in blocks -- enforced between:
                   * 1) the operator signalling their intent to register for a service, via calling `Slasher.optIntoSlashing`
                   * and
                   * 2) the operator completing registration for the service, via the service ultimately calling `Slasher.recordFirstStakeUpdate`
                   * @dev note that for a specific operator, this value *cannot decrease*, i.e. if the operator wishes to modify their OperatorDetails,
                   * then they are only allowed to either increase this value or keep it the same.
                   */
                  uint32 stakerOptOutWindowBlocks;
              }
              /**
               * @notice Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator.
               * @dev Used in computing the `STAKER_DELEGATION_TYPEHASH` and as a reference in the computation of the stakerDigestHash in the `delegateToBySignature` function.
               */
              struct StakerDelegation {
                  // the staker who is delegating
                  address staker;
                  // the operator being delegated to
                  address operator;
                  // the staker's nonce
                  uint256 nonce;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              /**
               * @notice Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator.
               * @dev Used in computing the `DELEGATION_APPROVAL_TYPEHASH` and as a reference in the computation of the approverDigestHash in the `_delegate` function.
               */
              struct DelegationApproval {
                  // the staker who is delegating
                  address staker;
                  // the operator being delegated to
                  address operator;
                  // the operator's provided salt
                  bytes32 salt;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              /**
               * Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
               * In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal`, the data is resubmitted and the hash of the submitted
               * data is computed by `calculateWithdrawalRoot` and checked against the stored hash in order to confirm the integrity of the submitted data.
               */
              struct Withdrawal {
                  // The address that originated the Withdrawal
                  address staker;
                  // The address that the staker was delegated to at the time that the Withdrawal was created
                  address delegatedTo;
                  // The address that can complete the Withdrawal + will receive funds when completing the withdrawal
                  address withdrawer;
                  // Nonce used to guarantee that otherwise identical withdrawals have unique hashes
                  uint256 nonce;
                  // Block number when the Withdrawal was created
                  uint32 startBlock;
                  // Array of strategies that the Withdrawal contains
                  IStrategy[] strategies;
                  // Array containing the amount of shares in each Strategy in the `strategies` array
                  uint256[] shares;
              }
              struct QueuedWithdrawalParams {
                  // Array of strategies that the QueuedWithdrawal contains
                  IStrategy[] strategies;
                  // Array containing the amount of shares in each Strategy in the `strategies` array
                  uint256[] shares;
                  // The address of the withdrawer
                  address withdrawer;
              }
              // @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails.
              event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails);
              /// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails
              event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails);
              /**
               * @notice Emitted when @param operator indicates that they are updating their MetadataURI string
               * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
               */
              event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);
              /// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
              event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
              /// @notice Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares.
              event OperatorSharesDecreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
              /// @notice Emitted when @param staker delegates to @param operator.
              event StakerDelegated(address indexed staker, address indexed operator);
              /// @notice Emitted when @param staker undelegates from @param operator.
              event StakerUndelegated(address indexed staker, address indexed operator);
              /// @notice Emitted when @param staker is undelegated via a call not originating from the staker themself
              event StakerForceUndelegated(address indexed staker, address indexed operator);
              /**
               * @notice Emitted when a new withdrawal is queued.
               * @param withdrawalRoot Is the hash of the `withdrawal`.
               * @param withdrawal Is the withdrawal itself.
               */
              event WithdrawalQueued(bytes32 withdrawalRoot, Withdrawal withdrawal);
              /// @notice Emitted when a queued withdrawal is completed
              event WithdrawalCompleted(bytes32 withdrawalRoot);
              /// @notice Emitted when a queued withdrawal is *migrated* from the StrategyManager to the DelegationManager
              event WithdrawalMigrated(bytes32 oldWithdrawalRoot, bytes32 newWithdrawalRoot);
              
              /// @notice Emitted when the `minWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
              event MinWithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);
              /// @notice Emitted when the `strategyWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
              event StrategyWithdrawalDelayBlocksSet(IStrategy strategy, uint256 previousValue, uint256 newValue);
              /**
               * @notice Registers the caller as an operator in EigenLayer.
               * @param registeringOperatorDetails is the `OperatorDetails` for the operator.
               * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator.
               *
               * @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself".
               * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
               * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
               */
              function registerAsOperator(
                  OperatorDetails calldata registeringOperatorDetails,
                  string calldata metadataURI
              ) external;
              /**
               * @notice Updates an operator's stored `OperatorDetails`.
               * @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`.
               *
               * @dev The caller must have previously registered as an operator in EigenLayer.
               * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
               */
              function modifyOperatorDetails(OperatorDetails calldata newOperatorDetails) external;
              /**
               * @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated.
               * @param metadataURI The URI for metadata associated with an operator
               * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
               */
              function updateOperatorMetadataURI(string calldata metadataURI) external;
              /**
               * @notice Caller delegates their stake to an operator.
               * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer.
               * @param approverSignatureAndExpiry Verifies the operator approves of this delegation
               * @param approverSalt A unique single use value tied to an individual signature.
               * @dev The approverSignatureAndExpiry is used in the event that:
               *          1) the operator's `delegationApprover` address is set to a non-zero value.
               *                  AND
               *          2) neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator
               *             or their delegationApprover is the `msg.sender`, then approval is assumed.
               * @dev In the event that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
               * in this case to save on complexity + gas costs
               */
              function delegateTo(
                  address operator,
                  SignatureWithExpiry memory approverSignatureAndExpiry,
                  bytes32 approverSalt
              ) external;
              /**
               * @notice Caller delegates a staker's stake to an operator with valid signatures from both parties.
               * @param staker The account delegating stake to an `operator` account
               * @param operator The account (`staker`) is delegating its assets to for use in serving applications built on EigenLayer.
               * @param stakerSignatureAndExpiry Signed data from the staker authorizing delegating stake to an operator
               * @param approverSignatureAndExpiry is a parameter that will be used for verifying that the operator approves of this delegation action in the event that:
               * @param approverSalt Is a salt used to help guarantee signature uniqueness. Each salt can only be used once by a given approver.
               *
               * @dev If `staker` is an EOA, then `stakerSignature` is verified to be a valid ECDSA stakerSignature from `staker`, indicating their intention for this action.
               * @dev If `staker` is a contract, then `stakerSignature` will be checked according to EIP-1271.
               * @dev the operator's `delegationApprover` address is set to a non-zero value.
               * @dev neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator or their delegationApprover
               * is the `msg.sender`, then approval is assumed.
               * @dev This function will revert if the current `block.timestamp` is equal to or exceeds the expiry
               * @dev In the case that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
               * in this case to save on complexity + gas costs
               */
              function delegateToBySignature(
                  address staker,
                  address operator,
                  SignatureWithExpiry memory stakerSignatureAndExpiry,
                  SignatureWithExpiry memory approverSignatureAndExpiry,
                  bytes32 approverSalt
              ) external;
              /**
               * @notice Undelegates the staker from the operator who they are delegated to. Puts the staker into the "undelegation limbo" mode of the EigenPodManager
               * and queues a withdrawal of all of the staker's shares in the StrategyManager (to the staker), if necessary.
               * @param staker The account to be undelegated.
               * @return withdrawalRoot The root of the newly queued withdrawal, if a withdrawal was queued. Otherwise just bytes32(0).
               *
               * @dev Reverts if the `staker` is also an operator, since operators are not allowed to undelegate from themselves.
               * @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
               * @dev Reverts if the `staker` is already undelegated.
               */
              function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot);
              /**
               * Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed
               * from the staker. If the staker is delegated, withdrawn shares/strategies are also removed from
               * their operator.
               *
               * All withdrawn shares/strategies are placed in a queue and can be fully withdrawn after a delay.
               */
              function queueWithdrawals(
                  QueuedWithdrawalParams[] calldata queuedWithdrawalParams
              ) external returns (bytes32[] memory);
              /**
               * @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer`
               * @param withdrawal The Withdrawal to complete.
               * @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array.
               * This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused)
               * @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array
               * @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves
               * and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies
               * will simply be transferred to the caller directly.
               * @dev middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies `slasher.canWithdraw`
               * @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that
               * any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in
               * any other strategies, which will be transferred to the withdrawer.
               */
              function completeQueuedWithdrawal(
                  Withdrawal calldata withdrawal,
                  IERC20[] calldata tokens,
                  uint256 middlewareTimesIndex,
                  bool receiveAsTokens
              ) external;
              /**
               * @notice Array-ified version of `completeQueuedWithdrawal`.
               * Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer`
               * @param withdrawals The Withdrawals to complete.
               * @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array.
               * @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index.
               * @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean.
               * @dev See `completeQueuedWithdrawal` for relevant dev tags
               */
              function completeQueuedWithdrawals(
                  Withdrawal[] calldata withdrawals,
                  IERC20[][] calldata tokens,
                  uint256[] calldata middlewareTimesIndexes,
                  bool[] calldata receiveAsTokens
              ) external;
              /**
               * @notice Increases a staker's delegated share balance in a strategy.
               * @param staker The address to increase the delegated shares for their operator.
               * @param strategy The strategy in which to increase the delegated shares.
               * @param shares The number of shares to increase.
               *
               * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
               * @dev Callable only by the StrategyManager or EigenPodManager.
               */
              function increaseDelegatedShares(
                  address staker,
                  IStrategy strategy,
                  uint256 shares
              ) external;
              /**
               * @notice Decreases a staker's delegated share balance in a strategy.
               * @param staker The address to increase the delegated shares for their operator.
               * @param strategy The strategy in which to decrease the delegated shares.
               * @param shares The number of shares to decrease.
               *
               * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
               * @dev Callable only by the StrategyManager or EigenPodManager.
               */
              function decreaseDelegatedShares(
                  address staker,
                  IStrategy strategy,
                  uint256 shares
              ) external;
              /**
               * @notice returns the address of the operator that `staker` is delegated to.
               * @notice Mapping: staker => operator whom the staker is currently delegated to.
               * @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator.
               */
              function delegatedTo(address staker) external view returns (address);
              /**
               * @notice Returns the OperatorDetails struct associated with an `operator`.
               */
              function operatorDetails(address operator) external view returns (OperatorDetails memory);
              /*
               * @notice Returns the earnings receiver address for an operator
               */
              function earningsReceiver(address operator) external view returns (address);
              /**
               * @notice Returns the delegationApprover account for an operator
               */
              function delegationApprover(address operator) external view returns (address);
              /**
               * @notice Returns the stakerOptOutWindowBlocks for an operator
               */
              function stakerOptOutWindowBlocks(address operator) external view returns (uint256);
              /**
               * @notice Given array of strategies, returns array of shares for the operator
               */
              function getOperatorShares(
                  address operator,
                  IStrategy[] memory strategies
              ) external view returns (uint256[] memory);
              /**
               * @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw
               * from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay.
               * @param strategies The strategies to check withdrawal delays for
               */
              function getWithdrawalDelay(IStrategy[] calldata strategies) external view returns (uint256);
              /**
               * @notice returns the total number of shares in `strategy` that are delegated to `operator`.
               * @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator.
               * @dev By design, the following invariant should hold for each Strategy:
               * (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator)
               * = sum (delegateable shares of all stakers delegated to the operator)
               */
              function operatorShares(address operator, IStrategy strategy) external view returns (uint256);
              /**
               * @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise.
               */
              function isDelegated(address staker) external view returns (bool);
              /**
               * @notice Returns true is an operator has previously registered for delegation.
               */
              function isOperator(address operator) external view returns (bool);
              /// @notice Mapping: staker => number of signed delegation nonces (used in `delegateToBySignature`) from the staker that the contract has already checked
              function stakerNonce(address staker) external view returns (uint256);
              /**
               * @notice Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover.
               * @dev Salts are used in the `delegateTo` and `delegateToBySignature` functions. Note that these functions only process the delegationApprover's
               * signature + the provided salt if the operator being delegated to has specified a nonzero address as their `delegationApprover`.
               */
              function delegationApproverSaltIsSpent(address _delegationApprover, bytes32 salt) external view returns (bool);
              /**
               * @notice Minimum delay enforced by this contract for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
               * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
               * Note that strategies each have a separate withdrawal delay, which can be greater than this value. So the minimum number of blocks that must pass
               * to withdraw a strategy is MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy])
               */
              function minWithdrawalDelayBlocks() external view returns (uint256);
              /**
               * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
               * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
               */
              function strategyWithdrawalDelayBlocks(IStrategy strategy) external view returns (uint256);
              /**
               * @notice Calculates the digestHash for a `staker` to sign to delegate to an `operator`
               * @param staker The signing staker
               * @param operator The operator who is being delegated to
               * @param expiry The desired expiry time of the staker's signature
               */
              function calculateCurrentStakerDelegationDigestHash(
                  address staker,
                  address operator,
                  uint256 expiry
              ) external view returns (bytes32);
              /**
               * @notice Calculates the digest hash to be signed and used in the `delegateToBySignature` function
               * @param staker The signing staker
               * @param _stakerNonce The nonce of the staker. In practice we use the staker's current nonce, stored at `stakerNonce[staker]`
               * @param operator The operator who is being delegated to
               * @param expiry The desired expiry time of the staker's signature
               */
              function calculateStakerDelegationDigestHash(
                  address staker,
                  uint256 _stakerNonce,
                  address operator,
                  uint256 expiry
              ) external view returns (bytes32);
              /**
               * @notice Calculates the digest hash to be signed by the operator's delegationApprove and used in the `delegateTo` and `delegateToBySignature` functions.
               * @param staker The account delegating their stake
               * @param operator The account receiving delegated stake
               * @param _delegationApprover the operator's `delegationApprover` who will be signing the delegationHash (in general)
               * @param approverSalt A unique and single use value associated with the approver signature.
               * @param expiry Time after which the approver's signature becomes invalid
               */
              function calculateDelegationApprovalDigestHash(
                  address staker,
                  address operator,
                  address _delegationApprover,
                  bytes32 approverSalt,
                  uint256 expiry
              ) external view returns (bytes32);
              /// @notice The EIP-712 typehash for the contract's domain
              function DOMAIN_TYPEHASH() external view returns (bytes32);
              /// @notice The EIP-712 typehash for the StakerDelegation struct used by the contract
              function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32);
              /// @notice The EIP-712 typehash for the DelegationApproval struct used by the contract
              function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32);
              /**
               * @notice Getter function for the current EIP-712 domain separator for this contract.
               *
               * @dev The domain separator will change in the event of a fork that changes the ChainID.
               * @dev By introducing a domain separator the DApp developers are guaranteed that there can be no signature collision.
               * for more detailed information please read EIP-712.
               */
              function domainSeparator() external view returns (bytes32);
              
              /// @notice Mapping: staker => cumulative number of queued withdrawals they have ever initiated.
              /// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
              function cumulativeWithdrawalsQueued(address staker) external view returns (uint256);
              /// @notice Returns the keccak256 hash of `withdrawal`.
              function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32);
              function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external;
          }
          // SPDX-License-Identifier: BUSL-1.1
          pragma solidity >=0.5.0;
          /**
           * @title The interface for common signature utilities.
           * @author Layr Labs, Inc.
           * @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
           */
          interface ISignatureUtils {
              // @notice Struct that bundles together a signature and an expiration time for the signature. Used primarily for stack management.
              struct SignatureWithExpiry {
                  // the signature itself, formatted as a single bytes object
                  bytes signature;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
              // @notice Struct that bundles together a signature, a salt for uniqueness, and an expiration time for the signature. Used primarily for stack management.
              struct SignatureWithSaltAndExpiry {
                  // the signature itself, formatted as a single bytes object
                  bytes signature;
                  // the salt used to generate the signature
                  bytes32 salt;
                  // the expiration timestamp (UTC) of the signature
                  uint256 expiry;
              }
          }