Research/Education/Uniswap/How Uniswap Works: The Pool Sets the Price From Two Balances
# Uniswap

How Uniswap Works: The Pool Sets the Price From Two Balances

BloFin Academy09/10/2026
A walk through how a Uniswap swap hits a pool, how k = x * y sets the fill, and how v3 and v4 change where liquidity sits and how the pool is stored.

Two-sided trading usually waits for someone else to rest an order at your size and price, and if that other side is thin, or missing, your trade sits, or it walks through whatever size is already posted until the fill is complete.

That wait is the friction whenever you wanted a fill now against inventory that is already sitting somewhere. A book can show a size at a price before anyone trades, and it can also vanish before you get there.

Automated market makers answer that by holding both tokens in a shared pool and pricing the fill from the two balances, so you send one token in and the pool sends the other token back so the product of those two balances, usually written as k, stays put. A larger pull against a thin pool moves that ratio more, which is price impact.

Uniswap is that design, taught as a sequence, and on the classic constant-product version a 30-basis-point fee comes off the input first. The protocol named in what Uniswap is is the same idea, now walked as the moment the second reserve has to move.


After the first token lands, the other reserve has to move

Once the input token has landed in the pair, the output token can leave only by an amount that keeps k, because if the output reserve dropped by more than that the product would fall, and if it dropped by less you would be underpaid. The contract solves for the other reserve from the product rule, and it skips a discretionary "fair" price.

Suppose a toy pool starts with 8 ETH and 32,000 USDC, which makes a product of 256,000 and a spot ratio of 4,000 USDC per ETH. You want 1 ETH out, so ETH must fall to 7, and to keep k at 256,000, USDC must rise to about 36,571. You pay about 4,571 USDC for that 1 ETH, rather than 4,000, and the extra is price impact: the curve answering your size against the inventory that was sitting there.

x and y are token amounts, so 8 ETH and 32,000 USDC can share the same k even if ETH's external dollar price has moved, as long as nobody has traded this pool yet. The first swap is what restates the ratio, which is why a stale pool can quote a silly price: k only knows the two balances sitting in the contract.

v2 is a new implementation based on the same formula as v1's constant product design. Traders pay a 30-basis-point fee on trades, which goes to liquidity providers, and the contracts are non-upgradeable (source: Uniswap v2 Core whitepaper). The toy walk skips that fee so the algebra stays in one step, and in a live v2 swap the fee comes out of the input first, so k actually rises a little.

Token prices are determined by the amount of each token in a pool, and the pool contract maintains a constant with x times y equal to k. During each swap, some of one token leaves and some of the other token enters, and the balances adjust so k holds, which is the new price (source: Uniswap Labs, How are token prices determined?).

A tenth-size pull would move the ratio much less, so the same 8 ETH pool can fill 0.1 ETH near 4,000 USDC. Size versus depth is the whole impact story, and the formula cares how much of the output token is still sitting there when the input has already changed.

The fill comes from pool inventory already sitting in the contract

On Uniswap you trade against reserves that are already in the contract, rather than waiting for someone to hit a bid, and the AMM updates the pair as those balances change. That is a different market structure from a book of bids and asks.

They use a simple pricing rule called the constant product formula. Liquidity pools replace the book, and you interact with the pool directly (source: Uniswap Blog, What is an Automated Market Maker?).

Step Order book Uniswap pool
You send A bid or an ask Tokens into the pair
The other side Someone's rest order The two reserves
Price after Last match New ratio of x and y

A generic primer on how AMMs work is the category picture, and the Uniswap-specific contrast with books sits in AMM versus order books. Your fill path stays the same either way: USDC went in, ETH came out, and k held.

The book can show a size at a price before anyone trades, while the pool quotes the curve evaluated at your size. After the swap, the next trader faces a new ratio, which is why a thin pool feels slippery even when nobody is spoofing a book.

Two swaps in a row share a product that has already moved, because the second swap sees the reserves the first swap left behind, and a mid you screenshot can be stale by the time you sign. A rest bid on a book can be canceled before it matches, while a confirmed pool swap already moved x and y. Front-running still obeys k, and it just takes a better place in line against the same product.

Anyone can create the pool; the core prices from the reserves

The protocol skips a whitelist of which pair may exist, so anyone with gas can start a pool for two tokens, and the core contracts then price swaps from the reserves. They leave discretionary fills and desk pauses off the matching path.

