<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Khusniddin Qalandarov</title>
    <description>The latest articles on DEV Community by Khusniddin Qalandarov (@khusniddin_qalandarov_e33).</description>
    <link>https://dev.to/khusniddin_qalandarov_e33</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2586249%2F6a045c36-e8cc-4e9f-b88c-acbd8c748dd7.jpg</url>
      <title>DEV Community: Khusniddin Qalandarov</title>
      <link>https://dev.to/khusniddin_qalandarov_e33</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khusniddin_qalandarov_e33"/>
    <language>en</language>
    <item>
      <title>AMM Mathematics: Constant Product and Beyond — How Uniswap's x·y=k Formula Powers DeFi</title>
      <dc:creator>Khusniddin Qalandarov</dc:creator>
      <pubDate>Thu, 14 May 2026 06:50:34 +0000</pubDate>
      <link>https://dev.to/khusniddin_qalandarov_e33/amm-mathematics-constant-product-and-beyond-how-uniswaps-xyk-formula-powers-defi-i9h</link>
      <guid>https://dev.to/khusniddin_qalandarov_e33/amm-mathematics-constant-product-and-beyond-how-uniswaps-xyk-formula-powers-defi-i9h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Decentralized Finance (DeFi) has transformed how we think about financial primitives. At the heart of this transformation lies a deceptively simple equation: &lt;strong&gt;x · y = k&lt;/strong&gt;. This invariant, introduced by Uniswap V2, underpins billions of dollars in daily trading volume and gave birth to the Automated Market Maker (AMM) paradigm. Yet beneath its simplicity lies a rich mathematical structure — one that governs pricing, liquidity, slippage, and the often-misunderstood phenomenon of impermanent loss.&lt;/p&gt;

&lt;p&gt;In this article, we derive the constant-product formula from first principles, analyze its mathematical properties, explore how impermanent loss emerges naturally from the model, and then examine how Uniswap V3's concentrated liquidity model extends and generalizes the original invariant.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is an Automated Market Maker?
&lt;/h2&gt;

&lt;p&gt;Traditional exchanges use an &lt;strong&gt;order book&lt;/strong&gt;: buyers post bids and sellers post asks, and trades execute when the two sides match. This model requires active market participants and suffers from low liquidity in thin markets.&lt;/p&gt;

&lt;p&gt;An AMM replaces the order book with a &lt;strong&gt;mathematical pricing function&lt;/strong&gt;. A smart contract holds reserves of two tokens — say, token X (e.g., ETH) and token Y (e.g., USDC) — and uses a formula to deterministically quote prices based solely on the current reserve balances. No counterparty is needed; the contract itself is always willing to trade at the formula-determined price.&lt;/p&gt;

&lt;p&gt;The key insight is that the AMM does not need to know the "true" price. Arbitrageurs will continuously trade against it until the AMM price aligns with the broader market, making the system self-correcting.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Deriving the Constant-Product Formula
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 The Invariant
&lt;/h3&gt;

&lt;p&gt;Let &lt;code&gt;x&lt;/code&gt; denote the reserve of token X and &lt;code&gt;y&lt;/code&gt; the reserve of token Y. Uniswap V2 enforces the following invariant after every trade (ignoring fees for now):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x * y = k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;k&lt;/code&gt; is a constant. This means the product of the two reserves must remain unchanged after any swap.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.2 Price Derivation
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;marginal price&lt;/strong&gt; of token X in terms of token Y is the instantaneous rate at which the curve trades one for the other. Taking the total differential of the invariant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d(x * y) = 0
y dx + x dy = 0
dy/dx = -y/x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The negative sign indicates that as we buy X (x decreases), y must increase. The &lt;strong&gt;spot price&lt;/strong&gt; of X in terms of Y at any point on the curve is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P = y / x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the marginal price. Notice it is &lt;strong&gt;not&lt;/strong&gt; constant — it changes with every trade. This is precisely what creates slippage.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Executing a Swap
&lt;/h3&gt;

