New to Nutbox?

Steem for script kiddies: Top N pending powerdowns

5 comments

remlaps-lite
76
3 years agoSteemit3 min read

Just for fun, I slapped together a little toy bash script tonight to pull down the top pending power-downs for the following week. It runs from the linux command line and has been tested in ubuntu and OpenSUSE, including ubuntu under WSL.

image.png

Pixabay license, source

By default, it shows the top 5 pending powerdowns from each day. To show a different number, just run with the preferred number as the first command line argument.

Note that curl, jq, and perl are required.


#!/bin/bash

N=${1:-5}

VESTING_FUND_STEEM=$(curl -s --data '{"jsonrpc":"2.0", "method":"condenser_api.get_dynamic_global_properties", "params":[], "id":1}' https://api.steemit.com | jq -Scr '.result | ( .total_vesting_fund_steem )' | awk '{print $1}')
VESTING_FUND_VESTS=$(curl -s --data '{"jsonrpc":"2.0", "method":"condenser_api.get_dynamic_global_properties", "params":[], "id":1}' https://api.steemit.com | jq -Scr '.result | ( .total_vesting_shares )' | awk '{print $1}')
STEEM_PER_MVEST=$(perl -e "print ${VESTING_FUND_STEEM} / (1000000 * ${VESTING_FUND_VESTS})")

for DAYS in 0 1 2 3 4 5 6 7
do
   date
   PDOWN_DATE=$(date -d "+${DAYS} days" +%Y-%m-%d)
   CMD='{"jsonrpc":"2.0", "method":"database_api.list_accounts", "params": {"start":["'${PDOWN_DATE}'T00:00:00", ""], "limit":1000, "order":"by_next_vesting_withdrawal"}, "id":1}'
   echo "Looking for powerdowns on ${PDOWN_DATE}"
   echo ----
   curl -s --data "${CMD}" https://api.steemit.com| \
      jq -Sc '.result[][] | {name, next_vesting_withdrawal, vesting_withdraw_rate}' | \
      egrep "${PDOWN_DATE}" | \
      awk -F, '{print $1" "$2" "$3" "$5 "--- " $4}'  | \
      sed 's/ \"precis.*//g' | \
      sed 's/\"//g' | \
      sed 's/.*name://g' | \
      sed 's/next.*withdrawal://g' | \
      sed 's/vest.*amount:/ /g' | \
      awk '{print $NF" "$2" "$1}' | \
      sort +0 -1nr | \
      awk '{print $2 " - " $1 " VESTS, " '${STEEM_PER_MVEST}' * $1" STEEM"}' | \
      head -${N}
      echo ; echo
done

exit

And here's some sample output:

$ ./topPd.sh 3
Fri May 6 07:45:30 PM EDT 2022
Looking for powerdowns on 2022-05-06


2022-05-06T23:57:45 - 55842548183 VESTS, 30.6799 STEEM
2022-05-06T23:56:21 - 25262709500 VESTS, 13.8793 STEEM

Fri May 6 07:45:31 PM EDT 2022
Looking for powerdowns on 2022-05-07


2022-05-07T16:42:09 - 13776765241354 VESTS, 7568.95 STEEM
2022-05-07T01:09:48 - 2276495606494 VESTS, 1250.71 STEEM
2022-05-07T04:33:42 - 1928968646580 VESTS, 1059.78 STEEM

Fri May 6 07:45:32 PM EDT 2022
Looking for powerdowns on 2022-05-08


2022-05-08T16:02:51 - 272898561077682 VESTS, 149930 STEEM
2022-05-08T15:34:33 - 18134861822825 VESTS, 9963.29 STEEM
2022-05-08T10:39:12 - 9110132863205 VESTS, 5005.11 STEEM

Fri May 6 07:45:32 PM EDT 2022
Looking for powerdowns on 2022-05-09


2022-05-09T03:39:36 - 27418822710312 VESTS, 15063.9 STEEM
2022-05-09T07:15:33 - 12108897817505 VESTS, 6652.63 STEEM
2022-05-09T00:54:06 - 9114884043078 VESTS, 5007.72 STEEM

Fri May 6 07:45:33 PM EDT 2022
Looking for powerdowns on 2022-05-10


2022-05-10T01:54:24 - 8393906036416 VESTS, 4611.61 STEEM
2022-05-10T03:28:48 - 5686210657619 VESTS, 3124 STEEM
2022-05-10T03:28:27 - 5601953742528 VESTS, 3077.71 STEEM

Fri May 6 07:45:34 PM EDT 2022
Looking for powerdowns on 2022-05-11


2022-05-11T00:51:33 - 121315538772036 VESTS, 66650.8 STEEM
2022-05-11T11:21:09 - 32121262388259 VESTS, 17647.4 STEEM
2022-05-11T03:58:12 - 14183777709627 VESTS, 7792.57 STEEM

Fri May 6 07:45:35 PM EDT 2022
Looking for powerdowns on 2022-05-12


2022-05-12T10:23:45 - 236482207773807 VESTS, 129923 STEEM
2022-05-12T10:28:48 - 135473453158428 VESTS, 74429.1 STEEM
2022-05-12T03:17:24 - 91022194131026 VESTS, 50007.6 STEEM

Fri May 6 07:45:36 PM EDT 2022
Looking for powerdowns on 2022-05-13


2022-05-13T02:14:27 - 8833484886240 VESTS, 4853.12 STEEM
2022-05-13T02:32:42 - 5931608199279 VESTS, 3258.83 STEEM
2022-05-13T15:40:36 - 4558341353901 VESTS, 2504.35 STEEM

How to add the account name is left as a simple exercise for the reader. ; -)

Comments

Sort byBest