November 18, 2022: @nagaking π π
Join the live Llama Party with the great @nagaking at 9 AM PT
Join
live for a Llama Party at 9 AM PT streamed at the above link!Or come join the party in the Discord: https://discord.gg/FJpF8zFR?event=1042444914174197781 β members can join before and after in the private VIP room!
Some background on the great @nagaking:
CMC
Ser King β tell us a bit about yourself! Who are you, what do you do, whatβs your role with Curve? How did you get so smart?
nagaking
Hey! I do research and analytics for the Curve DAO. My main job is pool optimization, but I also do some other analyses related to market dynamics, risk appraisal, and whatever else it seems like we should take a close quantitative look at.
One great thing about Curve pools (both V1 and V2), is that they have adjustable parameters that allow you to fine-tune their market-making strategies -- so you can optimize these parameters to "dial in" good approaches for different token pairs, market regimes, pool sizes, etc. So, a lot of what I work on is trying to estimate the best parameters for each pool, with the goal of maximizing returns given a reasonable risk tolerance.
Who I am is maybe a harder question. You could probably think of me as somewhere between a nerd and an aging punk kid with a pathological focus on freedom. To the extent that I'm smart, it probably comes from my mom pulling strings in the PTA to get me the best teachers from a young age. From then on, I mostly learned from the internet, and a few proper geniuses I cornered into mentoring me for years until I had downloaded their minds.
CMC
Tell us about the new Curve Sim. For the readers who are interested in tech but not coders themselves, what should they know?
nagaking
Curve Sim is a tool for optimizing Curve pools by simulating how they would likely behave if their parameters were changed. Typically, we use it to estimate how changing pool parameters (i.e., for V1, A and fee parameters) would have effected profits, volume, pool balance, etc. given recent price action (usually 2 months). We then use those results to help inform the DAO of potential risk/reward of various parameter proposals, or to make proposals ourselves.
Initially, this package was essentially a (messily-coded) script that did one type of analysis. It took a price feed and a V1 pool, and simulated arbitrageurs trading against the pool at each timestep, with their potential trading volume limited by historical volume.
Now, working with (the amazing) Chan-ho Suh, we have developed this into a much more flexible package. Essentially, we wanted to address limitations of the original version which we had identified through the previous market cycle, and also to generate a more developer-friendly package to facilitate community contributions.
So, this first official release is our first major stride towards that. We have entirely refactored the code from the ground up, and broken down its functionality into easily customizable sub-components. So, rather than a single script, you now have a factory for simulation pipelines, and "volume-limited arbitrage" is just one of many potential pipelines.
Having now built this platform, we are now working on filling out this design space by implementing more pool objects (including V2 pools and competitor pools) and additional pipeline components that we expect to provide more robust, generalizable, and informative results. For example, instead of just using historical prices, we will also generate other "alternate price histories" with similar statistical properties to help us get a sense of the generalizability of the results.
We're also working on smarter ways of sampling and analyzing the parameter space. So, instead of doing a naive parameter sweep, any pipeline will be able to iteratively refine its search of the parameter space based on user-defined goals. Perhaps most interestingly, this will include multi-objective optimizations, so the simulator will actually take into consideration tradeoffs betweeen, say, profits and pool imbalance (currently humans do this).
CMC
For the more technical, youβve been very busy on Github lately, and you run a bunch of interesting analyses diving into the higher level math of DeFi. Whatβs your tech stack?
nagaking
Well, I wish I had something more interesting to say here, but its a pretty standard python "stack". Most often I'm using pandas, with scipy for numerical optimization. The fancier optimizations I mentioned above use the skopt (scikit-optimize) and pymoo packages, which are both delightful. We also use gmpy2 for faster big-integer computation. I also like SymPy for just toying around with math ideas.
CMC
Thereβs been a ton of interest in crvUSD of course. What are your thoughts? From the conversation about it so far, what would you want to add into the conversation? What do you predict about what might happen and how it might reshape Curve?
nagaking
crvUSD is another giga-brain, almost shockingly creative idea from Michael that exemplifies how DeFi can accelerate innovation well beyond stale tradfi approaches. The main thing I'd want to emphasize in the current conversation is that, in my opinion, the core innovation is how quasi-liquidations work. With crvUSD, there is not a fixed bound that triggers liquidation whenever it is crossed (even transiently!). This is replaced with a smoothed-out mechanism that is more akin to an automated market-maker, so that a "scam-wick" liquidation is replaced with a transient moment of impermanent loss -- no liquidation. If you think about that a bit, it becomes apparent it is quite revolutionary.
My prediction is that it will be a game changer, but I don't have firm expectations of exactly how. To venture a conservative hypothesis, I imagine it will take some market share from stables that use more "unfriendly" mechanisms.
CMC
Youβre among the very few people to understand Curve v2 math - how exactly does it work under the hood? Now that itβs a year old, what might people still not understand? How can they use it best?
nagaking
A good mental heuristic is that its like a V1 pool, but the usual "balance-point" (i.e., 1:1 exchange rate) shifts over time based on a running average of recent exchange rates. So, instead of maximizing liquidity at 1:1 exchange rate, it maximizes liquidity around the recent price.
Now, one more layer of complexity comes in here. Since constantly rebalancing the pool based on the changing reference price would result in horrendous impermanent loss (aka being "arbed to death"), a "guard" is put in place. The pool is only allowed to rebalance if it would lose less than typical IL plus half its fees.
I think the main information gap right now is about communicating historical and expected returns. People want to have a clearer sense of what they stand to gain or lose given various price movements. There are a lot of people working towards that goal throughout the Curve community right now, and I expect this will be cleared up soon.
The best way to use it is for passive liquidity provision. The idea is that it should do the work for you. One current weakness is that its complexity requires a fair amount of gas. That entails that it is most desirable to traders who are making large trades (since gas is a fixed cost). So, that suggests it might be best to use it on some L2 where gas is cheap, but I don't think this will be the case forever... (see "alfa" below).
CMC
Tell us a bit about these:
nagaking
These are prototypes for V2 simulation tools. They show a results viewer and two of the more advanced optimization tools I mentioned above. Since V2 has a large number of parameters, a complete search of the parameter space is infeasible. So, we needed some way to sample the parameter space more efficiently. Those were first proofs-of-concept showing that this is possible, and we can find optimal parameters much faster than a naive parameter sweep. This will probably be incorporated into the package in the next few months, and we'll use it for both V1 and V2.
CMC
What do you make of the rivalry between Curve and Uniswap?
I guess it depends which day you ask me. In general, I think healthy competition is good and there's no doubt both teams are delivering incredible products. The one gripe I've had is that I don't really think Uni v3 is actually that great for stablecoins, and that Uni or Uni-adjacent people haven't been particularly forthcoming about the potential risks there. That UST depeg chart is an example of one thing I don't think has been made clear enough to LPs. When the price exits your last tick, you are 100% in the losing coin. The marketing was kind of dangerous in that way: it framed things fully in terms of maximizing liquidity density, and not fitting the appropriate liquidity density to the market and its risks.
nagaking
What protocols getting built on top of Curve do you think are interesting or noteworthy?
Honestly, I haven't had much time to explore them all very deeply. But I've been pretty impressed by the level of ingenuity and creativity I've seen across the board.
CMC
You comment a lot about the regulatory state for crypto. Are we effed? What do you see as the narrative for cryptocurrency long term?
nagaking
I'm not sure. Crypto always has a last-ditch pivot available where we take it completely encrypted/private, but I hope it doesn't come to that. I think its a given that many politicans and government officials are incentivized to be as resistant to crypto as they can be. But I've been encouraged by the quality of the lawyers and lobbying efforts that we've seen develop over the last couple of years. FTX obviously set us back, but it was good to see JP Morgan, for example, making clear the distinction between CeFi and DeFi.
All in all, though, I'm a simple man -- I buy whenever I start to feel like its going to 0 forever.
CMC
You often weigh in on changing pool parameters -- talk through your thought process a bit on this.
nagaking
I basically view this as our primary responsibility in doing these analyses. If we're not keeping the DAO informed, then what's the point? Typically I try to consider what I think anyone would consider: risk vs. reward. One of the worst things the DAO could do is set parameters in a way that exposes LPs to unneccessary risk. At the same time, of course, potential payoffs usually scale with risk. So we need to essentially optimize that tradeoff. That's one reason I'm really excited about this multi-objective optimization stuff -- we can compute those tradeoffs a bit more rigorously.
I also try to consider how likely the simulation results are to be predictive of the future, and make that clear whenever I post results. I also think its important to consider how each pool interacts with the broader ecosystem. In some cases, that highlights something that isn't well accounted-for by the sims.
CMC
Whatβs the DeFi product market fit - normies or large institutions?
nagaking
This is a good question -- I had to think about it for a while. I think my ultimate conclusion is that it cannot work without both. If we truly want to democratize finance, and eliminate built-in payoffs for priveleged money-handlers, we absolutely need normies to be able to easily interact with DeFi, pool their money, and even potentially contribute to governance. On the other hand, large institutions of course hold the big bucks, and interactions involving those large sums is where sustainable profits will be made. Ideally, one important role of DeFi would be to act as an unbiased intermediary between everyday people and large institutions.
CMC
Any alfa you can give? Other things I should have asked?
nagaking
The best alfa is that incredible progress has been made on reducing the gas for the V2 contract. We're talking some genuinely giga-brain stuff here. So that will be coming out sooner or later. Maybe people already know that? I'm not sure.