February 5, 2024: Llamma-Simulator π¦π¬
Exploring parameter spaces for forthcoming Curve isolated lending markets
Llamalend, aka Curve Lend, has yet to be released, but it appears to already be affecting the Curve ecosystem.
There are many wonderful things about permissionless isolated lending markets, but one tangential benefit would be that it would provide a brand new market for Michi to play with for his enjoyment of using lending protocols with his ample $CRV stash.
Speaking as foot soldiers on the front lines fighting FUD every day, weβre particularly look forward to seeing how this mutates Curve FUD into a more grotesque form.
According to some rumors, some of the $CRV shorts have caught wind of the plans and already started closing their position, but I either sourced this from potentially-Photoshopped pics in private chats, or some dark and twisted dream from the dankest depths of my subconscious. Needless to say, neither should be considered reputable sources.
What is real and far more immediate is the release of various simulation results performed on the upcoming lending markets, a sign weβre quite close.
The headline claims are enticing⦠the ability for degens to permissionlessly create their own isolated lending markets on various chains, with soft liquidation protections and hefty LTV ratios⦠you can just imagine how much fun the community may have with such powers.
Smoller-brain, reporting for duty! The nice thing about these simulators is that they are generally quite easy to follow β itβs in fact intended that anybody can (and should) download the repo and make adjustments to parameters and report their results.
The prerequisites are installation of some of the most common and easy to install Python libraries.
You then need to get some price history data for your tokens, to provide the simulator real-world data of how the tokens actually trade in the wild.
You can simply use the sample data already pulled from Binance in the data directory, but better to use the included scripts to pull your own over a different window.
As you can see, Mich has run simulations on $CRV and a variety of tokens that indicate a cross-chain future: $ARB, $BNB, $LINK, $TRX, $ETH, as well as fiat-based memecoins like $EUR.
The script is not complex if you want to pull from a source other than Binanceβs API, or modify it to pull your own.
It can be a bit of a slow process β running one of these on my local machine took a bit over an hour, meaning I couldnβt really run too many simulations outside of confirming the sample data provided.
Once you have the data, the simulator focuses on sweeping over various parameter spaces to see how the performance would be affected by very slight tweaks.
The README cites the example of testing how a userβs loss would be affected by different AMM fees. Presuming you want to minimize and not maximize user losses, the sweet spot is cited around 0.6% for a $CRV market.
The script uses an extremely risky position (4 bands) and a moderate value of 50 for the A parameter (both of which are also tested later). The fee as a variable runs over a logarithmic space, from .05% to 5%
Estimated Losses by Fee Results for CRV
In the chart above, you can see the local minimum of losses (y-axis) hits with fees around .6. The jagged nature of the line is because these are just simulations with random chance odds.
The nice thing is that the results for the other tokens tested come up similar. Looking below, you can easily eyeball that for most of the tokens, something under 1% fees is the sweet spot.
ARB
EUR
TRX
BNB
As you can seeβ¦ for several of the tokens, they also include an orange line in addition to the blue line. The orange line is the βloan discountβ β the sum of losses and the value of liquidity if price slowly goes down, which weβll discuss below. For these fee graphs, simply note that the orange line makes little difference, itβs basically just the blue line but a bit higher.
ETH
LINK
A Parameter
The fees above were all tested presuming an A parameter of 50 β but what does it look like if we vary the A parameter? The second batch of tests looks at A, over a logarithmic space from 10 to 300, using the value of .6% from above for the fees and again at the riskiest 4 bands. Again, we optimized against user losses.
CRV
Here the orange line makes a bigger impact. This line represents the βliquidation discount,β and serves as the line we attempt to minimize. This line also informs the LTV for the market.
The optimal values for A look fairly similar among volatile crypto tokens
ARB
BNB
A bit lower losses for $BNB
ETH
$ETH even lower losses, and can handle a larger range of A parameters.
EUR
Very low losses for the Euro, which is unofficially hard-pegged to the USD.
LINK
LINK behaves similar to BNB
TRX
Number of Bands
Mich being a DeFi adrenaline junkie means heβs particularly interested in how the lending market is performant against the minimum of 4 bands, but some of us are more timid. He therefore also looks at how losses fall off with higher bands.
While $CRV saw about 0.6% losses per day at the optimal parameters for N=4, this drops down to a mere 0.06% if you expand to 50 bands. Note that the default number of bands in the UI is 10, which would be a bit under 3% losses.
As of publication, not every token had been updated with these charts. These charts donβt really have any value to βminimize,β although you can use it to eyeball the severity of the dropoff.
ETH
LINK
TRX
More
The $CRV market in particular has more robust testing than most. For instance, the $CRV market tests the value of T-exp, which affects the exponential moving average:
As you can see from this, the actual surface space of the parameters being optimized is quite large. We have several parameters, but just 2d monitors and 1d brains. This way of attacking the problem is sufficient for finding local minima, but holding nearly every parameter constant is a reductive approach.
Given enough time and compute, one could simulate this over the entire surface of possible parameters and identify a Pareto optimization. Itβs unlikely that significantly more efficient minima exist, but simulations and reality often uncover surprising results.
Weβve seen good results looking over 2d parameter surfaces where two parameters are varied at a timeβ¦ for instance, the TriCrypto simulations run last year:
Given that these simulations have an element of random chance, better if many people conduct these trials independently on different sets of data to confirm if further optimizations are possible.
Fortunately, you have all the tools at your disposal! Make sure the $CRV lending market is safe so we donβt accidentally death spiral ourselves! Llamas, you now know how to get it done!