# RAI Dollar RAI Dollar(RD) is an immutable $1 stablecoin that is only backed by ETH. RD uses principles from both Liquity's LUSD and Reflexer's RAI to achieve unparalleled market stability for ETH-only backed stablecoins. ### Main Features of RD -Collateralized Debt Position(CDP) stablecoin. Users lock ETH as collateral and mint RD as a loan. -Completely immutable and unstoppable -Floating par mechanism creates market price stability around $1 -RD is redeemable for ETH at par value. -The protocol operates its own RD/ETH pool w/ UniV4 hooks, allowing swap liquidity to be used for liquidations and redemptions. ## Stability mechanism RD uses a floating *par* value to target a RD market price of $1. *Par* is the value at which RD can be redeemed for and also the value at which the system prices RD debt. While RAI also uses a floating redemption value, the RAI market price itself is unbounded. Targeting a constant market price of $1 provides a better value prop to most stablecoin holders and borrowers. Below is a formal defintion of the RD stability feedback mechanism. Feel free to skip ahead to "How it works" if you want non-math intuition of its behavior. ### Formal Definition Formally, the RD stability mechanism is a PI controller with integral decay. It measures the error between the RD market price and $1 and controls the RD redemption value. Discrete PI w/ decay: $u_{n} = K_pe_{n} + K_i( \alpha^{\Delta t} \sum_{i=0}^{n-1}e_i \Delta t + e_{n}\Delta t) + u_0$ | Variable | Formal Name | System Value | | -------- | -------- | -------- | | $u(n)$ | control variable | redemption value| | $u(0)$ | bias term, starting output value | $1| | $e(n)$ | error, $r(n) - y(n)$ | $1 - market price | | $r(n)$ | target | $1 | | $y(n)$ | process output | market price| | $\alpha$ | decay coefficent | decay coefficent | | $\sum_{i=0}^{n-1}e_i$ | integral | integral of error | | $K_p$ | proportional gain | weight of current error | | $K_i$ | integral gain | weight of historical error | ## How It Works RD uses the RD/USD market price signal to adjust the par value of RD. ### Definitions: **RD Market Price**: TWAP of RD/USD derived from RD/ETH TWAP and Chainlink ETH/USD TWAP. **RD Redemption Price**: aka **par**. The value of RD when redeemed for ETH or pricing a vault's RD debt. ### Stability Mechanism Overview * If the market price > $1, the redemption price is lowered. * If the market price < $1, the redemption price is raised. * The redemption price slowly decays towards $1 over time. ### Above Peg: Market Price > $1 Consider a market price *above* $1. In this case, the system *lowers* the redemption value of the RD, until the market responds and lowers to $1. ![image](https://hackmd.io/_uploads/Hy4kpGkLA.png) #### Why does the market price respond to a lower redemption value? #### 1) Arbitrage Because of the minimum collateral ratio(CR) of 110%, there will be an immediate lock+mint+sell arbitrage when $redemption\ value < 1/1.10$. The total market value of debt will be greater than the value of collateral locked, so arbitragers will lock collateral, sell the debt and "walk away". As long as market price > $1, the system keeps lowering the redemption value. Market participants understand that eventually this will lead to the above abitrage and the market will inevitably go to $1. This threat of future arbitrage invokes market actors to sell before this happens. This arbitrage is the same mechanism used by Liquity V1 and other CDP protocols to provide an upper bound on market price. *However, in RD's case the market price is driven to $1,* instead of lingering around some value between $1 and the upper bound. #### 2) Higher and Less Risky Collateral Ratio(CR) A vault's CR is calculated using the system redemption price. Lowering the redemption price, will raise a vault's CR, making it safer from liquidation. The CR of all system vaults being lowered will a) reduce buying demand for RD in order to re-pay debt and avoid liquidation b) increase leverage demand due to more room for debt These effects should be less powerful than the above arbitrage effects, but still present. ### Below Peg: Market Price < $1 Consider a market price in *below* $1. In this case, the system will *raise* the redemption value of the RD, until the market trades at $1. ![image](https://hackmd.io/_uploads/SJlu0zkIC.png) #### Why does the market price respond to a higher redemption value? #### 1) Redemption Arbitrage Through the System Pool, RD is directly redeemable for the redemption value in ETH. Therefore, an increasing redemption value will make buy+redeem arbitrarage more attractive, increasing the market price to $1. Once `market price > $1`, the redemption value will start to fall, redemptions will become unprofitable, and the market price will return to $1. #### 2) Lower and Riskier Collateral Ratio A vault's CR is calculated using the system redemption value. Raising the redemption value will lower a vault's CR, increasing the risk of liquidation. Borrowers that want to pay back debt and avoid liquidation will increase demand for RD, raising the market price. ### Will the redemption value return to 1? In the above examples, the system had to move the redemption value away from $1 to induce the market price to correct back to $1. Does the redemption value just stay deviated forever? #### Consider the `market < $1` scenario above. According to the mechanism we described above, in order for the redemption value to return to $1, the *market will have to overshoot the target of $1*. See below. ![image](https://hackmd.io/_uploads/rJGnuNII0.png) #### But what if the market price doesn't overshoot and just converges? The redemption value will still slowly converge back to $1. This is the *decay* portion of the price controller. ### Redemption value decay after market reaches $1 Even though the market has reached $1, the redemption value will slowly decay back to $1. This might make the market price react and deviate again from $1(and the cycle continues), but it provides an automated way for redemption to ultimately converge to $1 also. #### Decay Example 1: Redemption value > $1 ![image](https://hackmd.io/_uploads/H1XTvsgUC.png) #### Decay Example 2: Redemption value < $1 ![image](https://hackmd.io/_uploads/HkG1_igUR.png) ## Price Bounds ### Market Price: Practical Upper bound The upper bound is re-inforced by lock-mint-sell arbitrage with a minimum c-ratio of 110%. Any market value above this price allows an immediate profit to abitrageurs and will be immediately corrected. `practical market price upper bound = 1.1 * redemption value` This is the upper bound of the market price for any redemption value. Practically, the market price upper bound is $1.10. ### Market Price: Theoretical Upper bound Since the market price upper bound is dependent on the redemption value, it's theoretically possible to see a market price > $1.10. For example: Let `redemption value = $1.05` then `market price upper bound = 1.1 * 1.05 = $1.155` However, in order for redemption value to reach $1.05 in the first place, the market price must have been previously depegged *down* below $1. So only immediately after a depegging < $1, can the market achieve a price > $1.10. This is unlikey but possible in volatile market conditions. However, it would still be immediately corrected by the system. As market reaches $1.15 in the above scenario, the redemption value will start to fall, eventually reaching $1. As redemption value reaches $1, the market price will fall back to $1.10 due to arbitrage. ### Market Price: Lower Bound The lower bound of the market price is supported by redemptions. As seen in other decentralized stablecoins, high risk-free rates can push the market price < $1. This is also expected with RD. However, unlike other stablecoins that encounter this problem, RD will has the ability to change the redemption value. When market < $1, the RD redemption value will increase, pushing the market price > $1. The longer market stays < $1, the higher the redemption value will go, making redemption arbitrage more profitable. Long-term depeggings < $1 should be very unlikely because of this. ### Redemption Value: Lower bound This lower bound is also re-inforced by lock-mint-sell arbitrage with a minimum c-ratio of 110%. `redemption value lower bound = market/1.10` With market > $1, the redemption value will decrease until it reaches `market/1.10`. At this point arbitrage is possible and market will decrease to $1. When the market reaches $1, the redemption value will stop decreasing. Any deviation less than $1 by the market price will start an increase of the redemption value. So the practical lower bound of redemption value is `1/1.10 = $0.9090` ### Redemption Value: Upper bound The upper bound of the redempion value will primarily be an unknown function of the risk-free rate. The max redemption value will be achieved when there is a some equilibrium between the risk free rate and redemption arbitrage. With a rising redemmption value, market buyers might still price RD at a discount to $1 for yield-bearing stablecoins, while RD minters might still value RD > $1 under a rising redemption values. Redemption arbitrageurs will obviously value RD > $1 as redemption value rises > $1. However, unlike other stablecoins, this unknown equilibrium redemption value will still eventually result in a market price of $1. It is unknown if the market will price RD at a risk-free offset to the redemption value or as an offset to $1. However, both market conditions will still result in market convergence and stability around $1. Also, vaults can be liquidated by a rising redemption value. So very low c-ratio vaults will act to buy RD when the rising redemptiom value threaten liquidations. This will raise the market > $1 and induce a redemption value decrease. #### Bounds | Name | Value | | -------- | -------- | | Market upper bound | $1.10 | | Market lower bound | $1 - redemption_fee | | Redemption upper bound | | | Redemption lower bound | $0.9090 | ## System Pool ### Overview The System Pool(SP) is used to back liquidation and redemptions of RD for ETH, *while also providing swap liquidity*. Users can stake RD and ETH in the SP in exchange for fees. #### Similarities with Liquity V1 Stability Pool -Users can stake RD to receive GOV emissions -Staked RD is used to process liquidations, with stakers receiving a liquidated vault's leftover ETH. #### Differences from Liquity V1 Stability Pool -RD SP is used to process ETH redemptions first so vaults are less likely to be redeedm against. Vaults are only redeemed against when SP ETH buffers are empty and RD/ETH liquidity is below critical levels. -SP ETH stakers receive redemption fees. -RD SP is used for swap liquidity and stakers receive swap fees. More RD liquidity on the market. -SP stakers get constant stream of vault interest rates, not one-time loan fees ### Pool Incentives Pool providers that stake RD/ETH will receive *five* sources of revenue -redemption fees -liquidation profits -swap fees -loan fees -token emissions ### Redemption and Liquidations from System Pool #### How it works SP removes both sides of liquidity(RD and ETH) from the pool when processing a liquidation or redemptions. This ensures the market price is unaffected. This will leave an excess of either RD or ETH in the SP from this operation. The excess is stored in the *SP Buffers* for future operations. In the event of a vault liquidation, the RD is used to process the liquidation, and the removed ETH is stored in the SP ETH Buffer. In the event of an ETH redemption, the ETH is used to process the redemption, and the removed RD is stored in the SP RD Buffer. TODO: images #### System Pool Buffers It is expected the SP buffers will grow uneven, having more RD or more ETH. The SP will periodically try to add common liquidity back to the DEX pair to increase swap liquidity. #### Swaps against buffers Swaps can be made against any RD or ETH excess in the System Pool buffer at the pool's current market price. This is done by calling a swap function directly on the SP, and not through the pool itself. Up to 1/2 of the buffer balanced can be swapped out. This will result in an equal balance between RD and ETH remaining, which is then added to the pool's liquidity. TODO: images ### Rebalancing RD/ETH pool Automatic rebalancing of the RD/ETH pool needs to be done in order to accomodate drift of ETH/USD prices. A large ETH/USD increase will cause the RD/ETH price to go down and possible go out of the current range. When the RD/ETH TWAP is near the edge of the current LP'd range, the system will automatically remove current liquidity and re-add it at a new range. This operation will reduce active liquidity and leave some excess in the buffer. The excess will be RD or ETH depending on which way the RD/ETH price has moved. TODO: Images ### Rebalance Frequency How often the pool rebalances depends on ETH volatility. The more volatile ETH prices are, the more frequent the RD/ETH range needs to be changed, and vice versa. Using the historically high estimate of ETH volatilty of 25%, we can run a simulation on how often rebalances will happen. Out of 100 simulations over a period of 180 days, the mean frequency of rebalances is about 0.12. This means the mean time between rebalances is about $1/0.12=8$ days. ![image](https://hackmd.io/_uploads/HkFubPLFR.png) TODO: Table with rebalance frequencies for different volatilities. ### Last Resort Liquidations and Redemptions The System Pool will only process liquidations and redemptions if they do not push liquidity level < 1% of total debt. Redemptions performed against the pool, do not decrease the outstanding supply of RD. If there is not enough RD in the system pool, liquidations will be available for external bidders and then socialized to the general CDP population. Similarly, if there is not enough ETH in the System Pool, redemptions will be perfomed against vaults. Redemption performed against vaults, *do* decrease the outstanding supply. ## Uniswap V4 Hooks ### before add liquidity ensure msg.sender is Pool Manager ### after add liquidity ### before remove liquidity ### after remove liquidity minimum liquidity check ### before swap ### after swap update TWAPs and price controller rebalance if RD/ETH TWAP is at threshold ## Immutable and Unstoppable The system will be ossified from day 1. The only parameter that can be changed will be a bounded fee portion to send to GOV stakers. The fee switch will the only control GOV holders have over the protocol. ### Decentralized Frontends Similar to Liquity, the RD protocol will provide kickbacks in fees to operators of frontends. # Appendix ## Historical ETH Volatility ![image](https://hackmd.io/_uploads/Bk8SnUItA.png)