The Magic Frog: Curator Rewards and updated Reward Distribution! (Development Update)

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@mkt·
0.000 HBD
The Magic Frog: Curator Rewards and updated Reward Distribution! (Development Update)
<center>https://the-magic-frog.com/avatar.png</center>

#### Repository
https://github.com/mktcode/the-magic-story-machine

**About the Project**
https://the-magic-frog.com
*The Magic Frog is a Bot/Website utilizing the STEEM blockchain to reward participants for collaboratively telling a story. By submitting small pieces of text, that the community can vote on everyday, the story evolves and sometimes takes quite strange, funny or interesting turns.*

*The Magic Frog is currently available in English, French and German and more languages will follow!*

# Curators were underrated!

For the success of the project I always thought it needs delegators the most. While this might be still true to a certain degree, I totally underrated the curators that give their upvotes everyday and thereby filling the pot with SBD. With more delegation the project would be more independent from those curators/upvotes and this independence is still what I want for the project but I also have to admit that since there are no really big delegations the project would not survive without all the people who support it with their daily upvotes.

Also some inspiring words from the community made me think about this and that I'm maybe missing something important here. While I was still talking to her, @helo was already working on an [endpoint for the API to fetch all the curators](https://busy.org/@helo/the-magic-frog-in-french-development-update-3-by-helo) and their respective upvote values and this actually made me realize how important that is.

Thanks to @helo the top 12 curators are now honored in the Hall of Fame on the website: https://the-magic-frog.com/hall-of-fame

**And they also get a portion of the story pot. Just like the storytellers and delegators. This is what this contribution is about.**

# Updated Reward Distribution

To sum up the reward generation very briefly: The stories are told piece by piece and everyday one such small piece is appended to the story and a new post is published. This means if a story consists of, let's say... 25 small pieces/sentences, there are 25 posts that can generate rewards. The rewards for those posts are set to 50 % SBD and 50 % SP. So half of all the rewards generated by those posts make the final story pot. So if all those 25 posts generated an overall value of 80 $, this means the value of the story pot is 40 SBD. (The rest powers up the account, resulting in even higher rewards in the future.) Those 40 SBD are then split into 4 equal pieces.

- Winning Storyteller: A random person who contributed at least on little piece/sentence to the story.
- Other Storytellers: All other people who helped telling the story, but had no luck in the final raffle.
- Delegators: Everyone who delegated SP to the respective frog account.
- Curators: Everyone who upvoted at least one of the story post.

**I just decided to publish a separate post, explaining the reward generation and distribution in detail.** Stay tuned! There's something in it for everyone!

# Implementation

It's again just this single commit:
https://github.com/mktcode/the-magic-story-machine/commit/9d0b99eeb8293c76b56a807a3856a3d19f680b45

And it's very similar to the delegators reward distribution.

https://github.com/mktcode/the-magic-story-machine/blob/master/helper.js#L87
Here I added a new method to fetch the top 100 curators. So if a story has more than 100 curators... we have a problem. But if too many curators become a problem.... that will be a good problem. For now it's ok like this.

In the main script we count the total curation (rshares) and calculate the percentage of the curator pot that each curator should get.
https://github.com/mktcode/the-magic-story-machine/blob/master/bot.js#L140

For the memo of the transfer I added those two methods:
https://github.com/mktcode/the-magic-story-machine/blob/master/helper.js#L239
https://github.com/mktcode/the-magic-story-machine/blob/master/locales.js#L114

The challenge here was to display the SBD value that a curator has contributed with his upvotes. The API (thanks again @helo) returns a list of curators for the current story, together with the total amount of rshares (reward pool shares) they contributed. So the question is how to get from rshares to SBD. This is how:
https://github.com/mktcode/the-magic-story-machine/blob/master/helper.js#L246

First you get the information about the post reward pool: `steem.api.getRewardFund('post', (err, fund) => { ...`

It contains the current reward pool size and the recent claims:

`const rewardBalance = parseFloat(fund.reward_balance.replace(' STEEM', ''));`
`const recentClaims = parseInt(fund.recent_claims);`

Then you need the current STEEM/SBD ratio:
```
steem.api.getCurrentMedianHistoryPrice((err, price) => {
   const SBDPrice = parseFloat(price.base.replace(' SBD', ''));
   ...
```

And after some brainfuck and research you come up with this:
```
// calculate SBD value for each vote
resolve(rewardBalance / recentClaims * SBDPrice);
```

The result is a factor to multiply the rshares value with, to get it's SBD representation. So in the end, you just have to do this:
https://github.com/mktcode/the-magic-story-machine/blob/master/bot.js#L154
`sbd: curator.rshares * rsharesToSBDFactor`

Simple... isn't it.

# Next Steps
- explain reward system in detail
- stability improvements
- own account creation system
- write visibility task request on Utopian
- provide "closed" versions for schools

# Contribute

If you want to help with the development of this project, contact us on Discord: https://discord.gg/6GKvTC

Or submit Pull Requests for one of the following repositories:

- The Website: https://github.com/mktcode/the-magic-frog
- The Bot: https://github.com/mktcode/the-magic-story-machine
- The API: https://github.com/mktcode/the-magic-link
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,