[PHP WORKS] Steem upvoters new implements!! | Upvote calculation
- What feature(s) did you add?
Upvoters total upvote value
Given upvote to your latest post by upvoter's
- How did you implement it/them?
First, let me adress you the commits;
2 new files under /modules folder added. One of them is "reputationcalculator.php". I had carried the lines in a different place to make project more flexible/reachable/understandable by others. New file which named "upvalue.php" for to calculate upvote value based on "vests".
What i have done there ?
I had needed a lot of API endpoints. Thus, i gather all required datas to get a result of upvote values.
To do the calculation, i got the data from steemconnect. "recent_claims" and "reward_funds".
$reward_info = 'https://api.steemjs.com/get_reward_fund?name=post';
$content_fund = file_get_contents($reward_info);
$json_fund = json_decode($content_fund, true);
$recent_claims = $json_fund['recent_claims'];
$reward_fund = floatval($json_fund['reward_balance']);
Then i needed to get price of SBD.
// get feed history //
$sbd_feed = 'https://api.steemjs.com/get_feed_history';
$content_feed = file_get_contents($sbd_feed);
$json_feed = json_decode($content_feed, true);
// Get sbd price on steemit base //
$sbd_price = $json_feed['current_median_history']['base'];
$sbd_price = floatval($sbd_price);
// get steem price on steemit base //
$steem_price = $json_feed['current_median_history']['quote'];
$steem_price = floatval($steem_price);
// in anycase if something change (this part is useless) //
$price_last = $sbd_price / $steem_price;
Yet, those datas were just a numbers without a single meaning on user side. Had to do couple of calculations to find out real value of upvotes.
$upvote_value = $author_details['user']['vesting_shares'];
$upvote_value = floatval($upvote_value);
$upvote_value = $upvote_value * 1000000;
$upvote_value = $upvote_value * 0.02;
$upvote_value = $upvote_value / $recent_claims;
$upvote_value = $upvote_value * $reward_fund;
$upvote_value = $upvote_value * $price_last;
$upvote_value = round($upvote_value, 2);
I might gather all in one function but i love to see clean and clear steps even if it means that i will spend my time more than as it should be.
Before and after
Next step
- New formula to see the result of their upvote by currencies ( USD, EURO etc)
- New input to see the result for specific post.
- How many SBD and SP will be gained per upvoter.
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey @vladimir-simovic, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
Güzel bir çalışma olmuş. Ben beğendim ve kullandım düzgünce çalışıyor.
Teşekkür ederim @ozanyaman.
Hey @omeratagun I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x