June 16, 2023: The Peg Keepers ⚖️💰
Semi-Technical Dive into how Peg Keepers keep $crvUSD Balanced
No Llama Party today! In case you are disappointed by these developments, we can offer you a special bonus if you read to the end!
Even without a party, we can leave you with some video content to enjoy. A five minute semi-technical dive into the $crvUSD Peg Keeper pools:
Putting together this video was perfect timing. Over the past month, we’ve seen issues with both $TUSD and $USDT, both relatively minor. This is the ideal sort of “test in prod” style choppy waters that $crvUSD is theoretically constructed to sail through smoothly.
For its part, here is how $crvUSD has interpreted the various stablecoins via the great new Curve Monitor dashboard.
Here we see the role of the four Peg Keepers on display. Each of the Peg Keeper contracts is responsible for interfacing with one of its associated pools. Each of them have fluctuated, but the Peg Keeper can average out among the discrepancies to decide what the truth is. In the event the above-mentioned pools depeg, the $crvUSD Monetary Policy can reduce its reliance on the errant pool and continue tracking peg.
Here we see the affiliated Curve pools:
The Peg Keeper pools are simple vanilla pools. Similar to 3pool, they’re just optimized to do an outstanding job trading two tokens which are meant to hold a stable value.
The entire $crvUSD monetary policy takes it cues automatically from the Peg Keepers. Based on the balances of the pools, the various $crvUSD markets adjust the borrowing rate. In the early days, with the TVL relatively small, we see this can cause wild fluctuations of the borrow rate, but potentially at scale this volatility may diminish.
Even fully redeemable 1:1 backed stablecoins have issues. Enter the Peg Keepers. Peg Keepers have a unique power. Other than directly taking out a loan against collateral, the Peg Keepers are the only other contracts authorized to mint $crvUSD. However, their powers are limited to the confines of their programming, which allow them only to trade $crvUSD into and out of their affiliated pool to try and stabilize it.
Even if you don’t code, we expect you can follow the basic logic. Depending on the supply and demand of the different assets, they are merely trying to trade imbalances in the pool to make a profit. In other words, it will mint new $crvUSD into the pool if the price is too high (dumping the stablecoin) or remove $crvUSD from the pool if the price is too low (pumping the stablecoin).
Astute readers may wonder about one fact — smart contracts can’t call themselves. So who is calling this update function? Chainlink has an ability to run scheduled tasks, but $crvUSD has a more elegant mechanism…
Here, step back to note that $crvUSD’s entire architecture represents a careful balancing of incentives among all participants to push the system forward. For instance, we know arb traders will always desire to trade stablecoins to make profits, so their behavior in arb trading the Peg Keeper pools will work to reinforce the peg.
Similarly, we know that nobody would pay the gas to call the update
function without a reason, so it literally pays to do so. That is, the Peg Keepers are trying to add and remove $crvUSD from the pools to trade them to a profit. Whoever calls the update
function gets a share of the profit (it’s set to 20% to begin with, with the remainder sloshing back to the Curve ecosystem.)
Now, $crvUSD remains quite small, so you’re not likely to get rich off this at the moment. For the video, we looked at the current state of mainnet and saw that, indeed, the UDSP pool had built up some unclaimed profits (about $4.92 worth).
Simulating the transaction, we see that you actually receive $4.95 (the received amount is equal to or slightly higher than the forecast amount due to the increasing value of the LP token). Not bad, but it would have cost $7.23 in gas to do so. Not a great return, and hence why this is probably just sitting there. Maybe if you are cozy with validators you could find a way to run these functions cheaper?
Nonetheless, we told you we’d give you a bonus for reading to the end of the article, and there it is. A money faucet that occasionally leaks money to whomever is willing to help crowdsource trading of these $crvUSD pools via the Peg Keeper contracts.
Here is the github repository for the brownie script to runs this for educational purposes only! https://github.com/curvefi/vyper-tutorial/tree/main/crvusd/peg-keeper
Awesome video and code repo! Thanks for sharing the love! 👏👏 Always wanted to know how to do these checks and maybe become a pegkeeper myself
Fabulous!