Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script for deploying and verifying yneigen #158

Merged
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ac9bca5
added folders
MrDeadCe11 Aug 23, 2024
162d1f9
base deployer, setting up bash script
MrDeadCe11 Aug 23, 2024
da6df02
getting the bash script to start working
MrDeadCe11 Aug 23, 2024
3b036f0
script is setup and base deployer is tested
MrDeadCe11 Aug 23, 2024
3dda0ac
missing files
MrDeadCe11 Aug 23, 2024
1a69d68
script for deploying and verifying yneigen
dan13ram Aug 24, 2024
1a59226
script for deploying and verifying yneigen
dan13ram Aug 24, 2024
22433c7
foundry.toml fix
MrDeadCe11 Aug 24, 2024
22ca977
Merge branch 'feat/YnEigenScript' of https://github.com/raid-guild/yi…
MrDeadCe11 Aug 24, 2024
13b6e54
added cast wallet deployment
MrDeadCe11 Aug 24, 2024
99bf480
missing files
MrDeadCe11 Aug 24, 2024
aa836c0
missing files
MrDeadCe11 Aug 24, 2024
0cd27cb
finished bash script
MrDeadCe11 Aug 24, 2024
a7b2eef
Merge branch 'feat/YnEigen-Deployer' into feat/YnEigenScript
MrDeadCe11 Aug 24, 2024
54cd443
Merge pull request #1 from raid-guild/feat/YnEigenScript
MrDeadCe11 Aug 24, 2024
f6c3bcb
update env sample
MrDeadCe11 Aug 24, 2024
41305a4
Merge branch 'feat/YnEigen-Deployer' of https://github.com/raid-guild…
MrDeadCe11 Aug 24, 2024
89a9d0f
removed private key from the deployment script to use cast wallet
MrDeadCe11 Aug 24, 2024
902f423
added folders
MrDeadCe11 Aug 23, 2024
9057e58
base deployer, setting up bash script
MrDeadCe11 Aug 23, 2024
b21f09d
getting the bash script to start working
MrDeadCe11 Aug 23, 2024
f43667a
script is setup and base deployer is tested
MrDeadCe11 Aug 23, 2024
0241b3f
missing files
MrDeadCe11 Aug 23, 2024
89a3755
foundry.toml fix
MrDeadCe11 Aug 24, 2024
46efb0c
update env sample
MrDeadCe11 Aug 24, 2024
737b3f4
script for deploying and verifying yneigen
dan13ram Aug 24, 2024
4374aa2
added cast wallet deployment
MrDeadCe11 Aug 24, 2024
1632605
missing files
MrDeadCe11 Aug 24, 2024
25f9e96
missing files
MrDeadCe11 Aug 24, 2024
2e225d7
finished bash script
MrDeadCe11 Aug 24, 2024
d8443df
removed private key from the deployment script to use cast wallet
MrDeadCe11 Aug 24, 2024
50c153a
fixed old forge scripts + updated ynEigen make script to not require …
dan13ram Aug 25, 2024
833a55a
updated make script to also broadcast and verify
MrDeadCe11 Aug 26, 2024
d240a94
Merge branch 'feat/YnEigen-Deployer' of https://github.com/raid-guild…
MrDeadCe11 Aug 26, 2024
3ee0768
updated make script to also broadcast and verify
MrDeadCe11 Aug 26, 2024
537ac36
added verify only script to make file
MrDeadCe11 Aug 27, 2024
08134a0
added verify to bash script
MrDeadCe11 Aug 27, 2024
05b5814
rebaned original YnLSDe-17000 to YnLSDe-17000-original.json
MrDeadCe11 Aug 27, 2024
eea4473
fixed bash cases
MrDeadCe11 Aug 27, 2024
8fceacd
working factory but over the size limit
dan13ram Aug 25, 2024
8415a75
refactored scripts
dan13ram Aug 25, 2024
41139e5
refactor ynEigenViewer to support initialization
dan13ram Aug 25, 2024
b6cd0a4
minor fix for ynEigenViewer
dan13ram Aug 25, 2024
bc3da91
read account name from .env
dan13ram Aug 27, 2024
c2dd3fb
Merge pull request #2 from raid-guild/feat/ynEigen-Factory
dan13ram Aug 27, 2024
72b0da4
fixed make file
dan13ram Aug 27, 2024
334c850
Revert "refactor ynEigenViewer to support initialization"
dan13ram Aug 27, 2024
498985f
use generic rpc_url, remove unwanted files
dan13ram Aug 27, 2024
c08e7a4
revert ContractAddresses.sol
dan13ram Aug 27, 2024
6af03e4
fixed assets in inputJson for ynLSDe
MrDeadCe11 Aug 27, 2024
c86dc0c
moved YNEigenStructs and YnEigenFactory to the script/YnEigen folder …
MrDeadCe11 Aug 27, 2024
55aa1d9
added missing files
MrDeadCe11 Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ STAKING_ADMIN_ADDRESS=
STAKING_NODES_ADMIN_ADDRESS=
VALIDATOR_MANAGER_ADDRESS=
REWARDS_DISTRIBUTOR_ADDRESS=
PROXY_OWNER
PROXY_OWNER=

