Start typing to search this publication.
https://crypto.news/
Open menu

Subscribe to https://crypto.news/

Get new posts delivered straight to your inbox.

How Does a DEX Decide the Price of a Token? Pool Math

https://crypto.news/
3 min read

After you see a DEX quote, you are seeing a price calculated from the two token balances in a liquidity pool. shiba swap is a decentralized exchange that uses token pools to quote swaps. In a constant-product pool, no one sets the ongoing price by hand: an automated market maker (AMM) follows x*y=k, and each trade changes the balances that determine the next price.

How does a pool turn a swap into a new price?

A pool turns a swap into a new price when a trader deposits one token and takes out the other, changing the ratio between its reserves. Liquidity providers supply the tokens held in the pool. As ethereum.org’s glossary explains, those pooled funds are used to facilitate DEX trades.

Take a pool holding 10 ETH and 20,000 USDC. Its spot price for ETH is the USDC reserve divided by the ETH reserve: 20,000 / 10 = 2,000 USDC per ETH. That is the price at the pool’s current balance, before a new trade moves it. For a constant-product pool, multiply the reserves to get k: 10 × 20,000 = 200,000.

Say you buy 1 ETH from that pool. You add USDC and leave 9 ETH behind. Ignoring fees for this calculation, the pool needs 200,000 / 9, or about 22,222 USDC, to keep the product unchanged. You therefore pay about 2,222 USDC. The pool’s new spot price is about 22,222 / 9 = 2,469 USDC per ETH.

The first fraction of ETH you bought cost close to the starting spot price; each next fraction cost more as ETH became scarcer in the pool. Your average price was about 2,222 USDC, while 2,469 USDC is the spot price left for the next trader. That gap between the starting spot price and your average execution price is price impact. The Uniswap v2 Core whitepaper describes the constant-product rule behind this result. The arithmetic here applies to that pool design and leaves out trading fees; other pool designs can use different pricing rules.

Trade size matters relative to reserves. Buying 1 ETH takes a tenth of the ETH in this pool, so the ratio moves sharply. The same purchase from a pool with much larger reserves at the same starting price would remove a smaller share of its ETH and have less price impact. That is why a token can show a familiar spot price yet produce a costly quote for a large swap.

A pool also has its own price. If ETH rises elsewhere from 2,000 to 2,100 USDC while this pool sits untouched, its reserve ratio still says 2,000. An outside price update cannot change the tokens in this pool. An arbitrage trader can buy ETH from the cheaper pool and sell it at the higher price elsewhere. Buying removes ETH and adds USDC, pushing the pool price upward until the remaining difference no longer pays for fees and trading costs.

This explains why prices across exchanges tend to converge without being identical at every moment. A thin pool may stay out of line when the available profit is too small to cover the costs of correcting it. When using shiba swap, read the estimated token output alongside the pool price and price impact. The output tells you what this trade is expected to receive; the spot price alone describes only the pool’s starting ratio.

What is slippage on a DEX?

Slippage on a DEX is the difference between the quote you saw and the price when your swap executes. The quote already accounts for your estimated price impact, but another trade can change the reserves before yours runs. A slippage limit sets the worst execution you will accept; a swap outside that limit reverts.

Can anyone list a token on a DEX?

On many permissionless DEXs, anyone can create a pool for a supported token pair and supply its first liquidity. Those initial deposits establish the starting reserve ratio. Later trades move it, and arbitrage can bring an outlying pool price toward prices elsewhere. A newly created pool with little liquidity can therefore show large price impact even when its displayed spot price looks ordinary.

  • Spot price is the reserve of the token you pay divided by the reserve of the token you buy.

  • A trade changes both reserves, so larger trades relative to the pool cause more price impact.

  • Arbitrage trades pull a pool price toward prices elsewhere when the difference covers trading costs.

Subscribe to https://crypto.news/