Skip to content

Commit 8498171

Browse files
committed
deploy script for safe
1 parent 7144bf2 commit 8498171

6 files changed

+154
-7
lines changed

deploy/1_deploy_fee_recipient_implementation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const func: DeployFunction = async function ({
1616
};
1717

1818
func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment): Promise<boolean> {
19-
const shouldSkip = (await isDeployed("FeeRecipient", deployments)) || network.name.endsWith("_consensys");
19+
const shouldSkip = (await isDeployed("FeeRecipient", deployments)) || network.name.endsWith("_consensys") || network.name.endsWith("_safe");
2020
if (shouldSkip) {
2121
console.log("Skipped");
2222
}

deploy/2_deploy_staking_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment)
179179
const shouldSkip =
180180
((await isDeployed("ConsensusLayerFeeDispatcher_Proxy", deployments)) &&
181181
(await isDeployed("ExecutionLayerFeeDispatcher_Proxy", deployments)) &&
182-
(await isDeployed("StakingContract_Proxy", deployments))) || network.name.endsWith("_consensys");
182+
(await isDeployed("StakingContract_Proxy", deployments))) || network.name.endsWith("_consensys") || network.name.endsWith("_safe");
183183
if (shouldSkip) {
184184
console.log("Skipped");
185185
}

