Last active
March 26, 2021 20:41
-
-
Save novy4/83efb35cfe133cccd52fa8c8c0e5ba2d to your computer and use it in GitHub Desktop.
Bitsong Redelegate Rewards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SELF_ADDR="" | |
OPERATOR="" | |
WALLET_NAME="" | |
NODE="tcp://localhost:26657" | |
WALLET_PWD="" | |
BIN_FILE="/usr/local/bin/bitsongcli" | |
COIN="ubtsg" | |
CHAIN_ID="bitsong-1" | |
KEEPONWALLET=3010000 | |
while true; do | |
# withdraw reward | |
echo -e "$WALLET_PWD\n$WALLET_PWD\n" | $BIN_FILE tx distribution withdraw-rewards $OPERATOR --commission --chain-id $CHAIN_ID --from $WALLET_NAME -y --node $NODE | |
sleep 10 | |
# check current balance | |
BALANCE=$($BIN_FILE query account $SELF_ADDR --chain-id $CHAIN_ID -o json | jq -r .value.coins[0].amount | tr -d '"' ) | |
echo . | |
echo CURRENT BALANCE IS: $BALANCE | |
echo . | |
if (( $BALANCE > 4000000 ));then | |
#BALANCE=$(expr $BALANCE - 500000) | |
#echo BALANCE AFTER FEES: $BALANCE | |
PERMITED=$((BALANCE-KEEPONWALLET)) | |
PERMITED+=$COIN | |
echo . | |
echo "Let's delegate $PERMITED of REWARD tokens to $SELF_ADDR" | |
echo . | |
# delegate balance | |
echo -e "$WALLET_PWD\n$WALLET_PWD\n" | $BIN_FILE tx staking delegate $OPERATOR $PERMITED --chain-id $CHAIN_ID --from $WALLET_NAME -y --node $NODE | |
else | |
echo . | |
echo "Reward is less than $BALANCE $COIN" | |
fi | |
#loop | |
echo 'NEXT CHECK IN 1 hour' | |
sleep 3600 #1 hour for MainNet | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment