Skip to main content
Uruguay Can

News from across crypto

How SunSwap calculates swap prices from pool liquidity

SunSwap calculates swap prices from a pool’s pricing model, available liquidity, trade size and fees, which shape the output you see.

Uruguay Can Editorial

How SunSwap calculates swap prices from pool liquidity

SunSwap calculates a swap quote from the selected pool’s pricing model, available liquidity, trade size and fees; together, these determine your estimated output and average exchange rate.

  • The pool’s reserves or active liquidity set the starting price.
  • The trade’s size changes how much liquidity remains and can move the pool price.
  • Fees reduce the amount you receive.
  • The pool version and any V4 hook can change how the quote is calculated.

Because an AMM calculates a quote from a liquidity pool instead of matching resting exchange orders, TRON swap pool pricing shows why the pool matters. A TRON swap through a different pool can return a different amount for the same input.

To understand a quote, first check whether the pool is SunSwap V2, V3 or V4. There is no single formula for every pool: V2 uses token reserves, V3 concentrates liquidity within price ranges chosen by liquidity providers, and V4 adds hooks that can run custom logic during a swap. A V4 hook may change fees or use a custom curve, so check whether the selected pool has one and what it does.

A larger V2 trade moves the pool price

In a SunSwap V2 constant-product pool, the token reserves follow x × y = k. The output depends on the input and both reserves, so the pool’s starting exchange rate is not the average rate you get across a trade.

Picture a V2 pool with 100 A and 1,000 B. Its starting rate is 10 B per A. If you swap 10 A, the pool has 110 A after the input; to keep x × y constant, it must leave about 909.1 B in reserve. The output is 1,000 − (100 × 1,000 ÷ 110), or about 90.9 B before fees. That gives you an average rate of about 9.09 B per A, below the starting rate, because your trade moves the pool price.

The same input can have a smaller effect in a deeper pool and a larger effect in a thinner one. Fees lower the output further because only the amount left after the fee participates in the swap; the exact fee depends on the pool and, in V4, may depend on its hook.

When you compare quotes, use the estimated output and average rate, not just the starting price. If the pool changes before your swap executes, its available liquidity and price may shift, changing the final output. This is why the pool version and any V4 hook are useful details to check before you confirm.