# for use with cast wallet. store the deployer private key in the keystore and put the public address here.
DEPLOYER_ADDRESS=
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@ deploy-protocol :; forge script script/DeployYieldNest.s.sol:DeployYieldNest --
# Verify

verify-roles :; forge script script/Verify.s.sol --rpc-url ${rpc}

# to set up cast wallet run: cast wallet import yieldnestDeployerKey --interactive
# then import the private key with which you wish to deploy, create a password and add the public address of that key to the .env under DEPLOYER_ADDRESS.

# make ynEigen path=script/ynEigen/input/lsd-mainnet.json rpc=https://mainnet.infura.io/v3/your-key deployer=0xYourPublicAddressThatCorrespondsToYourSavedPrivateKeyInyieldnestDeployerKey api=etherscanApiKey
dan13ram marked this conversation as resolved.
Show resolved Hide resolved
deployerAccountName ?= yieldnestDeployerKey
ynEigen :; forge script script/ynEigen/YnEigenScript.s.sol:YnEigenScript --rpc-url ${rpc} --sig "run(string)" ${path} --account ${deployerAccountName} --sender ${deployer} --broadcast --etherscan-api-key ${api} --verify

# make ynEigen-verify path=script/ynEigen/input/lsd-mainnet.json rpc=https://mainnet.infura.io/v3/your-key
ynEigen-verify :; forge script script/ynEigen/YnEigenScript.s.sol:YnEigenScript --rpc-url ${rpc} --sig "verify(string)" ${path} --broadcast

