Steemit Pending Curation Rewards
utopian-io·@firedream·
0.000 HBDSteemit Pending Curation Rewards
## [Steemit Pending Curation Rewards](https://fdsteemtools.neocities.org/curation_flow.html) ### About [Pending Curation Rewards](https://fdsteemtools.neocities.org/curation_flow.html) Steemit Pending Curation Rewards is a single web-page tool that shows the potential *curation rewards* earned based on your upvotes.  With all the upvotes that are given to posts, curation rewards are earned. There were really good documents on calculation formula of curation rewards. * @YabapMatt has a [tool and a really explaining post](https://steemit.com/utopian-io/@yabapmatt/curation-reward-estimation-tool) for a single post curation estimation. This tool I used for verification of my calculations. * @miniature-tiger has a [great post](https://steemit.com/curation/@miniature-tiger/an-illustrated-guide-to-curation-from-the-simple-to-the-complex-with-real-examples-from-past-posts-part-1) on visually explaining the curation reward system. With the help of his tool, I had a deeper understanding and slightly differentiated @YabapMatt's formula to fit my code, giving exactly the same result. ### How to use Curation Flow? * Go to web-page https://fdsteemtools.neocities.org/curation_flow.html * Enter your name in the username section  * Press "Calculate" button  * You will see your curation reward pay-outs and the dates in the divs. ### Code Curation flow is using HTML and [steem.js](https://github.com/steemit/steem-js) API * Calculate the feed-price, this is used to convert SBD payments to steem. ``` // Get current feed price var feed; var the_voter; steem.api.getFeedHistory(function(err, result) { var feed_arr = result.current_median_history.base; feed = feed_arr.split(" ")[0]; }); ``` * Get all the posts the user has voted and eliminate the ones that are older than 7 days. ``` var aut = []; var perm = []; var post_date = []; // Get all the post data that user have upvoted steem.api.getAccountVotes(the_voter, function(err, result) { // Calculate the current time as UTC since post dates are in UTC var now = new Date(); var nowUtc = new Date(now.getTime() + (now.getTimezoneOffset() * 60000)); // Convert UTC date to timestamp var now_stamp = now.getTime(); var nowUtc_stamp = nowUtc.getTime(); // Put variable to check -7 days var limit = nowUtc_stamp - 24 * 60 * 60 * 1000 * 7 for (let i = 0; i < result.length; i++) { // convert post date to timestamp var ptime = Date.parse(result[i].time); post_date.push(ptime); // Disregard if it is a downvote or if the post is older than exactly 7 days if ((result[i].rshares > 0) && (ptime >= limit)) { // form the arrays with information of suitable posts aut.push((result[i].authorperm).split("/")[0]); perm.push((result[i].authorperm).split("/")[1]); } } get_content(aut, perm, limit); }); } ``` * Get the content of the posts that are upvoted ``` // This function forms the content array according to the voted posts function get_content(aut, per, limit) { var result_array = []; var count = 0; for (let i = 0; i < aut.length; i++) { // get the content for each author and permlink steem.api.getContent(aut[i], per[i], function(err, result) { var p_date = result.created; var p_date_stamp = Date.parse(p_date); // check if the post or comment is new < 7 days if (p_date_stamp > limit) { // if fresh, fill the arrays result_array.push(result); } // check if the async function got all the results // if OK, send results for calculation count++; if (count > aut.length - 1) { calculate(result_array); } }); } } ``` * Calculate the curation rewards ``` // function for calculation of curation rewards function calculate(result) { var votes = [] var sbd_pay = []; var ratio; var before; var now; var p_date; var p_date_parsed; var v_date; var v_date_parsed; var penalty; var sbd_arr; var sbd; var tot_share; var temp; var vote = []; var netshares = []; var author = []; var permlink = []; var postdate = []; for (let i = 0; i < result.length; i++) { before = 0; // get the active votes vote = result[i].active_votes; // sort the votes according to vote time vote.sort(compare); votes.push(vote); for (let j = 0; j < vote.length; j++) { tot_share = parseInt(result[i].net_rshares); now = before + parseInt(vote[j].rshares); // if the current total rshares is negative due to downvotes it must be equal to zero! if (now < 0) { now = 0; } // make the calculation when user is the voter if (vote[j].voter == the_voter) { // formula of curation reward calculation ratio = (Math.sqrt(now) - Math.sqrt(before)) / (Math.sqrt(tot_share)); p_date = result[i].created; p_date_parsed = Date.parse(p_date); v_date = vote[j].time; v_date_parsed = Date.parse(v_date); // calculate the ratio if the post is voted before 30 minutes penalty = (v_date_parsed - p_date_parsed) / (30 * 60 * 1000); if (penalty >= 1) { penalty = 1; } sbd_arr = result[i].pending_payout_value; sbd = sbd_arr.split(" ")[0]; // if the post is a total downvote, no pay-out if (parseInt(result[i].net_rshares) < 0) { sbd_pay.push(0); } // calculate the SP payment if (parseInt(result[i].net_rshares) >= 0) { sbd_pay.push((sbd * 0.25 * ratio * penalty) / feed); } } before = now; // no need for this, extra security! if (before < 0) { before = 0; } } // form the arrays netshares.push(parseInt(result[i].net_rshares));//this array is not used, just for check! author.push(result[i].author); var str = "https://steemit.com/@" + result[i].author + "/" + result[i].permlink; var lin = (result[i].permlink).substring(0, 70) + "......."; permlink.push(lin.link(str)); postdate.push(result[i].cashout_time); } // send all to final function to be written in DIV final(permlink, sbd_pay, postdate); } ``` It is the sqrt formula that calculates the curation rewards Ratio of reward ``` ratio = (Math.sqrt(now) - Math.sqrt(before)) / (Math.sqrt(tot_share));``` The penalty for voting before 30 mins ```penalty = (v_date_parsed - p_date_parsed) / (30 * 60 * 1000);``` The full code can be found [here](https://github.com/firedreamgames/steem_curation_flow/blob/master/curation_flow.html) ### Connect @FireDream - Steemit @firedream#3528 - Discord ### Links Curation flow tool : https://fdsteemtools.neocities.org/curation_flow.html GitHub: https://github.com/firedreamgames/steem_curation_flow ### Proof of work 
👍 firedream, ipumba, yabapmatt, untapentuoreja, steembasicincome, boyasyie, zulfikarkamui, itasteemit, muadzis, al-abdallah, maimunsteemit, afdalsteemit, cutyusra, penjahit, muhammadabdallah, diligentboy, ziadsteemit, gardeniazz, zianzolla, rajeszulfakar, amaroftheking, david007, edam007, beurgek01, angelaladiba, kamalsaputra, marsyudin, holger80, duncankrista12, soekie, transisto, diezeldiddy, schoolofminnows, knoxman, trollogy, ausbitbank, kowinnhtunn, steemchessboard, sasha-lee1678, risemultiversity, margate, mfethu, hobopunks, resteemable, gktown, resources, decentric, rockyridge, cryptocupcake, sweetjoy, merrycrab, forballies, fruitjuice, schooloffreeride, drakos, waarheid, dungeonmaster, hillhunters, strayanimals, plantl, moonlightmining, mahala, plantlovers, usidame, steemrollmix, goodbadandugly, africansafaris, intshebe, remora, buddhaboy, omargalk, sheilamae, zzulhas, vampstakes, pixiefire, damon9, aunglat99, saintjames, mhmetu, gonetroppo, highhorse, growroomsa, omravi, streetsurfer, kettle, steelrage, anjacolleen, tombdbad, cryptotours, emeraldearth, ali2star, zacanarchy143, martinbuilds, heclgang, hispeedimagins, jtomes123, woe-is-meme, xomemes, obvious, lulafleur, corazen, lifeofroman, tineschreibt, xers, k3ldo, tonkatonka, rlt47, tooxaj, snackaholic, zynatrix, flugschwein, utopian-1up, dyancuex, helo, mahdiyari, ronimm, simonluisi, thinkkniht, jesdn16, stoodkev, luisrod, ansonoxy, eastmael, jamesbarraclough, espoem, moorkedi, kslo, nathalie13, not-a-bird, bitopia, jutdagut, evilest-fiend, navx, family.app, varja, maphics, sebastiengllmt, phgnomo, zlatkamrs, amosbastian, proffgodswill, sweeverdev, kodeblacc, jerybanfield, rhotimee, deejee, rsteem, yeswanth, exploreand, photohunter1, photohunter3, photohunter4, photohunter5, howtosteem, roj, criptokingko, flinter, opulence, dexter24, pepememes, minersean, ilyastarar, flauwy, jfuenmayor96, instantania.cat, harshallele, xtramedium, dakeshi, smafey, gotgame, zulfan88, steaknsteem, kimaben, eleonardo, checkthisout, handfree42, ilovekrys, not-a-cat, carsonroscoe, mountainjewel, xplore, layanmarissa, kekegist, jayboss, solomon507, patatesyiyen, naturallife, onin91, isabella394, emailbox19149, videosteemit, organicgardener, saifannur-mzy, petvalbra, hmctrasher, livsky, aderemi01, killbill73, amirdesaingrafis, fai.zul, aliyu-s, muratti, maribelanzola, pixelproperty, carlitojoshua, donjyde, crispycoinboys, bluestorm, daszod, jayo, sugandhaseth, knot, ahmad097, lsanek, lykia, realness, musicbot, flugbot, ernoldlvb, kryptogermany, gydronium, clevershovel, nazmulrana, truthtrader, gnaimul, niouton, wave.beads, editorspicks, syahrin, cryptocopy, artsyunicorn, femidada, steemit-username, oezixxx, ongolodesire, thabiggdogg, minnowboosted, kuttmoped, wise-confucius, flag-haejin, haejin-sucks, steemit-abuse, born2crypto, cute-teen, frieder, rancho-relaxo, xbox-gamer, downtempo, special-agent, ewuoso, esme-svh, biplob12, murad06, odesanya, camillius, used-lessboy, kaell, hendragunawan, toninux, soydandan, wealth4good, odibezeking, lauraesfeliz, mrmaracucho, michelios, jdc, devilonwheels, abbyrich, solpaman, steemassistant, emotionalsea, bargolis, phasma, carloniere, steemitcanarias, armandofd, jramirezviera, saksham, techmojo, isaganicabrales, idlebright, adhew, shenoy, thescholarlyowl, jrmiller87, kaking, gwapoaller, khairulfahmi92, kilianparadise, cauac, arcjen02, mikefrancis, polbot, utopian-io, enchantedspirit, hometownhero, felipejoys, novogel, soleto, theinbox, jrawsthorne, tibra,