Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch/patches/v2rc2.1 #38

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contracts/v2/core/SharedDepositMinterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";

import {ETH2DepositWithdrawalCredentials} from "../lib/ETH2DepositWithdrawalCredentials.sol";

/// @title SharedDepositMinterV2
/// @author ChimeraDefi - [email protected] | sharedstake.org
/// @notice Mints LSD tokens for ETH deposited to the contract. Handles the depositing of ETH to the ETH2 deposit contract and validator creation
/// @dev Deployment params:
/// - addresses : [feeCalc, sgeth, wsgeth, gov]
contract SharedDepositMinterV2 is AccessControl, Pausable, ReentrancyGuard, ETH2DepositWithdrawalCredentials {
/* ========== STATE VARIABLES ========== */
uint256 public adminFee;
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/core/WithdrawalQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {SharedDepositMinterV2} from "./SharedDepositMinterV2.sol";
* 3. Fulfill any remaining redeemRequests i.e. totalPendingRequest,
* for all RedeemRequest events from requestsFulfilled to requestsCreated
*/
contract WithdrawalQueue is AccessControl, GranularPause, ReentrancyGuard, FIFOQueue, OperatorSettable {
contract WithdrawalQueue is AccessControl, ReentrancyGuard, GranularPause, FIFOQueue, OperatorSettable {
using Address for address payable;

struct Request {
Expand Down
4 changes: 2 additions & 2 deletions contracts/v2/periphery/FeeCalc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
config.adminFee = amount;
}

function processDeposit(uint256 value, address sender) external view returns (uint256 amt, uint256 fee) {
function processDeposit(uint256 value, address _sender) external view returns (uint256 amt, uint256 fee) {

Check failure on line 44 in contracts/v2/periphery/FeeCalc.sol

View workflow job for this annotation

GitHub Actions / build (20.x)

Variable "_sender" is unused
// TODO: semder is currently unsused but can be used later to calculate a fee reduction based on token holdings
if (config.chargeOnDeposit) {
fee = (value * adminFee) / BIPS;
amt = value - fee;
}
}

function processWithdraw(uint256 value, address sender) external view returns (uint256 amt, uint256 fee) {
function processWithdraw(uint256 value, address _sender) external view returns (uint256 amt, uint256 fee) {

Check failure on line 52 in contracts/v2/periphery/FeeCalc.sol

View workflow job for this annotation

GitHub Actions / build (20.x)

Variable "_sender" is unused
// TODO: semder is currently unsused but can be used later to calculate a fee reduction based on token holdings
if (config.refundFeesOnWithdraw) {
fee = (value * adminFee) / BIPS;
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
31 changes: 26 additions & 5 deletions deploy/04_minter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
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;
Expand All @@ -19,12 +40,12 @@ const func: DeployFunction = async hre => {
// 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: 10,
exitFee: 0,
refundFeesOnWithdraw: true,
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
13 changes: 13 additions & 0 deletions deploy_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

- sepolia

-- deployed with new hardhat deploy tooling, see deployment log for deets
{
SgETH: '0xCF4831EBE785437DC54a90018b1b410Bd16c8533',
WSGETH: '0x514dfd2d10eC6775f030BA2abcf7A2445C0CA6Fb',
SharedDepositMinterV2: '0x36c2F00cC7D02be7Df0BC9be2a8e08b74C4f2E56',
PaymentSplitter: '0x38E86964A811Ee66D1139CD97C838B713F63779B',
WithdrawalQueue: '0x93Ec5A17176336C95Bfb537A71130d6eEA6eF73D',
RewardsReceiver: '0xAeBD9A9b883f539894A28CBCD866d50ca34000FD',
MockDepositContract: '0xEb9e7570f8D5ac7D0Abfbed902A784E84dF16a78'
}

-- deployed with old pipeline

{
SgETH: '0xA3A244Db2C07061E159090BB8b354ae4662fB0C3',
WSGETH: '0xc8BD8F8AC1410e6f59a5EeAf7be00703232EcD56',
Expand Down
1 change: 1 addition & 0 deletions deployments/localhost/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
265 changes: 265 additions & 0 deletions deployments/localhost/DepositContract.json

Large diffs are not rendered by default.

Loading
Loading