Read the Beforeitsnews.com story here. Advertise at Before It's News here.
Profile image
By FalkenBlog (Reporter)
Contributor profile | More stories
Story Views
Now:
Last hour:
Last 24 hours:
Total:

A Simpler Formula for Impermanent Loss

% of readers think this story is Fact. Add your two cents.


There are many articles on impermanent loss, and most present an explanation where a formula is alluded to in many words but never presented (see here, here, here, and here). To cut to the chase, the Impermanent Loss for an unrestricted Uniswap liquidity pool can be calculated as

This is a unitless measure in that it represents the Impermanent Loss as a percent of the initial investment value, in that the graph below is identical regardless of whether your initial price is 1.0 or 100, or whether you put in $7 or $777. If you put in $100 of tokens, the formula above tells you that you would lose $2.34 if the price fell 39%, as shown in the chart below.

I found two articles online with formulas, but they require the user to read a bunch of words to figure out how to apply them. For example, Peteris Erins presents the formula:

eq2

I find this formulation annoying because in the Uniswap v3 white paper k is liquidity^2, while here it is the gross return, pt/p0. Further, you are assumed to know this should be multiplied by the initial token quantities at the current price.

Another common online formula can be found in the oft-referenced study of LP impermanent loss by TopazeBlue, which presents the IL as

eq3

They make it unnecessarily complicated by defining xt as the ‘exchange ratio normalized so that x0=1,’ as opposed to defining it as the gross return (i.e., pt/p0). Their number applies to the initial pool investment as mine does.

I like my formula because it makes the pnl distribution more intuitive: it’s proportional to the square of the difference in starting and ending square root of price. Further, it is obvious how the LP’s loss is symmetric and negative, analogous to a short straddle position. Plus, I don’t add new letters like x or k!1

All three give identical results, however, so, use whatever works for you.

For anyone interested, it can be derived in two ways:

Derivation 1

Everything comes out of a couple of equations. First, the price is represented by the ratio of the tokens in the pool. For example, with 2500 USD stable coins and 1 ETH, the price would be 2500, which is just common sense.

eq4

Secondly, for an existing pool, a trade with ETH going in and USD going out is subject to the following rule: the product of both tokens must be maintained at its existing level, a constant we will call k.

eq5

The two above equations are the basis for calculating changes in price or tokens as a function of other variables. Any change in USD or ETH must satisfy the following equation so that the product of the two tokens remains constant: 

k will vary for a given price as liquidity is added and removed. For example, with {USD, ETH} equal to {2500, 1}, k=2500, while if it were {5000, 2}, k=10000. We define liquidity as the square root of k, the geometric mean of the tokens in the pool. This metric is more meaningful (see below), so we will replace k using the definition

Given liquidity and price, we can derive the amount of USD in the pool. We do this by combining eq4 and eq5 to get

Which simplifies to

eq6

Similar math applied to ETH gives the equation for ETH as a function of liquidity and price:

eq7

Change in price and change in tokens

Given eq6 and eq7, a change in tokens is simply the difference in the quantities computed at an initial price (p0) and an ending price (pt): 

eq8

eq9

Here we see that liquidity represents the number of dollars exchanged for every integer change in the square root of price. This is why liquidity is more intuitively meaningful than k.

Fill price as geometric mean

Unlike centralized limit order books, a nontrivial order will not take out a singular price listed by a limit order, but traverse a continuum of prices based on the above axioms. This makes the fill price a little trickier. The fill price (pFill) is defined as the ratio of the USD and tokens exchanged in the trade.

Substituting with eq8 and eq9 we get

This simplifies via standard algebra to the geometric mean of p1 and p0. This fill price formula allows us to get better intuition as to token amounts in ranges.

While the above does not work if p1=p0 (division by zero), in that case, the fill price is trivially p1 or p0.

The LP’s profit as a function of the starting and ending price of a transaction is the number of tokens bought/sold times the difference in the current (or ending) price and the fill price.

substituting we get

simplifying we get

eq11

