[PHP WORKS] Steem upvoters new implements!! | Upvote calculation

in #utopian-io7 years ago (edited)
  • 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;

Commit #1

Commit #2

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

Sort:  

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

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

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

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.034
BTC 89118.52
ETH 3131.33
USDT 1.00
SBD 2.76