The Uniswap protocol is a set of immutable onchain smart contracts that implement AMM-based trading and liquidity across protocol versions (source: Uniswap Docs, Protocol glossary). v2's whitepaper also says the contracts are non-upgradeable. A later router can be replaced, while the pair that holds the tokens is a fixed matching engine.

v2 splits core and periphery, so the factory and pairs are the small set of contracts that holds funds, and routers sit around them. Because of Uniswap's permissionless nature, those core contracts have no special privileges. Unlike Uniswap v1 pools, v2 pairs skip native ETH, so ETH to ERC-20 pairs must be emulated with WETH, and the router can wrap and unwrap so a UI can still show ETH (source: Uniswap Docs, v2 architecture). Anyone can write another router, and the pool still prices from k.

The call still settles on a chain. On Ethereum, payment for computation is made in the form of a gas fee, and the fee is paid whether a transaction succeeds or fails (source: ethereum.org, Gas and fees). ETH is the fee token for that call, even when your pool is USDC and UNI.

How Ethereum works is the chain picture, and a BloFin order stays on the venue ledger and leaves that call unsent.

Permissionless listing is also why junk pairs exist, because the core will price whatever reserves it holds and skip a quality screen on the other token. Check the token addresses.

Starting a pool is a different action from filling it, and a factory pair with dust reserves will still quote a ratio. That first ratio is whatever the first depositor put in, so you can swap into a junk ticker that looks like USDC and the core will still settle the math.

Later versions change where liquidity sits, then how the pool is stored

v2, v3, and v4 still price a swap from pool state. They keep that idea and change where the inventory sits inside the curve, then how many contracts store the pools.

Dated launch history belongs on Uniswap history and versions. v2 puts liquidity across the whole curve, and the 8 ETH / 32,000 USDC toy is that picture: every price has some depth, including prices nobody will trade. v3 keeps the same product inside a range, and v4 keeps v3's range model and changes the storage.

Uniswap v3 is a noncustodial automated market maker. Liquidity providers can concentrate capital inside a chosen price range, and fees on that position accrue when the price sits in the band (source: Uniswap v3 Core whitepaper). If you only want to earn fees near 4,000 USDC per ETH, that capital can sit in a band around that price. Inside the band, a swap still moves along a product curve, and outside the band that position is idle for the swap that is pulling inventory. Tick math and how to set a range sit in concentrated liquidity on Uniswap v3.

A v3 pool can also pick a fee tier at creation, so the 30-basis-point v2 default is one line among several, and the fill you see still comes from whatever liquidity is in range at that moment.

Architecturally, all v4 pool state and operations are managed by a single contract, PoolManager.sol. Creating a pool is a state update. Developers can attach extra logic to the swap lifecycle through hooks, which run before or after pool actions (source: Uniswap Docs, v4 architecture).

For you, the visible fill is still tokens in, tokens out, and a price from pool state, while the singleton is how many pools share one contract. Flash accounting nets token debts inside a transaction so intermediate hops can settle together at the end. A hook is extra code that pool opted into, and a badly written hook is pool-local risk. Depth on hooks is Uniswap v4 and hooks.

v4 left v2 and v3 pools in place, so a router can still reach an old pair, and liquidity stays where it was deposited unless someone moves it.

The other side of the swap is an LP share, while UNI is the vote token

The ETH you received came from someone who deposited the pair. That depositor is a liquidity provider, or LP, which is a depositor with a claim on that pool. The claim that tracks the deposit changes by version.

v2 mints a fungible pool token, an ERC-20 share of the pair, while v3 tracks a position as an NFT-style claim for a chosen range. Those claims can earn a share of swap fees on that pool, and they remain a pool claim, while UNI is the ERC-20 used to vote. Pool depth, fee share, and what an LP actually holds sit in Uniswap liquidity pools. You traded against deposited reserves, so the LP's claim is a share of that inventory.

Swap fees and protocol fees are different cuts: LP fees accrue to the share, and protocol fees, when on, are a governance-set slice that can feed UNI burns. They skip a pro-rata payout to whoever holds UNI. Tally proposal 100 is executed, and its adopted text is to activate it on a subset of v4 pools on these same chains (source: Uniswap Foundation vote, Activate v4 Protocol Fees (Part 1/2)). Read a v4 label as a version family, then check the family and the chain before you treat protocol fees as on.

If an LP withdraws, both reserves can leave and k falls because inventory left. Holding UNI in a wallet leaves you off the other side of this trade, and you are on the other side only if your share is still in that pool. A UNI balance and an LP share can sit in the same wallet and still be two claims.

