Skip to main content
Coinvane

News from across crypto

What Is a Trading Pair on a DEX? Read Its On-Chain Price

A DEX trading pair is a smart contract holding two token reserves; their ratio sets the swap price. Learn to read token order, reserves and routes.

The Coinvane Desk3 min read

What Is a Trading Pair on a DEX? Read Its On-Chain Price

A trading pair on a decentralized exchange is a smart contract that holds reserves of two tokens and sets swap prices from their ratio. The pair is the market itself, so there is no order book matching buyers and sellers.

Think of the pair as two connected jars: a swap takes some tokens from one and adds tokens to the other. That changes their ratio, which changes the price. The analogy stops there; on-chain, the contract enforces the swap rules. In Uniswap V2-style systems, a Factory creates each pair with createPair, and the pair contract keeps the reserves. The Fraxswap Factory, pair contracts and Router use these distinct roles.

A pair’s token order determines how to read its price

In a constant-product pair, the reserves follow x·y=k, where each swap changes the amounts while keeping their product roughly constant. The spot price of token0 in token1 is reserve1 divided by reserve0, after accounting for token decimals.

Token0 is always the token with the lower contract address, not the token shown first in a website’s pair name or swap box. That difference can reverse the ratio you read. The Uniswap V2 pair interface exposes token0, token1 and getReserves; check the addresses first, then match each reserve to its token.

Take a FRAX/WETH pair holding 300,000 FRAX and 100 WETH. If WETH is token0, its reserve is 100 and FRAX’s is 300,000, so reserve1 ÷ reserve0 gives about 3,000 FRAX per WETH. If FRAX is token0, the same reserves produce about 0.000333 WETH per FRAX. The pool has not changed; only the direction of the price has.

Calling getReserves returns the reserve values in token0, token1 order. A UI may label the pair FRAX/WETH while the contract orders WETH first. Match the returned values to the token addresses before calculating a price, or you may report the reciprocal.

Routes and reserves shape the swap you receive

A Router can connect pairs when no direct market exists. To trade a token for WETH without a token/WETH pair, it might route token→FRAX→WETH, swapping through two separate pools. The Router coordinates the path; each pair contract supplies its own reserves and price.

Each swap shifts a pair’s reserve ratio, so a larger trade moves the price more in a shallow pool than in a deep one. That movement is price impact. The displayed spot price comes from current reserves, while the amount received depends on how the trade changes them along the route.

Related

What is the difference between base and quote token in a pair?

The quote token is the unit used to express the price of the base token. A price of 3,000 FRAX per WETH makes WETH the base and FRAX the quote, regardless of which address is token0.

Why is there no pair for my token?

A pair exists only if a Factory has deployed a contract for those two token addresses on that chain. A Router may still find a multi-hop route through other pairs, but it cannot route a swap if no usable path exists.

A DEX pair’s reserves set its current price because the contract is the market. Read token0 and token1 before dividing reserves, and you can interpret both the quoted price and the route a swap may take.