|
| 1 | +// SPDX-License-Identifier: UNLICENSED |
| 2 | +pragma solidity ^0.8.27; |
| 3 | + |
| 4 | +// EigenLayer imports |
| 5 | +import { |
| 6 | + IAllocationManagerTypes |
| 7 | +} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; |
| 8 | +import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; |
| 9 | +import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; |
| 10 | + |
| 11 | +// Testing imports |
| 12 | +import {Script} from "forge-std/Script.sol"; |
| 13 | +import {console} from "forge-std/console.sol"; |
| 14 | +import {Logging} from "../utils/Logging.sol"; |
| 15 | +import {ELScriptStorage} from "../utils/ELScriptStorage.s.sol"; |
| 16 | +import {DHScriptStorage} from "../utils/DHScriptStorage.s.sol"; |
| 17 | +import {Accounts} from "../utils/Accounts.sol"; |
| 18 | + |
| 19 | +/** |
| 20 | + * @title AllocateOperatorStake |
| 21 | + * @notice Allocates full magnitude to the validator operator set. |
| 22 | + * Must be run AFTER SignUpValidator (needs at least 1 block gap |
| 23 | + * for the allocation delay to initialize). |
| 24 | + */ |
| 25 | +contract AllocateOperatorStake is Script, ELScriptStorage, DHScriptStorage, Accounts { |
| 26 | + function run() public { |
| 27 | + string memory network = vm.envOr("NETWORK", string("anvil")); |
| 28 | + Logging.logHeader("ALLOCATE OPERATOR STAKE"); |
| 29 | + console.log("| Network: %s", network); |
| 30 | + Logging.logFooter(); |
| 31 | + |
| 32 | + _loadELContracts(network); |
| 33 | + _loadDHContracts(network); |
| 34 | + |
| 35 | + IStrategy[] memory strategies = new IStrategy[](deployedStrategies.length); |
| 36 | + for (uint256 i = 0; i < deployedStrategies.length; i++) { |
| 37 | + strategies[i] = IStrategy(address(deployedStrategies[i].strategy)); |
| 38 | + } |
| 39 | + |
| 40 | + uint64[] memory newMagnitudes = new uint64[](strategies.length); |
| 41 | + for (uint256 i = 0; i < strategies.length; i++) { |
| 42 | + newMagnitudes[i] = 1e18; |
| 43 | + } |
| 44 | + |
| 45 | + IAllocationManagerTypes.AllocateParams[] memory allocParams = |
| 46 | + new IAllocationManagerTypes.AllocateParams[](1); |
| 47 | + allocParams[0] = IAllocationManagerTypes.AllocateParams({ |
| 48 | + operatorSet: OperatorSet({ |
| 49 | + avs: address(serviceManager), id: serviceManager.VALIDATORS_SET_ID() |
| 50 | + }), |
| 51 | + strategies: strategies, |
| 52 | + newMagnitudes: newMagnitudes |
| 53 | + }); |
| 54 | + |
| 55 | + vm.broadcast(_operatorPrivateKey); |
| 56 | + allocationManager.modifyAllocations(_operator, allocParams); |
| 57 | + Logging.logStep( |
| 58 | + string.concat("Allocated full magnitude for operator: ", vm.toString(_operator)) |
| 59 | + ); |
| 60 | + } |
| 61 | +} |
0 commit comments