How does Uniswap work? What category of DeFi application is it?

Hans-Helmut Kraus
Hans-Helmut Kraus
Ethereum smart contract auditor and security expert; 以太坊智能合约审计师与安全专家。

Alright, no problem. Let's talk in plain language about how Uniswap actually works.


How Does Uniswap Work? And What Category of DeFi Application Is It?

Imagine you have some apples and want to trade them for your friend's oranges. In real life, you'd both need to agree on a price first, like "one apple for two oranges," before the exchange can happen.

Traditional cryptocurrency exchanges (like Binance, Huobi) are like a giant marketplace. If you want to sell apples (e.g., sell ETH), you'd place a "sell order" on the market: "I'm selling apples at this price!" If you want to buy oranges (e.g., buy USDT), you'd place a "buy order": "I'm buying oranges at that price!" For the trade to succeed, someone needs to accept your price. This record of buyers' and sellers' intentions is called an Order Book.

But Uniswap works completely differently.

Uniswap is more like a magical, unattended, automated exchange pool.


The Core Magic: Liquidity Pools and Automated Market Makers (AMM)

Uniswap's core isn't an "order book"; it's "liquidity pools."

  1. What is a Liquidity Pool? You can imagine each trading pair (e.g., ETH/USDT) as a giant pool of funds. This pool contains two assets: a large amount of ETH and a large amount of USDT. This pool is open to everyone.

  2. Who Puts Money into the Pool? It's ordinary users like us! Anyone holding ETH and USDT can deposit both tokens into the pool, according to the current ratio in the pool. These individuals who provide the funds are called Liquidity Providers (LPs).

  3. Why Do They Put Their Money In? To earn money, of course! Every time you make a trade on Uniswap, for example, exchanging ETH for USDT, Uniswap charges a small trading fee (e.g., 0.3%). This fee doesn't go to the Uniswap team; instead, it's distributed proportionally among all the liquidity providers who have supplied funds to the pool. This becomes a form of passive income for them.

  4. How is the Price Determined? – This is the Crucial Automated Market Maker (AMM) Part This pool operates on a very simple iron rule:

    Quantity of Token A in the pool × Quantity of Token B in the pool = A Constant Value (K)

    This formula x * y = k is the soul of Uniswap. Let's use an example to understand it.


Example: Exchanging ETH for DAI

Let's say there's an ETH/DAI pool. For simplicity, we'll assume it contains:

  • 10 ETH
  • 10,000 DAI

So, according to the formula, the constant value K for this pool is 10 * 10,000 = 100,000. This 100,000 will remain constant unless liquidity is added or removed.

Now, you want to exchange 1 ETH for DAI. What happens?

  1. You put 1 ETH into the pool. Now the pool has 10 + 1 = 11 ETH.
  2. Maintain Balance. To keep the x * y product at 100,000, the amount of DAI in the pool must decrease. The new amount of DAI should be 100,000 / 11 ≈ 9090.9 DAI.
  3. You Receive DAI. The pool originally had 10,000 DAI, and now only needs 9090.9 DAI. The surplus 10,000 - 9090.9 = 909.1 DAI will be automatically sent to you.

Transaction complete! You've exchanged 1 ETH for 909.1 DAI.

You'll notice that throughout this process, there's absolutely no need to find a counterparty willing to buy your 1 ETH for 909.1 DAI. You're trading directly with this "pool of funds," which automatically calculates the price for you based on its iron rule. This is the magic of an Automated Market Maker (AMM).

At the same time, after the transaction, the new state of the pool is 11 ETH and 9090.9 DAI. Since ETH increased and DAI decreased, the price of ETH relative to DAI has automatically become cheaper. If the next person also wants to exchange ETH for DAI, they will receive slightly less DAI than you did. This is how prices are dynamically adjusted.


What Category of DeFi Application Does Uniswap Belong To?

Based on the explanation above, we can clearly categorize it:

  1. Broad Category: Decentralized Exchange (DEX) It is an exchange, but it's not operated by a centralized company. Its code runs open-source on the Ethereum blockchain, your assets always remain in your own wallet, and you interact directly with smart contracts during trades. This is the fundamental difference between Uniswap and centralized exchanges (CEXs) like Binance.

  2. Specific Sub-Category: Automated Market Maker (AMM) Within the large family of DEXs, there are many implementation methods. Uniswap is a prime example of an AMM-based model. It doesn't use traditional order books but instead relies on liquidity pools and mathematical formulas to price and facilitate asset trades.


In Summary

  • What is Uniswap? A decentralized cryptocurrency exchange (DEX).
  • How does it work? It doesn't use an order book; instead, it uses liquidity pools.
  • Who provides the money for trading? Ordinary users (Liquidity Providers), who earn fees for doing so.
  • How are prices determined? Automatically calculated by a simple mathematical formula x * y = k, a mechanism known as an Automated Market Maker (AMM).

Hopefully, this explanation helps you understand what Uniswap is all about. It's like a 24/7, globally shared, automatic currency exchange machine powered by mathematical rules.