August 22, 2023: LLAMMA Oracles 🔮⛓️
Should $crvUSD discontinue the use of Chainlink oracles as a failsafe?
Under the radar, a serious and nuanced debate is occurring on the Curve governance forums about the use of Chainlink oracles in $crvUSD’s LLAMMA markets.
Wait a minute! Just a month ago, didn’t everybody universally praise the use of lending markets relying on Chainlink oracles to source the price of $CRV externally? Had they relied on the borked CRV/ETH pool, the fear is we’d have seen even greater carnage in DeFi.
Indeed, it’s complicated… and this debate is more nuanced than most. The problem being addressed here is not that Chainlink oracles are faulty, but rather too good.
Oracles in DeFi
If you follow lending markets closely, you’ve no doubt noted that oracles are a big part of the game. What counts as a “depeg?” What counts as “truth?” Who gets to serve as the source of truth in periods of extreme volatility when nobody can agree?
99% of the time it’s easy… you don’t even need to look, you can just say USDC is worth $1 and you’ll be right. It’s the errant 1 block where a price is weirdly skewed, or the confusing depeg weekend, which can make all the difference. The outlier situations when everything is on fire tends to be the most critical period for oracles.
What’s the true price of a token when the CEX is temporarily down, Uni v3 liquidity is out of range, and gas onchain has spiked to such high numbers that the infrastructure is breaking down? Plato never said…
During these weird periods of foul weather, Curve pools usually have the distinction of being singularly functional, while also holding enough liquidity that arb traders can take advantage of momentary fluctuations elsewhere to book profits in their token of choice. The best “truth” value is monetary: wherever traders can plunder the most tokens of their choice amidst the chaos. In times of chaos, this often ends up being the Curve pool. This is one way in which Curve so often claims some degree of “pricing power.”
As we sadly saw last month, this reliability is not as foolproof as hoped. If you don’t plan for the [hopefully] one-off event in which a Curve pool gets its state borked through a hack, then you’re toast. Tricky, innit?
It tends to be the protocols with the most failsafes in place that are best able to survive the traumatic “black swan” events that seem to play out so regularly in crypto.
Oracles in $crvUSD
With a few months in operation, we get to see precisely how the current utilization of oracles in $crvUSD has actually played out in practice.
The broad strategy for determining the oracle price of $crvUSD is to compare four separate Peg Keeper pools. By discounting the influence of pools that are furthest from peg, $crvUSD has been remarkably stable.
From the latest chart published you’ll note that the most concerning hiccup came earlier in August during the fallout from the Curve hack, and even then it was stable within $0.003
So the oracle price of $crvUSD is working pretty well and doesn’t need to be touched necessarily.
The oracle price by which different $crvUSD markets are able to judge the price of the collateral are a completely different beast. These oracles can be replaced and upgraded anytime. Even a few months after release, they remain in an active state of development.
The nice thing about the LLAMMA liquidation mechanism is that the stakes are a bit lower than traditional lending markets. In most lending markets, if there’s a sudden wick, your entire collateral may disappear. For $crvUSD, the risk is that your collateral might get nibbled away at slightly more than you might think is fair. You getting hit at, say, 3.2% instead of 3.1% is not quite the high stakes game of insta-liquidations.
Still, this is the crux of the question being debated on the governance forums. $crvUSD relies heavily on the use of an “exponential moving average” to smooth out sudden price swings. You can see the effect with these plots of Ethereum prices below:
You can see a few different stories in the above graph. The red line is the price of Ethereum wicking under $1800 for about a minute, then recovering to $1850 fairly promptly, as measured accurately by the Chainlink oracle consensus. The dotted green and blue lines show that the exponential moving average was laggy enough as to miss the entire dip below $1800. The two smoothly catch up around $1850.
If you set your collateral to start getting liquidated at $1800, you probably care a great deal about the discrepancy in this chart. These users would prefer to rely only on the EMA price, so the oracle never registers below $1800 and no collateral gets converted (a lossy process due to trading fees).
The “grey” line in the middle is how the system actually functioned trying to split the difference. The story of this line is that it tends to follow the EMA lines, but it has a failsafe mechanism built in by which it moves to rely on Chainlink’s price if it moves more than 1.5% away from the EMA.
The practical upshot of this policy, as shown in the graph above, is that the prices default towards Chainlink prices during periods of extreme volatility.
This is a touch ironic because the EMA exists to smooth out this volatility. It’s a weird situation where $crvUSD relies heavily on EMAs to avoid the burstiness of the volatile crypto markets, but then tosses out this EMA during the most volatile periods when it would most benefit users.
These oracles were all designed with the conceit that Chainlink oracles should serve as a failsafe in mind. After all, Chainlink is a good and accurate measure of spot prices. But the issues with combining a smoothed price with a spot price were foreseen, and hence the code comes with a simple toggle to flip off Chainlink dependency.
Since crvUSD was designed and tested with the smoother EMA in mind, the performance we’re seeing in prod is likely worse than ideal. This was the gist of the proposal, which points out that the spiky spot prices also caused needless losses in real portfolios.
Mich also provides some analysis on potential manipulation vectors under EMA.
The forum discussion is quite active, including an interesting post by @observerdq diving into arbitrageur profits
The consideration that keeps us awake at night these days is those “unknown unknowns,” such as we saw earlier this month in the CRV/ETH hack. The existence of the Chainlink oracle might cause slightly higher losses for users at the moment, but if we reasonably believed it could protect against an unforeseen catastrophic, then arguably it’s worthwhile?
The idea of limiting losses further under $crvUSD LLAMMA is directionally correct, but in practice $crvUSD is already the friendliest mechanism by a country mile. We’ll give subscribers a sneak peek at some numbers we’re crunching on this front…