# alternative bash script with less inputs
# make ynEigen-bash path=script/ynEigen/input/lsd-mainnet.json
ynEigen-bash :; ./script/ynEigen/bash/deployYnEigen.sh ${path}
File renamed without changes.
37 changes: 37 additions & 0 deletions deployments/ynLSDe-17000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
dan13ram marked this conversation as resolved.
Show resolved Hide resolved
"ADMIN": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"DEFAULT_SIGNER": "0x09D5Bd4a4f1dA1A965fE24EA54bce3d37661E056",
"EIGEN_STRATEGY_ADMIN": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"PAUSE_ADMIN": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"PROXY_ADMIN_OWNER": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"STAKING_ADMIN": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"STAKING_NODES_OPERATOR": "0x9Dd8F69b62ddFd990241530F47dcEd0Dad7f7d39",
"STRATEGY_CONTROLLER": "0x1234567890123456789012345678901234567890",
"TOKEN_STAKING_NODE_CREATOR": "0x9Dd8F69b62ddFd990241530F47dcEd0Dad7f7d39",
"UNPAUSE_ADMIN": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"YNDev": "0x9Dd8F69b62ddFd990241530F47dcEd0Dad7f7d39",
"YnSecurityCouncil": "0x743b91CDB1C694D4F51bCDA3a4A59DcC0d02b913",
"implementation-assetRegistry": "0x8cDdf7438129b804D885783A7aCB60fC5F28f2be",
"implementation-eigenStrategyManager": "0x619ce9BF204A59ccDA269bD90A0994B89996BBb1",
"implementation-rateProvider": "0xab632238a54826214E59eDBA5c94e626905cA9A1",
"implementation-tokenStakingNodesManager": "0x7D0B79d84A984702Aa2DFb77D3D80d948Ec7d791",
"implementation-ynEigenDepositAdapter": "0x982EFC86035e838de7967De1b1A8f72097d84733",
"implementation-ynEigenViewer": "0xDeec1A7992709789909193E9BD77C338f1647768",
"implementation-ynLSDe": "0xb2beB68518eB9aE27E2a32871b3308A2C5ae365d",
"proxy-assetRegistry": "0xBaa16BAd02Ad7Aacb710BE8e0aA815578955fCfc",
"proxy-eigenStrategyManager": "0x8c329218deE2f9D0e20AfEEE63fD6E8086B37B4a",
"proxy-rateProvider": "0x758BCc6fFc9BF1A11059102A829c533297A0CFB5",
"proxy-tokenStakingNodesManager": "0x0e95dFa4E0F55c19836863cF409381edf08EA821",
"proxy-ynEigenDepositAdapter": "0xA32b0d22cf72556D9caa1397E3c1096bFBb9CdCe",
"proxy-ynEigenViewer": "0x1d598591374D314AfFB2aed1370D8c81CbbA261F",
"proxy-ynLSDe": "0x28805623a91a3b0815AB606F1e12A1F8381Cb2f2",
"proxyAdmin-assetRegistry": "0x26c823ef39CDdb4150aF6E6fD138ce6C8D5608B6",
"proxyAdmin-eigenStrategyManager": "0x0880CD2745D0FE53b288B3317D9c5D44b29D56da",
"proxyAdmin-rateProvider": "0x982Ae0A525d19f7CAB4c1C8A5fFAFefb51E3eC8f",
"proxyAdmin-tokenStakingNodesManager": "0x75C578444C83ca38E1cEEec2176298eB1eBFBf0D",
"proxyAdmin-ynEigenDepositAdapter": "0x81Fb8AD8d5096A5Ec695225FD21cED72A295487f",
"proxyAdmin-ynEigenViewer": "0x5247B86B5261A2aa57b0E68d255bA072B8238B93",
"proxyAdmin-ynLSDe": "0xbE0DfF04313B1AcA78bfA60c53656A79fC5cb1cB",
"tokenStakingNodeImplementation": "0xa71C5e4A5468C782B952C09C9E7Fa70A1caaA113",
"upgradeTimelock": "0x4b0545EAD66B54577560378649856D509FAa41d2"
}
10 changes: 7 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ src = 'src'
out = 'out'
libs = ['lib']
test = 'test'
cache_path = 'cache'
cache_path = 'cache'

fs_permissions = [{ access = "read-write", path = "./deployments"}, { access = "read", path = "./"}]
fs_permissions = [
{ access = "read-write", path = "./deployments" },
{ access = "read", path = "./" },
]

optimizer = true
optimizer-runs = 200
evm_version = "cancun"
solc_version = "0.8.24"
prompt_timeout = 120

ignored_error_codes = [5159,2018,5574,3860]
ignored_error_codes = [5159, 2018, 5574, 3860]
14 changes: 13 additions & 1 deletion script/BaseScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import {ynETH} from "src/ynETH.sol";
import {Script} from "lib/forge-std/src/Script.sol";
import {Utils} from "script/Utils.sol";
import {ActorAddresses} from "script/Actors.sol";
import {ContractAddresses} from "script/ContractAddresses.sol";
import {console} from "lib/forge-std/src/console.sol";

