Skip to content

Commit 99f5459

Browse files
committed
chore(protocol-staking): clean, improve and add tasks
1 parent 918435b commit 99f5459

File tree

15 files changed

+498
-178
lines changed

15 files changed

+498
-178
lines changed

protocol-contracts/staking/.env.example

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MAINNET_RPC_URL=
77
SEPOLIA_RPC_URL=
88

99
# ----------------------------------------------------------------------------
10-
# ProtocolStaking deployment
10+
# ProtocolStaking deployment and configuration
1111
# ----------------------------------------------------------------------------
1212
# Address of the underlying staking ERC20
1313
ZAMA_TOKEN_ADDRESS=0x0000000000000000000000000000000000000001
@@ -25,6 +25,10 @@ PROTOCOL_STAKING_COPRO_VERSION=1
2525
# Cooldown period in seconds before unstaked tokens can be released
2626
PROTOCOL_STAKING_COPRO_COOLDOWN_PERIOD=604800 # 7 days
2727

28+
# Initial reward rate
29+
# Note: The reward rate is in tokens (using 18 decimals) per second
30+
PROTOCOL_STAKING_COPRO_REWARD_RATE=10000000000000000
31+
2832
# ----------------------------------------------------------------------------
2933
# KMS
3034
# ----------------------------------------------------------------------------
@@ -35,8 +39,12 @@ PROTOCOL_STAKING_KMS_VERSION=1
3539
# Cooldown period in seconds before unstaked tokens can be released
3640
PROTOCOL_STAKING_KMS_COOLDOWN_PERIOD=604800 # 7 days
3741

42+
# Initial reward rate
43+
# Note: The reward rate is in tokens (using 18 decimals) per second
44+
PROTOCOL_STAKING_KMS_REWARD_RATE=10000000000000000
45+
3846
# ----------------------------------------------------------------------------
39-
# OperatorStaking deployment
47+
# OperatorStaking deployment and configuration
4048
# ----------------------------------------------------------------------------
4149
# ----------------------------------------------------------------------------
4250
# Coprocessor
@@ -49,11 +57,20 @@ OPERATOR_STAKING_COPRO_TOKEN_NAME_0="OperatorStakingCopro1"
4957
OPERATOR_STAKING_COPRO_TOKEN_SYMBOL_0="stZAMAcopro1"
5058
OPERATOR_STAKING_COPRO_OWNER_ADDRESS_0="0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" # accounts[2] (address)
5159

60+
# OperatorRewarder coprocessor 1
61+
# Initial owner fee
62+
# Note: The owner fee is in basis points (in 1/100th of a percent, so 10000 = 100.00%)
63+
OPERATOR_REWARDER_COPRO_OWNER_FEE_0=2000
64+
5265
# OperatorStaking coprocessor 2
5366
OPERATOR_STAKING_COPRO_TOKEN_NAME_1="OperatorStakingCopro2"
5467
OPERATOR_STAKING_COPRO_TOKEN_SYMBOL_1="stZAMAcopro2"
5568
OPERATOR_STAKING_COPRO_OWNER_ADDRESS_1="0x90F79bf6EB2c4f870365E785982E1f101E93b906" # accounts[3] (address)
5669

70+
# OperatorRewarder coprocessor 2
71+
# Initial owner fee
72+
# Note: The owner fee is in basis points (in 1/100th of a percent, so 10000 = 100.00%)
73+
OPERATOR_REWARDER_COPRO_OWNER_FEE_1=1000
5774

5875
# ----------------------------------------------------------------------------
5976
# KMS
@@ -66,23 +83,27 @@ OPERATOR_STAKING_KMS_TOKEN_NAME_0="OperatorStakingKms1"
6683
OPERATOR_STAKING_KMS_TOKEN_SYMBOL_0="stZAMAkms1"
6784
OPERATOR_STAKING_KMS_OWNER_ADDRESS_0="0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" # accounts[2] (address)
6885

