September 5, 2023: Labor of Love 🛠️❤️
Unpacking the Labor Day governance proposal to optimize TriCrypto pools
You may have been enjoying your Labor Day weekend, but Michi was clearly busy.
Next time you reprehensible jackals feel like giving Mich crap for not being homeless, remember who shows up at the arena nearly every weekend and holidays.
If you’re anything like me, you probably glanced it over and said to yourself… “eh, this looks complicated. I’ll wait for the CurveCap Substack post to come out and explain it like I’m five.”
Well, I for one was taking a holiday, so I rugged you all for 24 hours while I struggled to comprehend it myself. Here’s my stab at it…
Firstly, this post presumes prior knowledge of Curve v2 parameters. If you’re fuzzy on these parameters, review Nagaking's classic post:
Curve v2 Pools and Their Levers
If you’ve followed Curve for any length of time, you’re likely familiar with the “A” parameter that defines how tight any given pool holds its peg.
In order to trade volatile assets, v2 pools introduced many more parameters that affect the shape of the curve and other functionality of the pool
Bonding Curve Parameters: These are the heart of the pool, determining how assets are priced when traded. The eponymous curve is shaped by two main controls:
A: Affects how flat the middle of the curve is, ensuring liquidity is focused around the most common trade prices.
Gamma: Adjusts the overall shape of the bonding curve, useful when the pool gets imbalanced.
Price Scaling Parameters: These parameters affect the pool's 'memory' of recent prices.
Instead of setting a fixed price for assets, Curve v2 pools store an average of recent trade prices and compute a moving average of these prices to extrapolate the actual price of these assets (“price oracle”)
MA half time: Dictates the smoothness of this price oracle’s curve, which overall affects how sensitive the pool is to changes in the assets’ prices.
If conditions are right, pools repeg the main trading price (“price scale”) to match this moving average (“price oracle”). This repegging only occurs when the pool may do so “profitably” and passes minimum thresholds set by two more adjustable parameters:
Adjustment step: Minimum difference between price scale and price oracle to allow repegging.
Allowed extra profit: Affects the minimum threshold of profits which must be banked to allow repegging (excluding losses due to price fluctuations)
Fees: Curve v2 doesn't charge a fixed fee. Instead, the fee depends on how balanced or imbalanced the pool is.
Fee Mid: The fee when everything's balanced.
Fee Out: The fee when things are totally out of whack.
Fee Gamma: Controls how quickly fees change between these two extremes when the pools grows imbalanced.
This is admittedly a lot, but you only need to remember three of these parameters to understand this weekend’s analysis… Gamma, Fee Gamma, and Fee Out.
Mich’s Analysis
The excitement from this weekend came as Mich looked over results from the newer TriCRV pool and compared its performance with existing TriCrypto pools.
In particular, he was curious why TriCRV tends to see such better trading APYs. These are the profits that accumulate to LPs (and veCRV stakers) based on pocketing trading fees. So setting these values correctly can stimulate TVL and possibly, if crypto traders were more rational, the price of $CRV.
Since v2 pools handle volatile assets, one might think that trading fees due simply to arbitraging these pools to exchange prices would be very good relative to v1 pools, since the prices of assets move so often. Yet observe how much better TriCRV performs against TriCrypto.
TriCrypto USDT
TriCrypto USDC
TriCRV
As you can see, TriCRV is earning between 4-5x the trading fees. The two TriCrypto pools also have some key differences in their parameters from the TriCRV pool.
We’re most concerned with the parameters that directly affect fees here, which are the three parameters in the middle. The mid fee, for when the pool is balanced, is identical among all pools. But the out fee is way higher for TriCRV. So it seems quite obvious that this could be causing the TriCRV pool to be way more profitable.
But there’s a delicate balance here. Of course, if you raise fees to a kajillion dollars, you could hope to make a lot of money, but volumes would plummet to zero and nobody would bother trading the pool and you’d lose it all.
To test this, Mich included a companion GitHub repository which is easy enough to understand that even noncoders should feel comfortable browsing.
The core of it is a short python file simulation_int_many_2_1.py which approximates how a rational trader would trade. This behavior is simulated against real price data (stored in the price_feeds folder). Using this file, anybody can feed in different parameters, and see how the pool activity would fare in terms of things like slippage, volume, and most importantly APY.
The outputs of his various trials are all included in the Github repo, and cross-posted to the governance forum. For further convenience, here we present them all as one image so they can be lined up and compared among each other.
Essentially, each individual chart has two axes which iterate two adjustable parameters (gamma and fee gamma) across a fixed range. On each row of charts, the color of the heatmap shows the outcome of a particular variable we’d like to optimize: APY, slippage, and volume. Finally, for each column of charts, we adjust the out_fee, to see how the overall behavior changes.
One final note that may affect your reading of this, and the real tricky part, is that the color scale is not constant across all columns. So if you just think… “hey, there’s more red on the left side of the APY, let’s do that!" you’re missing the fact that the leftmost chart is a range from 2% to 12% APY, while the rightmost chart ranges from 5% to 55%!
Since it’s tough to see in the heatmaps above, there is also a plot of the actual best results as we sweep the range of potential out fees.
You might notice that this appears to follow some fairly smooth curves — in which APYs always get higher as you increase the out fee, but the effect tapers off above 3%. Meanwhile, the typical slippage gets minimized between 2-3% and the volume peaks around 2.5-3.5% — and therefore Mich suggests trying an out fee of 3%
Within the charts, there’s sort of a sweet spot in the bottom left quadrant where you can select a value for gamma and fee gamma that gets you in the red zone for volume and APY, while landing towards the blue zone for slippage.
Therefore, Mich suggests adjusting one of the two TriCrypto pools to these new parameters to see how it works in the wild. If it works as well as it does in theory, then it means a sort of triple whammy for Curve — optimizing slippage, volume, and APYs in one shot.
If it goes well, then other TriCrypto pools could be adjusted after the fact. However, it’s not so cut and dry that it’s worth immediately changing these parameters. There’s a few other consideration for veCRV whales when voting on this.
For starters… the author of the proposal recommended against implementing it yet!
“Ahhh… I’m optimizing!”
If it interferes with LLAMMA, there’s a few other considerations before it makes sense to sign off on this trade. For example, the Peg Keeper pools rely on extreme precision to keep $crvUSD pegged so tight. Also, don’t forget that one of the Peg Keepers is undergoing its own split test to see the effect of doubling fees, so maybe some variables could get contaminated.
A lot going on behind the scenes, but it’s the sort of iterative “test in prod” sort of stuff that’s to be expected with Curve at the bleeding edge of experimentation. Thanks to Mich for being the leader we need!
appreciat 😊