I recently made a post about how I removed USD payout display from SteemLiberator Condenser and instead show the actual SBD and STEEM (SP) payouts. Due to the fact that it has been receiving such great support, I have decided to also release the microservice that I created to handle this function.
The reason a micro-service was created is because the application needs to keep a living history of all of the filled conversion requests to be able to properly estimate the STEEM rate at the time of payout. Instead of polluting the Condenser code base with these extra dependencies, I have created this micro-service example to keep things nice and sectioned off.
This is a microservice application used to get the actual SBD/SP payout of a given post
git clone https://github.com/SteemDevs/steem-examplescd steem-examples/javascript/steem-price-rate-historynpm installmongod --fork --logpath ./logs/mongodb.logconfig.jsnpm run setupdbnpm run start{ created: '2018-01-23T00:42:03',
promoted: '0.000 SBD',
author_rewards: '0',
total_payout_value: '0.000 SBD',
max_accepted_payout: '1000000.000 SBD',
curator_payout_value: '0.000 SBD',
percent_steem_dollars: '10000',
pending_payout_value: '2.370 SBD',
total_pending_payout_value: '0.000 STEEM' }
curl 'https://steemrate.steemliberator.com/?created=2018-01-23T00%3A42%3A03&promoted=0.000%20SBD&author_rewards=0&total_payout_value=0.000%20SBD&max_accepted_payout=1000000.000%20SBD&curator_payout_value=0.000%20SBD&percent_steem_dollars=10000&pending_payout_value=2.370%20SBD&total_pending_payout_value=0.000%20STEEM'{"payoutPending":true,"averageRate":0,"fallbackActive":true,"sbdPayout":1.185,"steemPayout":null,"curatorSteemPayout":0}
The STEEM Rate is calculated from a moving average over the payout period of the post. If you check the value of a newly created post, there likely will not be enough information to calculate this average. In this situation, the current median STEEM price is determined from the Steem API at that time.
The STEEM Rate is calculated by checking Filled Convert Requests that occured over the course of the payout period of the post. By viewing how much SBD went in and how much STEEM came out, we are able to get a very accurate estimate of the STEEM price.