&lt;p&gt;Suppose a trader wants to buy &lt;code&gt;Δx&lt;/code&gt; tokens of X by depositing &lt;code&gt;Δy&lt;/code&gt; tokens of Y. The new reserves must satisfy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(x - Δx)(y + Δy) = k = x * y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expanding and solving for &lt;code&gt;Δx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x*y - Δx*y + x*Δy - Δx*Δy = x*y
-Δx*y + x*Δy - Δx*Δy = 0
Δx(y + Δy) = x * Δy
Δx = (x * Δy) / (y + Δy)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, solving for the input needed to obtain a given output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Δy = (y * Δx) / (x - Δx)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This closed-form solution means swaps can be computed in O(1) with no order book traversal, which is why AMMs are extremely gas-efficient on-chain.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.4 Effective Price vs. Spot Price
&lt;/h3&gt;

&lt;p&gt;The effective price paid per unit of X is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P_eff = Δy / Δx = y / (x - Δx)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compared to the spot price &lt;code&gt;P_spot = y/x&lt;/code&gt;, we see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P_eff = P_spot * (x / (x - Δx)) &amp;gt; P_spot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ratio &lt;code&gt;x / (x - Δx)&lt;/code&gt; captures &lt;strong&gt;price impact&lt;/strong&gt; — the larger the trade relative to reserves, the worse the execution price.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Impermanent Loss: A Mathematical Analysis
&lt;/h2&gt;

&lt;p&gt;Impermanent loss (IL) is the difference in value between holding tokens in an AMM pool versus simply holding them in a wallet. It is one of the most important risks for liquidity providers.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Setup
&lt;/h3&gt;

&lt;p&gt;Assume a liquidity provider (LP) deposits into a pool when the price of X in terms of Y is &lt;code&gt;P_0 = y_0 / x_0&lt;/code&gt;. The invariant gives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x_0 * y_0 = k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the LP's portfolio value in terms of Y is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V_hold = x_0 * P_0 + y_0 = 2 * y_0  (since x_0 * P_0 = y_0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 After a Price Change
&lt;/h3&gt;

