Skip to content
Verified contractPartialProprietary

OrchestratorV1

Address0x9f74eed39dc48d55ebd0a7a6799fbce0bb344ffb
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.29

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.29+commit.ab55807c
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
cancun
Via IR
yes
License
Proprietary
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
22,931,924
Creation transaction
0x375e1652a2…c2bdab9615

44 files

src/OrchestratorV1.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { BeneficiaryAddress } from "src/state/orchestratorUpgradeable/BeneficiaryAddress.sol";
import { TVSBeaconAddress } from "src/state/orchestratorUpgradeable/TVSBeaconAddress.sol";

import { OrchestratorUpgradeableBase } from "src/OrchestratorUpgradeableBase.sol";

import { BatchUpgradeableTVSCreator } from "src/batchContracts/BatchUpgradeableTVSCreator.sol";

/// @title Upgradeable Orchestrator with upgradeable TVS
/// @author Alluvial Finance Inc.
/// @notice Orchestrator implementation for the first version of the Orchestrator
contract OrchestratorV1 is BatchUpgradeableTVSCreator, OrchestratorUpgradeableBase {
    constructor(address beaconDepositContract) OrchestratorUpgradeableBase(beaconDepositContract) { }

    /// @notice Initialize the Orchestrator
    /// @param owner The owner of the Orchestrator
    /// @param tvsBeacon The address of the TVS Beacon
    /// @param staker The address of the staker
    /// @param keeper The address of the keeper
    /// @param beneficiaryAddress The address of the beneficiary
    /// @param configManagerAddress The address of the Config Manager
    /// @param depositContractAddress The address of the deposit contract
    /// @dev PLEASE NOTE: The beneficiary address should not be set to the orchestrator address as it will break
    ///      the sweep functionality due to lack of receive function in the Orchestrator contract.
    function initialize(
        address owner,
        address tvsBeacon,
        address staker,
        address keeper,
        address beneficiaryAddress,
        address configManagerAddress,
        address depositContractAddress
    )
        public
        initializer
    {
        if (owner == address(0)) revert InvalidZeroAddress();

        __AccessControl_init();
        __UUPSUpgradeable_init();
        TVSBeaconAddress.set(tvsBeacon);

        _configureOwner(owner);
        _preConfigRoles(staker, keeper);
        _saveBaseConfig(beneficiaryAddress, configManagerAddress, depositContractAddress);
    }

    /// @notice Create validator sets
    /// @param count Number of validator sets to create
    /// @return The addresses of the created validator sets
    function createValidatorSets(uint256 count)
        external
        override
        onlyRole(VALIDATOR_SET_CREATOR_ROLE)
        isNotPaused
        returns (address[] memory)
    {
        return _createValidatorSets(count, address(this), BeneficiaryAddress.get(), TVSBeaconAddress.get());
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
    struct AccessControlStorage {
        mapping(bytes32 role => RoleData) _roles;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;

    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
        assembly {
            $.slot := AccessControlStorageLocation
        }
    }

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        AccessControlStorage storage $ = _getAccessControlStorage();
        bytes32 previousAdminRole = getRoleAdmin(role);
        $._roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (!hasRole(role, account)) {
            $._roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @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]
 * ```solidity
 * 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 Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 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.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._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.
     *
     * 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.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * 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.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._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() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @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.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.22;

import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        _checkProxy();
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * 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. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual notDelegated returns (bytes32) {
        return ERC1967Utils.IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data);
    }

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
     * See {_onlyProxy}.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC-1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardTransientUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuardTransient.sol)

pragma solidity ^0.8.24;

import {TransientSlot} from "@openzeppelin/contracts/utils/TransientSlot.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Variant of {ReentrancyGuard} that uses transient storage.
 *
 * NOTE: This variant only works on networks where EIP-1153 is available.
 *
 * _Available since v5.1._
 */
abstract contract ReentrancyGuardTransientUpgradeable is Initializable {
    using TransientSlot for *;

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant REENTRANCY_GUARD_STORAGE =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    /**
     * @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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function __ReentrancyGuardTransient_init() internal onlyInitializing {
    }

    function __ReentrancyGuardTransient_init_unchained() internal onlyInitializing {
    }
    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_reentrancyGuardEntered()) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);
    }

    function _nonReentrantAfter() private {
        REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false);
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return REENTRANCY_GUARD_STORAGE.asBoolean().tload();
    }
}

lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

lib/openzeppelin-contracts/contracts/access/IAccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

lib/openzeppelin-contracts/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.20;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 */
interface IERC1967 {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}

lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.20;

/**
 * @dev ERC-1822: 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);
}

lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.22;

import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This library provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
 */
library ERC1967Utils {
    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @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 ERC-1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit IERC1967.Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the ERC-1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {IERC1967-AdminChanged} event.
     */
    function changeAdmin(address newAdmin) internal {
        emit IERC1967.AdminChanged(getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the ERC-1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit IERC1967.BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}

lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.20;

/**
 * @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.
     *
     * {UpgradeableBeacon} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

lib/openzeppelin-contracts/contracts/proxy/beacon/UpgradeableBeacon.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/UpgradeableBeacon.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "./IBeacon.sol";
import {Ownable} from "../../access/Ownable.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 The `implementation` of the beacon is invalid.
     */
    error BeaconInvalidImplementation(address 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 initial owner who can upgrade the beacon.
     */
    constructor(address implementation_, address initialOwner) Ownable(initialOwner) {
        _setImplementation(implementation_);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function implementation() public view virtual 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);
    }

    /**
     * @dev Sets the implementation contract address for this beacon
     *
     * Requirements:
     *
     * - `newImplementation` must be a contract.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert BeaconInvalidImplementation(newImplementation);
        }
        _implementation = newImplementation;
        emit Upgraded(newImplementation);
    }
}

lib/openzeppelin-contracts/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)

pragma solidity ^0.8.20;

import {Errors} from "./Errors.sol";

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, bytes memory returndata) = recipient.call{value: amount}("");
        if (!success) {
            _revert(returndata);
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

lib/openzeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

lib/openzeppelin-contracts/contracts/utils/Errors.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @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 ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}

lib/openzeppelin-contracts/contracts/utils/TransientSlot.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.

pragma solidity ^0.8.24;

/**
 * @dev Library for reading and writing value-types to specific transient storage slots.
 *
 * Transient slots are often used to store temporary values that are removed after the current transaction.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 *  * Example reading and writing values using transient storage:
 * ```solidity
 * contract Lock {
 *     using TransientSlot for *;
 *
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
 *
 *     modifier locked() {
 *         require(!_LOCK_SLOT.asBoolean().tload());
 *
 *         _LOCK_SLOT.asBoolean().tstore(true);
 *         _;
 *         _LOCK_SLOT.asBoolean().tstore(false);
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library TransientSlot {
    /**
     * @dev UDVT that represent a slot holding a address.
     */
    type AddressSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a AddressSlot.
     */
    function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
        return AddressSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represent a slot holding a bool.
     */
    type BooleanSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a BooleanSlot.
     */
    function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
        return BooleanSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represent a slot holding a bytes32.
     */
    type Bytes32Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Bytes32Slot.
     */
    function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
        return Bytes32Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represent a slot holding a uint256.
     */
    type Uint256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Uint256Slot.
     */
    function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
        return Uint256Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represent a slot holding a int256.
     */
    type Int256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Int256Slot.
     */
    function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
        return Int256Slot.wrap(slot);
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(AddressSlot slot) internal view returns (address value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(AddressSlot slot, address value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(BooleanSlot slot) internal view returns (bool value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(BooleanSlot slot, bool value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Bytes32Slot slot, bytes32 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Uint256Slot slot) internal view returns (uint256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Uint256Slot slot, uint256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Int256Slot slot) internal view returns (int256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Int256Slot slot, int256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }
}

lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

lib/tvs/src/TVSUpgradeable/interfaces/ITVSUpgradeable.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import "../../interfaces/ITVS.sol";

/**
 * @title TVS Interface (Upgradeable)
 * @author Alluvial Finance Inc.
 * @notice Interface for the TVS contract.
 * @dev This interface is used to interact with the TVS contract.
 * @dev The TVSUpgradeable contract is an upgradeable implementation of the TVS contract
 */
interface ITVSUpgradeable is ITVS {
    /**
     * @notice Emitted when the beacon address is updated.
     * @param beacon The new beacon address.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @notice Error thrown when the beacon address is invalid.
     */
    error InvalidBeacon();

    /**
     * @notice Sets a new beacon address for the TVS.
     * @dev Only the owner can call this function.
     * @dev Emits a {BeaconUpgraded} event.
     * @param beacon The new beacon address.
     */
    function setBeacon(address beacon) external;

    /**
     * @notice Retrieves the current beacon address.
     * @return The address of the beacon.
     */
    function beacon() external view returns (address);
}

lib/tvs/src/TVSUpgradeable/proxies/TVSBeaconProxy.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import "../state/proxy/Beacon.sol";

/**
 * @title TVSBeaconProxy
 * @author Alluvial Finance Inc.
 * @notice This is an EIP-1167 minimal proxy that interacts with an upgradable beacon contract
 * @dev It uses the beacon contract to fetch the implementation address and delegate the call.
 * @dev The beacon contract is expected to have an `implementation()` function that returns the address of the
 *      implementation.
 */
contract TVSBeaconProxy {
    error InitializationFailed();
    error InvalidBeacon();

    /**
     * @notice Constructs a new TVSBeaconProxy instance
     * @dev The constructor will get the implementation address from the beacon, and delegate the initialization call
     *      to the implementation.
     * @dev This function will revert if the implementation on the beacon is not a contract, or the input data to
     *      initialize has invalid addresses.
     * @param beacon The address of the beacon contract
     * @param initData The initialization data to be passed to the implementation contract
     */
    constructor(address beacon, bytes memory initData) {
        address implementation = _getImplementation(beacon);
        if (implementation.code.length == 0) revert InvalidBeacon();
        (bool success,) = implementation.delegatecall(initData);
        if (!success) {
            revert InitializationFailed();
        }
    }

    /**
     * @notice Fallback function that delegates all calls to the implementation address returned by the beacon
     * @dev This function uses inline assembly to first fetch the implementation address from the beacon
     * @dev and then delegates the call to it.
     */
    fallback() external payable {
        address implementation = _getImplementation(Beacon.get());
        assembly ("memory-safe") {
            // Copy the call data to memory
            calldatacopy(0, 0, calldatasize())

            // Perform the delegate call to the implementation address
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data from the delegate call
            returndatacopy(0, 0, returndatasize())

            // If the delegate call failed, revert with returned data
            if iszero(result) { revert(0, returndatasize()) }

            // Return the data from the delegate call
            return(0, returndatasize())
        }
    }

    /**
     * @notice Internal function to fetch the implementation address from the beacon
     * @dev This function uses inline assembly to fetch the implementation address from the beacon
     * @param _beacon The address of the beacon contract
     * @return _implementation The address of the implementation contract
     */
    function _getImplementation(address _beacon) internal view returns (address _implementation) {
        assembly ("memory-safe") {
            let ptr := mload(0x40)

            // Store the function selector for `implementation()` (keccak256("implementation()") = 0x5c60da1b)
            mstore(ptr, 0x5c60da1b00000000000000000000000000000000000000000000000000000000)

            // Perform the staticcall to the BEACON_ADDRESS
            let success :=
                staticcall(
                    gas(), // forward all remaining gas
                    _beacon, // address of the beacon
                    ptr, // input starts at ptr
                    0x04, // size of the function selector (4 bytes)
                    ptr, // store output at ptr (reuse memory)
                    0x20 // size of the output (32 bytes, address size)
                )

            // Check if the staticcall was successful
            if iszero(success) { revert(0, 0) } // revert if the call failed

            // Load the returned address from memory (stored at ptr)
            _implementation := mload(ptr)
        }
    }
}

lib/tvs/src/TVSUpgradeable/state/proxy/Beacon.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import "openzeppelin-contracts/contracts/utils/StorageSlot.sol";

/**
 * @title Beacon
 * @author Alluvial Finance Inc.
 * @notice This library manages the beacon address for the proxy contract
 * @dev The beacon address is the address of the contract that holds the implementation address
 * @dev The implementation address is the address of the contract that contains the business logic
 * @dev The beacon address is expected to have an `implementation()` function that returns the address of the
 *      implementation
 * @dev The proxy contract is expected to have a `BEACON_SLOT` slot that stores the beacon address
 */
library Beacon {
    /**
     * @dev Slot for the beacon address
     * @dev The slot is defined using the EIP-1967 standard
     */
    bytes32 internal constant BEACON_SLOT = bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1); // from the
        // EIP-1967 standard

    /**
     * @notice Set the beacon address
     * @param newBeacon The new beacon address
     */
    function set(address newBeacon) internal {
        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
    }

    /**
     * @notice Get the beacon address
     * @return The beacon address
     */
    function get() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }
}

lib/tvs/src/interfaces/ITVS.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

/**
 * @title TVS Interface
 * @author Alluvial Finance Inc.
 * @notice Interface for the TVS contract.
 * @dev This interface is used to interact with the TVS contract.
 * @dev The TVS contract is the withdrawal credential of a set of validators in the system.
 */
interface ITVS {
    /**
     * @notice Struct to represent a consolidation request.
     * @param srcPubkeys The public keys of the validators to consolidate from.
     * @param targetPubkey The public key of the validator to consolidate to.
     */
    struct ConsolidationRequest {
        bytes[] srcPubkeys;
        bytes targetPubkey;
    }

    /**
     * @notice Emitted when funds are swept to the beneficiary.
     * @param beneficiary The address to which funds were swept.
     * @param amount The amount of funds swept.
     */
    event Swept(address indexed beneficiary, uint256 indexed amount);

    /**
     * @notice Emitted when the beneficiary address is updated.
     * @param newBeneficiary The new beneficiary address.
     */
    event BeneficiaryUpdated(address indexed newBeneficiary);

    /**
     * @notice Emitted when the excess fee sent as part of a {consolidation}, or {withdrawal} - (partial or full)
     * request could not be refunded to the {excessFeeRecipient} recipient.
     * @param excessFeeRecipient The address to which the excess fee should have been sent.
     * @param excessFee The amount of excess fee sent.
     */
    event UnsentExcessFee(address indexed excessFeeRecipient, uint256 indexed excessFee);

    /**
     * @notice Emitted when the ownership of the TVS is transferred to a new owner.
     * @param newBeneficiary The address of the new beneficiary.
     * @param newOwner The address of the new owner.
     */
    event Transferred(address indexed newBeneficiary, address indexed newOwner);

    /**
     * @notice Emitted when a withdrawal request is submitted for a validator.
     * @param pubkey The public key of the validator.
     * @param amount The amount to withdraw from the validator.
     * @param fee The fee paid for the withdrawal.
     */
    event WithdrawalRequested(bytes pubkey, uint64 indexed amount, uint256 indexed fee);

    /**
     * @notice Emitted when a consolidation request is submitted.
     * @param srcPubkey The public key of the source validator.
     * @param targetPubkey The public key of the target validator.
     * @param fee The fee paid for the consolidation.
     */
    event ConsolidationRequested(bytes srcPubkey, bytes targetPubkey, uint256 indexed fee);

    /**
     * @notice Error thrown when an invalid address is provided for any reason.
     */
    error InvalidAddress();

    /**
     * @notice Error thrown when an unauthorized access attempt is made.
     * @param caller The address of the caller attempting unauthorized access.
     */
    error Unauthorized(address caller);

    /**
     * @notice Error thrown when an attempt to sweep more funds than available is made.
     * @param available The amount of funds currently available for sweeping.
     * @param required The amount of funds that were requested to be swept.
     */
    error InsufficientBalance(uint256 available, uint256 required);

    /**
     * @notice Error thrown when a fee exceeds the maximum allowed.
     * @dev This error is associated with the {consolidation} and {withdrawal} functions
     * @param currentFee The current fee for the operation.
     * @param maxAllowedFee The maximum allowed fee that can be paid.
     */
    error FeeTooHigh(uint256 currentFee, uint256 maxAllowedFee);

    /**
     * @notice Error thrown when the length of input arrays does not match.
     * @param expected The expected length of the input arrays.
     * @param actual The actual length of the input arrays provided.
     */
    error LengthMismatch(uint256 expected, uint256 actual);

    /**
     * @notice Error thrown when reading the fee fails.
     * @dev This error is associated with the {consolidation} and {withdrawal} functions, which read the fee from the
     * associated pectra EL contracts.
     */
    error FeeReadFailed();

    /**
     * @notice Error thrown when adding a consolidation or withdraw request fails.
     */
    error RequestFailed();

    /**
     * @notice Error thrown when the value provided is insufficient for the fee.
     * @dev This error is associated with the {consolidation} and {withdrawal} functions, which interact with the
     * associated pectra EL contracts.
     * @param value The value provided.
     * @param totalFee The total fee required.
     */
    error InsufficientValueForFee(uint256 value, uint256 totalFee);

    /**
     * @notice Error thrown when a TVS transfer couldn't be completed.
     */
    error TransferFailed();

    /**
     * @notice Error thrown when the length of a pubkey is invalid.
     * @param length The length of the pubkey.
     */
    error InvalidPubkeyLength(uint256 length);

    // Setters

    /*
     * @notice Fallback function to receive funds.
     */
    receive() external payable;

    /**
     * @notice Sweeps a specific amount, or all ETH on the TVS to the TVS beneficiary or a specified address.
     * @dev Only the owner can specify a custom beneficiary for the sweep
     * @dev Emits {Swept} event.
     * @param beneficiary Address to which funds will be swept, if zero address, sweeps to the  beneficiary address set
     * on the contract
     * @param amount Amount of funds to sweep, if zero, sweeps all funds on contract
     */
    function sweep(address beneficiary, uint256 amount) external;

    /**
     * @notice Sweeps a specific amount, or all ETH on the TVS to the TVS beneficiary contract or a specified
     * beneficiary contract address.
     * @dev Only the owner can specify a custom beneficiary for the sweep
     * @dev Emits a {Swept} event.
     * @param beneficiary Address for the contract to which funds will be swept, if zero address, sweeps to the
     * beneficiary address set
     * on the contract
     * @param amount  Amount of funds to sweep, if zero, sweeps all funds on contract.
     */
    function sweepToBeneficiaryContract(address beneficiary, uint256 amount) external;

    /**
     * @notice Sets a new beneficiary address for fund sweeping.
     * @dev Only the owner can call this function.
     * @dev Emits a {BeneficiaryUpdated} event.
     * @param beneficiary New beneficiary address.
     */
    function setBeneficiary(address beneficiary) external;

    /**
     * @notice Transfers the ownership of the TVS.
     * @dev This function sets a new beneficiary, transfers ownership to a new owner.
     * @dev Only the owner can call this function.
     * @dev Emits a {Transferred} event.
     * @param newBeneficiary The new beneficiary address.
     * @param newOwner The new owner address.
     */
    function transfer(address newBeneficiary, address newOwner) external;

    /**
     * @notice Adds a withdrawal request to the pectra EL withdrawal contract for a specified validator.
     * @dev Only the owner can call this function.
     * @param pubkeys The public keys of the validators to withdraw from.
     * @param amount The amount in gwei to withdraw from each validator. Zero indicates a full withdrawal (validator
     * exit).
     * @param maxFeePerWithdrawal The maximum fee allowed per withdrawal.
     * @param excessFeeRecipient The address to which excess fees will be sent.
     */
    function withdraw(
        bytes[] memory pubkeys,
        uint64[] calldata amount,
        uint256 maxFeePerWithdrawal,
        address excessFeeRecipient
    )
        external
        payable;

    /**
     * @notice Adds a consolidation request to the pectra EL consolidation contract for the given source validators.
     * @dev Only the owner can call this function.
     * @dev Both source and target validators (pubKeys) must be from the same TVS (this TVS).
     * @dev The excess fee is the difference between the maximum fee and the actual fee paid.
     * @dev Emits a {UnsentExcessFee} event if the excess fee is not sent.
     * @param requests An array of consolidation requests.
     * @param maxFeePerConsolidation The maximum fee allowed per consolidation request.
     * @param excessFeeRecipient The address to which excess fees will be sent.
     */
    function consolidate(
        ConsolidationRequest[] memory requests,
        uint256 maxFeePerConsolidation,
        address excessFeeRecipient
    )
        external
        payable;

    // Getters

    /**
     * @notice Retrieves the current beneficiary address.
     * @return The address of the beneficiary.
     */
    function getBeneficiary() external view returns (address);

    /**
     * @notice Retrieves the version of the contract.
     * @return Version of the contract
     */
    function version() external pure returns (string memory);
}

src/OrchestratorBase.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

import { IOrchestrator } from "src/interfaces/IOrchestrator.sol";
import { IConfigManager } from "src/interfaces/IConfigManager.sol";

import { BatchSweep } from "src/batchContracts/BatchSweep.sol";
import { BatchPectra } from "src/batchContracts/BatchPectra.sol";
import { BatchDeposit } from "src/batchContracts/BatchDeposit.sol";
import { BatchSetTVS } from "src/batchContracts/BatchSetTVS.sol";
import { BatchTVSTransfer } from "src/batchContracts/BatchTVSTransfer.sol";
import { ConfigManagerAddress } from "src/state/orchestratorUpgradeable/ConfigManagerAddress.sol";
import { Address } from "openzeppelin-contracts/contracts/utils/Address.sol";

import { DepositContractAddress } from "src/batchContracts/state/DepositContractAddress.sol";
import { BeneficiaryAddress } from "src/state/orchestratorUpgradeable/BeneficiaryAddress.sol";
import { TVSBeaconAddress } from "src/state/orchestratorUpgradeable/TVSBeaconAddress.sol";
import { AccessControlUpgradeable } from
    "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol";
import { ReentrancyGuardTransientUpgradeable } from
    "lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardTransientUpgradeable.sol";
import { UpgradeableBeacon } from "lib/openzeppelin-contracts/contracts/proxy/beacon/UpgradeableBeacon.sol";

import { MinSweepAmount } from "src/components/state/configManager/MinSweepAmount.sol";
import { AllocationConfig } from "src/components/state/configManager/AllocationConfig.sol";

/// @title Orchestrator (v1)
/// @author Alluvial Finance Inc.
/// @notice Orchestrator base implementation.
abstract contract OrchestratorBase is
    BatchSweep,
    BatchPectra,
    BatchDeposit,
    BatchTVSTransfer,
    BatchSetTVS,
    AccessControlUpgradeable,
    ReentrancyGuardTransientUpgradeable,
    IOrchestrator,
    IConfigManager
{
    using Address for address;
    using Address for address payable;

    /// @notice Storage slot of the pause status value
    bytes32 private constant _PAUSE_SLOT = bytes32(uint256(keccak256("orchestrator.state.pause")) - 1);

    ///--------------------------------------------------------------------///
    ///                           ROLES START                              ///
    ///--------------------------------------------------------------------///

    /// @dev This role would allow the address to pause the contract
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /// @dev This role would allow the address to deposit ETH into the contract
    bytes32 public constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE");

    /// @dev This role would allow the address to update the config manager
    bytes32 public constant CONFIG_MANAGER_ROLE = keccak256("CONFIG_MANAGER_ROLE");

    /// @dev This role would allow the address to withdraw ETH from the contract
    bytes32 public constant ETH_WITHDRAWER_ROLE = keccak256("ETH_WITHDRAWER_ROLE");

    /// @dev This role would allow calling the following functions:
    /// - depositValidatorSetToConsensusLayer
    bytes32 public constant DEPOSIT_CONSENSUS_LAYER_ROLE = keccak256("DEPOSIT_CONSENSUS_LAYER_ROLE");

    /// ----------- ROLES RELATED TO VALIDATOR SETS OPERATIONS ----------- ///

    ///  @dev This role would allow the address to set the beneficiary of a validator set
    bytes32 public constant BENEFICIARY_ROLE = keccak256("BENEFICIARY_ROLE");

    /// @dev This role would allow the address to create validator sets
    bytes32 public constant VALIDATOR_SET_CREATOR_ROLE = keccak256("VALIDATOR_SET_CREATOR_ROLE");

    /// @dev This role would allow the address to transfer validator sets to other addresses
    bytes32 public constant VALIDATOR_SET_TRANSFER_ROLE = keccak256("VALIDATOR_SET_TRANSFER_ROLE");

    /// @dev This role would allow the address to receive the transferred validator sets
    bytes32 public constant VALIDATOR_SET_RECIPIENT_ROLE = keccak256("VALIDATOR_SET_RECIPIENT_ROLE");

    /// @dev This role would allow the address to:
    /// - Do partial or full withdrawals on-chain
    /// - Signal the off-chain process to trigger validator exits
    bytes32 public constant VALIDATOR_MANAGER_ROLE = keccak256("VALIDATOR_MANAGER_ROLE");

    ///--------------------------------------------------------------------///
    ///                             ROLES END                              ///
    ///--------------------------------------------------------------------///

    /// @dev Ensures the system is not paused before executing the function
    modifier isNotPaused() {
        if (LibUnstructuredStorage.getStorageBool(_PAUSE_SLOT)) {
            revert OrchestratorIsPaused();
        }
        _;
    }

    /// @dev Constructor to set the deposit contract address
    /// @param beaconDepositContract The address of the beacon deposit contract
    constructor(address beaconDepositContract) BatchDeposit(beaconDepositContract) {
        _disableInitializers();
    }

    /// @dev Save the base config
    /// @param _beneficiaryAddress The beneficiary address
    /// @param _configManagerAddress The config manager address
    /// @param _depositContractAddress The deposit contract address
    function _saveBaseConfig(
        address _beneficiaryAddress,
        address _configManagerAddress,
        address _depositContractAddress
    )
        internal
    {
        _setBeneficiary(_beneficiaryAddress);
        ConfigManagerAddress.set(_configManagerAddress);
        DepositContractAddress.set(_depositContractAddress);
    }

    /// @notice Pauses the contract
    function pause() external isNotPaused onlyRole(PAUSER_ROLE) {
        LibUnstructuredStorage.setStorageBool(_PAUSE_SLOT, true);
        emit Paused();
    }

    /// @notice Unpauses the contract
    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (!LibUnstructuredStorage.getStorageBool(_PAUSE_SLOT)) {
            revert OrchestratorIsNotPaused();
        }
        LibUnstructuredStorage.setStorageBool(_PAUSE_SLOT, false);
        emit Unpaused();
    }

    /// @inheritdoc IOrchestrator
    function deposit() external payable onlyRole(DEPOSITOR_ROLE) isNotPaused {
        emit ETHDeposited(msg.sender, msg.value);
    }

    /// @inheritdoc IOrchestrator
    function requestExits(uint256 amount) external onlyRole(VALIDATOR_MANAGER_ROLE) isNotPaused {
        emit ExitsRequested(msg.sender, amount);
    }

    /// @inheritdoc IOrchestrator
    function withdrawETH(uint256 amount, address destination) external onlyRole(ETH_WITHDRAWER_ROLE) isNotPaused {
        if (destination == address(0)) {
            _withdrawETH(msg.sender, amount);
        } else {
            _withdrawETH(destination, amount);
        }
    }

    /// @notice Withdraw ETH from the contract
    /// @param _destination The address to send the ETH to
    /// @param _amount The amount of ETH to withdraw
    function _withdrawETH(address _destination, uint256 _amount) internal isNotPaused {
        payable(_destination).sendValue(_amount);
        emit ETHWithdrawn(msg.sender, _destination, _amount);
    }

    /// @inheritdoc IOrchestrator
    function setBeneficiary(address beneficiary) external onlyRole(BENEFICIARY_ROLE) isNotPaused {
        _setBeneficiary(beneficiary);
    }

    /// @inheritdoc IOrchestrator
    function setBeneficiaryAndSyncToTVSs(
        address beneficiary,
        address[] calldata validatorSets
    )
        external
        onlyRole(BENEFICIARY_ROLE)
        isNotPaused
    {
        _setBeneficiary(beneficiary);
        _setTVSBeneficiary(validatorSets, beneficiary);
    }

    /// @notice Sets the config manager address on the Orchestrator
    /// @param configManagerAddress The new config manager address
    function setConfigManagerAddress(address configManagerAddress) external onlyRole(DEFAULT_ADMIN_ROLE) isNotPaused {
        ConfigManagerAddress.set(configManagerAddress);
        emit ConfigManagerAddressUpdated(ConfigManagerAddress.get(), configManagerAddress);
    }

    /// @inheritdoc IOrchestrator
    function setTVSBeaconImplementation(address tvsBeaconImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
        UpgradeableBeacon(TVSBeaconAddress.get()).upgradeTo(tvsBeaconImplementation);
        emit TVSBeaconUpdated(tvsBeaconImplementation);
    }

    /// @inheritdoc IOrchestrator
    function getTVSBeacon() external view returns (address) {
        return TVSBeaconAddress.get();
    }

    /// @inheritdoc IOrchestrator
    function getBeneficiary() external view returns (address) {
        return BeneficiaryAddress.get();
    }

    /// @inheritdoc IOrchestrator
    function getConfigManagerAddress() external view returns (address) {
        return ConfigManagerAddress.get();
    }

    ///--------------------------------------------------------------------///
    ///                          BATCH CONTRACTS                           ///
    ///--------------------------------------------------------------------///

    /// @inheritdoc BatchSweep
    function _sweepToBeneficiary(address[] calldata from, uint256[] calldata amount) internal override isNotPaused {
        super._sweepToBeneficiary(from, amount);
    }

    /// @inheritdoc BatchDeposit
    function _depositValidatorSetToConsensusLayer(
        bytes32 _depositRoot,
        ValidatorSet[] calldata _validatorSets
    )
        internal
        override
        onlyRole(DEPOSIT_CONSENSUS_LAYER_ROLE)
        isNotPaused
    {
        super._depositValidatorSetToConsensusLayer(_depositRoot, _validatorSets);
    }

    /// @inheritdoc BatchSetTVS
    function _setTVSBeneficiary(
        address[] calldata _validatorSets,
        address _beneficiary
    )
        internal
        override
        onlyRole(BENEFICIARY_ROLE)
        isNotPaused
    {
        super._setTVSBeneficiary(_validatorSets, _beneficiary);
    }

    /// @inheritdoc BatchSetTVS
    function _setTVSBeacon(
        address[] calldata _validatorSets,
        address _beacon
    )
        internal
        override
        onlyRole(DEFAULT_ADMIN_ROLE)
        isNotPaused
    {
        super._setTVSBeacon(_validatorSets, _beacon);
    }

    /// @inheritdoc BatchPectra
    function _withdrawFromValidatorSets(
        ValidatorWithdrawSelection[] calldata _validatorWithdrawSelections,
        address _excessFeeRecipient,
        uint256 _maxFeePerRequest
    )
        internal
        override
        onlyRole(VALIDATOR_MANAGER_ROLE)
        isNotPaused
    {
        super._withdrawFromValidatorSets(_validatorWithdrawSelections, _excessFeeRecipient, _maxFeePerRequest);
    }

    /// @inheritdoc IOrchestrator
    function sweepAndTransferTVSs(
        address[] calldata validatorSets,
        address newBeneficiary,
        address newOwner,
        bool requestValidatorExists
    )
        external
        onlyRole(VALIDATOR_SET_TRANSFER_ROLE)
        isNotPaused
    {
        _helperTransferTVSs(validatorSets, newBeneficiary, newOwner, true, requestValidatorExists);
    }

    /// @inheritdoc BatchTVSTransfer
    function transferTVSs(
        address[] calldata validatorSets,
        address newBeneficiary,
        address newOwner,
        bool requestValidatorExits
    )
        external
        override
        onlyRole(VALIDATOR_SET_TRANSFER_ROLE)
        isNotPaused
    {
        _helperTransferTVSs(validatorSets, newBeneficiary, newOwner, false, requestValidatorExits);
    }

    /// @dev Helper function to transfer validator sets
    /// @param validatorSets The validator sets to transfer
    /// @param newBeneficiary The new beneficiary of the validator sets
    /// @param newOwner The new owner of the validator sets
    /// @param sweep Whether to sweep the validator sets
    /// @param requestValidatorExits Whether to request validator exits
    function _helperTransferTVSs(
        address[] calldata validatorSets,
        address newBeneficiary,
        address newOwner,
        bool sweep,
        bool requestValidatorExits
    )
        internal
    {
        if (!hasRole(VALIDATOR_SET_RECIPIENT_ROLE, newOwner)) {
            revert NoTransferToRole();
        }
        _transferTVSs(validatorSets, newBeneficiary, newOwner, sweep, requestValidatorExits);
    }

    /// @inheritdoc IOrchestrator
    function changeOwner(address to) external isNotPaused onlyRole(DEFAULT_ADMIN_ROLE) {
        _changeOwner(to);
    }

    /// @dev Changes the owner of the Orchestrator
    /// @param _to The new owner of the Orchestrator
    function _changeOwner(address _to) internal {
        if (_to == address(0)) revert InvalidZeroAddress();
        _revokeRoles(msg.sender, _getOwnerRoles());
        _configureOwner(_to);
        emit OwnerChanged(msg.sender, _to);
    }

    /// @dev Get the roles of the owner
    /// @return roles The roles of the owner
    function _getOwnerRoles() internal view returns (bytes32[] memory roles) {
        roles = new bytes32[](11);
        roles[0] = DEFAULT_ADMIN_ROLE;
        roles[1] = DEPOSIT_CONSENSUS_LAYER_ROLE;
        roles[2] = DEPOSITOR_ROLE;
        roles[3] = VALIDATOR_MANAGER_ROLE;
        roles[4] = BENEFICIARY_ROLE;
        roles[5] = ETH_WITHDRAWER_ROLE;
        roles[6] = CONFIG_MANAGER_ROLE;
        roles[7] = VALIDATOR_SET_CREATOR_ROLE;
        roles[8] = VALIDATOR_SET_TRANSFER_ROLE;
        roles[9] = VALIDATOR_SET_RECIPIENT_ROLE;
        roles[10] = PAUSER_ROLE;
    }

    ///--------------------------------------------------------------------///
    ///                          CONFIG MANAGER                            ///
    ///--------------------------------------------------------------------///

    /// @notice Retrieve the current minimum sweep amount of the SMS
    /// @return The current minimum sweep amount - a multiple of 32 ETH
    function getMinSweepAmount() external view returns (uint256) {
        return MinSweepAmount.get();
    }

    /// @notice Get the current allocation configuration of the SMS
    /// @return allocationConfig The allocation configuration
    function getAllocationConfig() external view returns (StoredAllocationConfig memory allocationConfig) {
        allocationConfig.binWeightings = AllocationConfig.getBinWeightings();
        IConfigManager.Bin[] storage storedBins = AllocationConfig.getBins();

        // Create memory copy of bins
        allocationConfig.bins = new IConfigManager.Bin[](storedBins.length);
        for (uint256 i = 0; i < storedBins.length; i++) {
            allocationConfig.bins[i] = storedBins[i];
        }
        return allocationConfig;
    }

    /// @inheritdoc IConfigManager
    function setMinSweepAmount(uint256 amount) external onlyRole(CONFIG_MANAGER_ROLE) isNotPaused {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// @inheritdoc IConfigManager
    function setAllocationConfig(StoredAllocationConfig calldata allocationConfig)
        external
        onlyRole(CONFIG_MANAGER_ROLE)
        isNotPaused
    {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// @inheritdoc IConfigManager
    function addBin(
        Bin calldata bin,
        uint16[] calldata binWeightings
    )
        external
        onlyRole(CONFIG_MANAGER_ROLE)
        isNotPaused
    {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// @inheritdoc IConfigManager
    function updateBinWeightings(uint16[] calldata binWeightings) external onlyRole(CONFIG_MANAGER_ROLE) isNotPaused {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// @inheritdoc IConfigManager
    function updateValidatorSetSizes(uint32[] calldata validatorSetSizes)
        external
        onlyRole(CONFIG_MANAGER_ROLE)
        isNotPaused
    {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// @inheritdoc IConfigManager
    function updateNodeOperatorWeightings(
        uint256 bin,
        uint16[] calldata nodeOperatorWeightings
    )
        external
        onlyRole(CONFIG_MANAGER_ROLE)
        isNotPaused
    {
        ConfigManagerAddress.get().functionDelegateCall(msg.data);
    }

    /// ------------------------------------------------------------------------ ///
    ///                            CONFIG MANAGER END                            ///
    /// ------------------------------------------------------------------------ ///

    /// ------------------------------------------------------------------------ ///
    ///                            ROLE MANAGEMENT                               ///
    /// ------------------------------------------------------------------------ ///

    /// @dev Sets staker & keeper roles for supplied addresses at the time of deployment
    /// @param _staker The address to configure as a staker
    /// @param _keeper The address to configure as a keeper
    function _preConfigRoles(address _staker, address _keeper) internal {
        if (_staker != address(0)) {
            _configureStaker(_staker);
        }

        if (_keeper != address(0)) {
            _configureKeeper(_keeper);
        }
    }

    /// @dev Configures the owner role
    /// @param _owner The address to configure as the owner
    function _configureOwner(address _owner) internal {
        _grantRoles(_owner, _getOwnerRoles());
    }

    /// @dev Configures a staker role
    /// @param _staker The address to configure as a staker
    function _configureStaker(address _staker) internal {
        bytes32[] memory roles = new bytes32[](5);
        roles[0] = PAUSER_ROLE;
        roles[1] = DEPOSITOR_ROLE;
        roles[2] = CONFIG_MANAGER_ROLE;
        roles[3] = VALIDATOR_MANAGER_ROLE;
        roles[4] = VALIDATOR_SET_TRANSFER_ROLE;
        _grantRoles(_staker, roles);
    }

    /// @dev Configures a keeper role
    /// @param _keeper The address to configure as a keeper
    function _configureKeeper(address _keeper) internal {
        bytes32[] memory roles = new bytes32[](2);
        roles[0] = VALIDATOR_SET_CREATOR_ROLE;
        roles[1] = DEPOSIT_CONSENSUS_LAYER_ROLE;

        _grantRoles(_keeper, roles);
    }

    /// @dev Helper function to grant multiple roles to an account
    /// @param _account The address to grant the roles to
    /// @param _roles The roles to grant to the account
    function _grantRoles(address _account, bytes32[] memory _roles) internal {
        for (uint256 i = 0; i < _roles.length; i++) {
            _grantRole(_roles[i], _account);
        }
    }

    /// @dev Helper function to revoke multiple roles from an account
    /// @param _account The address to revoke the roles from
    /// @param _roles The roles to revoke from the account
    function _revokeRoles(address _account, bytes32[] memory _roles) internal {
        for (uint256 i = 0; i < _roles.length; i++) {
            _revokeRole(_roles[i], _account);
        }
    }

    /// @inheritdoc IOrchestrator
    function grantAndRevokeRoles(
        RoleMapping[] calldata grantRoles,
        RoleMapping[] calldata revokeRoles
    )
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
        isNotPaused
    {
        for (uint256 i = 0; i < grantRoles.length; i++) {
            for (uint256 j = 0; j < grantRoles[i].roles.length; j++) {
                if (grantRoles[i].roles[j] == DEFAULT_ADMIN_ROLE) {
                    revert InvalidOperation();
                }
                _grantRole(grantRoles[i].roles[j], grantRoles[i].account);
            }
        }

        for (uint256 i = 0; i < revokeRoles.length; i++) {
            for (uint256 j = 0; j < revokeRoles[i].roles.length; j++) {
                if (revokeRoles[i].roles[j] == DEFAULT_ADMIN_ROLE) {
                    revert InvalidOperation();
                }
                _revokeRole(revokeRoles[i].roles[j], revokeRoles[i].account);
            }
        }
    }

    /// @dev Sets the beneficiary address
    /// @param beneficiary The address to set as the beneficiary

    function _setBeneficiary(address beneficiary) internal {
        BeneficiaryAddress.set(beneficiary);
        emit BeneficiaryUpdated(BeneficiaryAddress.get(), beneficiary);
    }

    /// @notice Grants roles to an account
    /// @param account The account to grant the roles to
    /// @param roles The roles to grant to the account
    function grantRoles(address account, bytes32[] calldata roles) external onlyRole(DEFAULT_ADMIN_ROLE) isNotPaused {
        for (uint256 i = 0; i < roles.length; i++) {
            if (roles[i] == DEFAULT_ADMIN_ROLE) {
                revert InvalidOperation();
            }
            _grantRole(roles[i], account);
        }
    }

    /// @notice Revokes roles from an account
    /// @param account The account to revoke the roles from
    /// @param roles The roles to revoke from the account
    function revokeRoles(address account, bytes32[] calldata roles) external onlyRole(DEFAULT_ADMIN_ROLE) isNotPaused {
        for (uint256 i = 0; i < roles.length; i++) {
            if (roles[i] == DEFAULT_ADMIN_ROLE) {
                revert InvalidOperation();
            }
            _revokeRole(roles[i], account);
        }
    }

    /// ACCESS CONTROL SAFEGUARDING
    /// We are overriding the following functions to prevent the DEFAULT_ADMIN_ROLE from being revoked & granted.
    /// We only want the changeOwner function to be able to do that.

    /// @inheritdoc AccessControlUpgradeable
    function grantRole(bytes32 role, address account) public override onlyRole(DEFAULT_ADMIN_ROLE) isNotPaused {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert InvalidOperation();
        }
        _grantRole(role, account);
    }

    /// @inheritdoc AccessControlUpgradeable
    function revokeRole(bytes32 role, address account) public override onlyRole(DEFAULT_ADMIN_ROLE) isNotPaused {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert InvalidOperation();
        }
        _revokeRole(role, account);
    }

    /// @inheritdoc AccessControlUpgradeable
    function renounceRole(bytes32 role, address account) public override {
        revert InvalidOperation();
    }

    /// @notice Returns the version of the Orchestrator
    /// @return The version of the Orchestrator
    function version() external pure returns (string memory) {
        return "1.0.0";
    }
}

src/OrchestratorUpgradeableBase.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { OrchestratorBase } from "src/OrchestratorBase.sol";

import { Initializable } from "openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import { UUPSUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";

/// @title Orchestrator Upgradeable Base
/// @author Alluvial Finance Inc.
/// @notice This contract is intended to be inherited by Upgradeable Orchestrator contracts.
///         It contains the shared logic for all upgradeable orchestrator contracts.
abstract contract OrchestratorUpgradeableBase is Initializable, OrchestratorBase, UUPSUpgradeable {
    constructor(address beaconDepositContract) OrchestratorBase(beaconDepositContract) { }

    /// @dev This function is overridden to prevent the contract from being upgraded
    ///      by a role other than the DEFAULT_ADMIN_ROLE
    function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant { }
}

src/batchContracts/BatchDeposit.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibBytes } from "src/libraries/LibBytes.sol";
import { LibUint } from "src/libraries/LibUint.sol";
import { IDepositContract } from "src/interfaces/IDepositContract.sol";
import { DepositContractAddress } from "src/batchContracts/state/DepositContractAddress.sol";
import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol";

/// @title BatchDeposit (v1)
/// @author Alluvial Finance Inc.
/// @notice Contract for processing deposit of validators to the consensus layer in a batch
contract BatchDeposit {
    /// @notice The type of withdrawal credentials
    enum WithdrawCredentialType {
        Type0x01,
        Type0x02
    }

    /// @notice Size of a BLS Public key in bytes
    uint256 public constant PUBLIC_KEY_LENGTH = 48;
    /// @notice Size of a BLS Signature in bytes
    uint256 public constant SIGNATURE_LENGTH = 96;

    // ------------------------ Deposit functions ------------------------ //
    /// @title Validators count by operator
    /// @notice This struct represents a number of validators from the same operator
    struct ValidatorSelection {
        bytes[] _publicKeys; // The list of public keys to deposit
        bytes[] _signatures; // The list of signatures to deposit
        uint256 _depositAmount; // The deposit amount to use
    }

    /// @title Validator Set Type
    /// @notice This struct represents validator sets (VS), a set of validators sharing the same withdrawal credentials
    struct ValidatorSet {
        WithdrawCredentialType _withdrawalCredentialsType; // The type of withdrawal credentials to use
        address _withdrawalContractAddress; // The EL withdrawal address to use for withdrawal credentials
        ValidatorSelection[] _validatorSelections; // list of validators selected per operator
    }

    /// @notice Emitted when a new validator is funded
    /// @param withdrawalCredentials The withdrawal credentials of the validator
    /// @param publicKey The public key of the validator
    /// @param amount The amount of ETH staked to the validator
    event DepositedToConsensusLayer(bytes32 withdrawalCredentials, bytes publicKey, uint256 amount);

    /// @notice The received count of signatures to deposit is invalid
    error InvalidKeyCount();
    /// @notice Invalid deposit root
    error InvalidDepositRoot();
    /// @notice The withdrawal contract address is null
    error InvalidWithdrawalContractAddress();
    /// @notice The length of the BLS Public key is invalid during deposit
    error InconsistentPublicKeys();
    /// @notice The length of the BLS Signature is invalid during deposit
    error InconsistentSignatures();
    /// @notice The owner of the validator set is not the SMS
    error InvalidValidatorSetOwner();

    /// @notice Constructor to set the deposit contract address
    /// @param _depositContractAddress The address of the official Deposit contract
    constructor(address _depositContractAddress) {
        DepositContractAddress.set(_depositContractAddress);
    }

    /// @notice Deposits a set of validators to the consensus layer
    /// @param depositRoot The deposit root to validate against
    /// @param validatorSets The sets of validators to deposit
    function depositValidatorSetToConsensusLayer(bytes32 depositRoot, ValidatorSet[] calldata validatorSets) external {
        _depositValidatorSetToConsensusLayer(depositRoot, validatorSets);
    }

    /// @notice Internal function to deposit a set of validators to the consensus layer
    /// @param _depositRoot The deposit root to validate against
    /// @param _validatorSets The sets of validators to deposit
    function _depositValidatorSetToConsensusLayer(
        bytes32 _depositRoot,
        ValidatorSet[] calldata _validatorSets
    )
        internal
        virtual
    {
        if (IDepositContract(DepositContractAddress.get()).get_deposit_root() != _depositRoot) {
            revert InvalidDepositRoot();
        }

        for (uint256 i = 0; i < _validatorSets.length; i++) {
            ValidatorSet memory validatorSet = _validatorSets[i];

            if (validatorSet._withdrawalContractAddress == address(0)) {
                revert InvalidWithdrawalContractAddress();
            }
            // Please note that the assumption here is that the _withdrawalContractAddress is a valid TVS contract
            // The only other way to be absolutely sure is to check the bytecode.
            if (Ownable(validatorSet._withdrawalContractAddress).owner() != address(this)) {
                revert InvalidValidatorSetOwner();
            }

            bytes32 withdrawalCredentials =
                getCredentials(validatorSet._withdrawalContractAddress, validatorSet._withdrawalCredentialsType);

            for (uint256 j = 0; j < validatorSet._validatorSelections.length; j++) {
                uint256 keyCount = validatorSet._validatorSelections[j]._publicKeys.length;

                if (keyCount == 0 || keyCount != validatorSet._validatorSelections[j]._signatures.length) {
                    revert InvalidKeyCount();
                }

                // Deposit validators from the current selection, for the current withdrawal credentials
                for (uint256 idx = 0; idx < keyCount; idx++) {
                    _depositValidator(
                        validatorSet._validatorSelections[j]._publicKeys[idx],
                        validatorSet._validatorSelections[j]._signatures[idx],
                        withdrawalCredentials,
                        validatorSet._validatorSelections[j]._depositAmount
                    );
                }
            }
        }
    }

    /// @notice Deposits a validator to the official Deposit contract
    /// @param _publicKey The BLS public key of the validator, expected to be 48 bytes long
    /// @param _signature The BLS signature for the validator, expected to be 96 bytes long
    /// @param _withdrawalCredentials The withdrawal credentials, expected to be a 32-byte hash
    /// @param _depositAmount The amount of ETH to deposit, expected to be 32 ether
    function _depositValidator(
        bytes memory _publicKey,
        bytes memory _signature,
        bytes32 _withdrawalCredentials,
        uint256 _depositAmount
    )
        internal
    {
        if (_publicKey.length != PUBLIC_KEY_LENGTH) {
            revert InconsistentPublicKeys();
        }

        if (_signature.length != SIGNATURE_LENGTH) {
            revert InconsistentSignatures();
        }
        uint256 value = _depositAmount;

        uint256 depositAmount = value / 1 gwei;

        bytes32 pubkeyRoot = sha256(bytes.concat(_publicKey, bytes16(0)));
        bytes32 signatureRoot = sha256(
            bytes.concat(
                sha256(LibBytes.slice(_signature, 0, 64)),
                sha256(bytes.concat(LibBytes.slice(_signature, 64, SIGNATURE_LENGTH - 64), bytes32(0)))
            )
        );

        bytes32 depositDataRoot = sha256(
            bytes.concat(
                sha256(bytes.concat(pubkeyRoot, _withdrawalCredentials)),
                sha256(bytes.concat(bytes32(LibUint.toLittleEndian64(uint64(depositAmount))), signatureRoot))
            )
        );

        IDepositContract(DepositContractAddress.get()).deposit{ value: value }(
            _publicKey, abi.encodePacked(_withdrawalCredentials), _signature, depositDataRoot
        );

        emit DepositedToConsensusLayer(_withdrawalCredentials, _publicKey, value);
    }

    /// @notice Internal utility to get the withdrawal credentials from the provided address
    /// @param _withdrawalContract The withdrawal contract address. This should be a valid Ethereum address.
    /// @param _withdrawalCredentialType The type of withdrawal credentials to use.
    ///        It can be either `WithdrawCredentialType.Type0x01` or `WithdrawCredentialType.Type0x02`.
    /// @return The withdrawal credentials as a bytes32 value.
    function getCredentials(
        address _withdrawalContract,
        WithdrawCredentialType _withdrawalCredentialType
    )
        internal
        pure
        returns (bytes32)
    {
        if (_withdrawalCredentialType == WithdrawCredentialType.Type0x01) {
            return bytes32(uint256(uint160(_withdrawalContract)) | (1 << 248));
        } else {
            return bytes32(uint256(uint160(_withdrawalContract)) | (2 << 248));
        }
    }
}

src/batchContracts/BatchPectra.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { ITVS } from "tvs/interfaces/ITVS.sol";

/// @title BatchPectra
/// @author Alluvial Finance Inc.
/// @notice Contract for processing withdrawal requests for multiple validator sets in a batch
contract BatchPectra {
    /// @notice Error emitted when two arrays have different lengths
    error ArrayLengthMismatch();

    /// @notice Emitted when the fees sent are less than the total fee paid for withdrawal requests
    /// @param _feesReceived The amount of fees received
    /// @param _totalFeePaid The total fee paid
    error InsufficientFeesReceived(uint256 _feesReceived, uint256 _totalFeePaid);

    /// @notice Emitted when a withdrawal request is made
    /// @param _validatorWithdrawSelections Array of validator withdraw selections
    /// @param _maxFee Max fee the user is willing to pay per withdrawal request
    event WithdrawalRequested(ValidatorWithdrawSelection[] _validatorWithdrawSelections, uint256 _maxFee);

    /// @notice Selection of validators to withdraw from for a given validator set
    struct ValidatorWithdrawSelection {
        address _validatorSetAddress; // Address of the validator set
        bytes[] _publicKeys; // The list of public keys to withdraw from
        uint64[] _amount; // The amount in gwei to withdraw from a validator
    }

    /// @notice Withdraws from multiple validator sets in a single transaction
    /// @param validatorWithdrawSelections Array of withdrawal selections containing validator set addresses and
    /// withdrawal details
    /// @param _maxFeePerRequest Max fee the user is willing to pay per withdrawal request
    /// @dev This function enables batch withdrawals from different validator sets
    function withdrawFromValidatorSets(
        ValidatorWithdrawSelection[] calldata validatorWithdrawSelections,
        uint256 _maxFeePerRequest
    )
        external
        payable
    {
        _withdrawFromValidatorSets(validatorWithdrawSelections, msg.sender, _maxFeePerRequest);
    }

    /// @notice Internal function to handle validator withdrawal logic
    /// @param _validatorWithdrawSelections Array of withdrawal selections to process
    /// @param _excessFeeRecipient Address to receive excess fees
    /// @param _maxFeePerRequest Max fee the user is willing to pay per withdrawal request
    function _withdrawFromValidatorSets(
        ValidatorWithdrawSelection[] calldata _validatorWithdrawSelections,
        address _excessFeeRecipient,
        uint256 _maxFeePerRequest
    )
        internal
        virtual
    {
        uint256 feesReceived = msg.value;
        uint256 totalFeePaid;
        uint256 totalFeePerRequest;
        for (uint256 i = 0; i < _validatorWithdrawSelections.length; i++) {
            if (_validatorWithdrawSelections[i]._publicKeys.length != _validatorWithdrawSelections[i]._amount.length) {
                revert ArrayLengthMismatch();
            }
            totalFeePerRequest = _maxFeePerRequest * _validatorWithdrawSelections[i]._publicKeys.length;
            // Since we want to ensure that there is enough gas to process all the withdrawal requests,
            // we multiply the max fee per request by the number of withdrawal requests.
            ITVS(payable(_validatorWithdrawSelections[i]._validatorSetAddress)).withdraw{ value: totalFeePerRequest }(
                _validatorWithdrawSelections[i]._publicKeys,
                _validatorWithdrawSelections[i]._amount,
                _maxFeePerRequest,
                _excessFeeRecipient
            );
            totalFeePaid += totalFeePerRequest;
        }
        if (totalFeePaid > feesReceived) {
            revert InsufficientFeesReceived(feesReceived, totalFeePaid);
        }
        emit WithdrawalRequested(_validatorWithdrawSelections, _maxFeePerRequest);
    }
}

src/batchContracts/BatchSetTVS.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { ITVSUpgradeable } from "lib/tvs/src/TVSUpgradeable/interfaces/ITVSUpgradeable.sol";

/// @title Batch Set TVS Contract
/// @author Alluvial Finance Inc.
/// @notice This contract allows for the batch setting of beneficiaries and beacon for multiple validator sets
contract BatchSetTVS {
    /// @notice External function to set the beneficiary for multiple validator sets
    /// @dev This function allows for the batch setting of beneficiaries for a list of validator sets
    /// @param validatorSets The list of validator sets to set the beneficiary for
    /// @param beneficiary The address to set as the beneficiary
    function setTVSBeneficiary(address[] calldata validatorSets, address beneficiary) external {
        _setTVSBeneficiary(validatorSets, beneficiary);
    }

    /// @notice External function to set the beacon for multiple validator sets
    /// @param validatorSets The list of validator sets to set the beacon for
    /// @param beacon The address of the new beacon
    function setTVSBeacon(address[] calldata validatorSets, address beacon) external {
        _setTVSBeacon(validatorSets, beacon);
    }

    /// @notice Internal function to set beneficiary for multiple validator sets
    /// @param _validatorSets The list of validator sets to set the beneficiary for
    /// @param _beneficiary The address to set as the beneficiary
    function _setTVSBeneficiary(address[] calldata _validatorSets, address _beneficiary) internal virtual {
        for (uint256 i = 0; i < _validatorSets.length; i++) {
            // Implement the logic to set the beneficiary for the validator set
            ITVSUpgradeable(payable(_validatorSets[i])).setBeneficiary(_beneficiary);
        }
    }

    /// @notice Internal function to set the beacon for multiple validator sets
    /// @param _validatorSets The list of validator sets to set the beacon for
    /// @param _beacon The address of the new beacon
    function _setTVSBeacon(address[] calldata _validatorSets, address _beacon) internal virtual {
        for (uint256 i = 0; i < _validatorSets.length; i++) {
            ITVSUpgradeable(payable(_validatorSets[i])).setBeacon(_beacon);
        }
    }
}

src/batchContracts/BatchSweep.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { ITVS } from "tvs/interfaces/ITVS.sol";

/// @title BatchSweep
/// @author Alluvial Finance Inc.
/// @notice Contract for processing sweeps of funds from multiple validator sets in a batch
contract BatchSweep {
    /// @notice Thrown when there is a mismatch in the input lengths
    error InvalidInputLengths();

    /// @notice Emitted when a sweep is successful
    /// @param sources The list of TVS addresses to sweep from
    /// @param amounts The amounts swept in wei
    event Swept(address[] sources, uint256[] amounts);

    /// @notice Sweeps funds from multiple addresses to the beneficiary address stored in the TVS
    /// @param sources The list of TVS addresses to sweep from
    /// @param amounts The list of amounts to sweep in wei
    function sweepToBeneficiary(address[] calldata sources, uint256[] calldata amounts) external virtual {
        _sweepToBeneficiary(sources, amounts);
    }

    /// @notice Internal function to sweep funds from multiple addresses to the beneficiary address stored in the TVS
    /// @param sources The list of TVS addresses to sweep from
    /// @param amounts The list of amounts to sweep in wei
    function _sweepToBeneficiary(address[] calldata sources, uint256[] calldata amounts) internal virtual {
        if (sources.length != amounts.length) {
            revert InvalidInputLengths();
        }

        for (uint256 i = 0; i < sources.length; i++) {
            ITVS(payable(sources[i])).sweep(address(0), amounts[i]);
        }
        emit Swept(sources, amounts);
    }
}

src/batchContracts/BatchTVSTransfer.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { ITVS } from "lib/tvs/src/interfaces/ITVS.sol";

/// @title Batch TVS Transfer Contract
/// @author Alluvial Finance Inc.
/// @notice Contract for processing transfer of TVSs to a given address in a batch
contract BatchTVSTransfer {
    /// @notice Emitted when a validator set is transferred
    /// @param tvs The TVS address
    /// @param newOwner The new owner of the TVS
    event TVSTransferred(address indexed tvs, address indexed newOwner);

    /// @notice Event that is emitted when a TVS is transferred and its validators are requested to exit
    /// @param tvs The address of the TVS whose validators are requested to exit
    event TVSExitRequested(address indexed tvs);

    /// @notice Transfer validator sets to a given address
    /// @dev This function provides a one-step transfer of validator sets to a given address
    /// @param validatorSets The list of validator sets to transfer
    /// @param newBeneficiary The address to be set as beneficiary
    /// @param newOwner The address to transfer to
    function transferTVSs(
        address[] calldata validatorSets,
        address newBeneficiary,
        address newOwner,
        bool requestValidatorExits
    )
        external
        virtual
    {
        _transferTVSs(validatorSets, newBeneficiary, newOwner, false, requestValidatorExits);
    }

    /// @notice Internal function to transfer validator sets to a given address
    /// @param _validatorSets The list of validator sets to transfer
    /// @param _newBeneficiary The address to be set as beneficiary
    /// @param _newOwner The address to transfer to
    /// @param _sweep Whether to sweep the validator sets
    /// @param _requestValidatorExits Whether to request the validator sets to be exited
    function _transferTVSs(
        address[] calldata _validatorSets,
        address _newBeneficiary,
        address _newOwner,
        bool _sweep,
        bool _requestValidatorExits
    )
        internal
    {
        uint256 length = _validatorSets.length;
        for (uint256 i = 0; i < length; i++) {
            if (_sweep) {
                ITVS(payable(_validatorSets[i])).sweep(address(0x0), 0);
            }
            if (_requestValidatorExits) {
                emit TVSExitRequested(_validatorSets[i]);
            }
            // Implement the logic to transfer validator sets to _newOwner
            ITVS(payable(_validatorSets[i])).transfer(_newBeneficiary, _newOwner);
            emit TVSTransferred(_validatorSets[i], _newOwner);
        }
    }
}

src/batchContracts/BatchUpgradeableTVSCreator.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { TVSBeaconProxy } from "tvs/TVSUpgradeable/proxies/TVSBeaconProxy.sol";

/// @title BatchUpgradeableTVSCreator
/// @author Alluvial Finance Inc.
/// @notice Contract for creating multiple upgradeable validator sets in a batch
contract BatchUpgradeableTVSCreator {
    /// @notice Error emitted when an invalid address is provided
    error ZeroAddressNotAllowed();

    /// @notice Event emitted when an upgradeable validator set is created
    /// @param tvs The address of the created validator set
    /// @param beacon The address of the beacon
    event UpgradeableTVSCreated(address indexed tvs, address indexed beacon);

    /// @notice Internal function to create multiple validator sets
    /// @param _count The number of validator sets to create
    /// @param _owner The owner of the validator sets
    /// @param _beneficiary The beneficiary of the validator sets
    /// @param _beacon The beacon address
    /// @return An array of addresses of the created validator sets
    function _createValidatorSets(
        uint256 _count,
        address _owner,
        address _beneficiary,
        address _beacon
    )
        internal
        returns (address[] memory)
    {
        if (_owner == address(0) || _beneficiary == address(0) || _beacon == address(0)) {
            revert ZeroAddressNotAllowed();
        }
        address[] memory newValidatorSets = new address[](_count);
        address newValidatorSet;
        for (uint256 i = 0; i < _count; i++) {
            // Implement the logic to create new validator sets
            newValidatorSet = address(
                new TVSBeaconProxy(
                    _beacon,
                    abi.encodeWithSignature("initialize(address,address,address)", _beneficiary, _owner, _beacon)
                )
            );
            newValidatorSets[i] = newValidatorSet;
            emit UpgradeableTVSCreated(newValidatorSet, _beacon);
        }
        return newValidatorSets;
    }
}

src/batchContracts/state/DepositContractAddress.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

/// @title DepositContract Address Storage
/// @notice Utility to manage the DepositContract Address in storage
library DepositContractAddress {
    /// @notice Error thrown when the DepositContract Address is set to the zero address
    error InvalidZeroAddress();

    /// @notice Storage slot of the DepositContract Address
    bytes32 internal constant DEPOSIT_CONTRACT_ADDRESS_SLOT =
        bytes32(uint256(keccak256("orchestrator.state.depositContractAddress")) - 1);

    /// @notice Retrieve the DepositContract Address
    /// @return The DepositContract Address
    function get() internal view returns (address) {
        return LibUnstructuredStorage.getStorageAddress(DEPOSIT_CONTRACT_ADDRESS_SLOT);
    }

    /// @notice Sets the DepositContract Address
    /// @param _newValue New DepositContract Address
    function set(address _newValue) internal {
        if (_newValue == address(0)) {
            revert InvalidZeroAddress();
        }
        LibUnstructuredStorage.setStorageAddress(DEPOSIT_CONTRACT_ADDRESS_SLOT, _newValue);
    }
}

src/components/state/configManager/AllocationConfig.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { IConfigManager } from "src/interfaces/IConfigManager.sol";

/// @title Allocation Configuration Library
/// @notice This library manages the allocation configuration for node operators and bins
/// @dev The allocation configuration is used to decide how funds should be allocated among node operators and bins
library AllocationConfig {
    /// @notice Slot for bins storage
    bytes32 internal constant BINS_SLOT = bytes32(uint256(keccak256("configManager.state.bins")) - 1);

    /// @notice Slot for bin weightings storage
    bytes32 internal constant BIN_WEIGHTINGS_SLOT = bytes32(uint256(keccak256("configManager.state.binWeightings")) - 1);

    struct Slot {
        IConfigManager.StoredAllocationConfig value;
    }

    /// @notice Get the bin weightings for the SMS
    /// @return The bin weightings for the SMS
    function getBinWeightings() internal view returns (uint16[] storage) {
        bytes32 slot = BIN_WEIGHTINGS_SLOT;

        Slot storage r;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            r.slot := slot
        }

        return r.value.binWeightings;
    }

    /// @notice Get the bins for the SMS
    /// @return The bins for the SMS
    function getBins() internal view returns (IConfigManager.Bin[] storage) {
        bytes32 slot = BINS_SLOT;

        Slot storage r;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            r.slot := slot
        }
        return r.value.bins;
    }

    /// @notice Set the bin weightings for the SMS
    /// @param _binWeightings The new bin weightings
    function setBinWeightings(uint16[] memory _binWeightings) internal {
        bytes32 slot = BIN_WEIGHTINGS_SLOT;

        Slot storage r;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            r.slot := slot
        }

        r.value.binWeightings = _binWeightings;
    }

    /// @notice Set the global node operator weightings for the SMS
    function setBins(IConfigManager.Bin[] memory _bins) internal {
        bytes32 slot = BINS_SLOT;

        Slot storage r;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            r.slot := slot
        }

        uint256 existingLength = r.value.bins.length;
        uint256 newLength = _bins.length;

        // Adjust the length of the bins dynamic array if needed
        if (newLength < existingLength) {
            while (r.value.bins.length > newLength) {
                r.value.bins.pop();
            }
        } else if (newLength > existingLength) {
            // Extend the bins array
            for (uint256 i = existingLength; i < newLength; i++) {
                r.value.bins.push();
            }
        }

        // Update each bin
        for (uint256 i = 0; i < newLength; i++) {
            IConfigManager.Bin storage bin = r.value.bins[i];
            bin.validatorSetSize = _bins[i].validatorSetSize;

            // Adjust the length of the per bin NO weightings dynamic array
            uint256 nestedLength = _bins[i].nodeOperatorWeightings.length;
            uint256 existingNestedLength = bin.nodeOperatorWeightings.length;
            if (bin.nodeOperatorWeightings.length > nestedLength) {
                // Shrink the node operator weightings array
                for (uint256 j = nestedLength; j < existingNestedLength; j++) {
                    bin.nodeOperatorWeightings.pop();
                }
            } else if (existingNestedLength < nestedLength) {
                // Extend the node operator weightings array
                for (uint256 j = existingNestedLength; j < nestedLength; j++) {
                    bin.nodeOperatorWeightings.push();
                }
            }

            // Update node operator weightings
            for (uint256 j = 0; j < nestedLength; j++) {
                bin.nodeOperatorWeightings[j] = _bins[i].nodeOperatorWeightings[j];
            }
        }
    }
}

src/components/state/configManager/MinSweepAmount.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

/// @title Min Sweep Amount
/// @author Alluvial Finance
/// @notice This library manages the min sweep amount for for sweep operations
/// @dev The min sweep amount is used to decide when funds should be swept from the individual validator sets into
/// the global withdrawal credential.
library MinSweepAmount {
    /// @notice Slot for min sweep amount storage
    bytes32 internal constant MIN_SWEEP_AMOUNT_SLOT =
        bytes32(uint256(keccak256("configManager.state.minSweepAmount")) - 1);

    /// @notice Get the min sweep amount
    /// @return The min sweep amount denoted in ETH
    function get() internal view returns (uint256) {
        return LibUnstructuredStorage.getStorageUint256(MIN_SWEEP_AMOUNT_SLOT);
    }

    /// @notice Set the min sweep amount
    /// @param _newValue The new min sweep amount
    /// @dev Reverts if the min sweep amount is invalid
    /// @dev The min sweep amount must be a multiple of 32 ETH
    function set(uint256 _newValue) internal {
        LibUnstructuredStorage.setStorageUint256(MIN_SWEEP_AMOUNT_SLOT, _newValue);
    }
}

src/interfaces/IConfigManager.sol

// SPDX-License-Identifier: Proprietary

pragma solidity 0.8.29;

interface IConfigManager {
    /// @notice Structure used to store the per node operator allocation percentage.
    struct NodeOperatorWeighting {
        uint32 operatorIndex; // Node operator ID
        uint16 allocationPercent; // Percentage allocation to the node operator
    }

    /// @notice Structure used to define a bin with custom validator set size and node operator distribution
    struct Bin {
        uint32 validatorSetSize; // Validator set size
        NodeOperatorWeighting[] nodeOperatorWeightings; // Percentage allocation for each bin.
    }

    /// @notice Structure used to store the per bin allocation configuration
    struct StoredAllocationConfig {
        Bin[] bins; // Bins
        uint16[] binWeightings; // % allocated to each bin
    }

    /// @notice Emitted when a new minimum sweep amount is set
    /// @param amount The new minimum sweep amount
    event MinSweepAmountSet(uint256 amount);

    /// @notice Emitted when a new allocation configuration is set
    /// @param allocationConfig The new allocation configuration
    event AllocationConfigSet(StoredAllocationConfig allocationConfig);

    /// @notice Emitted when a new bin is added
    /// @param bin The new bin
    /// @param binWeightings The new bin weightings
    event BinAdded(Bin bin, uint16[] binWeightings);

    /// @notice Emitted when the bin weightings are updated
    /// @param binWeightings allocation percentages for each bin in the SMS
    event BinWeightingsUpdated(uint16[] binWeightings);

    /// @notice Emitted when the validator set sizes are updated
    /// @param validatorSetSizes The new validator set sizes
    event ValidatorSetSizesUpdated(uint32[] validatorSetSizes);

    /// @notice Emitted when the node operator weightings are updated
    /// @param bin The bin index
    /// @param nodeOperatorWeightings The new node operator weightings
    event NodeOperatorWeightingsUpdated(uint256 bin, uint16[] nodeOperatorWeightings);

    /// @notice Error when the user input configuration is not valid
    error InvalidInputConfig();

    /// @notice Error when the validator set size is zero
    error InvalidValidatorSetSize();

    /// @notice Error when the validator set size of a given bin is lowered
    /// @dev Can only be adjusted up
    error InvalidDecreaseInValidatorSetSize();

    /// @notice Error when the total allocation percentages of all bins do not add up to 100%
    error InvalidTotalAllocation();

    /// @notice Error when the node operators in a bin are not sorted by operator index
    error InvalidNodeOperatorOrder();

    /// @notice Error when the total allocation percentages of all node operators in a bin do not add up to 100%
    error InvalidPerBinAllocation();

    /// @notice Error when the total number of allocation bins is lowered
    /// @dev Can only be adjusted up
    error InvalidDecreaseInNumberOfBins();

    /// @notice Error when the total number of node operators per bin is lowered
    /// @dev Can only be adjusted up
    error InvalidDecreaseInNumberOfNodeOperators();

    /// @notice Error when trying to update values but the size of the object does not match the existing configuration
    error InvalidSizeUpdate();

    /// @notice Sets the minimum sweep amount for sweep operation of the SMS
    /// @param amount The new minimum sweep amount - a multiple of 32 ETH
    function setMinSweepAmount(uint256 amount) external;

    /// @notice Sets the target allocation configuration for the SMS
    /// @notice If config already exists, new config object must include replacements for existing config such that
    /// total allocation (across bins and within bins), number of bins, validator size per bin, and node operators per
    /// bin do not reduce
    /// @param allocationConfig The new target allocation configuration
    function setAllocationConfig(StoredAllocationConfig calldata allocationConfig) external;

    /// @notice Adds a new bin to an allocation configuration
    /// @param bin The new bin to add
    /// @param binWeightings The new bin weightings
    function addBin(Bin calldata bin, uint16[] calldata binWeightings) external;

    /// @notice Update the bin allocation percentages
    /// @param binWeightings The new bin weightings
    /// @dev This function can only be called after setting the allocation configuration
    /// @dev Does not allow changes to the total number of bins. Only their relative weightings
    /// @dev Does not allow any bin acllocation percentage to be less than 1%
    function updateBinWeightings(uint16[] calldata binWeightings) external;

    /// @notice Increment the validator set sizes in each bin by zero or more
    /// @param validatorSetSizes The new validator set sizes
    /// @dev This function can only be called after setting the allocation configuration
    /// @dev Does not allow changes to the total number of validator set sizes nor number of bins
    /// @dev Does only allow `validatorSetSize` per bin to increase, never decrease
    function updateValidatorSetSizes(uint32[] calldata validatorSetSizes) external;

    /// @notice Update the bin allocation percentages
    /// @param bin Index of the bin to update
    /// @param nodeOperatorWeightings The new node operator weightings
    /// @dev This function can only be called after setting the allocation configuration
    /// @dev Does not allow changes in the total number of node operators per bin
    /// @dev Does not allow any node operator allocation percentage to be less than 1%
    function updateNodeOperatorWeightings(uint256 bin, uint16[] calldata nodeOperatorWeightings) external;
}

src/interfaces/IDepositContract.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

/// @title Deposit Contract Interface
/// @notice This interface exposes methods to perform validator deposits
interface IDepositContract {
    /// @notice Official deposit method to activate a validator on the consensus layer
    /// @param pubkey The 48 bytes long BLS Public key representing the validator
    /// @param withdrawalCredentials The 32 bytes long withdrawal credentials, configures the withdrawal recipient
    /// @param signature The 96 bytes long BLS Signature performed by the pubkey's private key
    /// @param depositDataRoot The root hash of the whole deposit data structure
    function deposit(
        bytes calldata pubkey,
        bytes calldata withdrawalCredentials,
        bytes calldata signature,
        bytes32 depositDataRoot
    )
        external
        payable;

    /// @notice Query the current deposit root hash.
    /// @return The deposit root hash.
    function get_deposit_root() external view returns (bytes32);
}

src/interfaces/IOrchestrator.sol

// SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

/// @title Orchestrator Interface
/// @author Alluvial Finance Inc.
/// @notice Interface for the Orchestrator contract
interface IOrchestrator {
    /// @notice Struct for mapping roles to an account
    /// @param account The account to map the roles to
    /// @param roles The roles to map to the account
    struct RoleMapping {
        address account;
        bytes32[] roles;
    }

    /// @notice Error thrown when a validator set is attempted to be transferred
    ///         to a non-transferrable address
    error NoTransferToRole();

    /// @notice Error thrown when functions which are not allowed in paused state are called
    error OrchestratorIsPaused();

    /// @notice Error thrown when functions which are not allowed in unpaused state are called
    error OrchestratorIsNotPaused();

    /// @notice Error thrown when a zero address is used
    error InvalidZeroAddress();

    /// @notice Raised when there is an attempt to revoke, renounce or grant DEFAULT_ADMIN_ROLE outside the
    ///         changeOwner function
    error InvalidOperation();

    /// @notice The system is now paused
    event Paused();

    /// @notice The system is now unpaused
    event Unpaused();

    /// @notice Event that is emitted when a user deposits ETH
    /// @param user The address of the user who deposited ETH
    /// @param amount The amount of ETH
    event ETHDeposited(address indexed user, uint256 amount);

    /// @notice Event that is emitted when a user with necessary role withdraws ETH
    /// @param sender The address of the user who withdrew ETH
    /// @param destination The address of the user withdrawn ETH was sent to
    /// @param amount The amount of ETH
    event ETHWithdrawn(address indexed sender, address indexed destination, uint256 amount);

    /// @notice Event that is emitted when the beneficiary address stored on the orchestrator is updated
    /// @param oldBeneficiary The address of the old beneficiary
    /// @param newBeneficiary The address of the new beneficiary
    event BeneficiaryUpdated(address indexed oldBeneficiary, address indexed newBeneficiary);

    /// @notice Event that is emitted when the config manager address stored on the orchestrator is updated
    /// @param oldConfigManager The address of the old config manager
    /// @param newConfigManager The address of the new config manager
    event ConfigManagerAddressUpdated(address indexed oldConfigManager, address indexed newConfigManager);

    /// @notice Event that is emitted when the TVS Beacon is updated
    /// @param newTVSBeacon The address of the new TVS Beacon
    event TVSBeaconUpdated(address indexed newTVSBeacon);

    /// @notice Event that is emitted when the orchestrator owner is changed
    /// @param oldOwner The address of the old owner
    /// @param newOwner The address of the new owner
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    /// @notice Event that is emitted when a user requests a withdrawal
    /// @param user The address of the user who requested the withdrawal
    /// @param amount The amount of ETH
    event ExitsRequested(address indexed user, uint256 amount);

    /// @notice Pauses the contract
    function pause() external;

    /// @notice Unpauses the contract
    function unpause() external;

    /// @notice A function which allows a user to deposit funds into the contract
    function deposit() external payable;

    // ------------------------ Withdraw/Exit functions ------------------------ //
    /// @notice Emits an event to signal that withdraw is requested
    /// @dev This function is introduced for triggering off-chain exits
    /// @param amount The amount to withdraw
    function requestExits(uint256 amount) external;

    /// @notice Function that allows a user to withdraw ETH from the contract
    /// @dev    This is introduced in the case where the beneficiary of the ETH is set as
    ///         the contract itself.
    /// @param amount The amount of ETH to withdraw
    /// @param destination The address to withdraw the ETH to
    function withdrawETH(uint256 amount, address destination) external;

    /// @notice Function that allows a user to sweep and transfer validator sets
    /// @param validatorSets The validator sets to sweep and transfer
    /// @param newBeneficiary The new beneficiary of the validator sets
    /// @param newOwner The new owner of the validator sets
    /// @param requestValidatorExists Whether the validator are exited or not
    function sweepAndTransferTVSs(
        address[] calldata validatorSets,
        address newBeneficiary,
        address newOwner,
        bool requestValidatorExists
    )
        external;

    /// @notice Function that transfers DEFAULT_ADMIN_ROLE of the Orchestrator contract to a new address
    /// @dev    This would only be callable by the DEFAULT_ADMIN_ROLE of the Orchestrator contract
    /// @param to The address to transfer the role to
    function changeOwner(address to) external;

    /// @notice Create validator sets
    /// @param count Number of validator sets to create
    function createValidatorSets(uint256 count) external returns (address[] memory);

    /// @notice Sets the beneficiary on the Orchestrator
    /// @param beneficiary The new beneficiary address
    function setBeneficiary(address beneficiary) external;

    /// @notice Sets the beneficiary on the Orchestrator and propagates the change to the TVSs
    /// @param beneficiary The new beneficiary address
    /// @param validatorSets The list of validator sets to set the beneficiary for
    /// @dev Acts as setBeneficiary and setBeneficiaryForTVSs in one function
    /// @dev Acts like setBeneficiary if validatorSets is empty
    function setBeneficiaryAndSyncToTVSs(address beneficiary, address[] calldata validatorSets) external;

    /// @notice Returns the beneficiary address
    /// @return The beneficiary address
    function getBeneficiary() external view returns (address);

    /// @notice Sets the config manager address on the Orchestrator
    /// @param configManagerAddress The new config manager address
    function setConfigManagerAddress(address configManagerAddress) external;

    /// @notice Returns the config manager address
    /// @return The config manager address
    function getConfigManagerAddress() external view returns (address);

    /// @notice Sets the TVS Beacon implementation
    /// @param tvsBeaconImplementation The new TVS Beacon implementation
    function setTVSBeaconImplementation(address tvsBeaconImplementation) external;

    /// @notice Returns the TVS Beacon
    /// @return The TVS Beacon
    function getTVSBeacon() external view returns (address);

    /// @notice Grants roles to an account
    /// @param account The account to grant the roles to
    /// @param roles The roles to grant to the account
    function grantRoles(address account, bytes32[] calldata roles) external;

    /// @notice Revokes roles from an account
    /// @param account The account to revoke the roles from
    /// @param roles The roles to revoke from the account
    function revokeRoles(address account, bytes32[] calldata roles) external;

    /// @notice Grants and revokes roles
    /// @param grantRoles Array of roles to be granted
    /// @param revokeRoles Array of roles to be revoked
    function grantAndRevokeRoles(RoleMapping[] calldata grantRoles, RoleMapping[] calldata revokeRoles) external;
}

src/libraries/LibBytes.sol

//SPDX-License-Identifier: Unlicense
pragma solidity 0.8.29;

/// @title Lib Bytes
/// @notice This library helps manipulating bytes
library LibBytes {
    /// @notice The length overflows an uint
    error SliceOverflow();

    /// @notice The slice is outside of the initial bytes bounds
    error SliceOutOfBounds();

    /// @notice Slices the provided bytes
    /// @param _bytes Bytes to slice
    /// @param _start The starting index of the slice
    /// @param _length The length of the slice
    /// @return The slice of _bytes starting at _start of length _length
    function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {
        unchecked {
            if (_length + 31 < _length) {
                revert SliceOverflow();
            }
        }
        if (_bytes.length < _start + _length) {
            revert SliceOutOfBounds();
        }

        bytes memory tempBytes;

        // solhint-disable-next-line no-inline-assembly
        assembly ("memory-safe") {
            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;
    }
}

src/libraries/LibUint.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

/// @title Lib Uint256
/// @notice Utilities to perform uint operations
library LibUint {
    /// @notice Converts a value to little endian (64 bits)
    /// @param _value The value to convert
    /// @return result The converted value
    function toLittleEndian64(uint64 _value) internal pure returns (uint256 result) {
        uint256 tempValue = _value;
        result = tempValue & 0xFF;
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        tempValue >>= 8;

        result = (result << 8) | (tempValue & 0xFF);
        result <<= (24 * 8);
    }
}

src/libraries/LibUnstructuredStorage.sol

// SPDX-License-Identifier: Proprietary

pragma solidity 0.8.29;

/// @title Lib Unstructured Storage
/// @notice Utilities to work with unstructured storage
library LibUnstructuredStorage {
    /// @notice Retrieve an uint256 value at a storage slot
    /// @param _position The storage slot to retrieve
    /// @return data The uint256 value
    function getStorageUint256(bytes32 _position) internal view returns (uint256 data) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            data := sload(_position)
        }
    }

    /// @notice Sets an uint256 value at a storage slot
    /// @param _position The storage slot to set
    /// @param _data The uint256 value to set
    function setStorageUint256(bytes32 _position, uint256 _data) internal {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(_position, _data)
        }
    }

    /// @notice Retrieve an address value at a storage slot
    /// @param _position The storage slot to retrieve
    /// @return data The address value
    function getStorageAddress(bytes32 _position) internal view returns (address data) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            data := sload(_position)
        }
    }

    /// @notice Sets an address value at a storage slot
    /// @param _position The storage slot to set
    /// @param _data The address value to set
    function setStorageAddress(bytes32 _position, address _data) internal {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(_position, _data)
        }
    }

    /// @notice Retrieve a bool value at a storage slot
    /// @param _position The storage slot to retrieve
    /// @return data The bool value
    function getStorageBool(bytes32 _position) internal view returns (bool data) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            data := sload(_position)
        }
    }

    /// @notice Sets a bool value at a storage slot
    /// @param _position The storage slot to set
    /// @param _data The bool value to set
    function setStorageBool(bytes32 _position, bool _data) internal {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(_position, _data)
        }
    }
}

