Skip to content

Commit

Permalink
prod values along with deploy script (stader-labs#156)
Browse files Browse the repository at this point in the history
* prod vaules along with deploy script

* review fix

---------

Co-authored-by: Sanjay Yadav <[email protected]>
  • Loading branch information
sanjay-staderlabs and Sanjay Yadav authored May 26, 2023
1 parent 82c4348 commit b26d7f1
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 77 deletions.
4 changes: 2 additions & 2 deletions contracts/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ contract Auction is IAuction, Initializable, AccessControlUpgradeable, PausableU
__ReentrancyGuard_init();

staderConfig = IStaderConfig(_staderConfig);
duration = MIN_AUCTION_DURATION;
bidIncrement = 1e16;
duration = 2 * MIN_AUCTION_DURATION;
bidIncrement = 5e15;
nextLot = 1;

_grantRole(DEFAULT_ADMIN_ROLE, _admin);
Expand Down
4 changes: 2 additions & 2 deletions contracts/Penalty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract Penalty is IPenalty, Initializable, AccessControlUpgradeable, Reentranc
ratedOracleAddress = _ratedOracleAddress;
mevTheftPenaltyPerStrike = 1 ether;
missedAttestationPenaltyPerStrike = 0.2 ether;
validatorExitPenaltyThreshold = 2.5 ether;
validatorExitPenaltyThreshold = 2 ether;
_grantRole(DEFAULT_ADMIN_ROLE, _admin);

emit UpdatedPenaltyOracleAddress(_ratedOracleAddress);
Expand Down Expand Up @@ -110,7 +110,7 @@ contract Penalty is IPenalty, Initializable, AccessControlUpgradeable, Reentranc
// taking into account additional penalties and penalty reversals from the DAO.
uint256 totalPenalty = _mevTheftPenalty + _missedAttestationPenalty + additionalPenaltyAmount[pubkeyRoot];
totalPenaltyAmount[_pubkey[i]] = totalPenalty;
if (totalPenalty > validatorExitPenaltyThreshold) {
if (totalPenalty >= validatorExitPenaltyThreshold) {
emit ForceExitValidator(_pubkey[i]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/PermissionedNodeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ contract PermissionedNodeRegistry is
nextOperatorId = 1;
nextValidatorId = 1;
operatorIdForExcessDeposit = 1;
inputKeyCountLimit = 100;
maxOperatorId = 50;
maxNonTerminalKeyPerOperator = 1000;
inputKeyCountLimit = 50;
maxOperatorId = 10;
maxNonTerminalKeyPerOperator = 50;
verifiedKeyBatchSize = 50;
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/PermissionedPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ contract PermissionedPool is IStaderPoolBase, Initializable, AccessControlUpgrad
UtilLib.checkNonZeroAddress(_staderConfig);
__AccessControl_init_unchained();
__ReentrancyGuard_init();
protocolFee = 500;
operatorFee = 500;
staderConfig = IStaderConfig(_staderConfig);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/PermissionlessNodeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract PermissionlessNodeRegistry is
staderConfig = IStaderConfig(_staderConfig);
nextOperatorId = 1;
nextValidatorId = 1;
inputKeyCountLimit = 100;
inputKeyCountLimit = 50;
maxNonTerminalKeyPerOperator = 50;
verifiedKeyBatchSize = 50;
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
Expand Down
2 changes: 2 additions & 0 deletions contracts/PermissionlessPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ contract PermissionlessPool is IStaderPoolBase, Initializable, AccessControlUpgr
UtilLib.checkNonZeroAddress(_staderConfig);
__AccessControl_init_unchained();
__ReentrancyGuard_init();
protocolFee = 500;
operatorFee = 500;
staderConfig = IStaderConfig(_staderConfig);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/PoolSelector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract PoolSelector is IPoolSelector, Initializable, AccessControlUpgradeable
UtilLib.checkNonZeroAddress(_admin);
UtilLib.checkNonZeroAddress(_staderConfig);
__AccessControl_init_unchained();
poolAllocationMaxSize = 100;
poolAllocationMaxSize = 50;
staderConfig = IStaderConfig(_staderConfig);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
7 changes: 4 additions & 3 deletions contracts/StaderConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ contract StaderConfig is IStaderConfig, Initializable, AccessControlUpgradeable
setConstant(TOTAL_FEE, 10000);
setConstant(DECIMALS, 10**18);
setConstant(OPERATOR_MAX_NAME_LENGTH, 255);
setVariable(MIN_DEPOSIT_AMOUNT, 10**12);
setVariable(MIN_DEPOSIT_AMOUNT, 10**14);
setVariable(MAX_DEPOSIT_AMOUNT, 10000 ether);
setVariable(MIN_WITHDRAW_AMOUNT, 10**12);
setVariable(MIN_WITHDRAW_AMOUNT, 10**14);
setVariable(MAX_WITHDRAW_AMOUNT, 10000 ether);
setVariable(WITHDRAWN_KEYS_BATCH_SIZE, 100);
setVariable(WITHDRAWN_KEYS_BATCH_SIZE, 50);
setVariable(MIN_BLOCK_DELAY_TO_FINALIZE_WITHDRAW_REQUEST, 600);
setContract(ETH_DEPOSIT_CONTRACT, _ethDepositContract);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
7 changes: 6 additions & 1 deletion contracts/StaderOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ contract StaderOracle is IStaderOracle, AccessControlUpgradeable, PausableUpgrad
__AccessControl_init();
__Pausable_init();
__ReentrancyGuard_init();
erChangeLimit = 100; //1% deviation threshold
erChangeLimit = 500; //5% deviation threshold
setUpdateFrequency(ETHX_ER_UF, 7200);
setUpdateFrequency(SD_PRICE_UF, 7200);
setUpdateFrequency(VALIDATOR_STATS_UF, 7200);
setUpdateFrequency(WITHDRAWN_VALIDATORS_UF, 14400);
setUpdateFrequency(MISSED_ATTESTATION_PENALTY_UF, 50400);
staderConfig = IStaderConfig(_staderConfig);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
emit UpdatedStaderConfig(_staderConfig);
Expand Down
2 changes: 1 addition & 1 deletion contracts/StaderStakePoolsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract StaderStakePoolsManager is
__Pausable_init();
__ReentrancyGuard_init();
lastExcessETHDepositBlock = block.number;
excessETHDepositCoolDown = 7200;
excessETHDepositCoolDown = 3 * 7200;
staderConfig = IStaderConfig(_staderConfig);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
Expand Down
96 changes: 33 additions & 63 deletions scripts/deployContracts.ts
Original file line number Diff line number Diff line change
@@ -1,142 +1,112 @@
import { ethers, upgrades } from 'hardhat'

async function main() {

console.log('starting deployment process...')
const admin = process.env.ADMIN ?? ''
const tempAdmin = process.env.TEMP_ADMIN ?? ''
const externalAdmin = process.env.EXTERNAL_ADMIN ?? ''
const ethDepositContract = process.env.ETH_DEPOSIT_CONTRACT ?? ''
const permissionlessPoolWeight: any = process.env.PERMISSIONLESS_POOL_WEIGHT
const permissionedPoolWeight: any = process.env.PERMISSIONED_POOL_WEIGHT

const ratedOracle = process.env.RATED_ORACLE ?? ''
const ratedOracle = process.env.RATED ?? ''

const StaderConfig = await ethers.getContractFactory('StaderConfig')
const staderConfig = await upgrades.deployProxy(StaderConfig, [admin, ethDepositContract])
const staderConfig = await upgrades.deployProxy(StaderConfig, [tempAdmin, ethDepositContract])
console.log('stader config deployed at ', staderConfig.address)

const vaultFactory = await ethers.getContractFactory('VaultFactory')
const vaultFactoryInstance = await upgrades.deployProxy(vaultFactory, [admin, staderConfig.address])
const vaultFactoryInstance = await upgrades.deployProxy(vaultFactory, [externalAdmin, staderConfig.address])
console.log('vaultFactoryInstance deployed at ', vaultFactoryInstance.address)

const auctionFactory = await ethers.getContractFactory('Auction')
const auctionInstance = await upgrades.deployProxy(auctionFactory, [
admin,
staderConfig.address,
ethers.BigNumber.from('86400'),
ethers.utils.parseEther('0.001'),
externalAdmin,
staderConfig.address
])
console.log('auction contract deployed at ', auctionInstance.address)

const ETHxFactory = await ethers.getContractFactory('ETHx')
const ETHxToken = await upgrades.deployProxy(ETHxFactory, [admin, staderConfig.address])
const ETHxToken = await upgrades.deployProxy(ETHxFactory, [externalAdmin, staderConfig.address])
console.log('ETHx deployed at ', ETHxToken.address)

const penaltyFactory = await ethers.getContractFactory('Penalty')
const penaltyInstance = await upgrades.deployProxy(penaltyFactory, [admin, staderConfig.address, ratedOracle])
const penaltyInstance = await upgrades.deployProxy(penaltyFactory, [externalAdmin, staderConfig.address, ratedOracle])
console.log('penalty contract deployed at ', penaltyInstance.address)

const PermissionedNodeRegistryFactory = await ethers.getContractFactory('PermissionedNodeRegistry')
const permissionedNodeRegistry = await upgrades.deployProxy(PermissionedNodeRegistryFactory, [
admin,
externalAdmin,
staderConfig.address,
])
console.log('permissionedNodeRegistry deployed at ', permissionedNodeRegistry.address)

const permissinedPoolFactory = await ethers.getContractFactory('PermissionedPool')
const permissionedPool = await upgrades.deployProxy(permissinedPoolFactory, [admin, staderConfig.address])
const permissionedPool = await upgrades.deployProxy(permissinedPoolFactory, [externalAdmin, staderConfig.address])
console.log('permissionedPool deployed at ', permissionedPool.address)

const PermissionlessNodeRegistryFactory = await ethers.getContractFactory('PermissionlessNodeRegistry')
const permissionlessNodeRegistry = await upgrades.deployProxy(PermissionlessNodeRegistryFactory, [
admin,
externalAdmin,
staderConfig.address,
])
console.log('permissionlessNodeRegistry deployed at ', permissionlessNodeRegistry.address)

const permissionlessPoolFactory = await ethers.getContractFactory('PermissionlessPool')
const permissionlessPool = await upgrades.deployProxy(permissionlessPoolFactory, [admin, staderConfig.address])
const permissionlessPool = await upgrades.deployProxy(permissionlessPoolFactory, [externalAdmin, staderConfig.address])
console.log('permissionlessPool deployed at ', permissionlessPool.address)

const poolSelectorFactory = await ethers.getContractFactory('PoolSelector')
const poolSelector = await upgrades.deployProxy(poolSelectorFactory, [
admin,
staderConfig.address,
permissionlessPoolWeight,
permissionedPoolWeight,
externalAdmin,
staderConfig.address
])
console.log('poolSelector deployed at ', poolSelector.address)

const poolUtilsFactory = await ethers.getContractFactory('PoolUtils')
const poolUtilsInstance = await upgrades.deployProxy(poolUtilsFactory, [admin, staderConfig.address])
const poolUtilsInstance = await upgrades.deployProxy(poolUtilsFactory, [externalAdmin, staderConfig.address])
console.log('poolUtils deployed at ', poolUtilsInstance.address)

const SDCollateralFactory = await ethers.getContractFactory('SDCollateral')
const SDCollateral = await upgrades.deployProxy(SDCollateralFactory, [admin, staderConfig.address])
const SDCollateral = await upgrades.deployProxy(SDCollateralFactory, [externalAdmin, staderConfig.address])
console.log('SDCollateral deployed at ', SDCollateral.address)

const socializingPoolFactory = await ethers.getContractFactory('SocializingPool')
const permissionedSocializingPoolContract = await upgrades.deployProxy(socializingPoolFactory, [
admin,
externalAdmin,
staderConfig.address,
])
console.log('permissioned socializingPoolContract deployed at ', permissionedSocializingPoolContract.address)

const permissionlessSocializingPoolContract = await upgrades.deployProxy(socializingPoolFactory, [
admin,
externalAdmin,
staderConfig.address,
])
console.log('permissionless socializingPoolContract deployed at ', permissionlessSocializingPoolContract.address)

const insuranceFundFactory = await ethers.getContractFactory('StaderInsuranceFund')
const insuranceFund = await upgrades.deployProxy(insuranceFundFactory, [admin, staderConfig.address])
const insuranceFund = await upgrades.deployProxy(insuranceFundFactory, [externalAdmin, staderConfig.address])
console.log('insurance fund deployed at ', insuranceFund.address)

const staderOracleFactory = await ethers.getContractFactory('StaderOracle')
const staderOracle = await upgrades.deployProxy(staderOracleFactory, [admin, staderConfig.address])
const staderOracle = await upgrades.deployProxy(staderOracleFactory, [externalAdmin, staderConfig.address])
console.log('stader oracle deployed at ', staderOracle.address)

const poolManagerFactory = await ethers.getContractFactory('StaderStakePoolsManager')
const staderStakingPoolManager = await upgrades.deployProxy(poolManagerFactory, [admin, staderConfig.address])
const staderStakingPoolManager = await upgrades.deployProxy(poolManagerFactory, [externalAdmin, staderConfig.address])
console.log('staderStakingPoolManager deployed at ', staderStakingPoolManager.address)

const userWithdrawFactory = await ethers.getContractFactory('UserWithdrawalManager')
const userWithdrawManager = await upgrades.deployProxy(userWithdrawFactory, [admin, staderConfig.address])
const userWithdrawManager = await upgrades.deployProxy(userWithdrawFactory, [externalAdmin, staderConfig.address])
console.log('userWithdrawManager deployed at ', userWithdrawManager.address)

const NodeELRewardVault = await ethers.getContractFactory('NodeELRewardVault')
const nodeELRewardVault = await NodeELRewardVault.deploy()
await nodeELRewardVault.deployed()
console.log('nodeELRewardVault ', nodeELRewardVault.address)

// Grant Role
// const minterRole = await ETHxToken.MINTER_ROLE()
// await ETHxToken.grantRole(minterRole, staderStakingPoolManager.address)
// console.log('granted minter role to pool manager')

// const burnerRole = await ETHxToken.BURNER_ROLE()
// await ETHxToken.grantRole(burnerRole, userWithdrawManager.address)
// console.log('granted burner role to user withdraw manager')

// const nodeRegistryContract = await vaultFactoryInstance.NODE_REGISTRY_CONTRACT()
// await vaultFactoryInstance.grantRole(nodeRegistryContract, permissionlessNodeRegistry.address)
// await vaultFactoryInstance.grantRole(nodeRegistryContract, permissionedNodeRegistry.address)
// console.log('granted node registry role to permissioned and permissionless node registries')

// const managerRole = await staderConfig.MANAGER()
// await staderConfig.grantRole(managerRole, manager)
// console.log(`granted manager role to ${manager}`)

// const operatorRole = await staderConfig.OPERATOR()
// await staderConfig.grantRole(operatorRole, operator.address)
// console.log(`granted operator role to ${operator.address}`)

//update stader config admin at the last so we can update all contract address with stader internal admin

//Setter

// const addPool1Txn = await poolUtilsInstance
// .connect(operator.address)
// .addNewPool(permissionlessPoolId, permissionlessPool.address)
// addPool1Txn.wait()
// console.log('permission less pool added')
const ValidatorWithdrawalVault = await ethers.getContractFactory('ValidatorWithdrawalVault')
const validatorWithdrawalVault = await ValidatorWithdrawalVault.deploy()
await validatorWithdrawalVault.deployed()
console.log('validatorWithdrawalVault ', validatorWithdrawalVault.address)

// const addPool2Txn = await poolUtilsInstance.connect(operator.address).addNewPool(permissionedPoolId, permissionedPool.address)
// addPool2Txn.wait()
// console.log('permissioned pool added')
}

main()

0 comments on commit b26d7f1

Please sign in to comment.