Why DEX Prices Can Differ From Centralized Exchange Prices

in #firstdexonsupra • 7 days ago (edited)

DEX vs CEX_ Why Prices Differ.png

A trader can look at the price of a token on a centralized exchange and then see that the price is a little higher on a decentralized exchange. Initially, that may seem like a challenge. It is just a natural consequence in most instances of the price setting of each market.

A typical centralized exchange will have an order book on which buyers and sellers place orders at their price. The liquidity pool formula and assets will determine the price of automated market maker (AMM).

The difference will become clearer once you see what is going on in each market type.

A DEX gets its price from liquidity

Imagine that there is a DEX that has a token pool consisting of two tokens called Token A and Token B. A trader exchanges them for another one. The amount of tokens in the pool is changed by the trade, and the exchange rate fluctuates in accordance with the reserves.

In a traditional constant-product AMM, the pool follows a formula commonly expressed as x × y = k. When a trader removes one asset and adds the other, the reserve ratio changes, which changes the price available for the next trade.

That means there is not necessarily one fixed price sitting inside the DEX.

The quoted price depends on the pool, its current reserves and the size of the trade.

Dexlyn's swap system, for example, uses automated liquidity pools. Its developer documentation describes the pool contracts as automatically adjusting reserves and prices as trades take place.

A centralized exchange gets its price from orders

The mechanics are different on a centralized exchange.

Imagine a token has buyers willing to pay $100, $99.80 and $99.50, while sellers are asking for $100.20, $100.50 and $101. Market price is based on the buy and sell orders in that book, and the trades that are placed against them.

A DEX does not need someone on the other side of every trade to post an order. Traders can interact directly with the liquidity pool instead.

This is one reason two venues can show different prices at the same moment.

Arbitrage usually pulls prices back together

Suppose that the price of a token is $100 on one market and $101 on another.

A trader or trading bot can purchase the token at a lower price and sell it at a higher price. That trade pushes the two prices toward each other.

The same thing can happen between a DEX pool and a centralized exchange. If the outside market is ahead, then arbitrage traders can trade against the DEX pool until the price is closer to the outside market.

This process is not dependent upon the two markets' numbers being identical each time. There are any number of factors that can account for a slight difference, such as fees, trading size, network conditions and liquidity.

Small pools can move a lot after one trade

Liquidity depth matters.

In the beginning, there are two pools with a token each, both priced at around $100. The first pool has millions of dollars in liquidity, the second has only a small amount. A $20,000 trade may barely move the first pool but can move the second pool much more.

This is why the displayed token price alone does not tell you what price you will actually receive.

Chainlink's documentation also warns that assets with low liquidity or trading volume can be harder to price and may be more exposed to price manipulation.

DEX interfaces therefore show information such as slippage or price impact before a swap. Dexlyn, for instance, lets traders set slippage tolerance when making swaps.

Concentrated liquidity changes the picture

Not every AMM spreads liquidity across the entire possible price range.

With concentrated liquidity, liquidity providers can place capital inside a selected price range. When the current price sits inside that range, the position can take part in swaps and earn fees. Once the price moves outside the selected range, that position becomes inactive until the price returns.

This can make the available liquidity around the current market price quite different from what a simple TVL figure suggests.

Two DEXs can therefore have similar total liquidity but provide very different trading conditions at a particular price.

Why oracle prices may be different again

There is another price to consider: the oracle price.

In the beginning, there are two pools with a token each, both priced at around $100. The first pool has millions of dollars in liquidity, the second has only a small amount. That price does not necessarily come directly from one DEX.

Ethereum's documentation states that oracles are a means for smart contracts to access financial information like Exchange Rates and Asset Prices.

For instance, Chainlink combines the price data from several data sources via a decentralized network of node operators. It also has pricing methods designed for assets that trade mainly on DEXs, where on-chain liquidity can be more informative than a small number of recent trades.

So you may see three slightly different numbers:

DEX pool price → centralized exchange price → oracle reference price

This doesn't imply that either one of them is incorrect.

They can just be using different metrics.

What should traders check?

Before making a large swap, looking at the headline token price is only one part of the picture.

Check the amount you will actually receive, the pool's available liquidity, the expected slippage, the trading fee and whether the market has moved while your transaction is waiting to be confirmed.

If you plan to trade across different chains, there's even more to take into account as the markets on both chains may be in a different liquidity state.

The advantage a decentralized exchange can provide to traders is the access to on-chain markets, the downside being the mechanics of those markets. If there is a difference, it is helpful to know where it has come from, in order to ascertain whether it is normal or there is a problem that needs to be addressed.

Final thought

DEX and centralized exchange prices do not have to match tick for tick.

It involves everything from order books, AMM reserves, concentrated liquidity, arbitrage, fees and oracle design. With the knowledge that what's behind the number on the screen is what it is, a price difference is no longer opaque and becomes what it truly is: the outcome of market construction.