src/state/orchestratorUpgradeable/BeneficiaryAddress.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

/// @title Beneficiary Address Storage
/// @notice Utility to manage the Beneficiary Address in storage
library BeneficiaryAddress {
    /// @notice Error thrown when the Beneficiary Address is set to the zero address
    error InvalidZeroAddress();

    /// @notice Storage slot of the Beneficiary Address
    bytes32 internal constant BENEFICIARY_ADDRESS_SLOT =
        bytes32(uint256(keccak256("orchestrator.state.beneficiaryAddress")) - 1);

    /// @notice Retrieve the Beneficiary Address
    /// @return The Beneficiary Address
    function get() internal view returns (address) {
        return LibUnstructuredStorage.getStorageAddress(BENEFICIARY_ADDRESS_SLOT);
    }

    /// @notice Sets the Beneficiary Address
    /// @param _newValue New Beneficiary Address
    function set(address _newValue) internal {
        if (_newValue == address(0)) {
            revert InvalidZeroAddress();
        }
        LibUnstructuredStorage.setStorageAddress(BENEFICIARY_ADDRESS_SLOT, _newValue);
    }
}

src/state/orchestratorUpgradeable/ConfigManagerAddress.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

/// @title Config Manager Address Storage
/// @notice Utility to manage the Config Manager Address in storage
library ConfigManagerAddress {
    /// @notice Error thrown when the Config Manager Address is set to the zero address
    error InvalidZeroAddress();

    /// @notice Storage slot of the Config Manager Address
    bytes32 internal constant CONFIG_MANAGER_ADDRESS_SLOT =
        bytes32(uint256(keccak256("orchestrator.state.configManagerAddress")) - 1);

    /// @notice Retrieve the Config Manager Address
    /// @return The Config Manager Address
    function get() internal view returns (address) {
        return LibUnstructuredStorage.getStorageAddress(CONFIG_MANAGER_ADDRESS_SLOT);
    }

    /// @notice Sets the Config Manager Address
    /// @param _newValue New Config Manager Address
    function set(address _newValue) internal {
        if (_newValue == address(0)) {
            revert InvalidZeroAddress();
        }
        LibUnstructuredStorage.setStorageAddress(CONFIG_MANAGER_ADDRESS_SLOT, _newValue);
    }
}

