Uniswap: A Closer Look at the Bonding Curve

This article aims to provide a simple explanation of Uniswap’s price curve, a fundamental component of the protocol

Ian Devendorf
3 min readMay 28, 2021

As a quick refresher, Uniswap is a decentralized exchange powered by smart contracts that trade through automated market makers rather than a centralized entity. Automated market makers (AMMs) consist of a pool of assets formed by liquidity providers. The LPs deposit both assets in equal proportion according to a ratio driven by the instantaneous price of the assets. To use a simple example, consider a pool of 5 ETH and 15,000 USDC assuming a price of $3,000 per ETH. Let’s assume a user wants to purchase 1 ETH with 3,000 USDC.

The user would send 3,000 USDC to the pool, which is added to the USDC that was already there. The protocol would then use a formula, called the bonding curve, to calculate how much ETH to give the user in return. In the case of Uniswap, the bonding curve is simply X * Y = K which is the formula for a hyperbola. This is called the constant product formula whereby K stays constant and the relative price of the assets are changed by the trades. In this example, the pool would increase to 18,000 USDC and drop to around 4.2 ETH which would give the user roughly .8 ETH in return. Since this trade is large as a percentage of the total pool, it has significant slippage resulting in bad price execution.

Looking at the graph above, point A is pre-trade and point B is post-trade. The slopes in this graph represent the relative price of the assets. The tangent to A represents the pre-trade market price, the tangent of B represents the post-trade market price, and the segment from A to B represents the actual price executed in the trade. As we move down the curve, the slope gets flatter and more USDC is required to get a smaller amount of ETH.

If the price formula was X + Y = K, or a straight line, the price execution would be perfect. A user would be able to trade the 3,000 USDC and receive 5 ETH in return. This static price formula doesn’t work in practice however, because it fails to dynamically adjust prices. Users could continually buy ETH at 3,000 eventually draining the pool entirely of ETH which would disallow further trading. This is why hyperbolas work better for AMMs. They have asymptotes that approach zero and infinity but never touch them. This ensures that AMM pools will never run out of money. At worst, one asset would reach an astronomical price approaching infinity.

How will this look under V3? The bonding curve is tweaked a bit to incorporate an idea called concentrated liquidity. Stay tuned for a more in depth dive next week!

--

--