SBD Printing Code Walkthrough

in #steem7 years ago (edited)

STEEM code walkthrough.png

This post is a code walkthrough of claims I've made in this post about SBD, this post about the debt ratio, and this post about SBD and STEEM supply at higher market prices. The beauty of it all is that STEEM code is open source, so anyone can verify any claims made about its behavior.

Author SBD Payout

You can start to chase the code for SBD Payouts, and specifically the author payout here, which is in the middle of the function that separates curation reward from author reward.

This is the function that converts the assigned steem to SBD.

auto to_sbd = ( gpo.sbd_print_rate * steem.amount ) / STEEMIT_100_PERCENT;

Here, to_sbd reprents the amount of STEEM that should be converted to SBD. Pay attention to the sbd_print_rate. In normal conditions when the debt-ownership ratio is below threshold, sbd_print_rate is equal to STEEMIT_100_PERCENT, e.g. all of the STEEM intended for the SBD portion of the payout is converted to SBD.

auto to_steem = steem.amount - to_sbd;

Here, to_steem represents what will remain as STEEM (if the blockchain decides to start limiting SBD production).

auto sbd = asset( to_sbd, STEEM_SYMBOL ) * median_price;

Here is the logic to actually convert. Multiplies the amount of STEEM (to_sbd) by the median price feed (represents USD price per STEEM).

  • Thus, the SBD Portion of the payout is entirely dependent on the median price feed, and moreover, does not take into account SBD market rates.

Nor should it account for SBD market rate, because SBD is hard coded to represent 1 USD worth of STEEM, and it's up to the market and monetary policy to attempt to maintain the peg. And as I've mentioned in this post, the peg is easier to maintain as STEEM's price rises.

Debt Ownership Ratio Computation

Now if you've followed my discussion of debt-ownership ratio, this portion is a deeper dive into the code and verifying how the SBD print cap works.

Recall in the previous section that sbd_print_rate controls how much of your intended SBD payout will actually be converted to SBD, and this rate is usually at 100%.

The sbd_print_rate above is updated here, which is one of the first things that is adjusted before crawling through all the comments, and you can see its invocation here.

As the white paper mentions, the ceiling caps are computed in terms of virtual STEEM supply, and the computation is as follows:

virtual_supply = current_supply + (current_sbd_supply / median_price);

I've modified the line above to boil down to essentials. Virtual supply and current supply are in STEEM. If you are actually following, you'll note that it actually uses the * symbol, but it has been overloaded to mean "convert", and I made a noob mistake of not checking the operators for these C++ objects (Yes, I signed up for github just to ask that question).

auto percent_sbd = (current_sbd_supply / median_price) * 
    STEEMIT_100_PERCENT / virtual_supply;

Also slightly tweaked to clean it up a bit. It simply finds the ratio of the SBD portion of the virtual supply over the entire virtual supply.

Now we get to the actual ceiling cap portion:

if( percent_sbd <= STEEMIT_2_PERCENT )
  sbd_print_rate = STEEMIT_100_PERCENT;
else if( percent_sbd >= STEEMIT_5_PERCENT )
  dgp.sbd_print_rate = 0;
else
  dgp.sbd_print_rate = ( ( STEEMIT_5_PERCENT - percent_sbd ) * 
      STEEMIT_100_PERCENT ) / ( STEEMIT_5_PERCENT - STEEMIT_2_PERCENT );
  }

I've replaced the constants above with the hard coded percentages found here.

The SBD portion of the virtual supply is computed using the witness median price feed. If the median price feed is higher than the actual market rate, it will basically under-report the SBD ratio, which increases the ceiling and allows more SBD to be printed. Which by the way, would go against the intended function of the ceiling (based on market ratios).

The main takeaway?

  • If the SBD's portion of the virtual supply exceeds 2 percent, we start to throttle the SBD production, and at 5 percent, SBD stops being produced altogether. (We get paid in STEEM instead).

Current Ratios

These values are nabbed from steemd.com as of 12/30:

virtual_supply 263,626,318.187 STEEM
current_supply 261,992,170.411 STEEM
current_sbd_supply 4,627,906.502 SBD
feed_price
   base  2.832 SBD
   quote 1.000 STEEM