src/state/orchestratorUpgradeable/TVSBeaconAddress.sol

//SPDX-License-Identifier: Proprietary
pragma solidity 0.8.29;

import { LibUnstructuredStorage } from "src/libraries/LibUnstructuredStorage.sol";

/// @title TVS Beacon Address Storage
/// @author Alluvial Finance Inc.
/// @dev This beacon address is used for storing the upgradeable beacon address
/// @notice Utility to manage the Beacon Address in storage
library TVSBeaconAddress {
    /// @notice Error thrown when the TVS Beacon Address is set to the zero address
    error InvalidZeroAddress();

    /// @notice Storage slot of the Beacon Address
    bytes32 internal constant TVS_BEACON_ADDRESS_SLOT =
        bytes32(uint256(keccak256("orchestrator.state.tvsBeaconAddress")) - 1);

    /// @notice Retrieve the TVS Beacon Address
    /// @return The TVS Beacon Address
    function get() internal view returns (address) {
        return LibUnstructuredStorage.getStorageAddress(TVS_BEACON_ADDRESS_SLOT);
    }

    /// @notice Sets the TVS Beacon Address
    /// @param _newValue New TVS Beacon Address
    function set(address _newValue) internal {
        if (_newValue == address(0)) {
            revert InvalidZeroAddress();
        }
        LibUnstructuredStorage.setStorageAddress(TVS_BEACON_ADDRESS_SLOT, _newValue);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solady/=lib/tvs/lib/solady/src/",
    "tvs/=lib/tvs/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.