Skip to main content

Peg control

The controller's job is to keep RD's market price close to $1. It has two levers to do that: an interest rate that all borrowers pay, and an internal price called par that drives how redemption arbitrage values RD. Most of the time only the rate lever moves; the par lever is reserved for sustained stress.

RateParControl is the singleton split-range PI controller that produces both outputs from one input: the RD/USD market price. This page covers what the controller does, the constants it uses, and the conditions under which each lever fires. For a less technical introduction, see How RD stays near $1. For the research background, see Whitepaper & research.

Try it live

The exact controller runs against a simulated market in the interactive Peg Control simulator — including a low-liquidity severe-underpeg path that exercises the seven-day fallback.

The signal​

Input: the RD/USD price from the market oracle, MarketOracleAggregator, read through checkpointControlResult() on every update. The aggregator watches two Uniswap v4 pools, RD/USDC and RD/USDT, each run by an RdStableSwapHook (a StableSwap curve that also records price and liquidity observations). The price is the mean of the 24-hour TWAPs of the pools that qualify to contribute: a pool contributes when its 24-hour harmonic liquidity is at least 250,000 RD-equivalent. The oracle accepts a control price only when the contributing pools together hold at least 500,000 RD-equivalent of 24-hour liquidity, and the controller additionally requires an RD total supply of at least 5,000,000 RD. A rejected or unavailable reading skips the control step; it does not move rate or par. See RD Market Oracle for how the pools and observations work.

The price is bounded [$0.80, $1.20] at input; anything outside is clamped.

Error: error = $1.00 − price — measured against the fixed $1.00 peg (CO_BIAS_PAR), not the live par output (separate rate-error and par-error views exist inside the contract). Positive error means RD is trading below $1; negative means above.

MarketOracleAggregatorRD/USDC + RD/USDT poolsRD/USD · 24h TWAPRateParControlerror = $1.00 − pricesplit-range PIratepar
The controller's only input is the RD/USD price. It reads the mean 24-hour TWAP of the qualifying RD/USDC and RD/USDT Uniswap v4 pools from MarketOracleAggregator, clamped to [$0.80, $1.20], and turns it into an error against the fixed $1.00 peg. That single error drives both outputs — the borrow rate and par.

Two outputs, one baton​

RateParControl uses a baton that's held by exactly one of the two outputs at a time:

  • RATE mode (default). The rate PI is active. Par leaks slowly toward its bias ($1.00) with a ~7-day half-life.
  • PAR mode. Active only after sustained, large deviation. Par PI is active; rate leaks toward its bias (2% APY).
deadbandRATE modeRATE modePAR modePAR mode−1.0%+1.0%−0.15%+0.15%0$1.00 peg← RD below $1RD above $1 →
Price error bands, colored by which output holds the baton. A dead band in the center where nobody acts; the RATE mode owns everyday errors just outside it; and only a large, sustained error hands the baton to PAR mode further out. One mode is responsible for any given error — never both.

Why the split​

Two reasons:

  1. Rate moves fast, par moves slow. Acting on rate first lets the market correct cheaply (borrowers reprice immediately). Letting par drift is the heavier intervention.
  2. Avoid simultaneous double-action. Without a baton, par and rate would both react to the same error and amplify each other. The baton ensures one tool at a time.

Mode transitions​

The baton has two independent RATE → PAR entry paths. The fast path requires the rate to be pinned at a bound and still pushing; the fallback only requires a sustained, same-direction error. Whichever finishes first flips the baton:

PAR_ENTRY_DWELL = 24 hours (rate at bound + still pushing)
PAR_ENTRY_FALLBACK_DWELL = 7 days (same-direction |error| > 1¢)
PAR_EXIT_DWELL = 12 hours (PAR → RATE)

The fallback matters when market liquidity is low. Liquidity authority scales the measured error (see Liquidity authority), and its 20% floor can still leave the rate short of a bound; without a second path, that could strand the controller in RATE during the crisis PAR exists to handle. The fallback gives rate a full seven-day attempt, then admits PAR even if rate never saturates. It resets if price returns inside the 1¢ entry threshold or the committed error flips direction, so oscillation cannot accumulate time toward a handoff.

Dwell prevents thrashing: a brief price spike that crosses the threshold and returns won't switch modes. The two entry clocks are independent, so a liquidity drop that pulls rate off its bound resets the 24-hour clock without erasing progress on the seven-day clock.

RATE mode · defaultrate PI activepar leaks → $1.00 (~7 d)PAR modepar PI activerate leaks → 2% APY (~7 d)|error| > 1.0% · same directionrate at bound: 24 hfallback without bound: 7 derror subsidesPAR_EXIT_DWELL 12 hthe inactive output leaks toward its bias on a ~7-day half-life
A baton is held by exactly one output at a time, so rate and par never act on the same error at once. RATE is the default — cheap, fast correction while par leaks back to $1.00. The baton flips to PAR through either a 24-hour rate-bound dwell or a seven-day sustained-error fallback, then flips back once the error subsides for its own dwell. The fallback means low liquidity can slow active control without vetoing PAR indefinitely.

