<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stephen Hankinson on Medium]]></title>
        <description><![CDATA[Stories by Stephen Hankinson on Medium]]></description>
        <link>https://medium.com/@shankinson?source=rss-ca21b860e289------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PirtmdLDtz195T9E</url>
            <title>Stories by Stephen Hankinson on Medium</title>
            <link>https://medium.com/@shankinson?source=rss-ca21b860e289------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 01:46:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shankinson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Evaluating the profitability and impermanent loss of Uniswap v3 positions]]></title>
            <link>https://medium.com/arrakis-finance/uniswap-v3-position-gain-or-loss-for-specific-impermanent-loss-85372f7023fb?source=rss-ca21b860e289------2</link>
            <guid isPermaLink="false">https://medium.com/p/85372f7023fb</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[impermanent-loss]]></category>
            <category><![CDATA[uniswap-v2]]></category>
            <category><![CDATA[uniswap-v3]]></category>
            <category><![CDATA[liquidity-provider]]></category>
            <dc:creator><![CDATA[Stephen Hankinson]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 14:03:45 GMT</pubDate>
            <atom:updated>2022-04-26T19:23:27.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fv5y_Ry2Tqis5CUJe2Nfaw.png" /></figure><p>Uniswap V3 opens up the ability to have much more control over how a liquidity provider (LP) provides its liquidity to the open market. With this comes the ability to build different types of strategies to try and optimize the yield for providing this liquidity during different market conditions.</p><p>While researching some optimal rebalancing strategies for some <a href="https://arrakis.finance/">Arrakis Finance</a> vaults, I quickly realized that Impermanent Loss (IL) had a very serious impact on how well any strategy built atop Uniswap V3 would perform.</p><p>I recalled <a href="https://medium.com/auditless/how-to-calculate-impermanent-loss-full-derivation-803e8b2497b7">an article</a> that <a href="https://medium.com/u/7cf660fff514">Peteris Erins</a> had written on how to determine the IL for a Uniswap V2 pool and wondered if anyone had calculated something similar for Uniswap V3 pools. It turns out that the same author had derived the IL equation for Uniswap V3 as well in <a href="https://medium.com/auditless/impermanent-loss-in-uniswap-v3-6c7161d3b445">this article</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*civtvRIuqP-kkW34PO9fXA.png" /></figure><p>Here <strong><em>P</em></strong> is the initial price of asset <strong><em>X</em></strong> in terms of asset <strong><em>Y</em></strong>, while <strong><em>k</em></strong> is the gain that happens to <strong>P</strong> over a given timeframe. The values of <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong> are the lower and upper price bounds set by the Uniswap V3 position. <strong><em>ILa,b(k)</em></strong> is the impermanent loss experienced by that range for a given gain <strong><em>k </em></strong>and Uniswap V3 LP position.</p><p>While testing various rebalancing strategies on top of Uniswap V3 positions, I thought it would be useful to be able to enter a specific impermanent loss value for a given LP position and have it output the change in <strong><em>P</em></strong>, given by <strong><em>k</em></strong>, that achieves that <strong><em>impermanent loss</em></strong> value. This effectively meant rewriting the above equation to solve for <strong><em>k</em></strong> instead of impermanent loss.</p><p>That can be accomplished via the following steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_A0JpJCqFTTspvhIza0LA.png" /></figure><p>Now to make solving this a bit easier we can do the following substitutions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeM_WDZzVPU58gCUmYMKKQ.png" /></figure><p>To give us the following simpler equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7H8-SNriII0ivbh22dFHg.png" /></figure><p>This is now in the familiar form of a quadratic equation and can be easily solved.</p><p>The solution turns out to be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KqEvQW4N-4LEexV0IQm4w.png" /></figure><p>By replacing the <strong><em>a</em></strong> and <strong><em>b</em></strong> terms in the above equation with their substitutions shown further up, we can input the initial price <strong><em>P</em></strong>, the lower and upper bounds <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong>, and the <strong><em>impermanent loss</em></strong> under consideration to determine the gain in price or loss in price that would cause that specific amount of impermanent loss.</p><p>We can also use this equation to solve for <strong><em>k</em></strong> in a Uniswap V2 pool because a Uniswap V2 pool would look like a Uniswap V3 pool where <strong><em>Pa</em></strong> is 0 and <strong><em>Pb</em></strong> is ∞.</p><p>When this happens our <strong><em>a</em></strong> and <strong><em>b</em></strong> substitutions become:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0z3NrqYclmgkH8j0YvDsdQ.png" /></figure><p>So how might solving for <strong><em>k</em></strong> be useful to us?</p><p>Let’s consider an example Uniswap V3 position in ETH/USDC. If the current price of ETH is at $3500 and we set our limits to be 0.5X the price on the lower side and 2X the price on the higher side we have a position with <strong><em>Pa</em></strong> = $1750, <strong><em>Pb</em></strong> = $7000, <strong><em>P</em></strong> = $3500.</p><p>If we assume that this position is going to earn 25% APR in fees, we might want to know what the actual gain or loss in the price of ETH would be that would wipe out those earned fees via impermanent loss.</p><p>So in this case we would set <strong><em>IL</em></strong> to -0.25.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szaumvj9DeG46TZizrxtCg.png" /></figure><p>So what this is telling us is that as long as the price stays within our Uniswap V3 LP position lower and upper bounds while we earn the 25% APR, we should be ahead of simply holding outside of the Uniswap V3 position. Or in other words, we should be able to beat impermanent loss if the price stays within our range and we earn the expected amount of fees.</p><p>This is because a 25% loss to IL only happens when the price decreases by 0.4539X or increases by 2.2031X and anything in between would have a smaller impermanent loss as seen in the following graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwoUSFyfnDv_qVlYW6fyrg.png" /></figure><p><strong>Note:</strong> This graph is only valid when <strong><em>k</em></strong> varies between 0.5 and 2 for the example Uniswap V3 LP position as the position is out of bounds beyond those limits.</p><p>We can confirm that our solutions for <strong><em>k</em></strong> are correct by plugging the <strong><em>k</em></strong> values back into the original <strong><em>ILa,b(k)</em></strong> equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vV6mI69NhN8yGCgbTtq9Vw.png" /></figure><p>Another time when you possibly want to solve for <strong><em>k</em></strong> is when you might want to move your range if impermanent loss hits a specific value. For example, if you wanted to re-center your range when <strong><em>IL</em></strong> hit a loss of 10%. You’d simply plug in the position parameters along with the -0.10 for <strong><em>IL</em></strong> and then calculate the values of <strong><em>k</em></strong> that produce that impermanent loss.</p><p>This could help with building a strategy that chooses better times to move and rebalance an LP position instead of updating the position at a point where impermanent loss has already caused too much damage to recover from.</p><p>If you are interested in learning more about how to manage liquidity on Uniswap V3 in the most efficient way, then connect with us on the official Arrakis Ecosystem <a href="https://discord.gg/arrakisfinance">Discord</a> channel!</p><ul><li>Website: <a href="https://www.arrakis.finance/">https://www.arrakis.finance</a></li><li>Twitter: <a href="https://twitter.com/arrakisfinance">https://twitter.com/arrakisfinance</a></li><li>Telegram: <a href="https://t.me/arrakisfinance">https://t.me/arrakisfinance</a></li><li>Discord: <a href="https://discord.gg/arrakisfinance">https://discord.gg/arrakisfinance</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85372f7023fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arrakis-finance/uniswap-v3-position-gain-or-loss-for-specific-impermanent-loss-85372f7023fb">Evaluating the profitability and impermanent loss of Uniswap v3 positions</a> was originally published in <a href="https://medium.com/arrakis-finance">Arrakis Finance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selecting a Uniswap V3 Range]]></title>
            <link>https://medium.com/arrakis-finance/selecting-a-uniswap-v3-range-da34d8741089?source=rss-ca21b860e289------2</link>
            <guid isPermaLink="false">https://medium.com/p/da34d8741089</guid>
            <category><![CDATA[uniswap-v3]]></category>
            <category><![CDATA[liquidity-mining]]></category>
            <category><![CDATA[impermanent-loss]]></category>
            <category><![CDATA[uniswap-v2]]></category>
            <category><![CDATA[liquidity-provider]]></category>
            <dc:creator><![CDATA[Stephen Hankinson]]></dc:creator>
            <pubDate>Tue, 12 Apr 2022 12:58:13 GMT</pubDate>
            <atom:updated>2022-04-12T13:19:36.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGzD8BSSLH_EBHBNwt0_wg.png" /></figure><p>One of the hardest things to do with a Uniswap V3 LP Position is select the lower and upper bounds to use for a position. If we dig into some of the math behind the protocol, we can make better-informed choices about selecting a range that might make sense.</p><p>If we look at equation 2.2 from the Uniswap V3 paper, we can see an equation that relates tokens <strong><em>X</em></strong> and <strong><em>Y</em></strong>, the range limits <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong>, and liquidity<strong><em> L</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oNHQqxBf7_4hgTwGcFoKAg.png" /></figure><p>If we take the Uniswap V3 position range to the limit where <strong><em>Pa</em></strong> is 0 and <strong><em>Pb</em></strong> is infinity, the range terms tend to zero, leaving the familiar Uniswap V2 equation for <strong><em>x · y = k</em></strong>, where <strong><em>k</em></strong> is <strong><em>L²</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7P6F5nmcWy4ym3mYmfg4w.png" /></figure><p>This essentially lets us determine the least amount of liquidity that we would get for the Uniswap V3 position if we made the position cover the full range, and it would work very similar to a Uniswap V2 position.</p><p>Any position that is more narrow than the full range position will give us more liquidity for the same amount of assets as we are adding terms to both the X and Y multipliers, which is why this is known as concentrated liquidity in Uniswap V3.</p><p>To have your position earn more fees, you can increase your part of the total active liquidity by making your range more narrow. However, this does come at the risk of having elevated impermanent loss.</p><p>As shown in <a href="https://medium.com/auditless/impermanent-loss-in-uniswap-v3-6c7161d3b445">an article</a> by <a href="https://medium.com/u/7cf660fff514">Peteris Erins</a>, the impermanent loss can be determined for a Uniswap V3 position with the following equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAAxdR1wBcdj3XQZyJQ7Rw.png" /></figure><p>Here <strong><em>P</em></strong> is the initial price of asset <strong><em>X</em></strong> in terms of asset <strong><em>Y</em></strong>, while <strong><em>k</em></strong> is the gain that happens to <strong>P</strong> over a given timeframe. The values of <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong> are the lower and upper price bounds set by the Uniswap V3 position. <strong><em>ILa,b(k)</em></strong> is the impermanent loss experienced by that range for a given gain <strong><em>k </em></strong>and Uniswap V3 LP position.</p><p>As you can see, the more <strong><em>Pa</em></strong> moves up from 0 and the more <strong><em>Pb</em></strong> moves down from infinity, the denominator will get smaller for the same value of <strong><em>k</em></strong>, meaning a larger impermanent loss.</p><p>The main goal for a Uniswap V3 position should be to set a range that gives enough liquidity in the active range so that the position earns enough fees to at a minimum counteract the impermanent loss for the maximum expected price movement of the assets over the investment period.</p><p>In order to possibly work out what that range might be, we need to make a few assumptions. We need to have an idea of how much fees could be earned by the position and we need to have an opinion of how high or low the price of the assets could move over the investment time horizon.</p><p>If we take a look at the Uniswap V3 USDC/ETH 0.05% pool, as I’m writing this, it currently has 764M in daily volume, meaning the active liquidity is earning about $382k/day in fees. The total active liquidity for the pool at the time of writing is about 38313936.</p><p>Currently, the price shows that 1 ETH is equivalent to 3500 USDC. This means that for a full range Uniswap V3 position we would add 1 ETH for every 3500 USDC added and the liquidity <strong><em>L </em></strong>earned<strong><em> </em></strong>for such a position would be about 59.</p><p>That means that this position would earn about 0.00015% of the daily fees from the pool, or about $0.59/day. If this remained static for the year, that is $215.35 earned in fees for the initial $7000 investment, giving approximately a 3.1% APR.</p><p>If we assume for this example that the price of ETH will end the year somewhere between a 33.3% loss or a 50% gain, k = 2/3 or k = 3/2, for a full range position we get the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OknoiJ_ZaCQl85MzGDcThg.png" /></figure><p>This means that in our example the full range position would come out ahead, even if the price of ETH went down by 33.3% or went up by 50%, and do even better if the price ended the year somewhere in the middle of that range.</p><p>This is because the position would have earned 3.1% in fees and lost a maximum of 2% to <strong><em>IL</em></strong> in that price range, meaning a 1.1% improvement or better over buy and hold assuming the price remained within our <strong><em>k</em></strong> bounds.</p><p>In a future article, we will show how to determine the <strong><em>k</em></strong> values which give exactly a 3.1% impermanent loss. That will help show how far the price could move before the position becomes unprofitable due to the impermanent loss eating away at the earned fees.</p><p>What if we wanted to try and make a more concentrated position so that we can earn more fees? After all, that is what Uniswap V3 was designed to do.</p><p>The main issue is, how do you know what values to set the range of the LP position to?</p><p>Well, we can re-arrange the <strong><em>IL</em></strong> equation to solve for <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong> if we know the current price <strong><em>P</em></strong>, if we have a specific lower <strong><em>k</em></strong> and upper <strong><em>k</em></strong> in mind and have a maximum amount of <strong><em>IL</em></strong> that you’d be willing to hit.</p><p>If we re-arrange the <strong><em>IL</em></strong> equation to solve for <strong><em>Pa</em></strong> we get the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YgHaMRwB3Quub2j_yxGcPQ.png" /></figure><p>If we also re-arrange the <strong><em>IL</em></strong> equation to solve for <strong><em>Pb</em></strong> we get the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1iLYAc7o8ICyFTFKjJPZw.png" /></figure><p>Since we know the current price <strong><em>P</em></strong> and the max <strong><em>IL</em></strong> we want to see for our range of <strong><em>k</em></strong>, we can treat those two parameters basically like constants for our scenario.</p><p>If we substitute <strong><em>k</em></strong> in the Pa equation for <strong><em>k1</em></strong> to reference one of the gains we are targeting and substitute <strong><em>k</em></strong> in the <strong><em>Pb</em></strong> equation for <strong><em>k2</em></strong> to reference the other gain we are targeting, we can essentially solve the two equations with two unknowns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHUFaQ-DswKSUmGiDSleOA.png" /></figure><p>Replacing the <strong><em>Pb</em></strong> in the <strong><em>Pa</em></strong> equation with the second equation above and expanding things out and simplifying a bit, we end up with the following equation for <strong><em>Pa</em></strong> which depends only on <strong><em>P</em></strong>, <strong><em>k1</em></strong>, <strong><em>k2</em></strong>, and <strong><em>IL</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWHPrHYio1LrIvJroqCX9g.png" /></figure><p>Once we use this to solve for <strong><em>Pa</em></strong>, we can then enter that value into the <strong><em>Pb</em></strong> equation above to also solve for <strong><em>Pb</em></strong>.</p><p><strong>Note: This only works if you are using an IL in these equations that is less than the IL for a full range LP position, about -2% in our example. This is because making the range more narrow always increases IL (makes it more negative).</strong></p><p>Going back to our example, what if we were willing to tolerate up to 10% in impermanent loss. Would we earn enough fees to compensate for that?</p><p>For a 10% impermanent loss <strong><em>IL</em></strong>, <strong><em>k1</em></strong> being 2/3, <strong><em>k2</em></strong> being 3/2, and the current price <strong><em>P</em></strong> being 3500 we can solve for <strong><em>Pa</em></strong> and <strong><em>Pb</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KJyKUrO7p3FYYfhl80Akw.png" /></figure><p>Using these values, we can plot what <strong><em>IL</em></strong> looks like for a varying <strong><em>k</em></strong> over our expected range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3lKapuCT0DE9GGuXhK0mQ.png" /></figure><p>If we rework the initial equation mentioned at the top of this post to solve for liquidity, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6_nU5eiMHmqVxmrjiYVwFA.png" /></figure><p>If we solve this equation with <strong><em>Pa</em></strong>=2228.58, <strong><em>Pb</em></strong>=5496.76, <strong><em>x</em></strong>=1, <strong><em>y</em></strong>=3500, we end up with our liquidity <strong><em>L</em></strong> being about 292.8.</p><p>This new liquidity for the updated position would earn about 0.00076% of the daily fees from the pool, or about $2.92/day.</p><p>That means that this new liquidity position would earn about 0.00076% of the daily fees, or about $2.92/day. If this remained static for the year, that is $1065.80 earned in fees for the initial $7000 investment, giving approximately a 15% APR.</p><p>So as long as the price stays within our 33.3% loss to 50% gain estimate over the year-long period and we earn the expected fees, we should be guaranteed to be ahead of buy and hold by at least 5% since we will have at most 10% lost to impermanent loss for the 15% earned in fees. If the price moved less than these amounts we are even further ahead as seen in the graph above.</p><p>As mentioned, in a future article we will show how to determine the <strong><em>k</em></strong> values which give exactly a 15% impermanent loss to see how far the price could move before the position becomes unprofitable if all the assumptions hold true.</p><p>We are in no way saying that the price of ETH will remain within a 33.3% loss or a 50% gain window over a one-year period or that the swap volume will remain a constant $750M per day. We are simply using this as an example of how you might choose your Uniswap V3 position based on your opinion of price movements and the potential fee earnings of a pool.</p><p>If you are interested in learning more about how to manage liquidity on Uniswap V3 in the most efficient way, then connect with us on the official Arrakis Ecosystem <a href="https://discord.gg/arrakisfinance">Discord</a> channel!</p><ul><li>Website: <a href="https://www.arrakis.finance/">https://www.arrakis.finance</a></li><li>Telegram: <a href="https://t.me/arrakisfinance">https://t.me/arrakisfinance</a></li><li>Twitter: <a href="https://twitter.com/arrakisfinance">https://twitter.com/arrakisfinance</a></li><li>Discord: <a href="https://discord.gg/arrakisfinance">https://discord.gg/arrakisfinance</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da34d8741089" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arrakis-finance/selecting-a-uniswap-v3-range-da34d8741089">Selecting a Uniswap V3 Range</a> was originally published in <a href="https://medium.com/arrakis-finance">Arrakis Finance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>