RAI Controller Ungovernance

Thanks for following up with the Integral-term controller param explanations Bert!

I want to add some flavor about our methodology and thought process while evaluating the leak and Ki params.

Initially, we made a grid of possible parameters we could evaluate (at the end of Bert’s post, reposted here).

Looking at the numbers, we tried to answer what the leak and Ki should be and initially narrowed down on a Ki=2.23E-14 with a 90day leak. Notes below.

Screen Shot 2022-02-08 at 2.41.20 PM

Rationale for 90 day leak:

  • 90 day leak = the weight of all data older than 90 days is 5%, and the weight of everything in the last 90 days is 95%
  • RAI is new, so making historical inferences based on too long of a timeline is dangerous, once RAI is 5 years old, maybe we’ll move to 1-2 year leak
  • we’re running a 5 month experiment, so 90 day leak gives us time to evaluate the entire integral leak lifecycle
  • the leak also mitigates overshoot - if there was no leak, overshoot would be required to reach new equilibrium, with leak the amount of overshoot required is less, so a 90 day leak can limit I-term driven overshoot to roughly 1-2 months tops
  • if the leak is too fast (e.g. 30 days) then it doesn’t really act as an integrator over a long time period, only a few weeks, which seems pointless
  • due to the non-linear nature of our integral leak, if the leak is 60 days, then it mostly integrates over the last 30 days
  • so 90 days seems like a sweet spot where we integrate everything over a 3 months, and weight highest the last 1-2 months, and ignore everything older than 3 months

Rationale for Ki = 2.23E-14:

  • I-term should be tuned to correct steady state error, and largely ignore short-term impulses
  • our leak makes our I-term weird, because it doesn’t weight all the times in the given window the same, it exponentially decays historical error
    • so with a 90 day leak, 86% of the I-term is from the latest 60 days, and only 14% from 60 days+
    • this means our integral term is always “front loaded” somewhat, which we should keep in mind
  • the last month has been a prod experiment with +1% error and -7% (P-only) rates
  • we can ask “what should rates be today” after a constant 1% error for 30 days
  • I would think after 1 month of +1%, should be around 10-11%, or roughly +50% from P-only
  • this is also roughly based on the fact that CVXRAI returns are about 15%, meaning the real rates on RAI this month were (+8%), meaning if the I-term reached -7-8% then real rates on RAI would be 0%, and there would be no reason to hold RAI deposits in CVXRAI, and people would definitely sell their RAI for other coins…
    • so hypothetically, slowly raising rates by 3-4% over the past month may have caused some farmers to dump RAI as the farming rewards became less competitive, which would help bring RAI back down closer to equilibrium…
    • for example, rates on FRAX are around 10%, so even a few % drop in real RAI rates would incentivize people to switch over
  • total rates of 10-11% after 30 days of constant 1% error with a 90 day leak → corresponds to Ki of 2.23E-14
  • with Ki=2.23E-14 at 60/90 days, the rates would be 12.6% and 13.2%, so it gets almost up to 100% of Kp (maxes out at around 80%)
    • tbh this feels a bit weak to me, I think I would prefer if I-term could overcome P-term eventually (especially after 2-3 months)
    • like, if increasing rates by 3-4% didn’t work in month 1, why would raising rates by an additional 1% in months 2 and 3 solve anything?
    • the 180 day leak sort of fixes this, the 30 day rates are only somewhat larger than the equivalent 30 day rates with 90 day leak, but with 180 day leak the 60/90 day rates are much higher
  • comparing to Ki = 4.46E-14
    • after 30 days of constant 1%, the total rate is 15%, so I-term is already ~100% of the P-only response → feels… too fast to me
    • and then after 90 days it maxes out at a constant 19.3% or 163% of the P-value, meaning the maximum PI response is about 2.5x stronger than P-only
    • this feels… maybe a little too strong, but maybe right?
    • I would probably have a preference for a non-leaky integral with evenly weighted error sampling over 90 days, because that would more closely do what I want, which is “get stronger over time, but not too fast”
    • because on one hand, it feels weird to look at a rate of 19.3% resulting from only a 1% price gap, but also it’s a 1% price gap that persisted for 90 days even while the rate increased from 7% to 19%…
    • so I guess I wouldn’t mind the Ki=4.46E-14 if it ramped up slower, even if I do think its terminal strength is probably about right

After our initial parameter discussion, we decided to look more closely at intermediate Ki/leak steps, adding leak=120 days and Ki=3.35E-14 to the chart. We looked for params that, compared to (leak=90, Ki=2.23E-14) would result in:

  • a stronger maximum controller I-term response (>78% of P-value)
  • about the same 30d rate (50% of P-value)
  • round numbers, to make it easy to reason about :]

We arrived at leak=120 and Ki=2.4E-14, with the rationale as follows:

  • due to the nature of the leak exponentially decaying historical error and front-loading the I-term, it is difficult to increase the maximum controller response without also increasing the 30d rate…
  • increasing leak to 120 days and holding Ki constant (top box) increases the 1% error 30/60/90d rates by 0.4%/0.9%/1.5% respectively, which seems like an acceptable tradeoff.
  • increasing Ki slightly from 2.23E-14 to 2.4E-14 increases the 1% error 30/60/90d rates by 0.3%/0.5%/0.6% when compared to above, which is more front-loaded than is ideal…
  • however, increasing Ki to 2.4E-14 also results in nice round numbers when comparing Ki/Kp over time:
Ki/Kp Rate after 10 days Ki/Kp Rate after 20 days Ki/Kp Rate after 30 days Ki/Kp Rate after 60 days Ki/Kp Rate after 90 days
0.26 0.45 0.60 0.87 1.0
  • so in summary, we like the Ki=2.4E-14 with leak=120 days, because it has a 90day Ki, meaning that after 90 days of constant error, the I-term should be 100% of the P-term
  • and while the I-term being 60% of the P-term after only 30 days is higher than I would generally want, it seems like an OK trade off to get a stronger 60d/90d response and nice round numbers

Conclusion

Of course, tuning RAI has thus far involved a great deal of trial and error. The current Kp is about 1/4x as strong as it was when RAI launched, and it was only by testing in prod that we were able to determine that the current levels seem to work well. I don’t expect we’ll get the Ki params “right” either on our first try, but we will hopefully learn enough to make a more informed decision about how the Ki should work before our scheduled ungovernance in August.

2 Likes