The SMT setup emission operation explained

in #smt5 years ago (edited)


Hello everyone ! Today I want to write a bit of explanation on one of the core smt operations:

<p dir="auto"><center> smt_setup_emissions <p dir="auto">This operation is used, as it's name hints, to setup emission/inflation for an smt. In order to use it you must have previously called the <code>smt_create operation to create an smt object in the chain to send this operation on. <p dir="auto">Now let's look at the operation and it's parameters : <pre><code> account_name_type control_account; asset_symbol_type symbol; time_point_sec schedule_time; smt_emissions_unit emissions_unit; uint32_t interval_seconds = 0; uint32_t interval_count = 0; time_point_sec lep_time; time_point_sec rep_time; share_type lep_abs_amount; share_type rep_abs_amount; uint32_t lep_rel_amount_numerator = 0; uint32_t rep_rel_amount_numerator = 0; uint8_t rel_amount_denom_bits = 0; bool remove = false; bool floor_emissions = false; extensions_type extensions; <p dir="auto"><span>You can find this in : <a href="https://github.com/steemit/steem/blob/master/libraries/protocol/include/steem/protocol/smt_operations.hpp" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/steemit/steem/blob/master/libraries/protocol/include/steem/protocol/smt_operations.hpp <h1>the basics <p dir="auto">So first of all, you need to give the operation the information about which smt you want to add emission to : <p dir="auto">(note that the code examples will be in js from now on) <p dir="auto">this is where you set <ul> <li><p dir="auto">control_account<br /> with, for example : "howo" <li><p dir="auto">symbol<br /> it's an <code>asset_symbol_type which is a struct with a nai and a precision, so it would be akin to something like <p dir="auto"><code>{'nai': @@280090049, 'precision': 13} <ul> <li>schedule_time <p dir="auto">This is where you state when the emission starts, there is no end date for the emissions unless you set it in another emission call (we'll get to that later on) <h2>Emission units <p dir="auto">This is where we start to dive into the interesting parts, emission units define where the inflation actually goes, the structure looks like this : <pre><code>[ ['howo', 50], ['steempress', 50], ] <p dir="auto">And that's it ! Here I state that every time there is an emission, 50 tokens will go to me and 50 will go to steempress, you can put steem accounts and there are also three special strings that you can use : <p dir="auto"><code>$market_maker : inflation will go to the decentralized market in order to provide liquidity early on<br /> <code>$rewards: Fund the reward pool for your smt, if you don't set this, your token won't have proof of brain rewards via inflation (you could fund that account via other means like the ico)<br /> <code>$vesting: Fund the vesting rewards <p dir="auto">Since the parameter is an array you can set several inflation destination at the same time. <h2>Interval_second and interval_count <p dir="auto">Okay so we emit x tokens to those emission sources, but how how often ? <p dir="auto"><code>interval_seconds sets how often emissions will be triggered, note that the minimum is 21600, aka 6 hours.<br /> <code>interval_count sets a limit on how many times you want to emit. <p dir="auto">if you set it to 10 you will only emit 10 times. It's a good way to set a limit to your inflation, or to get all the tokens at once in everyone's hands. <h2>Variable emissions, because otherwise it would be too easy <p dir="auto"><span>This is where things get tricky, and I am not 100% sure myself but here's the gist of it, you can refer to the official smt documentation as well if I'm not making enough sense : <a href="https://github.com/steemit/smt-whitepaper/blob/master/smt-manual/manual.md#adding-time-modulation" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/steemit/smt-whitepaper/blob/master/smt-manual/manual.md#adding-time-modulation <p dir="auto">you can set curves for your inflation, in order to have, let's say a decreasing inflation. <p dir="auto">for that you have <code>lep_time and <code>rep_time to set both ends of the curve, lep stands for left end point, rep right end. <p dir="auto">values are like this : <code>1970-01-01T00:00:00 <p dir="auto">Side note : <ul> <li>For times before the left endpoint time, the amount at the left endpoint time is used. <li>For times after the right endpoint time, the amount at the right endpoint time is used. <p dir="auto">Then you have 4 parameters : <p dir="auto"><code>lep_abs_amount and <code>rep_abs_amount which are the values taken at lep and rep from which we'll get a curve (100 and 0 for instance to make inflation go to 0 over time). <p dir="auto">Abs use integer values aka 10, 20, 30 <p dir="auto"><code>lep_rel_amount_numerator and <code>rep_rel_amount_numeratorwhich are the same except that they use a different calculation to take advantage of decimals. Hence why they also have the <code>rel_amount_denom_bitsto bitwise righ shift the value by the number defined. <p dir="auto">So do we need to have both defined and what happens if we only want to set the abs and leave the rel alone ? This is where the <code>floor_emissions parameter comes in handly. this is basically what it does : <pre><code> if ( emission.floor_emissions ) new_token_supply = std::min( abs_amount, rel_amount ); else new_token_supply = std::max( abs_amount, rel_amount ); <p dir="auto">If floor emission is set to true, it will take the minimum value between the calculated absolute value and the calculated relative value otherwise it will take the biggest of the two. So if you want to use only abs emission, set <code>lep_rel_amount_numerator and <code>rep_rel_amount_numerator to 0 and <code>floor_emissions to false. <h1>Adding multiple emissions <p dir="auto">phew almost done ! Now here's an interesting thing about emissions, you don't have to have a single emission model, you can have several ones ! So you can reward early adopters with a high reward pool inflation and then switch to a model where it's more normal but inflation to vesting is now favored. <p dir="auto">You can have as many inflation as you want but they need to be 6 hours apart from each others. <h1>Deleting an emission <p dir="auto">Finally there is one last parameter : <code>delete if set to true, it will delete the emission model that you previously submitted. Quite useful if you found out that there is a parameter that isn't right huh ? <h1>conclusion <p dir="auto"><span>You can find a complete example for this on my hard fork 23 tests here : <a href="https://github.com/drov0/hf23-testing/blob/master/bulk_full_setup.js" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/drov0/hf23-testing/blob/master/bulk_full_setup.js <p dir="auto"><span>The reason I'm able to do this work and allocate time to it is thanks to the funds from the sps, please consider voting on it or unvoting the return proposal : <a href="https://steemproposals.com/proposal/50" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://steemproposals.com/proposal/50 every bit counts ! <p dir="auto"><span>And finally I am also doing this as part of the witness <a href="/@steempress">@steempress if you like what I'm doing please consider voting on it as well. Every bit counts ! It will take you but a few minutes but will greatly help me test the network and the more we test the more steemit and the witnesses will feel confident enough to launch on the main net
Sort:  

Thanks for doing all this.

Are you going to compile all the documentation you're creating in some more formal way? Like @intertia's documentation website?

Mmmh I was thinking of actually putting it on the devportal (aka inertia's website, although it's a steemit funded initiative at first), but most of the data is already formatted here : https://github.com/steemit/smt-whitepaper/blob/master/smt-manual/manual.md#adding-time-modulation

And for now my time is better spent actually testing than documenting, as writing stuff like this takes quite some time.

Great work @howo looks impressive explanation. I am non technical and followed your commentary pretty well.

Posted using Partiko iOS

Thanks ! Glad to hear that you could follow, it was mostly aimed at technical people so it's a great sign :)


Your post was mentioned in the Steem Hit Parade in the following category:Congratulations @howo!

  • Pending payout - Ranked 2 with $ 52,49

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

<table><tr><td><img src="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@howo/votes.png?202001070358" srcset="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@howo/votes.png?202001070358 1x, https://images.hive.blog/1536x0/https://steemitimages.com/60x70/http://steemitboard.com/@howo/votes.png?202001070358 2x" /><td>You distributed more than 34000 upvotes. Your next target is to reach 35000 upvotes. <p dir="auto"><sub><em>You can view <a href="https://steemitboard.com/@howo" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">your badges on your Steem Board and compare to others on the <a href="https://steemitboard.com/ranking/index.php?name=howo" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Steem Ranking<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <h6><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Thanks for the post.

Great work, I am sure community developers will find these tests and infos useful

Amazing piece of work @howo

I'm far from capable to understand all technicalities, however I can roughly see how useful this content can be for many.

Upvote on the way. And will vote on your sps proposal in a minute.

Would you mind telling me if blockchain is your passion or is your work somehow related to this topic as well? Just curious :)

Yours, Piotr