deploy/3_deploy_mainnet_vault_staking_contract_fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const func: DeployFunction = async function ({
1818
};
1919

2020
func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment): Promise<boolean> {
21-
const shouldSkip = await isDeployed("StakingContract_1.1_Implementation", deployments) || network.name !== "mainnet_vault" || network.name.endsWith("_consensys")
21+
const shouldSkip = await isDeployed("StakingContract_1.1_Implementation", deployments) || network.name !== "mainnet_vault" || network.name.endsWith("_consensys") || network.name.endsWith("_safe")
2222
if (shouldSkip) {
2323
console.log("Skipped");
2424
}

deploy/4_deploy_exit_and_withdrawals_contract_fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const func: DeployFunction = async function ({
2424
};
2525

2626
func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment): Promise<boolean> {
27-
const shouldSkip = (await isDeployed("StakingContract_1.2_Implementation", deployments) && await isDeployed("ConsensusLayerFeeDispatcher_1.2_Implementation", deployments)) || network.name.endsWith("_consensys");
27+
const shouldSkip = (await isDeployed("StakingContract_1.2_Implementation", deployments) && await isDeployed("ConsensusLayerFeeDispatcher_1.2_Implementation", deployments)) || network.name.endsWith("_consensys") || network.name.endsWith("_safe");
2828
if (shouldSkip) {
2929
console.log("Skipped");
3030
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { getContractAddress } from "ethers/lib/utils";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
4+
import { isDeployed } from "../ts_utils/index";
5+
6+
const getMaxFeeBps = (network: string): number => {
7+
switch (network) {
8+
case "holesky_dev_safe":
9+
return 1000;
10+
case "mainnet_safe":
11+
return 1000; //10% max user fee
12+
13+
default:
14+
return 1000;
15+
}
16+
};
17+
18+
const getMaxOperatorFeeBps = (network: string): number => {
19+
switch (network) {
20+
case "holesky_dev_safe":
21+
return 10000;
22+
case "mainnet_safe":
23+
return 10000; // Leave the possibility of doing the split onchain in the future
24+
25+
default:
26+
return 0;
27+
}
28+
};
29+
30+
const getFeeBps = (network: string): number => {
31+
switch (network) {
32+
case "holesky_dev_safe":
33+
return 600;
34+
case "mainnet_safe":
35+
return 600; //6% end-user fee
36+
37+
default:
38+
return 600;
39+
}
40+
};
41+
42+
const getOperatorFeeBps = (network: string): number => {
43+
switch (network) {
44+
case "holesky_dev_safe":
45+
return 0;
46+
case "mainnet_safe":
47+
return 0; // at the start all the fees go to the treasury
48+
49+
default:
50+
return 0;
51+
}
52+
};
53+
54+
const func: DeployFunction = async function ({
55+
deployments,
56+
getNamedAccounts,
57+
ethers,
58+
network,
59+
}: HardhatRuntimeEnvironment) {
60+
const { deployer, admin, depositContract, treasury } = await getNamedAccounts();
61+
62+
//1. Deploy Minimal Recipient
63+
const feeRecipientDeployment = await deployments.deploy("FeeRecipient", {
64+
from: deployer,
65+
log: true
66+
});
67+
68+
//2. Compute future staking contract address
69+
const signer = await ethers.getSigner(deployer);
70+
const txCount = await signer.getTransactionCount();
71+
const futureStakingContractAddress = getContractAddress({
72+
from: deployer,
73+
nonce: txCount + 4, // staking contract proxy is in 5 txs
74+
});
75+
76+
//3. Deploy ConsensusLayerFeeDispatcher without proxy
77+
const clfdDeployment = (await deployments.deploy("ConsensusLayerFeeDispatcher", {
78+
from: deployer,
79+
log: true,
80+
args: [0],
81+
}));
82+
83+
84+
const clf = await ethers.getContractAt("ConsensusLayerFeeDispatcher", clfdDeployment.address);
85+
await (await clf.initCLD(futureStakingContractAddress)).wait();
86+
87+
//4. Deploy ExecutionLayerFeeDispatcher without proxy
88+
const elfdDeployment = await deployments.deploy("ExecutionLayerFeeDispatcher", {
89+
from: deployer,
90+
log: true,
91+
args: [0],
92+
});
93+
94+
const elf = await ethers.getContractAt("ExecutionLayerFeeDispatcher", elfdDeployment.address);
95+
await (await elf.initELD(futureStakingContractAddress)).wait();
96+
97+
98+
//5. Deploy StakingContract without proxy
99+
const stakingContractDeployment = await deployments.deploy("StakingContract", {
100+
from: deployer,
101+
log: true,
102+
});
103+
104+
const stakingContract = await ethers.getContractAt("StakingContract", stakingContractDeployment.address);
105+
106+
const initStaking_1 = await stakingContract.initialize_1(
107+
admin,
108+
treasury,
109+
depositContract,
110+
elfdDeployment.address,
111+
clfdDeployment.address,
112+
feeRecipientDeployment.address,
113+
getFeeBps(network.name),
114+
getOperatorFeeBps(network.name),
115+
getMaxFeeBps(network.name),
116+
getMaxOperatorFeeBps(network.name),
117+
);
118+
await initStaking_1.wait();
119+
120+
if (stakingContractDeployment.address.toLowerCase() !== futureStakingContractAddress.toLowerCase()) {
121+
throw new Error("Invalid future deployment address for staking contract");
122+
}
123+
};
124+
125+
func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment): Promise<boolean> {
126+
const shouldSkip = network.name !== "holesky_dev_safe" && network.name !== "mainnet_safe";
127+
if (shouldSkip) {
128+
console.log("Skipped");
129+
}
130+
return shouldSkip;
131+
};
132+
133+
export default func;

hardhat.config.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ const hhuc: HardhatUserConfig = {
2020
sources: "./src/contracts",
2121
},
2222
networks: {
23+
mainnet_safe: {
24+
url: process.env.RPC_URL || "",
25+
accounts: [process.env.PK || ""],
26+
},
27+
holesky_dev_safe: {
28+
url: process.env.RPC_URL || "",
29+
accounts: [process.env.PK || ""],
30+
},
2331
goerli_consensys: {
2432
url: process.env.RPC_URL || "",
2533
accounts: [process.env.PK || ""],
@@ -124,8 +132,10 @@ const hhuc: HardhatUserConfig = {
124132
mainnet_enzyme: "0x45DAD754897ef0b2780349AD7c7000c72717b24E",
125133
mainnet_komainu: "0xCf53Ef5be9C713585D2fEF40e72D9c7C4fE1D5F2",
126134
mainnet_consensys: "0x5Bc5ec5130f66f13d5C21ac6811A7e624ED3C7c6",
135+
mainnet_safe: "0x60CFAC5cD4aEed165023A81F57A0bc92D7CfEb6E",
127136
holesky_devnet: "0xb3eb29AC481FCFAFA7008A4acf04737c7d6733EA",
128-
holesky_testnet: "0xe6fe1936Fa8120e57c7Dee1733693B59b392672c"
137+
holesky_testnet: "0xe6fe1936Fa8120e57c7Dee1733693B59b392672c",
138+
holesky_dev_safe: "0xdA53Ce2F763A3270638127CEA2826e32Cd3428e5",
129139
},
130140
depositContract: {
131141
default: 4,
@@ -142,8 +152,10 @@ const hhuc: HardhatUserConfig = {
142152
mainnet_enzyme: "0x00000000219ab540356cBB839Cbe05303d7705Fa",
143153
mainnet_komainu: "0x00000000219ab540356cBB839Cbe05303d7705Fa",
144154
mainnet_consensys: "0x00000000219ab540356cBB839Cbe05303d7705Fa",
155+
mainnet_safe: "0x00000000219ab540356cBB839Cbe05303d7705Fa",
145156
holesky_devnet: "0x4242424242424242424242424242424242424242",
146-
holesky_testnet: "0x4242424242424242424242424242424242424242"
157+
holesky_testnet: "0x4242424242424242424242424242424242424242",
158+
holesky_dev_safe: "0x4242424242424242424242424242424242424242",
147159
},
148160
treasury: {
149161
default: 5,
@@ -160,8 +172,10 @@ const hhuc: HardhatUserConfig = {
160172
mainnet_enzyme: "0x1ad1fc9964c551f456238Dd88D6a38344B5319D7",
161173
mainnet_komainu: "0xCdB0570d55Ebe8c8d678e090F86fa73729EF8Fc7",
162174
mainnet_consensys: "0xb631dB8b5D95947025b77bFB44De32eFA8bc15Da",
175+
mainnet_safe: "0xF9beDA1d78916CC89D4B3F6beF092Dc1D302112b",
163176
holesky_devnet: "0xb3eb29AC481FCFAFA7008A4acf04737c7d6733EA",
164-
holesky_testnet: "0xe6fe1936Fa8120e57c7Dee1733693B59b392672c"
177+
holesky_testnet: "0xe6fe1936Fa8120e57c7Dee1733693B59b392672c",
178+
holesky_dev_safe: "0xdA53Ce2F763A3270638127CEA2826e32Cd3428e5",
165179
},
166180
},
167181
};

0 commit comments

Comments
 (0)