86+
# OperatorRewarder KMS 1
87+
# Initial owner fee
88+
# Note: The owner fee is in basis points (in 1/100th of a percent, so 10000 = 100.00%)
89+
OPERATOR_REWARDER_KMS_OWNER_FEE_0=1500
90+
6991
# OperatorStaking KMS 2
7092
OPERATOR_STAKING_KMS_TOKEN_NAME_1="OperatorStakingKms2"
7193
OPERATOR_STAKING_KMS_TOKEN_SYMBOL_1="stZAMAkms2"
7294
OPERATOR_STAKING_KMS_OWNER_ADDRESS_1="0x90F79bf6EB2c4f870365E785982E1f101E93b906" # accounts[3] (address)
7395

74-
# OperatorStaking KMS 3
75-
OPERATOR_STAKING_KMS_TOKEN_NAME_1="OperatorStakingKms3"
76-
OPERATOR_STAKING_KMS_TOKEN_SYMBOL_1="stZAMAkms3"
77-
OPERATOR_STAKING_KMS_OWNER_ADDRESS_1="0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65" # accounts[4] (address)
96+
# OperatorRewarder KMS 2
97+
# Initial owner fee
98+
# Note: The owner fee is in basis points (in 1/100th of a percent, so 10000 = 100.00%)
99+
OPERATOR_REWARDER_KMS_OWNER_FEE_1=1000
78100

79-
# ----------------------------------------------------------------------------
80-
# Post-deployment configuration
81-
# ----------------------------------------------------------------------------
82-
# ProtocolStaking initial reward rate
83-
# Note: The reward rate is in tokens (using 18 decimals) per second
84-
PROTOCOL_STAKING_REWARD_RATE=10000000000000000
101+
# OperatorStaking KMS 3
102+
OPERATOR_STAKING_KMS_TOKEN_NAME_2="OperatorStakingKms3"
103+
OPERATOR_STAKING_KMS_TOKEN_SYMBOL_2="stZAMAkms3"
104+
OPERATOR_STAKING_KMS_OWNER_ADDRESS_2="0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65" # accounts[4] (address)
85105

86-
# OperatorRewarder initial owner fee
106+
# OperatorRewarder KMS 3
107+
# Initial owner fee
87108
# Note: The owner fee is in basis points (in 1/100th of a percent, so 10000 = 100.00%)
88-
OPERATOR_REWARDER_OWNER_FEE=1000
109+
OPERATOR_REWARDER_KMS_OWNER_FEE_2=500

protocol-contracts/staking/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ build/site
4242
# only used to package @openzeppelin/contracts
4343
contracts/build/
4444
contracts/README.md
45+
.openzeppelin
4546

4647
# temporary artifact from solidity-coverage
4748
allFiredEvents