For the mechanism without the controller internals, watch What happens when increasing rates can’t fix the peg?. For the full low-liquidity path—including admitted authority, both entry clocks, and the fast-path reset—watch Restoring the peg under collateral impairment + liquidity crisis.

Deadbands​

There are two deadbands, both applied to the price error:

DB_R = 0.15% // rate-mode deadband
DB_P = 0.7% // par-mode deadband
PAR_ON = 1.0% // PAR-mode entry threshold (with hysteresis)

Below the active deadband, the controller does nothing: output holds, integrators don't accumulate. This filters oracle noise.

The fact that DB_R < DB_P is intentional: rate reacts to smaller errors than par. By the time par is moving at all, the system has already been pushing rate for a while.

holdrate PI actsrate PI actspar armspar armsPAR_ON1.0%DB_R0.15%DB_P0.7%0$1.00 peg24 h fast · 7 d fallback24 h fast · 7 d fallback← RD below $1RD above $1 →
Everything keys off the price error (market vs $1.00). Inside DB_R = 0.15% the controller does nothing — output holds, integrators don't accumulate, so oracle noise is filtered. Past it, the rate PI works the error. Only once the error holds beyond PAR_ON = 1.0% (24 h with the rate pinned at a bound, or 7 days in the same direction) does par arm; while in par mode its own deadband is the wider DB_P = 0.7%. Note DB_R < DB_P: rate reacts to smaller errors than par.

Liquidity authority​

Before the deadbanded error reaches either PI loop, it is multiplied by a liquidity authority q between 20% and 100%, so a thin market moves the controller less than a deep one:

q_fast = ramp of the contributing pools' 4-hour liquidity,
from 0 at 500,000 RD-equivalent to 1 at targetLpUtil × RD supply (targetLpUtil = 12.5%)
q_slow = GlobalFeeRouter LP-utilization EMA / targetLpUtil, capped at 1
q = max(MIN_LIQUIDITY_AUTHORITY = 20%, min(q_fast, q_slow))

The 20% floor applies only after the oracle has accepted the price and the RD-supply gate has passed; it never admits a rejected reading. It exists because a depeg tends to drain liquidity, and an unfloored q would let the controller walk back its own response exactly when it is needed. Slew limits, output clamps, dwell timers, leaks and the input price clamp are not scaled by q. Every committed step emits the authority it used in the RateParUpdated event.

Rate PI​

The rate output is bounded:

Lower: 0.25% APY (per-second equivalent 1.000000000079175551708715280e27)
Upper: 50% APY (per-second equivalent 1.000000012857214317438491660e27)
Bias: 2% APY (per-second equivalent 1.000000000627937192491029811e27)

Asymmetric proportional gain, symmetric integral gain:

Proportional (asymmetric):
Kp_over = 1e20
Kp_under = 4.5 × Kp_over = 4.5e20

Integral (symmetric — one Ki):
Ki = Kp_under / 5 days (5-day integral time constant)

The under-peg proportional gain is 4.5× stronger — falling-RD is the more dangerous failure mode, so the controller is more aggressive at recovering from it. The integral gain is deliberately not asymmetric: a sign-switched Ki would reprice the accumulated integrator whenever the error crosses the deadband boundary, cliffing the commanded rate. Instead, the integrator decays with a ~60-day half-life while the rate loop is active (RATE_MODE_ZR_LEAK_PER_SEC): a sustained rate level persists as equilibrium memory, fading slowly unless the market re-earns it — which lets the controller track secularly falling equilibrium rates without manufactured peg deviations.

Slew limit: max delta per hour ≈ 1% APR at the 2% bias point (about 24% APR/day). The rate cannot move arbitrarily fast.

Par PI​

When the baton hands over to par, par moves:

Lower: $0.75
Upper: $1.30
Bias: $1.00

Gains:

Kp_par = 1e18
Time constant = 7 days
Ki_par = 0.7e18 / 7 days

Slew limit: MAX_PAR_DELTA_PER_HOUR = $0.001. Par cannot move more than a tenth of a cent per hour. That's the contract.

What a par change does​

Par changes the protocol's internal valuation, not RD's market price or its $1 target. Raising par increases the collateral received per RD redeemed before fees, strengthening below-peg redemption arbitrage. For example, at par $1.02 with a 0.75% branch redemption fee, redeeming 1 RD returns about $1.01235 of collateral at oracle prices; the separate 0.25% protocol fee is paid in RD on top. This is a settlement example, not a guaranteed trading profit.

Lowering par reduces the value assigned to RD debt in collateral-ratio calculations. That gives borrowers more headroom to mint RD when demand has kept its market price high. The bounds and slew limit above keep these effects gradual.

Leaks​

When a mode is inactive, its output leaks toward its bias:

