steemit api tutorial part 4 - Calculating the worth of a vote in SBD

in steem-dev •  7 years ago 

programming-3186084_1280.png

Hello. Long time no see. It's been a hectic week.

Part 3 link

Look at my blog of follow the trail in the posts. Like a chain. hehehe.

Today we will see how to calculate the worth of a vote, and also all the calls required to make it work.

Step one.
We will get the reward fund.

The json payload will be

{
"id":"40",
"jsonrpc":"2.0",
"method":"get_reward_fund",
"params":["post"]
}

the result will be
ss1.png

Oh my dear lord, look at the amount of steem there is to distribute. Send some here people. heheheh.
Keep this data we will need it later on.

Step 2
We have to get the price history. The witnesses publish it. One of their jobs.
The json payload for the request will be :

{
"id":"40",
"jsonrpc":"2.0",
"method":"get_feed_history",
"params":[]
}

The result is
ss2.png

The base price is what we will need from this. It is 1.936 sbd for one steem at this point in time.

Step 3

In the previous post we had got our blog and within it was this

"active_votes": [
{
"voter": "jonknight",
"weight": 32034,
"rshares": "8397346078",
"percent": 10000,
"reputation": "2536377476524",
"time": "2018-03-13T05:27:06"
}
]

We will take the rshare value from this

The formula
(rshare/recent_claims)*reward_balance

"recent_claims": "439277663884761608",
8397346078/439277663884761608 = 1.911626009785675575512706965123e-8

e-8 means that you have to take the point 8 values down for the real value. My calculator cannot show that so...

the reward_balance is 726571.332 STEEM
you have to cut out STEEM
1.911626009785675575512706965123e-8 * 726571.332 = 0.01388932656215823337420134082575
let us round that for simplicity
0.013889 STEEM.
This vote is worth 0.013889 STEEM right now.

Now multiply this with the base from feed history.

"base": "1.936 SBD"
Omit the SBD
0.013889 * 1.936 = 0.026889104

So the vote is worth 0.026889104 SBD. Now because SBD is Supposed to be pegged at 1 USD they show it as 0.02 dollars. But if you multiply it with the current SBD rate it will increase in USD value.

Awesome right.

Tomorrow we will see how to calculate the value of your vote. It may be shitty like mine. But you got to know what its worth.

Have any questions, ask them in the comments.

PS : We will be watching how much your vote is worth, so don't hold back. heheheheheeh.

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!
Sort Order:  

Hi @hispeedimagines,

I'm fairly new to Steem/Steemit (and even newer to developing for it). I came here looking for a way to calculate a user's upvote value... THANKS for that by the way!!! ... been searching high and low.

My code was working just fine for posts that haven't reached payout yet:
upvote_sbd = VOTER.rshares / POST.vote_rshares * post_value
FYI: post_value = POST.pending_payout_value.split(' ')[0]

POST.pending_payout_value = 0 after payout though, changing that to POST.total_payout_value works just fine. but...
POST.vote_rshares is also 0 after post payout :-( ...

This post has given me a way to solve that problem... assuming in your formula ( (rshare/recent_claims)*reward_balance ) that 1) recent_claims and 2) reward_balance are the same (or at least very close) to the values they were at at the time of post payout... correct?

That leads me to actually caring about the whole infamous "crypto-posting, self-voting" whale that's generating 10 posts per day and upvoting themselves with huge amounts.

The question is thus: How is "recent_claims" calculated?

i.e. is it all the post_payouts over the last X minutes/hours/days?

if so, does the likes of XYZ whale creating posts 10 times per day and self-voting/friend voting by huge amounts not increase recent_claims?
i.e. which then means that everybody else's UV value (and as a result post payout) then decreases/is less as a direct result?

or... does reward_balance also increase with every vote cast?

Hey, thank you.

For the first question:
GINAbotBOT - 03/13/2018
@jonknight has upvoted your post! ($0.032)
3uud62-steem-api-tutorial-part-1
Vote weight: 100 %
Total votes: 5
Potential payout: 0.078 SBD
Time: 2018-03-13T11:22:03
this was my notification from gina
as you see, before payout it was 0.032

and in my above calculations I have used today's value of recent claims and reward balance, it is about 0.026, so a 0.006 diff, is ok I guess,

second question:
it is approx the infinite sum I guess , or its average, not sure, of the recent rshares redeemed for steem.
Well it increases the recent claims and as you say, it will decrease everyone's upvote value. reward balance keeps increasing, I guess that happens on each block mined, it is 20 blocks a minute.

this link is helpful

can vote for vote

Wow!!!! Nothing like a bit of light reading before bed!!! 😊

I'm going to go see if I can find your intro post now too hehehe. I gotta get to know my buddy from #buddyup!!!! 😄

hello, dreemsteem, thank you, hehe , sorry have been slow, a lot of work. have fun.

heheheh yeah - i read and commented on a bunch of your posts heheheh i DID have fun :)

heheh,

Hey, great, very helpful.
Easy, just have to find out what other calls there are... Espacialy about the history of lets say the transfers of Steem or sbd to an account in a given timeframe with value and memo is what im looking forward to. Probably will find out how that works soon.