&lt;p&gt;Let the external market price move to &lt;code&gt;P_1&lt;/code&gt;. Arbitrageurs will rebalance the pool to match. The new reserves &lt;code&gt;x_1&lt;/code&gt;, &lt;code&gt;y_1&lt;/code&gt; satisfy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x_1 * y_1 = k           ... (invariant)
y_1 / x_1 = P_1         ... (new price)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Solving:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x_1 = sqrt(k / P_1)
y_1 = sqrt(k * P_1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The LP's pool value in terms of Y is now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V_pool = x_1 * P_1 + y_1
       = sqrt(k / P_1) * P_1 + sqrt(k * P_1)
       = sqrt(k * P_1) + sqrt(k * P_1)
       = 2 * sqrt(k * P_1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 The IL Formula
&lt;/h3&gt;

&lt;p&gt;Let &lt;code&gt;r = P_1 / P_0&lt;/code&gt; be the price ratio. Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k = x_0 * y_0 = x_0 * (x_0 * P_0) = x_0^2 * P_0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;sqrt(k * P_1) = x_0 * sqrt(P_0 * P_1) = x_0 * P_0 * sqrt(r) = y_0 * sqrt(r)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Therefore:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V_pool = 2 * y_0 * sqrt(r)
V_hold = 2 * y_0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Impermanent loss is defined as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IL = (V_pool - V_hold) / V_hold
   = (2 * y_0 * sqrt(r) - 2 * y_0) / (2 * y_0)
   = sqrt(r) - 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More precisely, since the LP must compare pool value against holding the &lt;strong&gt;original token amounts&lt;/strong&gt; at the new price:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V_hold_new = x_0 * P_1 + y_0 = x_0 * r * P_0 + x_0 * P_0 = x_0 * P_0 * (1 + r) = y_0 * (1 + r)

IL = V_pool / V_hold_new - 1
   = (2 * sqrt(r)) / (1 + r) - 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the canonical impermanent loss formula. Let's check key values:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Price Ratio r&lt;/th&gt;
&lt;th&gt;IL (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1.0 (no change)&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.25 (+25%)&lt;/td&gt;
&lt;td&gt;-0.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.5 (+50%)&lt;/td&gt;
&lt;td&gt;-2.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.0 (+100%)&lt;/td&gt;
&lt;td&gt;-5.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4.0 (+300%)&lt;/td&gt;
&lt;td&gt;-20.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.5 (-50%)&lt;/td&gt;
&lt;td&gt;-5.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice that IL is &lt;strong&gt;symmetric&lt;/strong&gt; in log-price space: a halving and a doubling produce the same IL. Also, IL is always non-positive — the pool underperforms the holding strategy whenever prices change. However, trading fees can offset this loss.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Fees and the Real Invariant
&lt;/h2&gt;

&lt;p&gt;In practice, Uniswap V2 charges a 0.3% fee on every swap. This means only &lt;code&gt;(1 - 0.003) = 0.997&lt;/code&gt; of the input is effectively traded. If a user sends &lt;code&gt;Δy&lt;/code&gt; tokens of Y, the effective amount that shifts the invariant is &lt;code&gt;0.997 * Δy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The actual swap formula becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Δx = (x * 0.997 * Δy) / (y + 0.997 * Δy)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fees are collected in the pool, which &lt;strong&gt;increases k&lt;/strong&gt; over time. This is the mechanism by which LPs earn yield. After many trades, the pool's k grows as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k_new = k_old * (1 + fee_income / pool_value)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;LP shares (represented by ERC-20 LP tokens) represent a proportional claim on the pool's growing reserves.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Python Implementation
&lt;/h2&gt;

&lt;p&gt;Here is a minimal Python simulation of a Uniswap V2 pool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UniswapV2Pool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.003&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fee&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fee&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;spot_price&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Price of X in terms of Y&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;swap_x_for_y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Buy Y by selling dx of X. Returns amount of Y received.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
        &lt;span class="n"&gt;dx_eff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fee&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dx_eff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dx_eff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;swap_y_for_x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Buy X by selling dy of Y. Returns amount of X received.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
        &lt;span class="n"&gt;dy_eff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fee&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dy_eff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dy_eff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;impermanent_loss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;initial_x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;initial_y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Compute IL relative to holding initial balances at current price.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
        &lt;span class="n"&gt;P&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spot_price&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;v_pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
        &lt;span class="n"&gt;v_hold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initial_x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;initial_y&lt;/span&gt;
        &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v_pool&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;v_hold&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="c1"&gt;# Example
&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;UniswapV2Pool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 100 ETH, 200k USDC
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Initial price: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spot_price&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; USDC/ETH&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;K = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;initial_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;initial_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;

&lt;span class="c1"&gt;# Simulate a large buy of Y (selling ETH)
&lt;/span&gt;&lt;span class="n"&gt;dy_received&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;swap_x_for_y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Received: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;dy_received&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; USDC for 10 ETH&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;New price: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spot_price&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; USDC/ETH&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;IL: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;impermanent_loss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initial_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;initial_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;%&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. Uniswap V3: Concentrated Liquidity
&lt;/h2&gt;

&lt;p&gt;Uniswap V3 (released May 2021) introduced a fundamental generalization: &lt;strong&gt;concentrated liquidity&lt;/strong&gt;. Instead of spreading liquidity uniformly across all possible prices from 0 to infinity, LPs can choose a specific price range &lt;code&gt;[P_a, P_b]&lt;/code&gt; within which their capital is active.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.1 The Generalized Invariant
&lt;/h3&gt;

&lt;p&gt;Uniswap V3 transforms the V2 invariant by introducing &lt;strong&gt;virtual reserves&lt;/strong&gt;. If an LP provides liquidity in range &lt;code&gt;[P_a, P_b]&lt;/code&gt;, the pool behaves as if it has larger reserves &lt;code&gt;x_virtual&lt;/code&gt; and &lt;code&gt;y_virtual&lt;/code&gt; that include an offset:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(x + x_offset) * (y + y_offset) = L^2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;L&lt;/code&gt; is called &lt;strong&gt;liquidity&lt;/strong&gt; and the offsets are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x_offset = L / sqrt(P_b)
y_offset = L * sqrt(P_a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures the curve "runs out" of one token at each end of the price range.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.2 Liquidity as a Geometric Quantity
&lt;/h3&gt;

&lt;p&gt;The parameter &lt;code&gt;L&lt;/code&gt; measures the &lt;strong&gt;depth&lt;/strong&gt; of the market at the current price. It is defined as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;L = sqrt(x * y)   (for the full-range V2 case)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In V3, a position with liquidity &lt;code&gt;L&lt;/code&gt; in range &lt;code&gt;[P_a, P_b]&lt;/code&gt; requires the following capital:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Δx = L * (1/sqrt(P_current) - 1/sqrt(P_b))   if P_current &amp;lt; P_b
Δy = L * (sqrt(P_current) - sqrt(P_a))        if P_current &amp;gt; P_a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means the capital required for a given liquidity depth &lt;strong&gt;scales with the square root of the price&lt;/strong&gt;, not linearly.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.3 Capital Efficiency Comparison
&lt;/h3&gt;

&lt;p&gt;The key innovation of V3 is capital efficiency. Consider a pool with price at &lt;code&gt;P = 2000&lt;/code&gt; USDC/ETH and an LP who wants to provide liquidity only in the narrow range &lt;code&gt;[1900, 2100]&lt;/code&gt; (a ~10% band).&lt;/p&gt;

&lt;p&gt;In V2, the LP's capital is spread across &lt;code&gt;[0, infinity)&lt;/code&gt;, so only a tiny fraction is ever used for trades near the current price.&lt;/p&gt;

&lt;p&gt;In V3, &lt;strong&gt;all&lt;/strong&gt; of the LP's capital is concentrated in that narrow range, providing much deeper liquidity per dollar deployed. The capital efficiency gain is approximately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Efficiency Gain = sqrt(P_b / P_a) / (sqrt(P_b / P_a) - 1)

For [1900, 2100]: sqrt(2100/1900) / (sqrt(2100/1900) - 1)
                = sqrt(1.105) / (sqrt(1.105) - 1)
                = 1.0513 / 0.0513
                ~ 20.5x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A V3 LP in this narrow range achieves roughly &lt;strong&gt;20x better capital efficiency&lt;/strong&gt; than a V2 LP with the same amount of capital.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.4 Tick Architecture
&lt;/h3&gt;

&lt;p&gt;V3 discretizes the price range into &lt;strong&gt;ticks&lt;/strong&gt;. Each tick corresponds to a price:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P(i) = 1.0001^i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives approximately 1 basis point (0.01%) spacing between adjacent ticks. Liquidity positions are defined between integer tick boundaries, and the contract tracks aggregate liquidity per tick using a &lt;code&gt;tick bitmap&lt;/code&gt; for efficient O(1) updates.&lt;/p&gt;

&lt;p&gt;When a swap moves the price across a tick boundary, the contract initializes or exits LP positions at that boundary, updating the active liquidity accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.5 V2 vs V3: Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Uniswap V2&lt;/th&gt;
&lt;th&gt;Uniswap V3&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Price Range&lt;/td&gt;
&lt;td&gt;[0, infinity)&lt;/td&gt;
&lt;td&gt;[P_a, P_b] custom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Capital Efficiency&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Up to 4000x higher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LP Complexity&lt;/td&gt;
&lt;td&gt;Simple&lt;/td&gt;
&lt;td&gt;Requires active management&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fee Tiers&lt;/td&gt;
&lt;td&gt;Fixed 0.3%&lt;/td&gt;
&lt;td&gt;0.05%, 0.3%, 1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LP Token&lt;/td&gt;
&lt;td&gt;Fungible ERC-20&lt;/td&gt;
&lt;td&gt;Non-fungible ERC-721 (NFT)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IL Exposure&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Higher within range&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  7. Slippage Tolerance in Practice
&lt;/h2&gt;

&lt;p&gt;Real-world AMM integrations must handle &lt;strong&gt;slippage&lt;/strong&gt; — the difference between the expected price and the execution price. Most DEX aggregators let users set a slippage tolerance (e.g., 0.5%).&lt;/p&gt;

&lt;p&gt;The maximum output a user can receive is bounded by the constant-product formula. For a trade of &lt;code&gt;Δy&lt;/code&gt; input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Minimum output Δx_min = Δx_expected * (1 - slippage_tolerance)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the pool state changes between transaction submission and execution (due to front-running or sandwich attacks), and the output falls below &lt;code&gt;Δx_min&lt;/code&gt;, the transaction &lt;strong&gt;reverts&lt;/strong&gt;. This is enforced by Uniswap's smart contract via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require(amountOut &amp;gt;= amountOutMinimum, 'Too little received');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  8. Conclusion
&lt;/h2&gt;

&lt;p&gt;The constant-product formula &lt;code&gt;x * y = k&lt;/code&gt; is one of the most elegant and impactful mathematical primitives in modern finance. From it, we can derive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;closed-form pricing function&lt;/strong&gt; that requires no order book&lt;/li&gt;
&lt;li&gt;An &lt;strong&gt;impermanent loss formula&lt;/strong&gt; &lt;code&gt;IL = 2*sqrt(r)/(1+r) - 1&lt;/code&gt; that precisely quantifies LP risk&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;generalization&lt;/strong&gt; in Uniswap V3 that concentrates liquidity to dramatically improve capital efficiency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The brilliance of the design is that a single mathematical invariant — just three tokens and a multiplication — creates a self-contained, trustless exchange that operates entirely on-chain. Understanding the mathematics behind AMMs is essential for anyone building in DeFi, whether as a developer, LP, or protocol designer.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Adams, H., Zinsmeister, N., Salem, M., Keefer, R., &amp;amp; Robinson, D. (2021). &lt;em&gt;Uniswap v3 Core&lt;/em&gt;. Uniswap Labs. &lt;a href="https://uniswap.org/whitepaper-v3.pdf" rel="noopener noreferrer"&gt;https://uniswap.org/whitepaper-v3.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adams, H., Zinsmeister, N., &amp;amp; Robinson, D. (2020). &lt;em&gt;Uniswap v2 Core&lt;/em&gt;. Uniswap Labs. &lt;a href="https://uniswap.org/whitepaper.pdf" rel="noopener noreferrer"&gt;https://uniswap.org/whitepaper.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Angeris, G., Kao, H. T., Chiang, R., Noyes, C., &amp;amp; Chitra, T. (2019). &lt;em&gt;An analysis of Uniswap markets&lt;/em&gt;. arXiv:1911.03380.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pintail. (2019). &lt;em&gt;Understanding Uniswap Returns&lt;/em&gt;. Medium. &lt;a href="https://medium.com/@pintail/understanding-uniswap-returns-cc593f3499ef" rel="noopener noreferrer"&gt;https://medium.com/@pintail/understanding-uniswap-returns-cc593f3499ef&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Buterin, V. (2021). &lt;em&gt;Improving front running resistance of x*y=k market makers&lt;/em&gt;. Ethereum Research. &lt;a href="https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281" rel="noopener noreferrer"&gt;https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
