Steem Observatory update - Votes list, toggle reblogs, display steem power & time until post payout

in steemobservatory •  7 years ago 

I’ve released the first very early version of Steem Observatory two days ago, a little Steem statistics app I’m developing right now with ClojureScript & Reagent (announcement post). It’s in very early stages so don’t rely on the data that it displays just yet.

I’ve added a few new features over the last two days. Three small ones, and one bigger feature.

Screenshot-2017-11-12 http localhost(2).png

New features

  • Toggle display of reblogs (resteems)
  • Shows the account’s Steem Power
  • Shows time left until payout on posts
  • Shows list of votes a post received

The last one is the bigger feature in this update. When you click on the big circle with the number of votes a post received, it splits the window in two and displays a list of all the votes a post has received on the right, ordered by how much money the votes are worth (which is also the order in which Steemit displays the votes, didn’t know that before working on this!). This can be handy to see where most of your income on Steem is coming from.

It shows you the username, the time the vote was made, and possibly most interestingly, how much each vote is worth in Steem Dollars. The worth in Steem Dollars display only works for posts that are still active (haven’t been paid out after 7 days), for older posts I haven’t found out how to calculate that yet.

Adding the display of an account’s Steem Power was interesting, not just as a programmer but as a Steem user in general, since I learned something new about Steem while doing it. Steem Power doesn’t really exist, it’s an abstraction of a concept called vesting shares. The abstraction makes it more usable and friendlier for humans since the actual behind the scenes numbers to calculate this are really big and wouldn’t mean much to you as a Steem user. I explain the details below in the tech details section of this article if you’re interested.

Technical details for the programmers here

Keep in mind I’m learning while doing here, so don’t assume this is 100% correct and please do correct me if I’m wrong and you know better, the help is much appreciated!

Calculating Steem Power

The dsteem API I’m using to contact the Steem network has a method called getDynamicGlobalProperties which returns an object with a lot of information about the global Steem network. Two fields of that object are important for this calculation, total_vesting_fund_steem and total_vesting_shares.

getAccounts([“username”]) returns information about a user on Steem. We need the field vesting_shares from that.

Now we just need to do:

vesting_shares * (total_vesting_fund_steem / total_vesting_shares)

I use JavaScript’s .toFixed(3) method on the result to round it to the third decimal place, just like Steemit does it.

Showing time until post payout

I’m using moment.js for this, I tried timeago.js before but moment is better, it’s an allround JavaScript date/time tool, it also handles different timezones and displays the relative time the same way Steemit does. Timeago is more accurate, but the moment/Steemit way sounds more correct to a human. Hard to explain!

Showing list of votes ordered by worth, calculating Steem Dollar value of vote

The interesting bit here is probably how you order by the most valuable votes and how you calculate their worth in Steem Dollars. For both of these, the rshares field of the post’s active_votes field, which is a list of votes, is needed.

To sort by the most valuable votes, you just sort by the highest rshares value.

Now to calculate the worth in Steem Dollar of a vote, you also need the post’s net_rshares field and the post’s pending_payout_value. The net_rshares field is reset to 0 once a post’s rewards have been paid out, so this only works for posts less than 7 days old. There might be a better way to do this that also works for older posts, but I haven’t figured it out yet.

Anyhow, to calculate the Steem Dollar value I’m doing:

pending_payout_value * (rshares / net_rshares)

Hope this helps some other developers here. Until next time, cheers! ;)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!