-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautostaking_stratos.sh
More file actions
44 lines (44 loc) · 2.07 KB
/
autostaking_stratos.sh
File metadata and controls
44 lines (44 loc) · 2.07 KB
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
#!/bin/bash
GREEN_COLOR='\033[0;32m'
RED_COLOR='\033[0;31m'
WITHOU_COLOR='\033[0m'
DELEGATOR_ADDRESS='st1thzvl...'
VALIDATOR_ADDRESS='stvaloper1...'
DELAY=3600/4 #in secs - how often restart the script
ACC_NAME=name_wallet
NODE="tcp://localhost:26657" #change it only if you use another rpc port of your node
CHAIN_NAME=tropos-1
project=stchaincli
coin=ustos
for (( ;; )); do
echo -e "Get reward from Delegation"
${project} tx distribution withdraw-rewards ${VALIDATOR_ADDRESS} --chain-id ${CHAIN_NAME} --from ${DELEGATOR_ADDRESS} --gas=auto --fees=1000${coin} --commission --node ${NODE} --keyring-backend test --yes
for (( timer=30; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOUT_COLOR} sec\r" $timer
sleep 1
done
BAL=$(${project} query account ${DELEGATOR_ADDRESS} -o json | jq -r '.value | .coins | .[].amount')
echo -e "BALANCE: ${GREEN_COLOR}${BAL}${WITHOU_COLOR} ${coin}\n"
echo -e "Claim rewards\n"
${project} tx distribution withdraw-all-rewards --from ${DELEGATOR_ADDRESS} --chain-id ${CHAIN_NAME} --gas=auto --fees=1000${coin} --keyring-backend test --yes
for (( timer=30; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
sleep 1
done
BAL=$(${project} query account ${DELEGATOR_ADDRESS} -o json | jq -r '.value | .coins | .[].amount');
BAL=$(($BAL-1000000))
echo -e "BALANCE: ${GREEN_COLOR}${BAL}${WITHOU_COLOR} ${coin}\n"
echo -e "Stake ALL\n"
if (( BAL > 1000000 )); then
${project} tx staking delegate ${VALIDATOR_ADDRESS} ${BAL}${coin} --from ${DELEGATOR_ADDRESS} --gas=auto --fees=1000${coin} --node ${NODE} --chain-id ${CHAIN_NAME} --keyring-backend test --yes
else
echo -e "BALANCE: ${GREEN_COLOR}${BAL}${WITHOU_COLOR} ${coin} BAL < 10000000 ((((\n"
fi
for (( timer=${DELAY}; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
sleep 1
done
done