-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathe2e_non-liquid.sh
executable file
Β·478 lines (424 loc) Β· 35 KB
/
e2e_non-liquid.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#!/bin/bash
export FOUNDRY_ETH_RPC_URL=http://localhost:4201
export PRIVATE_KEY=0x$(openssl rand -hex 32)
OWNER_KEY=$PRIVATE_KEY
OWNER_ADDRESS=$(cast wallet address $OWNER_KEY)
STAKER_KEY=0x$(openssl rand -hex 32)
STAKER_ADDRESS=$(cast wallet address $STAKER_KEY)
CONTRACT_ADDRESS=$(cast compute-address $(cast wallet address $OWNER_KEY) --nonce 1 | cut -d ' ' -f 3)
COMMISSION_ADDRESS=$(cast wallet address 0x$(openssl rand -hex 32))
DEPOSIT_ADDRESS=0x00000000005a494c4445504f53495450524f5859
BLS_PUB_KEY_1=0xb27aebb3b54effd7af87c4a064a711554ee0f3f5abf56ca910b46422f2b21603bc383d42eb3b927c4c3b0b8381ca30a3
CONTROL_KEY_1=0x65d7f4da9bedc8fb79cbf6722342960bbdfb9759bc0d9e3fb4989e831ccbc227
BLS_PUB_KEY_2=0xb37fd66aef29ca78a82d519a284789d59c2bb3880698b461c6c732d094534707d50e345128db372a1e0a4c5d5c42f49c
CONTROL_KEY_2=0x62070b1a3b5b30236e43b4f1bfd617e1af7474635558314d46127a708b9d302e
BLS_PUB_KEY_3=0xab035d6cd3321c3b57d14ea09a4f3860899542d2187b5ec87649b1f40980418a096717a671cf62b73880afac252fc5dc
CONTROL_KEY_3=0x56d7a450d75c6ba2706ef71da6ca80143ec4971add9c44d7d129a12fa7d3a364
BLS_PUB_KEY_4=0x985e3a4d367cbfc966d48710806612cc00f6bfd06aa759340cfe13c3990d26a7ddde63f64468cdba5b2ff132a4639a7f
CONTROL_KEY_4=0xdb670cbff28f4b15297d03fafdab8f5303d68b7591bd59e31eaef215dd0f246a
unbonding() {
# sleep two times as many seconds as many blocks the deposit withdrawal period
# consists of to wait long enough even if there is a 2 second average block time
sleep $(cast call $DEPOSIT_ADDRESS "withdrawalPeriod()(uint256)")
sleep $(cast call $DEPOSIT_ADDRESS "withdrawalPeriod()(uint256)")
}
joining() {
# $1 = blsPubKey
# $2 = privKey
echo "π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½"
cast send --legacy --value 100ether --private-key 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast wallet address $2) 1>/dev/null
status=$(cast send --legacy --json --private-key $2 $DEPOSIT_ADDRESS "setControlAddress(bytes,address)" $1 $CONTRACT_ADDRESS | jq '.status') 1>/dev/null
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ setControlAddress($1, $(cast wallet address $2))"
else
echo "π΄ setControlAddress($1, $(cast wallet address $2))"
fi
status=$(cast send --legacy --json --private-key $OWNER_KEY $CONTRACT_ADDRESS "join(bytes,address)" $1 $(cast wallet address $2) | jq '.status') 1>/dev/null
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ join($1, $(cast wallet address $2))"
else
echo "π΄ join($1, $(cast wallet address $2))"
fi
#echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()(bool[])" | grep -o "true" | wc -l
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
echo "πΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌ"
}
leaving() {
# $1 = blsPubKey
# $2 = privKey
echo "π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½"
echo -n "π’ controller balance: " && cast to-unit $(cast balance $(cast wallet address $2)) ether
echo -n "π’ committee: " && cast call $DEPOSIT_ADDRESS "getStakersData()(bool[],uint256[],uint256[])" | tail -1 | sed 's/ \[[0-9]e[0-9][0-9]\]//g'
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
pending=$(cast call $CONTRACT_ADDRESS "pendingWithdrawals(bytes)(bool)" $1)
echo -n "π’ pending withdrawals: " && echo $pending
while [[ "$pending" == "true" ]]; do
status=$(cast send --legacy --json --private-key $2 $CONTRACT_ADDRESS "leave(bytes)" $1 | jq '.status') 1>/dev/null
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ leave($1)"
else
echo "π΄ leave($1)"
fi
echo "############################### UNBONDING ##############################"
unbonding
echo "############################### RETRYING ##############################"
count=$(cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | grep -c -o "$1")
if [[ $count -gt 0 ]]; then
pending=$(cast call $CONTRACT_ADDRESS "pendingWithdrawals(bytes)(bool)" $1)
echo -n "π’ pending withdrawals: " && echo $pending
else
pending="false"
fi
done
count=$(cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | grep -c -o "$1")
if [[ $count -gt 0 ]]; then
temp=$(cast send --legacy --gas-limit 1000000 --json --private-key $2 $CONTRACT_ADDRESS "leave(bytes)" $1)
#temp=$(cast send --legacy --json --private-key $2 $CONTRACT_ADDRESS "leave(bytes)" $1)
status=$(echo $temp | jq '.status')
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ leave($1) $(echo $temp | jq '.transactionHash')"
else
echo "π΄ leave($1) $(echo $temp | jq '.transactionHash')"
fi
fi
echo -n "π’ committee: " && cast call $DEPOSIT_ADDRESS "getStakersData()(bool[],uint256[],uint256[])" | tail -1 | sed 's/ \[[0-9]e[0-9][0-9]\]//g'
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
count=$(cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | grep -c -o "$1")
if [[ $count -gt 0 ]]; then
pending=$(cast call $CONTRACT_ADDRESS "pendingWithdrawals(bytes)(bool)" $1)
echo -n "π’ pending withdrawals: " && echo $pending
fi
echo "############################### UNBONDING DEPOSIT DECREASE / STAKE REFUND ##############################"
unbonding
count=$(cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | grep -c -o "$1")
if [[ $count -gt 0 ]]; then
echo "############################### COMPLETING ##############################"
echo -n "π’ committee: " && cast call $DEPOSIT_ADDRESS "getStakersData()(bool[],uint256[],uint256[])" | tail -1 | sed 's/ \[[0-9]e[0-9][0-9]\]//g'
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
pending=$(cast call $CONTRACT_ADDRESS "pendingWithdrawals(bytes)(bool)" $1)
echo -n "π’ pending withdrawals: " && echo $pending
temp=$(cast send --legacy --gas-limit 1000000 --json --private-key $2 $CONTRACT_ADDRESS "completeLeaving(bytes)" $1)
#temp=$(cast send --legacy --json --private-key $2 $CONTRACT_ADDRESS "completeLeaving(bytes)" $1)
status=$(echo $temp | jq '.status')
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ completeLeaving($1) $(echo $temp | jq '.transactionHash')"
else
echo "π΄ completeLeaving($1) $(echo $temp | jq '.transactionHash')"
fi
fi
status=$(cast send --legacy --json --private-key $2 $CONTRACT_ADDRESS "claim()" | jq '.status') 1>/dev/null
if [[ "$status" == "\"0x1\"" ]]; then
echo "π’ claim()"
else
echo "π΄ claim()"
fi
# sleep four times as many seconds as many blocks an epoch consists of
# to wait long enough even if there is a 2 second average block time
sleep $(cast call $DEPOSIT_ADDRESS "blocksPerEpoch()(uint64)")
sleep $(cast call $DEPOSIT_ADDRESS "blocksPerEpoch()(uint64)")
sleep $(cast call $DEPOSIT_ADDRESS "blocksPerEpoch()(uint64)")
sleep $(cast call $DEPOSIT_ADDRESS "blocksPerEpoch()(uint64)")
echo -n "π’ committee: " && cast call $DEPOSIT_ADDRESS "getStakersData()(bool[],uint256[],uint256[])" | tail -1 | sed 's/ \[[0-9]e[0-9][0-9]\]//g'
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
echo -n "π’ controller balance: " && cast to-unit $(cast balance $(cast wallet address $2)) ether
echo "πΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌ"
}
rewards() {
bc -l <<< "scale=18; \
$(cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether)+\
$(cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $CONTROL_KEY_1) | sed 's/\[[^]]*\]//g') ether)+\
$(cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $CONTROL_KEY_2) | sed 's/\[[^]]*\]//g') ether)+\
$(cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $CONTROL_KEY_3) | sed 's/\[[^]]*\]//g') ether)+\
$(cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $CONTROL_KEY_4) | sed 's/\[[^]]*\]//g') ether)\
"
}
withdraw_rewards() {
echo "π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½π½"
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ controller balance: " && cast to-unit $(cast balance $(cast wallet address $1)) ether
echo -n "π’ controller rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $1) | sed 's/\[[^]]*\]//g') ether
temp=$(forge script script/WithdrawRewards.s.sol --broadcast --legacy --sig "run(address payable, string, string)" $CONTRACT_ADDRESS all all --private-key $1 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ WithdrawRewards $(cast wallet address $1)"
else
echo "π΄ WithdrawRewards $(cast wallet address $1) $temp"
fi
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ controller balance: " && cast to-unit $(cast balance $(cast wallet address $1)) ether
echo -n "π’ controller rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $1) | sed 's/\[[^]]*\]//g') ether
echo "πΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌπΌ"
}
#: 'πͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺ
# πͺ remove # at the beginning of the line above to continue execution at the marked location πͺ
echo "############################### RESTARTING ##############################"
cd ../zq2/
docker-compose down
docker-compose up -d
cd ../delegated_staking/
errors=1
while [ $errors -gt 0 ]; do
echo "π΄ block production has not started"
sleep 5s
temp=$(cast block-number 2>&1)
errors=$(echo $temp | grep -o -i -e "error" | wc -l)
done
echo "π’ block production has started"
echo "############################### DEPLOYING ##############################"
cast send --legacy --value 100ether --private-key 0x0000000000000000000000000000000000000000000000000000000000000002 $OWNER_ADDRESS 1>/dev/null
temp=$(forge script script/Deploy.s.sol --broadcast --legacy --sig "nonLiquidDelegation()" 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Deploy nonLiquidDelegation()"
else
echo "π΄ Deploy nonLiquidDelegation() $temp"
fi
temp=$(forge script script/Configure.s.sol --broadcast --legacy --sig "commissionRate(address payable, uint16)" $CONTRACT_ADDRESS 1000 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Configure commissionRate(address payable, uint16)"
else
echo "π΄ Configure commissionRate(address payable, uint16) $temp"
fi
temp=$(forge script script/Configure.s.sol --broadcast --legacy --sig "commissionReceiver(address payable, address)" $CONTRACT_ADDRESS $COMMISSION_ADDRESS 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Configure commissionReceiver(address payable, address)"
else
echo "π΄ Configure commissionReceiver(address payable, address) $temp"
fi
echo "############################### JOINING ##############################"
echo -n "π’ committee: " && cast call $DEPOSIT_ADDRESS "getStakersData()(bool[],uint256[],uint256[])" | tail -1 | sed 's/ \[[0-9]e[0-9][0-9]\]//g'
echo -n "π’ validators: " && cast call $CONTRACT_ADDRESS "validators()((bytes,uint256,bool,bool,bool,bool)[])" | sed 's/ \[[0-9]e[0-9][0-9]\]//g' | sed 's/, true//g' | sed 's/, false//g' | sed 's/0x[0-9a-f]*,//g' | sed 's/( //g' | sed 's/)//g'
joining $BLS_PUB_KEY_1 $CONTROL_KEY_1
joining $BLS_PUB_KEY_2 $CONTROL_KEY_2
joining $BLS_PUB_KEY_3 $CONTROL_KEY_3
joining $BLS_PUB_KEY_4 $CONTROL_KEY_4
echo "############################### EARNING ##############################"
sleep 10s
echo "############################### STAKING ##############################"
cast send --legacy --value 300ether --private-key 0x0000000000000000000000000000000000000000000000000000000000000002 $STAKER_ADDRESS 1>/dev/null
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
temp=$(forge script script/Stake.s.sol --broadcast --legacy --sig "run(address payable, uint256)" $CONTRACT_ADDRESS 200000000000000000000 --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Stake"
else
echo "π΄ Stake $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
priv_key=$CONTROL_KEY_3
cast send --legacy --value 1000ether --private-key 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast wallet address $priv_key) 1>/dev/null
echo -n "π’ staker balance: " && cast to-unit $(cast balance $(cast wallet address $priv_key)) ether
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
temp=$(forge script script/Stake.s.sol --broadcast --legacy --sig "run(address payable, uint256)" $CONTRACT_ADDRESS 1000000000000000000000 --private-key $priv_key 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Stake"
else
echo "π΄ Stake $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ controller rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $(cast wallet address $priv_key) | sed 's/\[[^]]*\]//g') ether
echo -n "π’ controller delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $(cast wallet address $priv_key) | sed 's/\[[^]]*\]//g') ether
echo -n "π’ controller balance: " && cast to-unit $(cast balance $(cast wallet address $priv_key)) ether
echo "############################### EARNING ##############################"
sleep 10s
echo "############################### WITHDRAWING REWARDS ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
temp=$(forge script script/WithdrawRewards.s.sol --broadcast --legacy --sig "run(address payable, string, string)" $CONTRACT_ADDRESS all all --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ WithdrawRewards"
else
echo "π΄ WithdrawRewards $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo "############################### UNSTAKING ##############################"
temp=$(forge script script/Unstake.s.sol --broadcast --legacy --sig "run(address payable, uint256)" $CONTRACT_ADDRESS 100000000000000000000 --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Unstake"
else
echo "π΄ Unstake $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo "############################### UNBONDING ##############################"
unbonding
echo "############################### STAKING REWARDS ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
temp=$(forge script script/StakeRewards.s.sol --broadcast --legacy --sig "run(address payable)" $CONTRACT_ADDRESS --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ StakeRewards"
else
echo "π΄ StakeRewards $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo "############################### CLAIMING ##############################"
echo -n "π’ claimable: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getClaimable()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
temp=$(forge script script/Claim.s.sol --broadcast --legacy --sig "run(address payable)" $CONTRACT_ADDRESS --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Claim"
else
echo "π΄ Claim $temp"
fi
echo -n "π’ claimable: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getClaimable()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo "############################### WITHDRAWING REWARDS ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
temp=$(forge script script/WithdrawRewards.s.sol --broadcast --legacy --sig "run(address payable, string, string)" $CONTRACT_ADDRESS all all --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ WithdrawRewards"
else
echo "π΄ WithdrawRewards $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ delegated amount: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo "############################### EARNING ##############################"
sleep 10s
echo "############################### COLLECTING ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
temp=$(forge script script/CollectCommission.s.sol --broadcast --legacy --sig "run(address payable)" $CONTRACT_ADDRESS 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ CollectCommission"
else
echo "π΄ CollectCommission $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo "############################### LEAVING ##############################"
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
leaving $BLS_PUB_KEY_1 $CONTROL_KEY_1
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
leaving $BLS_PUB_KEY_2 $CONTROL_KEY_2
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
leaving $BLS_PUB_KEY_3 $CONTROL_KEY_3
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
leaving $BLS_PUB_KEY_4 $CONTROL_KEY_4
#πͺ move the line below to mark the location where execution shall continue when running the script again πͺ
#πͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺπͺ'
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total withdrawals: " && cast to-unit $(cast call $CONTRACT_ADDRESS "totalPendingWithdrawals()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo "############################### NOT EARNING ##############################"
sleep 10s
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo "############################### UNSTAKING ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
temp=$(forge script script/Unstake.s.sol --broadcast --legacy --sig "run(address payable, uint256)" $CONTRACT_ADDRESS $(cast call $CONTRACT_ADDRESS "getDelegatedAmount()(uint256)" --from $STAKER_ADDRESS) --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Unstake"
else
echo "π΄ Unstake $temp"
fi
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo "############################### UNBONDING ##############################"
unbonding
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo "############################### CLAIMING ##############################"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo -n "π’ claimable: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getClaimable()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
temp=$(forge script script/Claim.s.sol --broadcast --legacy --sig "run(address payable)" $CONTRACT_ADDRESS --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ Claim"
else
echo "π΄ Claim $temp"
fi
echo -n "π’ claimable: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getClaimable()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo -n "π’ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo "############################### WITHDRAWING REWARDS ##############################"
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
temp=$(forge script script/WithdrawRewards.s.sol --broadcast --legacy --sig "run(address payable, string, string)" $CONTRACT_ADDRESS all all --private-key $STAKER_KEY 2>&1 1>/dev/null)
errors=$(echo $temp | grep -o -i -e "error" -e "fail" -e "revert" | wc -l)
if [ $errors -eq 0 ]; then
echo "π’ WithdrawRewards"
else
echo "π΄ WithdrawRewards $temp"
fi
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π’ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ commission: " && cast to-unit $(cast balance $COMMISSION_ADDRESS) ether
echo -n "π’ staker balance: " && cast to-unit $(cast balance $STAKER_ADDRESS) ether
echo -n "π’ staker rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "rewards()(uint256)" --from $STAKER_ADDRESS | sed 's/\[[^]]*\]//g') ether
echo "############################### WITHDRAWING VALIDATOR REWARDS ##############################"
withdraw_rewards $CONTROL_KEY_1
withdraw_rewards $CONTROL_KEY_2
withdraw_rewards $CONTROL_KEY_3
withdraw_rewards $CONTROL_KEY_4
echo -n "π’ exposure: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether)+$(echo $(rewards))"
echo -n "π‘ funds: " && bc -l <<< "scale=18; $(cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether)+0.9*$(cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether)"
echo -n "π’ total delegated: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getDelegatedTotal()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π’ total deposited: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getStake()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π‘ immutable rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getImmutableRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether
echo -n "π‘ total rewards: " && cast to-unit $(cast call $CONTRACT_ADDRESS "getRewards()(uint256)" | sed 's/\[[^]]*\]//g') ether