Orbion Logo
Orbion

Pricing Mechanics in DEX Pools on Solana

6/2/2025
4 min read

Pricing Mechanics in DEX Pools on Solana

How Crypto Pricing Works in DEX Pools on Solana

In a previous article, I shared how I started building an arbitrage bot on Solana, using liquidity from decentralized exchanges (DEX) and executing atomic multi-hop swaps.

Many readers asked one simple but critical question: Where does the price on a DEX actually come from? Who sets it, why does it change, and what exactly is slippage?

This article breaks down the core pricing mechanics in DEX liquidity pools, using clear language and real examples—no screenshots or fluff.

Pricing on CEX vs DEX

On centralized exchanges (CEX) like Binance or OKX, prices are derived from order books. Buyers and sellers submit orders, and the exchange matches them. The last matched trade sets the current market price.

But on a DEX, there's no centralized order book (unless it's a DEX like OpenBook). Instead, trades happen via liquidity pools, and prices are determined algorithmically.

What Is a Liquidity Pool?

A liquidity pool is a smart contract that holds two tokens—say, SOL and USDC. Anyone can trade one for the other, and the exchange rate is calculated from the token balances in the pool.

There are different types of pricing models used in these pools:

  • Order Book DEX — like OpenBook, similar to CEX mechanics
  • AMM (Automated Market Maker) — algorithmic pricing, no order books

Within AMMs, we see three main models:

  • CPMM (Constant Product Market Maker)
    Used in Raydium AMM v4, Uniswap v2
    Formula: X * Y = K

  • CLMM (Concentrated Liquidity)
    Used in Raydium CLMM
    Liquidity is allocated to specific price ranges (ticks)

  • DLMM (Dynamic Liquidity)
    Used in Meteora
    Liquidity dynamically follows price trends

Let's explore CPMM in depth.

Understanding the CPMM Formula

At the heart of CPMM is this elegant formula:

X * Y = K

Where:

  • X = amount of token A in the pool (e.g. SOL)
  • Y = amount of token B (e.g. USDC)
  • K = a constant value (product of the two token amounts)

This relationship must remain constant after each swap. So when you swap tokens, you change the balance of X and Y—but the product K stays the same.

Small Swap Example

Let's say the pool holds:

  • 1,000 SOL
  • 100,000 USDC
    Then K = 1,000 * 100,000 = 100,000,000

You want to swap 1 SOL for USDC. After adding your SOL:

X = 1,001  
Y = K / X = 100,000,000 / 1,001 ≈ 99,900.1

So you receive: 100,000 - 99,900.1 = 99.9 USDC
Your effective price is slightly less than 1 SOL = 100 USDC — this is slippage.

Large Swap Example

Same pool, but now you swap 100 SOL:

X = 1,100  
Y = 100,000,000 / 1,100 ≈ 90,909.1

You receive: 100,000 - 90,909.1 = 9,090.9 USDC
Now your effective price is 1 SOL ≈ 90.91 USDC — about 9% slippage due to swap size.

The Role of Fees

Most AMMs take a swap fee (e.g. 0.3%). Usually, this is deducted from the input amount before the swap calculation.

Let's say the fee is 10% (just for illustration):

  • You swap 10 SOL
  • 10% is taken as a fee → only 9 SOL enters the pool

Recalculating:

X = 1,009  
Y = 100,000,000 / 1,009 ≈ 99,108.0  
AmountOut = 100,000 - 99,108.0 = 892.0 USDC

You receive less because of the fee and slippage combined.

Multiple Swaps, Changing Prices

Swapping again after the first trade gives worse results. For example:

  • First 10 SOL → ~892 USDC
  • Second 10 SOL → ~765 USDC
  • Total for 20 SOL → ~1,657 USDC

Why? The pool becomes unbalanced: more SOL, less USDC. The formula keeps adjusting the price downward for SOL.

Key Takeaways

  • AMMs don't have fixed prices — they react to the ratio of tokens in the pool
  • Bigger swaps cause more slippage
  • Swap fees reduce your output
  • The "visible price" in the UI isn't the final price — it's an estimate based on the current pool state

This formula is the foundation for arbitrage strategies: if one pool is mispriced compared to another, bots can profit by correcting the difference.

Final Thoughts

Understanding the core formula X * Y = K is essential for anyone building or trading on Solana DEXs. Raydium, Orca, and Meteora all use variations of this model, each with different liquidity behaviors and pricing precision.

If you're writing bots or designing trading strategies, always simulate the swap math before execution — it can make or break your edge.

Want a breakdown of CLMM and DLMM pricing logic? Let me know and I'll dive into those next.