-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: consensys proxyless deployement (#95)
* feat: consensys proxyless deployement * fix: networks values * fix: admin address * feat: generate artifacts * mainnet deployment * feat: iso deployment * update yarn version --------- Co-authored-by: W <[email protected]>
- Loading branch information
1 parent
20438fc
commit 53f2d9b
Showing
31 changed files
with
7,883 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { getContractAddress } from "ethers/lib/utils"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { isDeployed } from "../ts_utils/index"; | ||
|
||
const getMaxFeeBps = (network: string): number => { | ||
switch (network) { | ||
case "goerli_uat_consensys": | ||
return 5000; | ||
case "goerli_dev_consensys": | ||
return 5000; | ||
case "mainnet_consensys": | ||
return 1500; //15% max fee | ||
|
||
default: | ||
return 5000; | ||
} | ||
}; | ||
|
||
const getMaxOperatorFeeBps = (network: string): number => { | ||
switch (network) { | ||
case "goerli_uat_consensys": | ||
return 5000; | ||
case "goerli_dev_consensys": | ||
return 5000; | ||
case "mainnet_consensys": | ||
return 10000; //100% of 15% = 15% | ||
|
||
default: | ||
return 5000; | ||
} | ||
}; | ||
|
||
const getFeeBps = (network: string): number => { | ||
switch (network) { | ||
case "goerli_uat_consensys": | ||
return 500; | ||
case "goerli_dev_consensys": | ||
return 500; | ||
case "mainnet_consensys": | ||
return 1000; //10% end-user fee | ||
|
||
default: | ||
return 500; | ||
} | ||
}; | ||
|
||
const getOperatorFeeBps = (network: string): number => { | ||
switch (network) { | ||
case "goerli_uat_consensys": | ||
return 500; | ||
case "goerli_dev_consensys": | ||
return 500; | ||
case "mainnet_consensys": | ||
return 9000; //90% of 10% = 9% for consensys, 1% for kiln | ||
|
||
default: | ||
return 500; | ||
} | ||
}; | ||
|
||
const func: DeployFunction = async function ({ | ||
deployments, | ||
getNamedAccounts, | ||
ethers, | ||
network, | ||
}: HardhatRuntimeEnvironment) { | ||
const { deployer, admin, depositContract, treasury } = await getNamedAccounts(); | ||
|
||
//1. Deploy Minimal Recipient | ||
const feeRecipientDeployment = await deployments.deploy("FeeRecipient", { | ||
from: deployer, | ||
log: true | ||
}); | ||
|
||
//2. Compute future staking contract address | ||
const signer = await ethers.getSigner(deployer); | ||
const txCount = await signer.getTransactionCount(); | ||
const futureStakingContractAddress = getContractAddress({ | ||
from: deployer, | ||
nonce: txCount + 4, // staking contract proxy is in 5 txs | ||
}); | ||
|
||
//3. Deploy ConsensusLayerFeeDispatcher without proxy | ||
const clfdDeployment = (await deployments.deploy("ConsensusLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [0], | ||
})); | ||
|
||
|
||
const clf = await ethers.getContractAt("ConsensusLayerFeeDispatcher", clfdDeployment.address); | ||
await (await clf.initCLD(futureStakingContractAddress)).wait(); | ||
|
||
//4. Deploy ExecutionLayerFeeDispatcher without proxy | ||
const elfdDeployment = await deployments.deploy("ExecutionLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [0], | ||
}); | ||
|
||
const elf = await ethers.getContractAt("ExecutionLayerFeeDispatcher", elfdDeployment.address); | ||
await (await elf.initELD(futureStakingContractAddress)).wait(); | ||
|
||
|
||
//5. Deploy StakingContract without proxy | ||
const stakingContractDeployment = await deployments.deploy("StakingContract", { | ||
from: deployer, | ||
log: true, | ||
}); | ||
|
||
const stakingContract = await ethers.getContractAt("StakingContract", stakingContractDeployment.address); | ||
|
||
const initStaking_1 = await stakingContract.initialize_1( | ||
admin, | ||
treasury, | ||
depositContract, | ||
elfdDeployment.address, | ||
clfdDeployment.address, | ||
feeRecipientDeployment.address, | ||
getFeeBps(network.name), | ||
getOperatorFeeBps(network.name), | ||
getMaxFeeBps(network.name), | ||
getMaxOperatorFeeBps(network.name), | ||
); | ||
await initStaking_1.wait(); | ||
|
||
if (stakingContractDeployment.address.toLowerCase() !== futureStakingContractAddress.toLowerCase()) { | ||
throw new Error("Invalid future deployment address for staking contract"); | ||
} | ||
}; | ||
|
||
func.skip = async function ({ deployments, network }: HardhatRuntimeEnvironment): Promise<boolean> { | ||
const shouldSkip = network.name !== "goerli_uat_consensys" && network.name !== "goerli_dev_consensys" && network.name !== "mainnet_consensys"; | ||
if (shouldSkip) { | ||
console.log("Skipped"); | ||
} | ||
return shouldSkip; | ||
}; | ||
|
||
export default func; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "goerli_dev_consensys", | ||
"chainId": "5", | ||
"contracts": { | ||
"ConsensusLayerFeeDispatcher": "0xD8875BAab3c5a1244d10fbBbC03b756f7649f320", | ||
"ExecutionLayerFeeDispatcher": "0x3fb3bf7D78150865eE891d5Ea344D0CC9c1E1E84", | ||
"FeeRecipient": "0x8Fa87245c0D88e2D0cfE05679cED0C367950514b", | ||
"StakingContract": "0x97230E85e6443371B5b7bB5d47FA868E2eE48301" | ||
}, | ||
"namedAccounts": { | ||
"deployer": "0xBcc3816221d083D8E72F2CB14959F24d89406810", | ||
"admin": "0xFb0961bea75145bC62fB6A53bE9Be70A0A7D206E", | ||
"depositContract": "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b", | ||
"treasury": "0xAb07A64D407c25f02f1a2dc0aF97076630a03F17" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "goerli_uat_consensys", | ||
"chainId": "5", | ||
"contracts": { | ||
"ConsensusLayerFeeDispatcher": "0xb4C5d4B5e4ed044e68f235a0BFE7346D2a2E634d", | ||
"ExecutionLayerFeeDispatcher": "0x6F4579e7C3B3aeb030dC325f2e2476E3c4f3AA60", | ||
"FeeRecipient": "0xe24F071021205Ba706fAfd4f8F1a74F24c303745", | ||
"StakingContract": "0xD36142289a230423Bb1341e2F9CbE9c549C5c93d" | ||
}, | ||
"namedAccounts": { | ||
"deployer": "0xBcc3816221d083D8E72F2CB14959F24d89406810", | ||
"admin": "0xFb0961bea75145bC62fB6A53bE9Be70A0A7D206E", | ||
"depositContract": "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b", | ||
"treasury": "0xAb07A64D407c25f02f1a2dc0aF97076630a03F17" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "mainnet_consensys", | ||
"chainId": "1", | ||
"contracts": { | ||
"ConsensusLayerFeeDispatcher": "0xC24162aa69C3267Ed5a4900a2976487BDDFC69d2", | ||
"ExecutionLayerFeeDispatcher": "0xeD216054cb9bA38d22E3E72B8245147F890329e4", | ||
"FeeRecipient": "0xFE1b6a789e2BD96a69C49a14353E51116b48107F", | ||
"StakingContract": "0xDc71aFFC862fceB6aD32BE58E098423A7727bEbd" | ||
}, | ||
"namedAccounts": { | ||
"deployer": "0x6C74FDa18Ea90E1C61e800Dd9B4508Ac782e0Dc8", | ||
"admin": "0x5Bc5ec5130f66f13d5C21ac6811A7e624ED3C7c6", | ||
"depositContract": "0x00000000219ab540356cBB839Cbe05303d7705Fa", | ||
"treasury": "0xb631dB8b5D95947025b77bFB44De32eFA8bc15Da" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 |
Oops, something went wrong.