Remember, feed price is supposed to represent the market price of STEEM, though it says SBD here. Which is still accurate, because to the blockchain SBD is equivalent to 1 USD. Sample computations of the feed price you can find e.g. here.

The white paper mentions that the STEEM accounts for STEEM POWER as well as liquid STEEM.

What is the current debt ratio then?

4,627,906.502 / 2.832 / 263,626,318.187 ~ 0.0062

Or 0.62%. So we're in good shape. But keep in mind the natural state is that on payout you have 50/50, so as time goes on, all other things equal (if the price of STEEM stays flat), this debt ratio increases.

In any case, the hesitance on the part of the witnesses to increase the price feed beyond market to accelerate SBD printing is not unfounded. If the debt ratio becomes high, none of us will get SBD at payout! The white paper mentions that any adjustments to the feed should be gradual, as it may have unintended consequences in the long term.

Summary

I've summarized the main conclusions below:

  • The SBD Portion of the payout is entirely dependent on the median price feed, and moreover, does not take into account SBD market rates.
    • This also bears repeating: The higher the STEEM rate, the higher the rate of SBD printing. Think about that.
  • If the SBD's portion of the virtual supply (computed based on price feed) exceeds 2 percent, we start to throttle the SBD production, and at 5 percent, SBD stops being produced altogether.
  • Right now the debt ratio is 0.6%. This slowly increases over time if STEEM's price is not increasing.

What does this mean for the average user? The reason I went on this journey was to investigate the state of SBD. It all boils down to this:

  • Don't HODL SBD and expect it to rise like Bitcoin. It won't. That's explained here.

Happy to answer any questions if you have any below. I know this isn't really for most audiences, but I really wanted to back up my recent claims with the actual source.

Sort:  

nice post, enjoy your upvote

Thanks for taking the effort and compiling all this info in one place. The math is a bit complicated but after reading your post I got much better isea how the system actually works.

So, and I say this as someone who is good with game theory, tolerable at math, but has traditionally given not a flip for fiscal instrumentation – what does this actually mean in terms of "what normal people should be aware of?"

Where "normal" really means "people who aren't the 2017/2018 equivalent of gold bugs?"

How does this affect my day-to-day – aside from sort of explaining why the payouts for authors are lopsided in the direction that they are between STEEM and SBD? As they say elsewhere, "explain it to me like I was five."

I've attempted to do that in my other posts. I added the takeaway that I think it says. It ended up not being anything most people didn't already know though.

Ah, yes, the payout part is a big one too, but I believe I covered that too. So many people have a misunderstanding of how the payout actually works.

Which language did you use.

Obviously, @eonwarped used English for this post.

I means which programing language
I saw if els statement in your post

Laughing at the cheekiness of the response. The code is in C++. Though I butchered some of the actual code in my re-copying of it (for clarity)

Obviously, @eonwarped used English for this post.

BWAHAHAHAHAH. THAT'S THE FUNNIEST THING I SAW ALL DAY. ROFL

hahahahaaha now I am blond! I thought the same thing hahaha Felt proud I understood that part of the conversation. :-)

Absolutely awesome, thank you for digging in and reporting. A lot of the technical stuff is over my head, but the take-away is clear:

Don't HODL SBD and expect it to rise like Bitcoin. It won't.

This is what I've been saying all along. At some point, SBD will return back to it's intended $1.00 peg. How or when I don't know, but STEEM is where the real investment is. As long as SBD is so valuable, it's best to trade it for other crypto, or better yet use the internal market to trade for STEEM and POWER UP! What a great opportunity we have right now. Time is ticking, it won't last forever. @ironshield

wow dude. You actually pinpoint the code which carry out the specific function and explain to us in layman way. It's not an easy post to do! Thanks for teaching me how to use github of steem to better understand how it works. YOu earned yourself an upvote and also a follower :) Keep on writing great quality post!

Erm yes, sounds all good to me as long as we get nice payouts :)

Hello Evan! Am not good definitely with the codes and stuff but I've already noted what you have ain mind. As fas I understand just don't HODL on SBD. Thanks for sharing this. This can help explain your POV in a more defined way.

Awesome writeup. Not sure I followed everything, because I haven't had the chance to delve in the code before. Following you now, in case you ever write on the steem code again.

Change the source code and set that I get 100% upvotes for every post from Ned.

Thank you.