Oscar D Þorson 🇺🇦🇮🇱 Profile picture
Outside the metaverse also sometimes known as Stefan Loesch. Finance. Tech. Banking. Fintech. Blockchain. IDCAP & https://t.co/WrruLg4e2y.

Oct 1, 2021, 31 tweets

I am working on paper on Impermanent Loss, and I want to put a few thoughts out here to get them sorted before the paper proper is published

quick reminder: Impermanent Loss is what happens to you when you provide liquidity in an AMM, and it usually is everything but impermanent

IL is generated because an AMM sells the outperforming asset and buys the underperforming asset, so you miss out on the moon shots, but you are fully invested all the way down...

if you think this looks like a positive Gamma buy-low-sell-high strategy, you are absolutely right; except you aren't because AMMs only keep the IL, but a convexity gains are handed over to arbitrageurs.

I've written about it here drive.google.com/file/d/1en044m…

(which in turn shows why the "Impermanent" moniker is such a mixed bag: if MOONTKN goes 50x your AMM only goes 10x. That's your IL. It is permanent unless MOONTKN comes crashing down again

our traditional AMM works using a bonding curve. the traditional bonding curve is k=x*y where k is a konstant, and x,y are the token amounts in their native units; an AMM is happy to trade anywhere on this bonding curve

(pro-tip: if f(x,y) = const than g(f(x,y)) = const as well; if you can choose an f such that f(lam x, lam y) = lam f(x,y); you'll thank me later).

In other words: we nowadays use k=sqrt(x*y)

for the k=sqrt(x*y) traditional AMM we find the following IL curve (in a complete abuse of notation now x is the price ratio between the two assets)

this IL function looks asymmetric, but this is a pathology introduced by a choice of numeraire; on the right hand side your risk asset moons, on the left hand side your numeraire asset moons; but as you measure in the numeraire asset you don't see it

now Impermanent Loss sucks, so what can you do about it? Stay tuned, will continue later...

alright, so let’s talk about curves; that’s our standard k=x*y curve; it hugs the x and y axis so it can cover the entire price space, but at the cost of slippage and IL (more on both below)

that on the other hand is the k=x+y curve; it is special in that if offers up its entire liquidity at a fixed price, until it runs out at either end

the red curve here is the same constant exchange ratio curve _except_ that is has two stops: it does not deplete the entire pool, but it stops trading when the curve goes vertical or horizontal

the blue curve is essentially the Curve curve, for trading stable coins: very flat in the middle, so a lot of apparent liquidity over a relatively small range of prices, and then it stops

and now what y’all have been waiting for - the Uniswap v3 curve: v2 in the sheets, Curve in the streets

In other words: where it hugs the green curve it is just k=x*y; where it goes off it stops trading

in fact, the real Uniswap v3 curve is this one: it is the same curve, but the coordinate system has been shifted to the red one by removing all the tokens that can never be traded out of the pool

and if this reminds you something, you are right — it is almost like this Curve-style pool from the beginning that would move 100% from one side to the other, except there is some curvature so the price is not fully flat

(maybe I should have mentioned that the slope of the curve is the exchange ratio of x and y, ie the price)

alright, moving on. let’s look again at the IL for reference and stick some numbers to it. Note that exchange ratios are now normalised to 100 initially, and the y axis is IN PERCENT

what we see here is that IL is relatively benign for narrow ranges - it is below 2% for 65-140 and even smaller for 80-120 or 90-110

We now put this together with our Uniswap v3 restricted curve from earlier on. In this picture the range is about 60-140 so maximum IL is 2pc. Right? Radio Yerewan answers: in principle, yes. But…

The “but” here is that the 2pc are on the unlevered AMM that started with $100 of each of the assets, but we removed all the assets that can never leave the AMM. As a percentage of the smaller amount the percentage IL is significantly higher.

I am still working on presenting this more nicely for the paper; suffice to say that the numbers can be higher for narrow ranges.

So this is point 1. Whilst IL in narrow ranges is small, so is the liquidity required. Once leverage is taken into account number goes up.

In the paper we look at a number of positions. From memory- I don’t have my computer- it’s a 20pc range that started out of the money and went through to the other side.

For a 90-110 range the unlevered IL is only about 0.2%; however, because of leverage it becomes 5%

So in the paper we are looking in much more detail at the various scenarios. It actually becomes surprisingly complex — especially dealing with positions that have multiple additions and/or withdrawals is …. hard

A related issue is what you should do about positions that are out of the money. Reminder: when you move through the money you always get exchanged into the asset that is falling!

So let’s consider a levered stable-to-stable pool. There are mostly two scenarios. (1) the coins are range trading, and 90-110 seems very generous for two USD coins. (2) one of the coins is collapsing (algo coin; audit issue; the works)

So 90/110 protects you against losses, right? Well…

Firstly IL is measured against HODL. In an unlevered AMM that stops trading at 90 HOLD still loses 50pc and so do you. What the 90 limit does is preventing you from buying into a falling asset. Little IL, big loss.

Secondly on the levered AMM you are already 100pc in the collapsing asset at 90. So yeah — you don’t buy more of if, but you don’t have to. So is one side is collapsing you still lose everything.

that was a bit of a tangent but shows how complex IL can become in a levered AMM world. you started out with $100 and end up with zero. $50 are HODL losses, $45 are directional losses, and only $5 is IL.

continues here

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling