# ๐งฎ ๐น Stake Or Die! ๐๐๐ ๐งฎ

**Some notes about the calculator:**

This tool is meant to provide a very good estimate of possible returns based on currently available information. It is not going to be perfect so stop expecting it to be ๐คฏ.

**First a quick pole**

- How do I do a poll?
- Look it up the internet - 0%
- Assume no one has ever wanted this feature and start building it from scratch - 100%

**How does is work?**

- Enter the amount you plan to stake
- Choose a validator
- Choose a compounding schedule
- Click Submit (Advanced) Try
- Check "Override Values"
- Change the Total and/or Bonded Supplies
- Click Submit Or
- Add a current and end of year USD price
- Click Submit Or
- Toggle the Prop 22 checkbox
- (Optional) Click Submit Or
- Add your wallet in at the top
- Click Submit

**What does this tell me?**

- The amount of ๐ง you're gonna be adding to your ๐ฅฉ each year.

**How does it really work like math wise?**

Behind the scenes the calculator's ๐งฎ algorithm is doing math stuff. To put as simply as I can, it's a hybrid organic quantum string theory regression function that uses airbag deployment entropy-like memory allocation ๐. Pretty much only CashManey truly understands. It's intense โบ๏ธ.

**Seriously?**

No, it's a basic formula with a few intricacies that made it fun to figure out ๐บ.

- Rewards are calculated based on the Inflation Rate and Total Supply.
- After backing out the Community Tax and Foundation Tax, the rewards are allocated based on the % of the Bonded Supply your Staked Amount represents. It's cross multiplying yo!
- Finally the Commission charged by the Validator you select is backed out and voila, you have your Yearly Staking Rewards.
- From those rewards we get a baseline ROI (No Compounding). That is then used to calculate compounded rewards.
- Compounding is calculated using a formula that Brendan from ๐คWhisperNode shared with me. (ToDo: add Brendan's formula here)

**That's it? Anyone could have built this thing then.**

Not so fast. There's more ๐.

- First off, based on Telegram complaints by unnamed parties ๐๐ฅฑ, we added fees for withdrawal and redelagation needed to compound rewards (Just kidding, thanks for the heads up sir). The number used is -92,500USCRT every redelegation. The way we add that up isn't perfect though, since those fees need to themselves compound, but, our head started to hurt ๐ค too much when we thought about that, so we stopped thinking about it ๐โ.
- Second, you have the ability to override the coin supply numbers, and that has some fun implications.
- Most of the time overriding won't change much, but do you see the Target Bonded Ratio of 67%? Also called the Goal Bonded Number, it can complicate matters significantly.
- To understand how we first need to introduce you to key player in this magical network we call Secret. This is Tendermint --> ๐ง. ๐ง is the genius consensus algorithm that powers everything.
- The Goal Bonded Number is ๐ง's desired state. ๐ง's goal is to have 2/3 of the coin supply bonded, and 1/3 liquid.
- If the Current Bonded Ratio is below or above 67%, then ๐ง tries to incentivize getting there. That is where the Min Inflation and Max Inflation amounts come in.
- The min and max, of 7% and 15% respectively, are the limit of what ๐ง is willing inflate to incentivize the movement towards the Target Bonded Ratio. At the time of this writing the Actual Bonded Ratio is about 45%. ๐ง wants more bonding. So the inflation is a super-high 15%, making people want to bond. In the future, if the bonded ratio goes above 67%, the inflation will move down over time until the ratio gets to 67% or the inflation reaches 7%.
- With me so far?
- The wild part is how the inflation rate moves towards the min or max. For every single block, all 6,311,520 of them, ๐ง recalculates the how far the Actual Bonded Ratio is from the Target Bonded Ratio. Then, using the Inflation Rate Change setting (currently 8%), it figures out how much the Inflation Rate should change over the next 6,311,520 blocks. That is the target. Take that target and divide by 6,311,520 and you get how much the Inflation Rate will change each block.
- I know I know this is too hard to follow, and maybe poorly worded, so lets just try an example.
- Lets say that the Total Supply was 100MM SCRT and the Bonded Supply was 90MM. That would give us an Actual Bonded Ratio of 90%. That is too high for ๐ง so the Inflation rate needs to go down. But by how much?
- The formula looks like this: (1 - 90% / 67%) * 8% = -2.74626866%
- If the inflation is was 15% (this would be strange but who cares), then ๐ง's goal would be to get 12.25373134% by one year from now, or said a different way the inflation rate will go down at a rate of 2.74626866% per year.
- Now we said this happens every block. Meaning the in the first block the inflation rate would go down by: -2.74626866% / 6,311,520 = -0.00000043512%. Reducing the Inflation rate for that block to 14.99999956488%
- The next block this happens again then again and again over and over until eventually, if the Actual Ratio stays high, the rate reaches the minimum of 7% and can go no lower. This would take a little less than 3 years.

- Okay so what does our calculator do with all this? It applies that formula, and assumes that if the rate is moving, it will move at a constant rate for the year we are forecasting. So it takes the mean of the current rate and the future rate 6,311,520 blocks (1 year) from now. More simply put, it divides the rate change by 2 and adds it to the current rate.
- So, in the example in which we are at 90% bonded with a 15% Inflation Rate, the calculator would reduce the Inflation rate by -2.74626866% / 2 = -1.3731343%. Thus the Inflation rate used to calculate yearly rewards would be 15% - 1.3731343% = 13.6268657%
- If you want you can try this out. Override the the Total and the Bonded supplies to be 100MM and 90MM respectively. Unless we made a huge goof ๐คฆโโ๏ธ, once you click submit it will show you 13.6268657% rounded to 13.63%.

Okay that was super boring ๐ด, or if you are like me and ๐ง, riveting.

Now here's the thing, we know this isn't perfect. We get it. What if the rate drops and then is going up but it will hit the max after 96 days? What then? What about the effect of interest increasing the Total Supply? What about.... We get it. To all these questions we will simply say. Isn't this good enough?

If not, you make one that's better!

โ๐ป out.

THE END