Now, here I’m using p1 instead of pt, but this applies to the cumulative change from p0 to pt as well. It’s more intuitive to think about as a single transaction, but whether one gets to pt via one transaction, or 27 transactions with buys and sells, the result is the same.

Note also I’m calling it the LP’s pnl, as opposed to the LP’s IL. This is because the LP is taking the other side of a trade that is pushing the price, and necessarily loses money the further the final price is pushed from the initial price. If the LP borrowed ETH to initiate his pool position, this would be his USD pnl; if he had the ETH initially, it would be an opportunity cost. In either case, it represents what is generally known as the IL.

If the price were USD/ETH, this would be denominated in USD. To turn it into a percent of the initial investment, we need to divide it by the initial investment. The USD value of the initial investment is just 2 times the value of the USD initial investment since the ETH initial investment value equals the USD initial investment. By substitution of eq6, our initial market value sent to the pool is then a function of liquidity and the initial price:

eq12

Dividing eq11 by eq12, we get the loss in percentage terms for the LP given a starting and ending price.

Derivation 2

The IL in USD for an ETH-USD pool is the value of the current pool position compared to the initial quantities at the current price.

rearranging we get this in the change in tokens

We can substitute for the change in USDC and ETH tokens using functions of liquidity, and starting and ending price. Note we always use the square root of price, which is why this is a state variable in Uniswap pools. Using eq8 and eq9, and substituting we get:

rearranging we get

which simplifies to

This is identical to eq11 above, and so it similarly transforms into the unitless measure of IL(%).


Source: http://falkenblog.blogspot.com/2022/11/a-simpler-formula-for-impermanent-loss.html


Before It’s News® is a community of individuals who report on what’s going on around them, from all around the world.

Anyone can join.
Anyone can contribute.
Anyone can become informed about their world.

"United We Stand" Click Here To Create Your Personal Citizen Journalist Account Today, Be Sure To Invite Your Friends.

Humic & Fulvic Liquid Trace Mineral Complex

HerbAnomic’s Humic and Fulvic Liquid Trace Mineral Complex is a revolutionary New Humic and Fulvic Acid Complex designed to support your body at the cellular level. Our product has been thoroughly tested by an ISO/IEC Certified Lab for toxins and Heavy metals as well as for trace mineral content. We KNOW we have NO lead, arsenic, mercury, aluminum etc. in our Formula. This Humic & Fulvic Liquid Trace Mineral complex has high trace levels of naturally occurring Humic and Fulvic Acids as well as high trace levels of Zinc, Iron, Magnesium, Molybdenum, Potassium and more. There is a wide range of up to 70 trace minerals which occur naturally in our Complex at varying levels. We Choose to list the 8 substances which occur in higher trace levels on our supplement panel. We don’t claim a high number of minerals as other Humic and Fulvic Supplements do and leave you to guess which elements you’ll be getting. Order Your Humic Fulvic for Your Family by Clicking on this Link , or the Banner Below.



Our Formula is an exceptional value compared to other Humic Fulvic Minerals because...


It’s OXYGENATED

It Always Tests at 9.5+ pH

Preservative and Chemical Free

Allergen Free

Comes From a Pure, Unpolluted, Organic Source

Is an Excellent Source for Trace Minerals

Is From Whole, Prehisoric Plant Based Origin Material With Ionic Minerals and Constituents

Highly Conductive/Full of Extra Electrons

Is a Full Spectrum Complex


Our Humic and Fulvic Liquid Trace Mineral Complex has Minerals, Amino Acids, Poly Electrolytes, Phytochemicals, Polyphenols, Bioflavonoids and Trace Vitamins included with the Humic and Fulvic Acid. Our Source material is high in these constituents, where other manufacturers use inferior materials.


Try Our Humic and Fulvic Liquid Trace Mineral Complex today. Order Yours Today by Following This Link.

Report abuse

    Comments

    Your Comments
    Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

    MOST RECENT
    Load more ...

    SignUp

    Login

    Newsletter

    Email this story
    Email this story

    If you really want to ban this commenter, please write down the reason:

    If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.