Skip to content

Commit

Permalink
Merge pull request #42 from chimera-defi/ch/newDeployScripts
Browse files Browse the repository at this point in the history
Ch/new deploy scripts
  • Loading branch information
chimera-defi authored Jul 2, 2024
2 parents 2f29613 + c410384 commit 355e281
Show file tree
Hide file tree
Showing 12 changed files with 619 additions and 118 deletions.
2 changes: 1 addition & 1 deletion contracts/v2/periphery/FeeCalc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract FeeCalc is Ownable2Step {
bool chargeOnDeposit;
bool chargeOnExit;
}
Settings private config;
Settings public config;
uint256 public adminFee;
uint256 public costPerValidator;

Expand Down
2 changes: 1 addition & 1 deletion deploy/03_paymentSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const func: DeployFunction = async hre => {
const multiSig = hre.network.tags.hardhat ? accounts.multiSig.address : "0x610c92c70eb55dfeafe8970513d13771da79f2e0";

const splitterAddresses = [accounts.deployer.address, multiSig, wsgEth.target];
const splitterValues = [6, 3, 31];
const splitterValues = [60, 30, 910]; // deploy splitter, with 1k total shares. 9% total fees - 6% for deployer, 3% for multisig, 91% for stakers.

await deploy(PaymentSplitter__factory, {
args: [splitterAddresses, splitterValues],
Expand Down
33 changes: 27 additions & 6 deletions deploy/04_minter.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
import {DeployFunction} from "hardhat-deploy/types";
import Ship from "../utils/ship";
import {SgETH, SgETH__factory, SharedDepositMinterV2__factory, WSGETH, WSGETH__factory} from "../types";
import {
SgETH,
SgETH__factory,
SharedDepositMinterV2__factory,
WSGETH,
WSGETH__factory,
DepositContract,
DepositContract__factory,
FeeCalc,
FeeCalc__factory,
} from "../types";
import {ZeroAddress} from "ethers";

const func: DeployFunction = async hre => {
const {deploy, connect, accounts} = await Ship.init(hre);

const sgEth = (await connect(SgETH__factory)) as SgETH;
const wsgEth = (await connect(WSGETH__factory)) as WSGETH;
const feeCalc = (await connect(FeeCalc__factory)) as FeeCalc;

let chainId = await hre.getChainId();

let depositContractAddr;
if (chainId != "1") {
let depositContract = (await connect(DepositContract__factory)) as DepositContract;
depositContractAddr = depositContract.target;
} else {
depositContractAddr = "0x00000000219ab540356cBB839Cbe05303d7705Fa";
}

const numValidators = 1000;
const adminFee = 0;

const multiSig = hre.network.tags.hardhat ? accounts.multiSig.address : "0x610c92c70eb55dfeafe8970513d13771da79f2e0";
const multiSig = hre.network.tags.hardhat ? accounts.multiSig.address : accounts.deployer.address;

// const FeeCalc = await ethers.getContractFactory("FeeCalc");
// const feeCalc = await FeeCalc.deploy(parseEther("0"), parseEther("0"));
// await feeCalc.deployed();

const addresses = [
ZeroAddress,
//feeCalc.address, // fee splitter
// ZeroAddress,
feeCalc.target, // fee splitter
sgEth.target, // sgETH address
wsgEth.target, // wsgETH address
multiSig, // government address
ZeroAddress, // deposit contract address - can't find deposit contract - using dummy address
depositContractAddr, // deposit contract address - can't find deposit contract - using dummy address
];

const minter = await deploy(SharedDepositMinterV2__factory, {
Expand All @@ -40,4 +61,4 @@ const func: DeployFunction = async hre => {

export default func;
func.tags = ["minter"];
func.dependencies = ["sgEth", "wsgEth"];
func.dependencies = ["sgEth", "wsgEth", "depositContract", "feeCalc"];
20 changes: 20 additions & 0 deletions deploy/04a_depositContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {DeployFunction} from "hardhat-deploy/types";
import Ship from "../utils/ship";
import {DepositContract__factory} from "../types";

/**
*
* This only needs to be deployed on testnets like sepolia which do not have a deposit contract.
* Do not deploy on mainnet
*/
const func: DeployFunction = async hre => {
const {deploy} = await Ship.init(hre);

const dc = await deploy(DepositContract__factory, {
args: [],
});
};

export default func;
func.tags = ["depositContract"];
func.dependencies = [];
27 changes: 27 additions & 0 deletions deploy/04b_feeCalc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {DeployFunction} from "hardhat-deploy/types";
import Ship from "../utils/ship";
import {FeeCalc__factory} from "../types";

/**
*
* This only needs to be deployed on testnets like sepolia which do not have a deposit contract.
*/
const func: DeployFunction = async hre => {
const {deploy} = await Ship.init(hre);

const fc = await deploy(FeeCalc__factory, {
args: [
{
adminFee: 0,
exitFee: 0,
refundFeesOnWithdraw: false,
chargeOnDeposit: true,
chargeOnExit: false,
},
],
});
};

export default func;
func.tags = ["feeCalc"];
func.dependencies = [];
15 changes: 15 additions & 0 deletions deploy/06_rewardsReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Ship from "../utils/ship";
import {
PaymentSplitter,
PaymentSplitter__factory,
RewardsReceiver,
RewardsReceiver__factory,
SgETH,
SgETH__factory,
Expand All @@ -14,6 +15,17 @@ import {
WithdrawalQueue__factory,
} from "../types";

function makeWithdrawalCred(params: any) {
// see https://github.com/ethereum/consensus-specs/pull/2149/files & https://github.com/stakewise/contracts/blob/0e51a35e58676491060df84d665e7ebb0e735d17/test/pool/depositDataMerkleRoot.js#L140
// pubkey is 0x01 + (11 bytes?) 20 0s + eth1 addr 20 bytes (40 characters) ? = final length 66
//
let withdrawalCredsPrefix = `0x010000000000000000000000`;
let eth1Withdraw = `${withdrawalCredsPrefix}${params.split("x")[1]}`;
console.log(`setWithdrawalCredential ${eth1Withdraw}`);

return eth1Withdraw;
}

const func: DeployFunction = async hre => {
const {deploy, connect} = await Ship.init(hre);

Expand All @@ -26,6 +38,9 @@ const func: DeployFunction = async hre => {
await deploy(RewardsReceiver__factory, {
args: [withdrawalQueue.target, [sgEth.target, wsgEth.target, paymentSplitter.target, minter.target]],
});

let rr = (await connect(RewardsReceiver__factory)) as RewardsReceiver;
await minter.setWithdrawalCredential(makeWithdrawalCred(rr.target));
};

export default func;
Expand Down
2 changes: 1 addition & 1 deletion deploy_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
SgETH: '0xCF4831EBE785437DC54a90018b1b410Bd16c8533',
WSGETH: '0x514dfd2d10eC6775f030BA2abcf7A2445C0CA6Fb',
SharedDepositMinterV2: '0x36c2F00cC7D02be7Df0BC9be2a8e08b74C4f2E56',
SharedDepositMinterV2: '0xd6Ad9a646330F1a937347a5cfaaDE57990109b5C',
PaymentSplitter: '0x38E86964A811Ee66D1139CD97C838B713F63779B',
WithdrawalQueue: '0x93Ec5A17176336C95Bfb537A71130d6eEA6eF73D',
RewardsReceiver: '0xAeBD9A9b883f539894A28CBCD866d50ca34000FD',
Expand Down
79 changes: 56 additions & 23 deletions deployments/sepolia/FeeCalc.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions deployments/sepolia/RewardsReceiver.json

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions deployments/sepolia/SharedDepositMinterV2.json

Large diffs are not rendered by default.

62 changes: 33 additions & 29 deletions deployments/sepolia/WithdrawalQueue.json

Large diffs are not rendered by default.

381 changes: 381 additions & 0 deletions deployments/sepolia/solcInputs/61fc510774bb4eddca51caab8f8d5192.json

Large diffs are not rendered by default.

0 comments on commit 355e281

Please sign in to comment.