Uniswap Explained: How the Largest Decentralized Exchange Works
Uniswap has proved that decentralized token trading could work at scale. Launched in 2018, it introduced the automated market maker (AMM) model to crypto.
It replaced traditional order books with liquidity pools and mathematical formulas. Today, Uniswap is the largest decentralized exchange by volume and one of the most important pieces of infrastructure in DeFi.
This guide covers how Uniswap works across its different versions, the UNI governance token, how liquidity provision functions, and the risks involved.
What Is Uniswap?
Uniswap is a decentralized exchange (DEX) protocol that allows anyone to swap ERC-20 tokens directly from their wallet without an intermediary.
There's no account creation, no KYC, no order book, and no company matching trades. Instead, trades execute against liquidity pools, smart contracts that hold reserves of token pairs and use mathematical formulas to determine prices.
Uniswap has gone through several major versions, each introducing significant architectural changes. Understanding these versions matters because they coexist; V2 and V3 pools are both still active, and V4 introduces yet another model.
How Uniswap Works: Version by Version
Uniswap V2: The Constant Product AMM
V2 is the version that established the AMM model most people know. It uses the constant product formula: x × y = k, where x and y are the reserves of two tokens in a pool, and k is a constant.
When someone swaps token A for token B, they add token A to the pool and remove token B.
The formula ensures that as one token becomes scarcer in the pool, its price increases relative to the other. This creates a smooth pricing curve that handles any trade size, though larger trades move the price more (slippage).
Key characteristics of V2:
- Liquidity is spread evenly across the entire price range from zero to infinity.
- Any ERC-20 token can be listed permissionlessly, meaning anyone can create a pool.
- LPs deposit equal values of both tokens and earn 0.3% on every trade.
- Simple to understand and provide liquidity to, but capital-inefficient, most liquidity sits at prices far from the current market price and never gets used.
Uniswap V3: Concentrated Liquidity
V3, launched in May 2021, introduced concentrated liquidity. V3 was arguably the most significant innovation in AMM design since the original constant product formula.
Instead of spreading liquidity across all prices, V3 lets liquidity providers choose a specific price range for their capital.
For example, instead of providing ETH/USDC liquidity across all possible prices, an LP might concentrate its liquidity between $2,000 and $4,000, the range where they expect most trading to occur.
The benefits:
- Capital efficiency: By concentrating in a relevant range, LPs can provide the same effective depth with far less capital. In theory, a V3 position can be up to 4,000x more capital-efficient than the equivalent V2 position.
- Higher fee earnings: More concentrated liquidity earns a larger share of fees for the same capital deployed.
- Custom fee tiers: V3 introduced multiple fee tiers (0.01%, 0.05%, 0.3%, 1%) so pools can match fee levels to the volatility of the pair.
The tradeoffs:
- Active management required: If the price moves outside your chosen range, your position earns zero fees and is entirely composed of the less valuable token. V3 LP positions require monitoring and rebalancing.
- More complex impermanent loss: Concentrated positions amplify impermanent loss compared to V2. The narrower the range, the higher the potential IL if the price moves against you.
- Higher barrier to entry: V3 LP is significantly more complex than V2. Choosing ranges, managing positions, and understanding the fee/IL dynamics requires more expertise.
Uniswap V4: Hooks and Customisation
V4, currently in development and early deployment, introduces "hooks". It's a custom code that can be attached to liquidity pools to modify their behaviour at various points in the trade lifecycle.
This makes Uniswap more of a platform than a single-purpose DEX.
Hooks enable things like:
- Dynamic fees that adjust based on volatility or other conditions.
- On-chain limit orders.
- Custom oracle implementations.
- Automated LP strategies built directly into the pool logic.
- MEV-aware execution modifications.
V4 also introduces a "singleton" contract architecture where all pools live in a single contract rather than each pool being a separate deployment. This dramatically reduces gas costs for pool creation and multi-hop swaps.
The UNI Token
Governance
UNI is Uniswap's governance token, launched in September 2020 via one of the largest airdrops in DeFi history (400 UNI to every address that had used the protocol).
UNI holders govern the Uniswap protocol through an on-chain governance system, voting on:
- Protocol fee parameters (whether to activate the "fee switch").
- Treasury grants and ecosystem funding.
- Deployment decisions for new chains.
- Protocol upgrades and parameter changes.
The Fee Switch
One of the most discussed aspects of UNI governance is the "fee switch". It's a mechanism that would redirect a portion of trading fees from liquidity providers to UNI token holders or the protocol treasury.
The fee switch has been a topic of governance debate for years. Activating it would give UNI direct revenue-sharing characteristics but would also reduce LP returns, potentially affecting liquidity depth.
The fee switch discussion represents a fundamental tension in protocol governance: how to balance the interests of token holders (who want value accrual) with liquidity providers (who want maximum fee earnings) and traders (who want deep liquidity and tight spreads).
Tokenomics
UNI has a total supply of 1 billion tokens, with allocations to the community (60%), team (21.266%), investors (18.044%), and advisors (0.69%). The community allocation includes the initial airdrop, liquidity mining programs, and the governance treasury, making it one of the largest protocol treasuries in DeFi.
Providing Liquidity on Uniswap
How LPs Earn
Liquidity providers earn trading fees proportional to their share of the pool's liquidity within the active trading range.
In V2, this is straightforward, where deposit tokens earn a share of 0.3% on every trade.
In V3, it's more nuanced, where you only earn fees when the price is within your chosen range, and your share depends on how much liquidity is concentrated at that price point.
Impermanent Loss
The primary risk for LPs is impermanent loss (IL). It's the difference between holding tokens in a pool versus simply holding them in a wallet.
When the relative price of the two tokens changes, the pool's rebalancing mechanism means LPs end up with more of the token that decreased in value and less of the token that increased. More about it has been explained in the blog about Impermanent Loss here.
For V2 pools, IL follows a well-understood formula. For V3 concentrated positions, IL is amplified; tighter ranges mean higher fee earnings but also higher IL when prices move.
Whether fee earnings compensate for IL depends on the specific pool, the price range chosen, and market conditions. There's no guarantee that LP positions are profitable.
Uniswap's Role in the DEX Ecosystem
Multi-Chain Deployment
Uniswap is deployed on Ethereum, Arbitrum, Optimism, Base, Polygon, BNB Chain, Avalanche, Celo, and several other chains.
Each deployment operates independently, with separate liquidity pools and governance decisions about fee parameters. The multi-chain strategy ensures Uniswap is available wherever DeFi activity exists.
Aggregator Integration
A significant portion of Uniswap's volume comes through DEX aggregators (1inch, Paraswap, CowSwap, etc.) rather than direct use of the Uniswap interface.
Aggregators route trades through Uniswap pools when they offer the best price, meaning Uniswap's liquidity serves the broader ecosystem even when users don't interact with Uniswap directly.
The Uniswap Frontend and Uniswap Labs
An important distinction: Uniswap, the protocol (the smart contracts), is separate from Uniswap Labs (the company that builds the frontend at app.uniswap.org).
The protocol is permissionless and immutable, which means anyone can build a frontend or integrate with the contracts.
Uniswap Labs, on the other hand, charges a frontend fee (0.25% on certain trades through their interface), which is separate from the protocol's LP fees. Users can avoid this by using alternative frontends or aggregators.
Key Risks to Understand
- Smart contract risk: While Uniswap's core contracts are among the most audited and battle-tested in DeFi, they still hold billions in value and represent a target. V4's hooks system introduces new complexity and potential attack surfaces from custom hook code.
- Impermanent loss: LPs can lose money relative to simply holding their tokens. That's how AMM functions; it's in its nature. Concentrated V3 positions amplify this risk.
- Token quality risk: Because anyone can create a Uniswap pool for any ERC-20 token, scam tokens and low-quality projects are common. Trading on Uniswap requires due diligence on the token contracts themselves.
- MEV and sandwich attacks: Uniswap trades on Ethereum mainnet are vulnerable to MEV extraction. Which means bots can front-run or sandwich trades to extract value. Using private mempools, aggregators with MEV protection, or L2 deployments can mitigate this.
- Regulatory risk: DEXs face increasing regulatory scrutiny. Uniswap Labs has already geo-blocked certain tokens on its frontend in response to regulatory pressure, though the underlying protocol remains permissionless.
The Bottom Line
Uniswap is a foundational DeFi infrastructure. It proved that automated market makers could work at scale, built concentrated liquidity with V3, and is evolving into a customisable DEX platform with V4's hooks.
Its liquidity supports much of the DeFi ecosystem, directly through trades on the protocol and indirectly through aggregator routing.
Understanding Uniswap is important for understanding how DeFi trading actually works. It helps to comprehend the constant product formula to concentrated liquidity, the governance debates about value distribution between traders, LPs, and token holders.
Whatever direction DeFi takes, Uniswap's innovations will be part of its foundation.
About Portals.fi: Portals.fi is the DeFi Super App. A one-click gateway to the entire on-chain economy.
Powered by real-time data and seamless execution, Portals.fi connects traders to over 20 million assets, thousands of protocols, and every major blockchain.
Disclaimer: The content of this blog is for informational purposes only. It is not investment advice. Please do your own research and consult with a qualified financial advisor before making any investment decisions.
DeFi investments carry significant risks, and past performance does not guarantee future results. More details here.
Portals.fi Blog Newsletter
Join the newsletter to receive the latest updates in your inbox.