abstract contract BaseScript is Script, Utils {
using stdJson for string;

ActorAddresses private _actorAddresses = new ActorAddresses();
ContractAddresses private _contractAddresses = new ContractAddresses();

function serializeActors(string memory json) public {
ActorAddresses.Actors memory actors = getActors();
vm.serializeAddress(json, "DEFAULT_SIGNER", address(actors.eoa.DEFAULT_SIGNER));
Expand Down Expand Up @@ -42,6 +46,14 @@ abstract contract BaseScript is Script, Utils {
}

function getActors() public returns (ActorAddresses.Actors memory actors) {
return (new ActorAddresses()).getActors(block.chainid);
return _actorAddresses.getActors(block.chainid);
}

function getChainAddresses() public returns (ContractAddresses.ChainAddresses memory chainAddresses) {
return _contractAddresses.getChainAddresses(block.chainid);
}

function isSupportedChainId(uint256 chainId) public returns (bool) {
return _contractAddresses.isSupportedChainId(chainId);
}
}
91 changes: 73 additions & 18 deletions script/BaseYnEigenScript.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: BSD 3-Clause License
dan13ram marked this conversation as resolved.
Show resolved Hide resolved
pragma solidity ^0.8.24;

import {stdJson} from "lib/forge-std/src/StdJson.sol";
import {ynEigen} from "src/ynEIGEN/ynEigen.sol";
import {AssetRegistry} from "src/ynEIGEN/AssetRegistry.sol";
Expand All @@ -10,18 +11,16 @@ import {ynEigenDepositAdapter} from "src/ynEIGEN/ynEigenDepositAdapter.sol";
import {IRateProvider} from "src/interfaces/IRateProvider.sol";
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";


import {Script} from "lib/forge-std/src/Script.sol";
import {Utils} from "script/Utils.sol";
import {ActorAddresses} from "script/Actors.sol";
import {ContractAddresses} from "script/ContractAddresses.sol";
import {BaseScript} from "script/BaseScript.s.sol";
import {ynEigenViewer} from "src/ynEIGEN/ynEigenViewer.sol";

import {console} from "lib/forge-std/src/console.sol";

abstract contract BaseYnEigenScript is BaseScript {
contract BaseYnEigenScript is BaseScript {
using stdJson for string;

struct Deployment {
ynEigen ynEigen;
AssetRegistry assetRegistry;
Expand All @@ -34,9 +33,65 @@ abstract contract BaseYnEigenScript is BaseScript {
ynEigenViewer viewer;
}

function tokenName() internal virtual pure returns (string memory);
struct Asset {
string name;
address strategy;
address token;
}

struct Input {
Asset[] assets;
uint256 chainId;
string name;
string symbol;
}

error IncorrectChainId(uint256 specifiedChainId, uint256 actualChainId);
error UnsupportedChainId(uint256 chainId);
error UnsupportedAsset(string asset, uint256 chainId);

Input public inputs;
ActorAddresses.Actors public actors;
ContractAddresses.ChainAddresses public chainAddresses;

address internal _deployer;

constructor() {
actors = getActors();
chainAddresses = getChainAddresses();
}

function _initDeployer() internal {
_deployer = msg.sender; // set by --sender when running the script
}

function _loadJson(string memory _path) internal {
string memory path = string(abi.encodePacked(vm.projectRoot(), "/", _path));
string memory json = vm.readFile(path);
bytes memory data = vm.parseJson(json);

function getDeploymentFile() internal virtual view returns (string memory) {
Input memory _inputs = abi.decode(data, (Input));

this.loadInputs(_inputs);
}

/**
* @dev this function is required to load the JSON input struct into storage untill that feature is added to foundry
*/
function loadInputs(Input calldata _inputs) external {
inputs = _inputs;
}

function _validateNetwork() internal virtual {
if (block.chainid != inputs.chainId) revert IncorrectChainId(inputs.chainId, block.chainid);
if (!isSupportedChainId(inputs.chainId)) revert UnsupportedChainId(inputs.chainId);
}

function tokenName() internal view returns (string memory) {
return inputs.symbol;
}

function getDeploymentFile() internal view virtual returns (string memory) {
string memory root = vm.projectRoot();

return string.concat(root, "/deployments/", tokenName(), "-", vm.toString(block.chainid), ".json");
Expand All @@ -46,7 +101,7 @@ abstract contract BaseYnEigenScript is BaseScript {
string memory json = "deployment";

// contract addresses
serializeProxyElements(json, tokenName(), address(deployment.ynEigen));
serializeProxyElements(json, tokenName(), address(deployment.ynEigen));
serializeProxyElements(json, "assetRegistry", address(deployment.assetRegistry));
serializeProxyElements(json, "eigenStrategyManager", address(deployment.eigenStrategyManager));
serializeProxyElements(json, "tokenStakingNodesManager", address(deployment.tokenStakingNodesManager));
Expand All @@ -56,8 +111,6 @@ abstract contract BaseYnEigenScript is BaseScript {
serializeProxyElements(json, "ynEigenViewer", address(deployment.viewer));
vm.serializeAddress(json, "upgradeTimelock", address(deployment.upgradeTimelock));


ActorAddresses.Actors memory actors = getActors();
// actors
vm.serializeAddress(json, "PROXY_ADMIN_OWNER", address(actors.admin.PROXY_ADMIN_OWNER));
vm.serializeAddress(json, "ADMIN", address(actors.admin.ADMIN));
Expand All @@ -71,7 +124,7 @@ abstract contract BaseYnEigenScript is BaseScript {
vm.serializeAddress(json, "YnSecurityCouncil", address(actors.wallets.YNSecurityCouncil));
vm.serializeAddress(json, "YNDev", address(actors.wallets.YNDev));
string memory finalJson = vm.serializeAddress(json, "DEFAULT_SIGNER", address((actors.eoa.DEFAULT_SIGNER)));

vm.writeJson(finalJson, getDeploymentFile());

console.log("Deployment JSON file written successfully:", getDeploymentFile());
Expand All @@ -81,12 +134,16 @@ abstract contract BaseYnEigenScript is BaseScript {
string memory deploymentFile = getDeploymentFile();
string memory jsonContent = vm.readFile(deploymentFile);
Deployment memory deployment;
deployment.ynEigen = ynEigen(payable(jsonContent.readAddress(string.concat(".proxy-", tokenName()))));
deployment.tokenStakingNodesManager = TokenStakingNodesManager(payable(jsonContent.readAddress(".proxy-tokenStakingNodesManager")));
deployment.ynEigen = ynEigen(payable(jsonContent.readAddress(string.concat(".proxy-", tokenName()))));
deployment.tokenStakingNodesManager =
TokenStakingNodesManager(payable(jsonContent.readAddress(".proxy-tokenStakingNodesManager")));
deployment.assetRegistry = AssetRegistry(payable(jsonContent.readAddress(".proxy-assetRegistry")));
deployment.eigenStrategyManager = EigenStrategyManager(payable(jsonContent.readAddress(".proxy-eigenStrategyManager")));
deployment.tokenStakingNodeImplementation = TokenStakingNode(payable(jsonContent.readAddress(".tokenStakingNodeImplementation")));
deployment.ynEigenDepositAdapterInstance = ynEigenDepositAdapter(payable(jsonContent.readAddress(".proxy-ynEigenDepositAdapter")));
deployment.eigenStrategyManager =
EigenStrategyManager(payable(jsonContent.readAddress(".proxy-eigenStrategyManager")));
deployment.tokenStakingNodeImplementation =
TokenStakingNode(payable(jsonContent.readAddress(".tokenStakingNodeImplementation")));
deployment.ynEigenDepositAdapterInstance =
ynEigenDepositAdapter(payable(jsonContent.readAddress(".proxy-ynEigenDepositAdapter")));
deployment.rateProvider = IRateProvider(payable(jsonContent.readAddress(".proxy-rateProvider")));
deployment.viewer = ynEigenViewer(payable(jsonContent.readAddress(".proxy-ynEigenViewer")));
deployment.upgradeTimelock = TimelockController(payable(jsonContent.readAddress(".upgradeTimelock")));
Expand All @@ -100,6 +157,4 @@ abstract contract BaseYnEigenScript is BaseScript {
string memory proxyKey = string.concat(".proxy-", contractName);
return jsonContent.readAddress(proxyKey);
}

}

Loading