Steem for script kiddies: Top N pending powerdowns
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.
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 STEEMFri 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 STEEMFri 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 STEEMFri 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 STEEMFri 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 STEEMFri 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 STEEMFri 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 STEEMFri 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. ; -)
Nice! I don't think many people deal with sh-scripts any more, do they?
The task was really not that difficult :-) Fortunately, you have already filtered out the account. :-)
Yeah, I don't know how common shell scripting is these days. It's still my "go to" when I want something fast though. I got stalled on the java stuff a while back because of time constraints, and today when I went to open my projects back up, the IDE was all messed up for some unknown reason. So instead of doing something productive, I'm uninstalling and reinstalling netbeans. Meanwhile, "vi" and "bash" are just always ready. ;-)
If you're coding all the time, the more advanced programming environment is nice, but as a hobbyist, it can sometimes be more of a hindrance than a help.
Right. It's already published on the blockchain, but for some reason it still feels like I shouldn't be publishing the account names in a post.
Right! I prefer "nano", but basically you're right.
That is annoying, of course.
I only use vscode now. With extensions, you can also use it for any language and no longer need a special development environment. So I can do Python, Javascript and everything for html pages in one environment.
That depends on the purpose, of course. For your weekly statistics, for example, I don't think the accounts are needed. But maybe you need them some day... :-)
I've never tried vscode, but I've seen others who use it, too. I should probably try it out one of these days.
I did not know about this , I will keep it in mind , thanks for your interesting post