A pool swap, a venue fill, and an intent auction are three different paths

If you wanted wallet buttons, a centralized-exchange order, an intent auction, or a generic AMM class, you wanted a different path, because the Uniswap pool still prices your fill from k and those other paths skip that product. Match the next click to the path.

How to buy UNI is the purchase walk, including venue clicks.

UniswapX is a permissionless, open source (GPL), Dutch auction-based protocol for trading across AMMs and other liquidity sources: you sign an order and fillers compete, which skips how a v2-style pool solved for the other reserve (source: Uniswap Blog, Introducing the UniswapX Protocol). The auction walk sits in UniswapX explained. A filler may use a Uniswap pool as inventory, and the intent is still the auction.

BloFin has listed UNI/USDT on spot since January 15, 2024, 11:00 UTC.

BloFin lists two UNI perpetuals: UNIUSDT at up to 75x, listed January 12, 2023, 10:00 UTC, and UNIUSD, an inverse contract settled in UNI, at up to 20x, listed June 27, 2025, 10:00 UTC. Those listings are venue books, so a fill there will show on BloFin, and it will leave a Uniswap pool's two balances untouched.

You can still hold UNI on BloFin and leave every pool untouched, which is a listing fact that leaves the pool formula where it is.


Frequently asked questions

If I swap UNI on Arbitrum, is that the same k as the Ethereum pool?

Each pool is a contract on one chain with its own reserves, so same tickers keep separate products. An Ethereum pair's k stays on Ethereum, and an Arbitrum pair's k stays on Arbitrum. Bridging UNI moves tokens and leaves those two products unmerged, so size a quote against the pool you will actually call. A screenshot of Ethereum reserves is a snapshot.

If k must hold, can the pool run out of one token?

It can get arbitrarily close, and it gets more expensive as it does. If you kept buying ETH, y would fall and each next unit would cost more USDC so the product stays at 256,000, which means the last wei of ETH is a steep point on the curve. In practice LPs add and remove, and other traders sell ETH back in, so the toy empty-reserve path is a limit of the curve. A pool with almost no ETH left is a warning about depth.

If my swap reverts, did the pool still move?

A revert leaves x and y as they were, though you can still pay gas for the failed call, because k skipped your input. A confirmed swap is the one that moved reserves, while a rejected wallet prompt is a canceled prompt and a pending nonce is a wait. Wait for the confirmation before you treat the pool as updated.

If I add ETH as an LP after the swap, does k stay 256,000?

k is the product of the reserves that sit in the pair right now. Your swap kept that product, then the fee-on-input path lifts it a little. An LP deposit is a different action: in v2 both sides go in and k rises, so the toy 256,000 is a snapshot. If you still see 256,000 after a deposit, you are looking at an old block.

Is a hook the same as Uniswap's protocol fee switch?

A hook is extra code a v4 pool opts into at set points in a swap or a liquidity action, local to that pool, while protocol fees are a governance-set slice on enabled pools and versions. Tally 100 turned v4 protocol fees on for some pool families on some chains. A pool can have a hook, a protocol fee, both, or neither, so treat a hook as pool-local code.

Can I read k on a block explorer before I swap?

You can read the two token balances and multiply them, and that product is k at that block. Your swap will use a later state if another trade lands first, so a UI quote is a simulation against the state it saw. Refresh the quote, then sign, and treat an explorer screenshot as a snapshot. If the explorer and the quote screen disagree, refresh both before you size the trade.

If I wrap ETH to WETH, is that a third token inside k?

A typical ETH and USDC pool on Uniswap holds WETH and USDC, because native ETH is wrapped first, so k is still two reserves. WETH is a wrapped reserve. If a UI shows "ETH" it is usually the wrapped reserve the pool actually stores, so count the balances the pair holds.


Researched and written by the BloFin Academy editorial team with AI-assisted drafting. Updated September 2026. Primary sources include the Uniswap v2 and v3 core whitepapers, Uniswap v4 architecture docs, and Tally proposal 100. All facts independently verified against cited documentation current as of September 2026.

This article is educational and general in nature, not financial or investment advice. Cryptocurrencies like UNI carry real risks, including price volatility, venue risk, smart-contract exploits in ecosystem apps, and the chance of losing funds. Nothing here is a recommendation to buy, sell, hold, or participate in any project. Do your own research, and consider speaking with a licensed professional before making financial decisions. BloFin does not provide investment advice.