Skip to content

Commit

Permalink
feat: deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Dec 3, 2024
1 parent 4f88989 commit 4e82d28
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions script/ynEigen/DeployWithdrawalsProcessor.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// SPDX-License-Identifier: BSD 3-Clause License
pragma solidity ^0.8.24;

import {TransparentUpgradeableProxy} from
"lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

import {IAssetRegistry} from "src/interfaces/IAssetRegistry.sol";
import {ITokenStakingNode} from "src/interfaces/ITokenStakingNode.sol";
import {ITokenStakingNodesManager} from "src/interfaces/ITokenStakingNodesManager.sol";

import {EigenStrategyManager} from "src/ynEIGEN/EigenStrategyManager.sol";
import {WithdrawalsProcessor} from "src/ynEIGEN/WithdrawalsProcessor.sol";

import {YnEigenDeployer} from "./YnEigenDeployer.s.sol";

// ---- Usage ----

// deploy:
// forge script script/DeployWithdrawalsProcessor.s.sol:DeployWithdrawalsProcessor --verify --slow --legacy --etherscan-api-key $KEY --rpc-url $RPC_URL --broadcast

contract DeployWithdrawalsProcessor is YnEigenDeployer {

address owner;
address keeper;

function run() public {
uint256 _pk = vm.envUint("DEPLOYER_PRIVATE_KEY");

require(!_isOngoingWithdrawals(), "!isOngoingWithdrawals");

vm.startBroadcast(_pk);

// set owner and keeper
{
owner = actors.wallets.YNSecurityCouncil;
keeper = actors.wallets.YNnWithdrawalsYnEigen;
}

// deploy withdrawalsProcessor
{
WithdrawalsProcessor withdrawalsProcessor = new WithdrawalsProcessor(
chainAddresses.ynEigen.WITHDRAWAL_QUEUE_MANAGER_ADDRESS, // address(withdrawalQueueManager)
chainAddresses.ynEigen.TOKEN_STAKING_NODES_MANAGER_ADDRESS, // address(tokenStakingNodesManager)
chainAddresses.ynEigen.ASSET_REGISTRY_ADDRESS, // address(assetRegistry)
chainAddresses.ynEigen.EIGEN_STRATEGY_MANAGER_ADDRESS, // address(eigenStrategyManager)
chainAddresses.eigenlayer.DELEGATION_MANAGER_ADDRESS, // address(delegationManager)
chainAddresses.ynEigen.YNEIGEN_ADDRESS, // address(yneigen)
chainAddresses.ynEigen.REDEMPTION_ASSETS_VAULT_ADDRESS, // address(redemptionAssetsVault)
chainAddresses.ynEigen.WRAPPER // address(wrapper)
);

withdrawalsProcessor = WithdrawalsProcessor(
address(
new TransparentUpgradeableProxy(
address(withdrawalsProcessor), chainAddresses.ynEigen.TIMELOCK_CONTROLLER_ADDRESS, ""
)
)
);

WithdrawalsProcessor(address(withdrawalsProcessor)).initialize(owner, keeper);
}

// @todo - queue manually?
// // grant roles to withdrawalsProcessor
// {
// vm.startPrank(actors.wallets.YNSecurityCouncil);
// eigenStrategyManager.grantRole(
// eigenStrategyManager.STAKING_NODES_WITHDRAWER_ROLE(), address(withdrawalsProcessor)
// );
// eigenStrategyManager.grantRole(
// eigenStrategyManager.WITHDRAWAL_MANAGER_ROLE(), address(withdrawalsProcessor)
// );
// withdrawalQueueManager.grantRole(
// withdrawalQueueManager.REQUEST_FINALIZER_ROLE(), address(withdrawalsProcessor)
// );
// vm.stopPrank();
// }
}

function _isOngoingWithdrawals() private returns (bool) {
IERC20[] memory _assets = IAssetRegistry(chainAddresses.ynEigen.ASSET_REGISTRY_ADDRESS).getAssets();
ITokenStakingNode[] memory _nodes =
ITokenStakingNodesManager(chainAddresses.ynEigen.TOKEN_STAKING_NODES_MANAGER_ADDRESS).getAllNodes();
for (uint256 i = 0; i < _assets.length; ++i) {
for (uint256 j = 0; j < _nodes.length; ++j) {
if (
_nodes[j].queuedShares(
EigenStrategyManager(chainAddresses.ynEigen.EIGEN_STRATEGY_MANAGER_ADDRESS).strategies(
_assets[i]
)
) > 0
) return true;
}
}
return false;
}

}

0 comments on commit 4e82d28

Please sign in to comment.