Skip to content

Commit

Permalink
fix(deploy): lint
Browse files Browse the repository at this point in the history
  • Loading branch information
loicttn authored and 0xvv committed Jul 31, 2023
1 parent 0adbe21 commit 1d276ef
Showing 1 changed file with 157 additions and 130 deletions.
287 changes: 157 additions & 130 deletions deploy/2_deploy_staking_contract.ts
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;

0 comments on commit 1d276ef

Please sign in to comment.