protocol-contracts/staking/hardhat.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import './tasks/accounts';
22
import './tasks/addEligibleAccount';
33
import './tasks/deployment';
4+
import './tasks/deposit';
45
import './tasks/ownership';
6+
import './tasks/setOwnerFee';
57
import './tasks/setRewardRate';
68
import './tasks/verify';
79
import '@nomicfoundation/hardhat-chai-matchers';
@@ -46,7 +48,7 @@ if (accounts == null) {
4648

4749
const config: HardhatUserConfig = {
4850
solidity: {
49-
version: '0.8.29',
51+
version: '0.8.27',
5052
settings: {
5153
optimizer: {
5254
enabled: true,
@@ -56,11 +58,11 @@ const config: HardhatUserConfig = {
5658
},
5759
},
5860
networks: {
59-
'mainnet': {
61+
mainnet: {
6062
url: process.env.MAINNET_RPC_URL || '',
6163
accounts,
6264
},
63-
'testnet': {
65+
testnet: {
6466
url: process.env.SEPOLIA_RPC_URL || '',
6567
accounts,
6668
},

protocol-contracts/staking/tasks/addEligibleAccount.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getProtocolStakingKMSProxyAddress,
66
getAllOperatorStakingKMSAddresses,
77
} from './utils/getAddresses';
8+
import { wait } from './utils/time';
89
import { task, types } from 'hardhat/config';
910
import { HardhatRuntimeEnvironment } from 'hardhat/types';
1011

@@ -28,8 +29,7 @@ task('task:addOperatorAsEligibleInProtocolStaking')
2829
types.string,
2930
)
3031
.setAction(async function ({ operatorStakingAddress, protocolStakingProxyAddress }, hre: HardhatRuntimeEnvironment) {
31-
const { ethers, deployments, network, getNamedAccounts } = hre;
32-
const { log } = deployments;
32+
const { ethers, network, getNamedAccounts } = hre;
3333

3434
// Get the deployer account
3535
const { deployer } = await getNamedAccounts();
@@ -45,17 +45,23 @@ task('task:addOperatorAsEligibleInProtocolStaking')
4545
// Add the operator as eligible
4646
await protocolStaking.addEligibleAccount(operatorStakingAddress);
4747

48-
log(`Operator ${operatorStakingAddress} added as eligible in protocol staking contract at
49-
address ${protocolStakingProxyAddress} on network ${network.name}`);
48+
console.log(
49+
[
50+
`👉 Added operator as eligible:`,
51+
` - Operator staking address: ${operatorStakingAddress}`,
52+
` - Protocol staking proxy address: ${protocolStakingProxyAddress}`,
53+
` - Added by manager (deployer): ${deployer}`,
54+
` - Network: ${network.name}`,
55+
'',
56+
].join('\n'),
57+
);
5058
});
5159

5260
// Add all coprocessor operators as eligible in the coprocessor protocol staking contract
5361
// Example usage:
5462
// npx hardhat task:addAllCoproOperatorsAsEligible --network testnet
5563
task('task:addAllCoproOperatorsAsEligible').setAction(async function (_, hre: HardhatRuntimeEnvironment) {
56-
const { log } = hre.deployments;
57-
58-
log('Adding all coprocessor operators as eligible in the coprocessor protocol staking contract...');
64+
console.log('Adding all coprocessor operators as eligible in the coprocessor protocol staking contract...\n');
5965

6066
const operatorStakingAddresses = await getAllOperatorStakingCoproAddresses(hre);
6167
const protocolStakingCoproProxyAddress = await getProtocolStakingCoproProxyAddress(hre);
@@ -66,16 +72,19 @@ task('task:addAllCoproOperatorsAsEligible').setAction(async function (_, hre: Ha
6672
operatorStakingAddress,
6773
protocolStakingProxyAddress: protocolStakingCoproProxyAddress,
6874
});
75+
76+
if (i < operatorStakingAddresses.length - 1) {
77+
// Wait for 5 seconds before adding the next operator as eligible in order to avoid underpriced transaction issues
78+
await wait(5);
79+
}
6980
}
7081
});
7182

7283
// Add all KMS operators as eligible in the KMS protocol staking contract
7384
// Example usage:
7485
// npx hardhat task:addAllKMSOperatorsAsEligible --network testnet
7586
task('task:addAllKMSOperatorsAsEligible').setAction(async function (_, hre: HardhatRuntimeEnvironment) {
76-
const { log } = hre.deployments;
77-
78-
log('Adding all KMS operators as eligible in the KMS protocol staking contract...');
87+
console.log('Adding all KMS operators as eligible in the KMS protocol staking contract...\n');
7988

8089
const operatorStakingAddresses = await getAllOperatorStakingKMSAddresses(hre);
8190
const protocolStakingKmsProxyAddress = await getProtocolStakingKMSProxyAddress(hre);
@@ -85,17 +94,23 @@ task('task:addAllKMSOperatorsAsEligible').setAction(async function (_, hre: Hard
8594
operatorStakingAddress,
8695
protocolStakingProxyAddress: protocolStakingKmsProxyAddress,
8796
});
97+
98+
if (i < operatorStakingAddresses.length - 1) {
99+
// Wait for 5 seconds before adding the next operator as eligible in order to avoid underpriced transaction issues
100+
await wait(5);
101+
}
88102
}
89103
});
90104

91105
// Add all operators as eligible in the relevant protocol staking contracts (coprocessor and KMS)
92106
// Example usage:
93107
// npx hardhat task:addAllOperatorsAsEligible --network testnet
94108
task('task:addAllOperatorsAsEligible').setAction(async function (_, hre: HardhatRuntimeEnvironment) {
95-
const { log } = hre.deployments;
96-
97-
log('Adding all operators as eligible in the protocol staking contract...');
109+
console.log('Adding all operators as eligible in the protocol staking contract...\n');
98110

99111
await hre.run('task:addAllCoproOperatorsAsEligible');
112+
113+
await wait(5);
114+
100115
await hre.run('task:addAllKMSOperatorsAsEligible');
101116
});

0 commit comments

Comments
 (0)