[KnackSteem API] - Delegators tokens distribution bot + Curation bot (voting + commenting + KNT distribution)steemCreated with Sketch.

in #utopian-io6 years ago

Repository & Pull Requests


https://github.com/knacksteem/knacksteem-api
https://github.com/knacksteem/knacksteem-api/pull/22


What is KnackSteem?


Knacksteem is an open source platform on the Steem blockchain that seeks to reward talents on a much broader scale, which eradicates partiality, and infuses transparency, on the blockchain. The initial goal of Steemit, which was to reward quality content was defeated in the sense that, creators of absolutely great content weren't recognized, and really cool talents were ignored. This major problem was the bane that stirred up the idea, creation, and finally, the development of Knacksteem. Talents and skills would never go unrecognized and unrewarded. The organization of Knacksteem makes this possible.

Source: https://steemit.com/knacksteem/@harry-heightz/knacksteem-the-new-den-of-talents-on-steem-blockchaingeneral-overview-and-personal-opinions-ideas-id-7dya4bjgagg


Screen Shot 2019-01-27 at 10.07.22 PM.png

High-level details of the work done


In this pull request, I completed the integration of a delegators' tokens distribution bot and a curation bot which includes voting based in a given weight, commenting, and assignation of the corresponding knack tokens per contribution.

The delegators' tokens distribution bot is scheduled to run every day at 12PM server time. In order to avoid missing a delegator, before the tokens distribution, the delegators are sync with our database to ensure that we have a user created for the delegator.

The formula used to determine daily rewards for delegators is given as the following:

(delegated amount * max daily rewards) / total delegated to knacksteem

For example, I am delegating 2,577.818 Steem, Knacksteem has 6,444.486 Steem delegated, and the max rewards per day is 100,000. Thus, I should receive the following daily amount (only if total delegation does not change):

(2,577.818 * 100000) / 6,444.486 = 40000.3678863609 KNT

On the other hand, the curation bot is scheduled based on the remaining time to reach 100% voting power. When the server first run, the curation bot is triggered. If the voting power is not 100%, it will calculate how long it will take to reach 100% and will schedule the next run for the given time. If the voting power is 100% but the queue is empty, the voting round is postponed to one hour later and so forth until there are posts into the queue.

Before taking action in a post, the usage is calculated and we determine if this action will lower our voting power below 80.0%. If so, the voting round is postponed until voting power is 100% again.

Voting power recharges at a rate of 20% per 24 hours. So, from 0% to 100% it will take exactly 5 days to reach full capacity. 5 days is equivalent to 432000 seconds. Given this data, to determine fill rate per hour, we just need to drop 2 zeros from the 5 days in seconds time. Thus, voting power recharges 1% every 4320 seconds which is 1.2 hours. If we reverse back, 1.2 * 20 gives 24 which is the actual hours to reach 20%.

Given the explanation above, we can say that the following formula will give the remaining time to refill voting power in seconds:

((100 - currentVp) * 4320)

Another way to calculate the remaining time is by taking percentages in hours. To reach 100% from 0% it takes 5 days which is 120 hours. If our current voting power is 95%, we just need to take the 95% of 120 and subtract it from 120. For example:

95% of 120 is 114.
120 - 114 = 6 hours to reach 100%

which gives the following formula:

120 - (N% of 120) = remaining time in hours

If we compare both formulas, they yield to the same results:

120 - (95% of 120) = 6hrs
((100 - 95) * 4320) = 21600s = 6hrs

In brief, here are the steps that the curation bot takes:

  • Check voting power
  • If 100%, query pending post queue, else calculate remaining time and re-schedule
  • Vote post
  • Comment post
  • Distribute KNT tokens to the user
  • Delete post from the queue
  • Calculate next curation round and re-schedule

And the delegators' tokens distribution bot takes the following step:

  • Sync delegators
  • Convert from vesting shares to Steem
  • Calculate total delegations to KnackSteem
  • Calculate rewards
  • Give rewards to delegators

Want to learn more about KnackSteem?


Visit the following posts:

https://steemit.com/knacksteem/@knacksteem.org/welcome-knackstore-and-knacktokens-to-knacksteem
https://steemit.com/knacksteem/@knacksteem.org/knacksteem-for-investors-and-the-talented


Contributions


Feel free to join our channel https://discord.gg/t5RhBvE and we can show some of the pending tasks we have :)


Any question regarding implementation?


Feel free to ask me any question in the channel mentioned above or in the comments and I will try my best to answer them all.

Sort:  

Thank you very much for your contribution @jaysermendez !

  1. it might be better to have delegations data obtained from blockchain instead of being hard-coded in delegations.json. This does not need to be at real time - I think you can do this in a separate process running at background periodically. Or, you can use @steemsql
  2. IMHO, i am not a big fan of posting templated comments on blockchain. It is kinda of spam - and it costs RC. You might want to introduce mechanisim to control the frequency of posting.
  3. Do you really want to check-in the yarn.lock according to this?

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Hello @justyy,

Thanks for the suggestions. I didn't realize about the yarn.lock being committed. Will surely remove it.

Regarding delegations.json, this is not hardcoded. It is served as a baseline for seeding purposes and it is patched with deltas thereafter. Before each distribution, it is patched with the latest data.

Regarding the comment template, @knowledges what do you think?

I am not a big fan of posting templated comments on blockchain.

The comment is made under each approved and scored knacksteem post. Very similar to what Utopian and other similar projects on the blockchain does. I don't consider this as spamming.

As for the delegation.json, it may look hard-coded but its not. It serves only as a baseline for seeding as explained by @jaysermendez

Thank you for your review, @justyy! Keep up the good work!

Welcome back! How's your job going?

Thanks man! Not back at all hahahhah. Still so busy at work! How about you?

Still busy with university, but I should be done with it this year (unless I start a masters degree). Also looking for a job, I guess, so "hopefully" I'll be in your situation soon, haha.

Hahahaah good luck man!

This post has been just added as new item to timeline of KnackSteem on Steem Projects.

If you want to be notified about new updates from this project, register on Steem Projects and add KnackSteem to your favorite projects.

Hi @jaysermendez!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Congratulations @jaysermendez! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 600 comments. Your next target is to reach 700 comments.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Support SteemitBoard's project! Vote for its witness and get one more award!

@jaysermendez You have received a 100% upvote from @intro.bot because this post did not use any bidbots and you have not used bidbots in the last 30 days!

Upvoting this comment will help keep this service running.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.



Hey, @jaysermendez!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Congratulations @jaysermendez! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!