Uniswap token swaps and liquidity
Uniswap is a decentralized exchange protocol that lets you swap tokens through liquidity pools and supply assets that can earn trading fees. A liquidity pool holds assets in smart contracts, which apply rules to calculate a swap’s output. The amount you receive depends on the trade size and liquidity available along its route. Providing liquidity puts your assets into that trading mechanism, with income and price exposure changing together. The protocol has evolved through several versions, including concentrated liquidity and customizable pool hooks. Its web app and wallets provide access, while pool-based swaps and signed-order trading use different execution arrangements.
A wallet swap from quote to confirmation
When your wallet pays gas for a pool swap, it needs spendable input tokens and enough network currency. Token balances, permissions and liquidity must match the selected network. Before authorization, check the output asset and the quote’s limits: minimum output when you fix the input amount, or maximum input when you fix the output amount. An ERC-20 approval grants a contract spending permission; it doesn’t exchange the tokens. Permit2 can add a signed spending authorization after an onchain token approval. Existing permissions and smart-wallet batching can change how these actions appear, so there’s no universal number of prompts.
A swap doesn’t require disclosure of your wallet’s recovery phrase.
Submission leaves a transaction pending until the network includes and executes it. Successful settlement delivers output to the designated recipient. A successful approval records permission only, so it can’t establish that a swap completed.
How do liquidity pools set a swap price?
An automated market maker (AMM) calculates swaps using pooled assets and pricing rules, with trade size affecting the average execution price. Uniswap v2 uses the constant-product relationship x × y = k to price swaps. Here, x and y represent token quantities, and k represents their product. Buying one token adds the other to the pool, shifting their relative quantities. Fees increase the raw reserve product during ordinary swaps, so k isn’t a fixed ratio or a permanently unchanged balance. Traders can arbitrage differences between pools and external markets, bringing prices closer when trading costs allow.
Price impact and slippage tolerance
Price impact measures how your own swap changes the pool’s price. Slippage describes the difference between the quoted outcome and execution. A quote can already include the impact of its trade size. Setting a tighter slippage tolerance doesn’t remove that impact; for an exact-input swap, it limits how far the output may fall below the quote. For a router-based exact-input swap, the minimum-output check provides that boundary. Its exact-output counterpart constrains the maximum input that the trade can spend.
Other transactions can change pool conditions while a swap waits for execution. Wider tolerance accepts less output for exact-input swaps or more input for exact-output swaps and can increase exposure to adverse transaction ordering. A stricter bound increases the chance that execution reverts when the price moves. Neither setting creates liquidity. Depth near the prices that the swap crosses determines how much output the pool can support.
The same v2 pool at two trade sizes
In this hypothetical comparison, a v2 pool contains 12,486 units of the input token and 27,934 units of the output token. The wallet holds 1,246 input units but lacks gas funding. Neither proposed swap can execute until that prerequisite is met.
Compare two independent swaps from that same starting pool state, assuming ordinary token transfers and no intervening trades. The v2 swap fee is 0.30% of input, so output follows y × (0.997 × a) ÷ (x + 0.997 × a). Here, x is the input reserve, y the output reserve and a the input amount. These calculations omit network costs and round the displayed output.
A swap of 126 input units quotes approximately 278.25 output units, or 2.2083 output units per input unit. A swap of 1,246 input units quotes approximately 2,527.73 output units, or 2.0287 per input unit. The larger quote offers more tokens overall at a worse average exchange rate.
Spending permission must exist before the router transfers input tokens. Execution must then satisfy the submitted minimum output. Successful settlement establishes the actual amount that the recipient receives. Missing gas funding stops this example before submission.
What changes between v2, v3 and v4?
V2 spreads liquidity across the full price curve, v3 adds selected price ranges and v4 introduces hooks with shared accounting. This development began with the original protocol in 2018 and its ETH-token markets. V2 extended pool design to direct ERC-20 pairs. V3 made capital allocation more flexible by letting providers select where their liquidity participates. V4 launched on January 31, 2025, adding pool customization and architectural changes. These versions use distinct contracts, so a newer release doesn’t automatically convert existing positions. Migration involves withdrawing from the old position and supplying a position in the destination version.
Pool hooks and shared accounting in v4
V4’s PoolManager holds pool state within one shared contract, reducing the transfers needed between pools. Flash accounting tracks balance changes during an operation and settles the net amounts. Actual execution cost reflects both the computation that the route requires and the network’s fee conditions.
Uniswap v4 supports native ETH pools without wrapping ETH into an ERC-20 token. For ETH pairs, v2 and v3 pools use wrapped ETH.
Hooks are external contracts that run custom logic around selected pool operations. They can implement dynamic fees or other pool-specific behavior. Pools can operate without hooks; an attached hook defines their custom behavior. Custom accounting lets hooks adjust the amounts owed and use different pricing curves. The attached hook’s code and controls matter for anyone swapping through or funding the pool.
Providing liquidity and choosing a price range
A liquidity provider (LP) position supplies inventory for swaps and gives its owner a claim on the resulting assets. V2 represents proportional pool ownership through fungible ERC-20 pool tokens. The standard v3 position manager represents individual positions through ERC-721 non-fungible tokens, or NFTs. In the standard concentrated-liquidity model used by v3 and v4, providers select a price range. Their fee share tracks their contribution to active liquidity at the prices that swaps cross.
A standard concentrated-liquidity position stops earning swap fees while the pool price lies outside its range. Its asset mix can become single-sided.
Narrow ranges concentrate more capital near selected prices and require attention when the market moves. Wider ranges spread that capital across more prices. Full-range positions remain an available choice in v3 and v4. Removing liquidity returns the position’s current asset mix, which can differ from the original deposit. Changing a range changes the position’s exposure; it doesn’t restore its earlier token quantities.
Can trading fees offset liquidity losses?
Trading fees can offset losses relative to holding when earned revenue exceeds the position’s shortfall. Impermanent loss measures how a liquidity position underperforms holding its original tokens, excluding trading fees, as relative prices change. The pool exchanges its inventory as traders move its price, changing the owner’s asset mix. A position can gain value in currency terms while underperforming those untouched holdings. The word impermanent doesn’t promise that prices will return. Trading volume, active liquidity share and price movement determine the balance between fee income and that shortfall. Network costs for managing and withdrawing the position reduce its net outcome further.
Pool fees and network costs
V2 pools charge 0.30% of the input amount for a standard swap. V3 uses pool-specific fee tiers, while v4 permits static or dynamic pool fees. The fee that the pool charges, trade size and route jointly influence the quote. V2 adds swap fees to reserves, while standard v3 and v4 positions accrue separately claimable fees. Protocol fees affect how swap-fee revenue divides between LPs and the protocol; they aren’t a synonym for gas. Governance controls the applicable protocol-fee configuration within each version’s rules. A custom v4 hook can also introduce fees that its own logic defines.
Gas pays for blockchain execution and varies with computation and network conditions. Uniswap Labs stopped charging interface fees on December 27, 2025.
Pool routing, UniswapX and limit orders
A swap route can use one pool, chain several pools together or split the input across paths. Routing compares the output after fees and the network-cost estimate. Deeper liquidity can improve execution even when it adds another pool to the path. Extra computation can also erase that improvement. The app can draw on v2, v3 and v4 liquidity.
UniswapX uses signed orders that third-party fillers compete to settle. Fillers supply assets themselves or obtain them through other liquidity sources. They pay the network cost for settlement, which affects the economics of the quote. A swapper may still need a paid token-approval transaction before using this route. Order-settlement contracts enforce the required token outputs, and an order can remain unfilled until it expires. Availability depends on the supported network, assets and execution arrangement.
The web app also supports limit orders on Ethereum Mainnet, which specify a target exchange condition and an expiry. They wait for eligible execution, so reaching a displayed market price alone doesn’t guarantee a fill. Filler participation, spendable input tokens, valid permissions and the order’s remaining lifetime still matter.
The protocol, its interfaces and UNI governance
Delegated UNI determines an address’s voting power over protocol decisions. LP positions separately account for claims on supplied liquidity and earned fees.
The pool contracts provide execution, while Uniswap Labs builds the web app and wallet that access them. Other integrations can also use pool liquidity, and anyone can create a pool. An interface’s eligibility and asset policies can differ from the contracts’ permissionless design. Network deployments hold separate balances and liquidity; a pool on one chain doesn’t contain funds held on another. Unichain, an Ethereum Layer 2 network, is part of the broader ecosystem, rather than another AMM version. Moving assets between networks requires a compatible transfer mechanism and the intended destination asset.
Public blockchain transactions reveal addresses and trading activity, which can connect swaps to a wallet’s other holdings. Self-custody puts control of signing permissions with the wallet owner. A completed pool swap changes the recipient’s holdings, and the interface can’t reverse that blockchain transaction.
Helpful answers about Uniswap
-
Do I need UNI before I can make a swap?
- You don’t need UNI to use ordinary token swaps, because UNI provides governance rights; a conventional wallet-submitted swap instead requires the input asset and the selected network’s gas token, unless a supported execution arrangement covers that network cost.
-
Can I provide liquidity using only one token?
- Standard concentrated-liquidity pools in v3 and v4 accept a single-token deposit when the chosen range lies outside the current price. If the range surrounds the current price, the position requires both assets in a ratio determined by that price and its boundaries. The ordinary v2 deposit uses both tokens in the pool’s existing ratio.
-
What happens to gas fees when a pool swap reverts?
- An included pool-swap transaction that reverts still consumes gas, even though its token exchange doesn’t complete. You pay for the computation that the network performs, not an unused portion of the gas limit. A transaction rejected before broadcast doesn’t consume execution gas. UniswapX orders that remain unfilled don’t charge the swapper settlement gas; separate approval transactions can still incur costs.
-
How long does a submitted swap take to finish?
- A wallet-submitted swap finishes only when the network includes and successfully executes its transaction. Congestion, network-fee settings and earlier pending transactions from the same conventional account can delay inclusion. A route’s deadline limits when execution remains valid; it doesn’t promise confirmation by that time. A signed UniswapX order instead waits for a filler and can expire unfilled.
-
Is a familiar token ticker proof that it is genuine?
- A familiar ticker doesn’t prove a token’s identity or backing. Different contracts can reuse names and symbols, while the network and contract address identify the actual token. Permissionless pool creation doesn’t certify the issuer or establish a claim on an external asset. Interface warnings can flag impersonation or harmful behavior, but their coverage and accuracy have limits.
-
Will disconnecting my wallet revoke token approvals?
- Disconnecting a wallet doesn’t revoke spending permissions recorded onchain. Standard ERC-20 allowances aren’t tied to browser sessions, while Permit2 authorizations can include their own expiry. Ending a connection leaves any unrevoked, unexpired allowance subject to its original limits. Revocation changes the relevant permission; closing a tab doesn’t change contract state.
Updated ·