# RAI Controller: Absolute vs Percent Error This post will detail a nuance in how the RAI system controller calculates the redemption rate and will propose a slight change. The system currently uses the *absolute error* of the market price to compute rates, but using the *percent error* will produce consistent rates under RAI/USD price changes. For a refresher on how the RAI controller works, go [here](https://medium.com/reflexer-labs/stability-without-pegs-8c6a1cbc7fbd). ## Rate Calcuation The mainnet RAI controller is currently only a P-controller, so the redemption rate is calculated as: $redemption\_rate = Kp * (redemption\_price - market\_price)$ where: $Kp=7.5e^{-8}$ and $error = redemption\_price - market\_price$ Since the error term is the absolute error between redemption and market prices, the resulting rate is dependent on the the RAI/USD price. In other words, a 1% market fluctuation will produce different rates in the cases of the RAI/USD redemption being $2,$3, $4, etc. ## Example To demonstrate the issue with using absolute error, consider the two cases below, each with a different starting redemption price. Each case shows the redemption and market prices(top), the absolute error(middle), and the resulting redemption rate(bottom). You can see while both market prices experience fluctations of 1%, the right case produces much higher rates because of the larger redemption price. ![](https://i.imgur.com/psJ9SMr.jpg) ## Implications If RAI/USD was to drift considerable from it's current starting point, the system will produce rates of a much different magnitude. Here are some possible values using the current system$Kp$of$7.5e^{-8}$. | Redemption Price | Market deviation | Annual Redemption Rate| |---------|----------|---------| |$1|1%| 2.4%| |$2|1%| 4.8%| |$3|1%| 7.4%| |$4|1%| 10.0%| |$5|1%| 12.6%| |$6|1%| 15.2%| ## Solution Instead of absolute error, the RAI controller can use percent error to calculate the market error.$pct\_error = \displaystyle \frac{redemption\_price - market\_price}{redemption\_price}$This will produce the same rates for % market deviations, irrespective of redemption price. ## Rates Produced From Pct Error Below are the same two cases aboves, but with the rate calculated using the percent error. ### But first, one caveat Using the percent error changes the units of the error, so$Kp$has to be adjusted if we want to produce similar rates. If we want to match the above case rate behavior, we simply need to multiply the original$Kp$by$3$.$rate_{pct} = rate_{absolute}Kp_{new} * pct\_error = Kp * absolute\_errorKp_{new} * 0.01 = Kp * 0.03Kp_{new} = \displaystyle \frac{Kp * 0.03}{0.01}Kp_{new} = 3 * Kp = 3 * 7.5e^{-8} = 2.25e^{-7}$And now the two previous cases, but with percent error. The rates are equal. ![](https://i.imgur.com/FXUwtrZ.jpg) When using percent error, the rates will be equal for equal % market deviations, no matter what the redemption price is. | Redemption Price | Market deviation | Annual Redemption Rate| |---------|----------|---------| |$1|1%| 7.4%| |$2|1%| 7.4%| |$3|1%| 7.4%| |$4|1%| 7.4%| |$5|1%| 7.4%| |\$6|1%| 7.4%|