Par leak rate = 999998853923969325151379472 / 1e27 per second (~7-day half-life toward $1.00)
Rate leak rate = 999998853923969325151379472 / 1e27 per second (~7-day half-life toward 2% APY)

After a stress event ends and the baton returns to RATE mode, par drifts slowly back to $1.00 over ~weeks.

Par leaks → $1.00while RATE mode is active$1.00$1.05~7d ½-lifetime →Rate leaks → 2% APYwhile PAR mode is active2%8%~7d ½-lifetime →
Whichever output isn't holding the baton doesn't freeze — it leaks back toward its bias on a ~7-day half-life. So after a stress event ends and the baton returns to RATE, a par that was pushed off $1.00 drifts home over weeks; and while par holds the baton, the rate relaxes toward its 2% bias.

Update cadence​

UPDATE_INTERVAL = 3 hours
UPDATE_INTERVAL_3 = 8 hours
UPDATE_MAX_REWARD = 60 RD
MAX_CONTROL_DT = 12 hours (cap on accumulated dt per update)

Anyone can call RateParControl.update(), and the protocol also calls it as a side effect of borrower operations, liquidations and redemptions. Keepers are paid through KeeperRewards.updateWithReward(), which drips interest and runs the update in one call. The update reward (getUpdateReward()) is zero until UPDATE_INTERVAL has passed since the last committed control step, then grows cubically to UPDATE_MAX_REWARD = 60 RD at UPDATE_INTERVAL_3, so early callers earn less and the system doesn't burn money calling every block. It is paid only if the update actually commits a step, and it is capped by the RD balance held in KeeperRewards (the drip reward is paid first).

If the controller hasn't been touched in a long time (e.g. nobody triggered an update for days), the accumulated dt is capped at MAX_CONTROL_DT = 12 hours. This prevents a stale oracle from causing a single huge step on first update.

Bootstrap period​

BOOTSTRAP_PERIOD = 14 days

For the first 14 days after deployment, redemptions are disabled (enforced in Aggregator.redeemCollateral). The controller is also frozen during bootstrap: it commits no control step, so rate and par hold at their bias values the entire time. RateParControl gates this itself — lastUpdateTime is initialized to the bootstrap-end timestamp, so no control time elapses until bootstrap is over. During bootstrap update() returns before reading the market oracle at all, and the update reward is zero. Only once bootstrap ends does the controller begin moving rate and par.

bootstrap · controller frozenday 14controller actsrateheld @ 2%parheld @ $1.00time (days) →
For the first 14 days the controller is frozen — lastUpdateTime is seeded to the bootstrap-end timestamp, so no control step is committed and rate and par simply hold at their biases (2% APY and $1.00). Redemptions are disabled over the same window. Only once bootstrap ends does the controller start moving either output.

Terminal shutdown​

If both market pools permanently retire (see RD Market Oracle), the oracle reports that controller shutdown is required. The next update latches controllerShutdown = true and emits ControllerShutdown. From then on every update() ignores the market and only decays: rate and par both leak toward their biases (2% APY and $1.00) on the ~7-day half-life, and no update reward is paid. The latch is permanent.

Reading the controller​

Public getterMeaning
par()Current par value, e.g. 1.000123e18 for $1.000123.
rate()Current per-second rate accumulator (in 1e27 precision).
mode()0 = RATE, 1 = PAR.
Zr() / Zp()Rate / par integrator state.
lastEr() / lastEp()Last committed errors, after the deadband and liquidity-authority scaling.
lastUpdateTime()Timestamp of last commit.
parEntryStart()Fast 24-hour PAR-entry timer. 0 = not armed.
parEntryFallbackStart()Seven-day sustained-error PAR-entry timer. 0 = not armed.
parExitStart()Twelve-hour RATE-return timer. 0 = not armed.
bootstrapEndTime()Timestamp at which the controller starts committing steps.
controllerShutdown()true once terminal shutdown has latched.
getUpdateReward()Current keeper reward for an update, in RD.

What you should remember​

  • Rate is the everyday tool. PAR mode is a stress response, not normal operation.
  • Low authority slows control; it cannot veto PAR forever. Sustained same-direction error triggers the seven-day fallback.
  • The controller is asymmetric. It responds harder to RD below $1 than RD above $1.
  • Everything is slow. Max rate slew about 1% APR per hour, max par slew $0.001/hour. If you see a sudden jump, it's a UI artifact, not the controller.
  • The controller is autonomous. No admin can set par or rate directly.

RD deposited in a branch's Stability Pool is available to absorb liquidations: the pool burns RD and receives collateral when it offsets a liquidated trove. Depositors' willingness to hold RD in the pool can support RD demand, but the pool is a solvency buffer, not a fourth output of the peg controller or a guaranteed price defense. If it cannot cover a liquidation, the branch can redistribute remaining debt and collateral instead. See Stability Pools and Liquidation paths.

Deep dive​