-
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.
- Loading branch information
Showing
1 changed file
with
157 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,181 @@ | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import { getContractAddress } from "ethers/lib/utils"; | ||
import { isDeployed } from '../ts_utils/index'; | ||
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_consensys': return 5000 | ||
case 'goerli_vault': return 5000 | ||
case 'goerli_live': return 5000 | ||
case 'mainnet_vault': return 5000 | ||
case 'mainnet_live': return 5000 | ||
case 'mainnet_enzyme': return 5000 | ||
case 'mainnet_komainu': return 5000 | ||
default: return 5000 | ||
} | ||
} | ||
switch (network) { | ||
case "goerli_consensys": | ||
return 5000; | ||
case "goerli_vault": | ||
return 5000; | ||
case "goerli_live": | ||
return 5000; | ||
case "mainnet_vault": | ||
return 5000; | ||
case "mainnet_live": | ||
return 5000; | ||
case "mainnet_enzyme": | ||
return 5000; | ||
case "mainnet_komainu": | ||
return 5000; | ||
default: | ||
return 5000; | ||
} | ||
}; | ||
|
||
const getMaxOperatorFeeBps = (network: string): number => { | ||
switch (network) { | ||
case 'goerli_consensys': return 5000 | ||
case 'goerli_vault': return 5000 | ||
case 'goerli_live': return 5000 | ||
case 'mainnet_vault': return 5000 | ||
case 'mainnet_live': return 5000 | ||
case 'mainnet_enzyme': return 5000 | ||
case 'mainnet_komainu': return 5000 | ||
default: return 5000 | ||
} | ||
} | ||
switch (network) { | ||
case "goerli_consensys": | ||
return 5000; | ||
case "goerli_vault": | ||
return 5000; | ||
case "goerli_live": | ||
return 5000; | ||
case "mainnet_vault": | ||
return 5000; | ||
case "mainnet_live": | ||
return 5000; | ||
case "mainnet_enzyme": | ||
return 5000; | ||
case "mainnet_komainu": | ||
return 5000; | ||
default: | ||
return 5000; | ||
} | ||
}; | ||
|
||
const getFeeBps = (network: string): number => { | ||
switch (network) { | ||
case 'goerli_consensys': return 500 | ||
case 'goerli_vault': return 700 | ||
case 'goerli_live': return 700 | ||
case 'mainnet_vault': return 700 | ||
case 'mainnet_live': return 800 | ||
case 'mainnet_enzyme': return 400 | ||
case 'mainnet_komainu': return 400 | ||
default: return 700 | ||
} | ||
} | ||
switch (network) { | ||
case "goerli_consensys": | ||
return 500; | ||
case "goerli_vault": | ||
return 700; | ||
case "goerli_live": | ||
return 700; | ||
case "mainnet_vault": | ||
return 700; | ||
case "mainnet_live": | ||
return 800; | ||
case "mainnet_enzyme": | ||
return 400; | ||
case "mainnet_komainu": | ||
return 400; | ||
default: | ||
return 700; | ||
} | ||
}; | ||
|
||
const getOperatorFeeBps = (network: string): number => { | ||
switch (network) { | ||
case 'goerli_consensys': return 500 | ||
case 'goerli_vault': return 0 | ||
case 'goerli_live': return 0 | ||
case 'mainnet_vault': return 0 | ||
case 'mainnet_live': return 0 | ||
case 'mainnet_enzyme': return 400 | ||
case 'mainnet_komainu': return 0 | ||
default: return 0 | ||
} | ||
} | ||
switch (network) { | ||
case "goerli_consensys": | ||
return 500; | ||
case "goerli_vault": | ||
return 0; | ||
case "goerli_live": | ||
return 0; | ||
case "mainnet_vault": | ||
return 0; | ||
case "mainnet_live": | ||
return 0; | ||
case "mainnet_enzyme": | ||
return 400; | ||
case "mainnet_komainu": | ||
return 0; | ||
default: | ||
return 0; | ||
} | ||
}; | ||
|
||
const func: DeployFunction = async function ({ | ||
deployments, | ||
getNamedAccounts, | ||
ethers, | ||
network | ||
}: HardhatRuntimeEnvironment) { | ||
const { deployer, proxyAdmin, admin, depositContract, treasury } = await getNamedAccounts(); | ||
deployments, | ||
getNamedAccounts, | ||
ethers, | ||
network, | ||
}: HardhatRuntimeEnvironment) { | ||
const { deployer, proxyAdmin, admin, depositContract, treasury } = await getNamedAccounts(); | ||
|
||
const feeRecipientDeployment = await deployments.get("FeeRecipient"); | ||
const feeRecipientDeployment = await deployments.get("FeeRecipient"); | ||
|
||
const signer = await ethers.getSigner(deployer); | ||
const txCount = await signer.getTransactionCount(); | ||
const futureStakingContractAddress = getContractAddress({ | ||
from: deployer, | ||
nonce: txCount + 5, // staking contract proxy is in 6 txs | ||
}); | ||
const signer = await ethers.getSigner(deployer); | ||
const txCount = await signer.getTransactionCount(); | ||
const futureStakingContractAddress = getContractAddress({ | ||
from: deployer, | ||
nonce: txCount + 5, // staking contract proxy is in 6 txs | ||
}); | ||
|
||
const clfdDeployment = await deployments.deploy("ConsensusLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [1], | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: 'initCLD', | ||
args: [ | ||
futureStakingContractAddress | ||
] | ||
} | ||
} | ||
}, | ||
}); | ||
const clfdDeployment = await deployments.deploy("ConsensusLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [1], | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: "initCLD", | ||
args: [futureStakingContractAddress], | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const elfdDeployment = await deployments.deploy("ExecutionLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [1], | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: 'initELD', | ||
args: [ | ||
futureStakingContractAddress | ||
] | ||
} | ||
} | ||
}, | ||
}); | ||
const elfdDeployment = await deployments.deploy("ExecutionLayerFeeDispatcher", { | ||
from: deployer, | ||
log: true, | ||
args: [1], | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: "initELD", | ||
args: [futureStakingContractAddress], | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const stakingContractDeployment = await deployments.deploy("StakingContract", { | ||
from: deployer, | ||
log: true, | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: 'initialize_1', | ||
args: [ | ||
const stakingContractDeployment = await deployments.deploy("StakingContract", { | ||
from: deployer, | ||
log: true, | ||
proxy: { | ||
owner: proxyAdmin, | ||
proxyContract: "TUPProxy", | ||
execute: { | ||
init: { | ||
methodName: "initialize_1", | ||
args: [ | ||
admin, | ||
treasury, | ||
depositContract, | ||
elfdDeployment.address, | ||
clfdDeployment.address, | ||
feeRecipientDeployment.address, | ||
getFeeBps(network.name), | ||
getOperatorFeeBps(network.name), | ||
treasury, | ||
depositContract, | ||
elfdDeployment.address, | ||
clfdDeployment.address, | ||
feeRecipientDeployment.address, | ||
getFeeBps(network.name), | ||
getOperatorFeeBps(network.name), | ||
getMaxFeeBps(network.name), | ||
getMaxOperatorFeeBps(network.name) | ||
] | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
if (stakingContractDeployment.address.toLowerCase() !== futureStakingContractAddress.toLowerCase()) { | ||
throw new Error("Invalid future deployment address for staking contract") | ||
} | ||
getMaxOperatorFeeBps(network.name), | ||
], | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
if (stakingContractDeployment.address.toLowerCase() !== futureStakingContractAddress.toLowerCase()) { | ||
throw new Error("Invalid future deployment address for staking contract"); | ||
} | ||
}; | ||
|
||
func.skip = async function ({ deployments }: HardhatRuntimeEnvironment): Promise<boolean> { | ||
const shouldSkip = | ||
await isDeployed("ConsensusLayerFeeDispatcher_Proxy", deployments) && | ||
await isDeployed("ExecutionLayerFeeDispatcher_Proxy", deployments) && | ||
await isDeployed("StakingContract_Proxy", deployments); | ||
if (shouldSkip) { | ||
console.log("Skipped"); | ||
} | ||
return shouldSkip; | ||
}; | ||
const shouldSkip = | ||
(await isDeployed("ConsensusLayerFeeDispatcher_Proxy", deployments)) && | ||
(await isDeployed("ExecutionLayerFeeDispatcher_Proxy", deployments)) && | ||
(await isDeployed("StakingContract_Proxy", deployments)); | ||
if (shouldSkip) { | ||
console.log("Skipped"); | ||
} | ||
return shouldSkip; | ||
}; | ||
|
||
export default func; |