Hello everyone, I'm Paul from Crypto Oddities. I hope to use my knowledge to help you understand a bit about this space. If you find it helpful, please follow me.

1. Counterparties in CEX (Centralized Exchanges)

In CEX (such as Binance, OKX, Coinbase), your trades are matched through the order book.

Matching mechanism: Order Book Matching: CEX maintains an order book that records all limit orders, divided into buy orders (Bid) and sell orders (Ask).

How does that match?

  1. You place a buy order, and CEX will look for the lowest-priced sell order in the order book to see if it can be executed.

  2. If there are multiple sell orders that meet the criteria, they will be matched based on price priority and time priority (Price-Time Priority), meaning the order that was placed first will be executed first.

  3. If it is a market order, it will immediately start filling from the top of the order book until the order quantity is completed.

Taking the above as an example:

  1. You place a market order to buy 1 BTC: the system directly matches to the sell order of 101,000 USDT → Transaction completed.

  2. Your counterparty is the person selling BTC for 101,000 USDT (this could be a retail trader, an institution, or a market maker).

So your counterparty in CEX may be:

  • Other users: When you place a buy order, your counterparty is the user placing a sell order; vice versa.

  • Market Makers: Most of the depth comes from market makers, especially in smaller coins; what you buy often comes from orders placed by market makers.

  • The exchange itself (in some cases): Although large exchanges claim not to bet against users, some smaller exchanges will directly fill liquidity as counterparties (even hedging against the real market).

2. Counterparties in DEX (Decentralized Exchanges)

Most DEXs adopt the AMM (Automated Market Maker) model, such as Uniswap, SushiSwap, and Curve. (A few DEXs use on-chain order books, like dYdX and 0x, but they are not widespread.)


AMM (Automated Market Maker) mechanism: AMM does not use limit orders for matching but uses a liquidity pool and formulas for automatic pricing.

Core formula: The classic Uniswap V2 uses x * y = k (constant product market maker, CPMM):

  • x = Amount of Token A

  • y = Amount of Token B

  • k = Constant (remains unchanged before and after the transaction)

When you swap A for B, x increases → y decreases → price changes automatically.

Example (ETH/USDC pool):

  • Initial: 10 ETH + 20,000 USDC, k = 200,000

  • You buy ETH with 1,000 USDC:

  • After the transaction, USDC changes to 21,000.

  • ETH quantity decreases, price increases.

  • The trading price is calculated by an algorithm, not set by a specific person.

So your counterparty in DEX may be:

  • Liquidity Providers (LP): They deposit tokens into a pool and earn trading fees, but they must bear impermanent loss.

  • The liquidity pool itself: You trade directly with the pool, and the price is determined by an algorithm.

  • Arbitrageurs: When the pool price deviates from the external market, they will trade to arbitrage, indirectly affecting your transaction price.


3. Summary

CEX is like an auction market: some people place sell orders while others place buy orders; the exchange simply acts as a referee to match you with another person for a trade.

DEX is like an automatic currency exchange machine: there are two types of coins in the pool; you put one in, and the formula spits out the other, and the price will change due to your transaction.