Skip to content

Instantly share code, notes, and snippets.

@andy108369
Last active December 2, 2022 14:59
Show Gist options
  • Save andy108369/74ed66855fd2bd5d4771b7d1d70b9714 to your computer and use it in GitHub Desktop.
Save andy108369/74ed66855fd2bd5d4771b7d1d70b9714 to your computer and use it in GitHub Desktop.
# For Sifchain
export SIFNODED_NODE=http://rpc.sifchain.finance:80
BIN=sifnoded
TOKEN=rowan
DP=18

# For Akash just uncomment these:
#export AKASH_NODE=https://rpc.akash.forbole.com:443
#BIN=akash
#TOKEN=uakt
#DP=6

# TS - Total Supply
TS=$($BIN query bank total -o json --page 1 --limit 10000 | jq -r '.supply[] | select(.denom == "'$TOKEN'") | .amount')
echo "Total Supply: $(echo "scale=0; $TS/10^$DP" | bc -l)"

# MI - Mint Inflation
MI=$($BIN query mint inflation)
##MI_GEN=$(curl -s $SIFNODED_NODE/genesis | jq -r '.result.genesis | .app_state.mint.minter.inflation')
echo "Mint Inflation: $(echo "scale=2;($MI*100)/1" | bc -l)%"

# AP - Annual Provisions
##AP=$($BIN query mint annual-provisions)
#AP=$(echo "$TS*$MI" | bc -l)

# TD - Total Delegated
##TD=$($BIN query staking validators -o json --page 1 --limit 5000 | jq -r '.validators[] | select(.status == "BOND_STATUS_BONDED") | .tokens' | xargs echo | tr ' ' '+' | bc -l)
TD=$($BIN query staking pool -o json | jq -r '.bonded_tokens')
echo "Total bonded: $(echo "scale=0; $TD/10^18" | bc -l)"

# CT - Community Tax
CT=$($BIN query distribution params -o json | jq -r '.community_tax')
echo "Community Tax: $(echo "scale=2;($CT*100)/1" | bc -l)%"

# BTR - Bonded Tokens Ratio
BTR=$(echo "$TD / $TS" | bc -l)
echo "Bonded tokens ratio: $(echo "scale=2;($BTR*100)/1" | bc -l)%"

APR=$(echo "(($MI * (1-$CT))/$BTR)*100" | bc -l)
echo "APR: $APR"

APR_C=$(echo "($MI * (1-($CT+0.05))/$BTR)*100" | bc -l)
APR=$APR_C
echo "APR after 5% commission to validator: $APR"



# set SHIFT to 1 day ago in blocks, assuming that block time is 6 seconds sharp
SHIFT=$(echo "(60/6)*60*24*1" | bc)

HEIGHT=$($BIN status |& jq -r '.SyncInfo.latest_block_height')

T1="$($BIN query block $HEIGHT | jq -r '.block.header.time')"
T2="$($BIN query block $((HEIGHT-SHIFT)) | jq -r '.block.header.time')"

T1s=$(date +%s%N -d "$T1")
T2s=$(date +%s%N -d "$T2")


AVG_BT=$(echo "(($T1s-$T2s)/$SHIFT)/10^9" | bc -l)
echo "Average Block Time: $AVG_BT"

# say you delegate 1mil tokens
STAKE=1000000
echo "For delegating: $STAKE tokens"

echo -n "Earning every block: "
echo "($STAKE * ($APR / 100 / (365 * 24 * 60 * (60/$AVG_BT))))" | bc -l

echo -n "Earning every minute: "
echo "($STAKE * ($APR / 100 / (365 * 24 * 60)))" | bc -l

echo -n "Earning every hour: "
echo "($STAKE * ($APR / 100 / (365 * 24)))" | bc -l

echo -n "Earning every day: "
echo "($STAKE * ($APR / 100 / 365))" | bc -l

echo -n "Earning every month: "
echo "($STAKE * ($APR / 100 / 12))" | bc -l

Output

Total Supply: 3065168600
Mint Inflation: 38.50%
Total bonded: 1098094781
Community Tax: 80.50%
Bonded tokens ratio: 35.82%
APR: 20.95607195995965836700
APR after 5% commission to validator: 15.58272017535461776000
Average Block Time: 6.00701440953263888888
For delegating: 1000000 tokens
Earning every block: .02968214885625000000
Earning every minute: .29647488918102000000
Earning every hour: 17.78849335086143000000
Earning every day: 426.92384042067445000000
Earning every month: 12985.60014612884813000000

Refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment