EN ▼
Favorites
My Favorites
View All
Market Cap Price 24h%

Disclaimer: Content does not constitute investment advice. Trading involves risks—please invest with caution!

How exactly does AMM price transactions? What is the role of x*y=k?

2026-08-25 00:22:38
Bookmark

How do automated market makers actually price transactions? What x*y=k is doing

Automated market makers do not receive quotes from buyers and sellers. It uses a formula-the most common being the constant product formula x*y=k (according to Uniswap's developer documentation)-to price transactions on a liquidity pool containing two tokens. The reserve ratio in the pool is set at a price before the transaction, but since the transaction itself changes this ratio, when the transaction size is small relative to the pool, the actual price paid will be worse than the price originally quoted.

The role of liquidity pools and formulas

According to the Uniswap blog, a liquidity pool is a smart contract that holds reserves of two tokens-such as ETH and USDC-that anyone can trade directly with. The liquidity provider deposits two tokens of equal value, injects initial liquidity into the pool, and sets an initial value of a constant k, which is the product of the two reserve amounts. From then on, every transaction must keep x times y equal to the same k. Uniswap's developer documentation describes k as an invariant that must remain constant or increase after each transaction. Since the two reserve balances must keep the product equal, withdrawing one token from the pool means that the other token must be increased to compensate, and a change in this ratio is the source of price changes.

Arithmetic example: Buying 1 ETH from a pool of 10 ETH / 20,000 USDC

The Uniswap blog provides a specific example. Start with a pool containing 10 ETH and 20,000 USDC. The constant is 10 times 20,000, or 200,000. At this initial point, the implicit spot price in the pool is 1 ETH to 2,000 USDC.

Now, a trader buys 1 ETH. ETH reserves in the pool were reduced to 9. To maintain a constant of 200,000, the USDC reserve must be increased to 200,000 divided by 9, which is approximately 22,222.22 USDC (based on calculations from the Uniswap blog). Therefore, in order to obtain this 1 ETH, traders need to invest 22,222.22 minus 20,000, or 2,222.22 USDC. The actual price they paid for the ETH they purchased was 2,222.22 USDC, rather than the 2,000 USDC quoted in the pool before the transaction.

This gap-the difference between the actual payment of 2,222.22 USDC and the initial offer of 2,000 USDC-is known as a slip point. This is not a fee, nor is it a fault; it is the formula that is operating as expected, repricing the pool as reserves change. The Uniswap blog points out that larger transactions relative to the pool size will lead to larger slip points, while more liquid pools can absorb the same transactions with smaller price changes. Uniswap's developer documentation also mentions this and calls this effect a price impact: relative to pool depth, the larger the transaction size, the greater the price changes; the smaller the transaction size, the closer the execution price is to the current spot price.

The Uniswap blog also gives a simpler retail perspective of the same mechanism: Users exchange USDC worth $100 for ETH and see the exchange rate calculated in real time by the constant product formula, and the smart contract charges USDC in a transaction and returns ETH, while rebalancing the pool.

Applicable boundaries for simple formulas

The above arithmetic for x*y=k describes a Uniswap v2-style pool where liquidity is distributed across all possible price ranges. Uniswap's developer documentation states that in v3 and v4, the formula only applies within the price range selected by each liquidity provider-a design called concentrated liquidity. In v3, the provider's positions within the range are represented as ERC-721 non-homogeneous tokens through a contract called NonfungiblePositionManager; in v4, positions are tracked through PositionManager's internal bookkeeping using ERC-6909, based on the same document. The actual result is that if two pools trading the same token pair are in different versions of Uniswap, or if the provider selects different liquidity ranges, even if both run a constant product formula, the price changes will be different for the same transaction.

Both Uniswap and Balancer belong to a larger family, which Guillermo Angeris and Tarun Chitra called constant function market makers (CFMM) in a 2020 paper-automatic market makers 'pricing rules are some fixed function of pool reserves, x*y=k is an example. The same paper pointed out that not all asset pairs are suitable for pricing using this particular curve. stablecoins, which are roughly pegged to the U.S. dollar but fluctuate within narrow ranges, are more efficient to price using a flatter curve when approaching the peg, so that transaction costs remain low when the pair approaches US$1 and increase when the price deviates-an approach the paper attributed to Curve's StableSwap design. The basic idea is the same as Uniswap-reserves and invariant price setting-but the shape of the curve, and the arithmetic traders need to calculate, are different.

How big was this market?

Angeris and Chitra's paper (dated March 2020) provides some data on the DeFi landscape described at the time. The paper pointed out that at that time, the digital assets locked in decentralized exchanges were approximately US$100 million, and the daily transaction volume sometimes exceeded US$10 million. A chart in the paper, dated February 12, 2020, citing DeFi Pulse data, shows that CFMM contracts hold $129.7 million, while LMSR-based forecast market makers such as Augur and Gnosis hold $721,000. The same paper also noted that Uniswap was established with $100,000 in funding from the Ethereum Foundation, compared to $24 million raised by 0x through its initial coin offering and $153 million raised by Bancor, and noted that as of the time of writing, Uniswap held approximately five to ten times the liquidity of the two competitors combined. These data describe market conditions in the five years or so before the creation of this page and serve only as historical examples of how a simply-designed automated market maker quickly surpassed more capital-funded, more complex alternatives-they do not represent the current status of these agreements of any size.

What is not covered on this page

This page explains the constant product formula based on the documentation of the Uniswap v2-style pool and uses the only working example with numbers in the evidence. It does not cover the concentrated liquidity mathematics of Uniswap v3 or v4, or the StableSwap curve used by Curve, because the materials referenced do not provide numerical examples for these situations-only descriptions of how they differ.

The above example of 10 ETH / 20,000 USDC does not include a handling fee. Uniswap's developer documentation states that transaction fees are configured by the pool and protocol versions, and protocol fees may apply when enabled through governance, but any source used on this page does not state the actual fee percentage for any particular pool, so the calculated above will be slightly higher in the actual charging pool.

The Uniswap blog warns that traders 'final execution prices may deviate slightly from the initial offer displayed on the screen, especially in cases of lack of liquidity or a surge in activity, but did not give a specific figure. No source used on this page explains how technologies such as sandwich trading interact with this gap in real-time trading, beyond general warnings.

Finally, the 2020 data on the total value of lockups and initial token issuance financing is a snapshot of a certain point in market history. The date for comparison of the total value of lockups is February 12, 2020, and the date for financing comparison is when the paper was published in March 2020. This should not be considered current data for the Uniswap, 0x, Bancor the broader DeFi market.

Disclaimer:

All content published on this website, including hyperlinks, related applications, forums, blogs, and other media accounts, originates from third-party platforms and their users. CoinMarketInsight makes no representations or warranties of any kind regarding the website or its content. All blockchain-related data and materials are provided for informational and research purposes only and do not constitute financial, legal, or investment advice. Users and third parties are solely responsible for the content they publish. CoinMarketInsight shall not be liable for any losses arising from the use of this website. You should exercise caution and conduct your own independent research, review, analysis, and verification before making any decisions.

Read Full Article
More News
TOP

TOP