Skip links

Uniswap V3 Explained

Uniswap exchange is an Ethereum protocol for swapping ERC20 tokens. Uniswap, unlike other exchanges, is intended to act as a public utility – a tool for the community to trade tokens without platform fees or intermediaries. Uniswap also employs a basic math equation and pools of tokens and ETH to conduct the same work as most exchanges, which pair buyers and sellers to calculate prices and execute trades. Let’s have a look at what new developments Uniswap V3 brings

History of Uniswap

Uniswap is currently a vital infrastructure for decentralized finance, allowing developers, traders, and liquidity providers to engage in a safe and robust financial system. In November 2018, Uniswap v1 was introduced as a proof of concept for automated market makers (AMMs), a sort of exchange in which anybody may pool assets into shared market-making strategies.

Uniswap v2 brought new features and improvements in May 2020, paving the way for exponential growth in AMM use. In less than a year since its establishment, v2 has handled over $135 billion in trade volume, making it one of the world’s biggest cryptocurrency spot exchanges.

On May 5, 2021, Uniswap v3 was launched on the Ethereum mainnet. Uniswap v3 included:

  • Concentrated liquidity gives independent LPs granular control over their capital’s price ranges apportioned. Individual positions are accumulated together into a single pool, forming one combined curve for users to trade against.
  • Several fee tiers enable LPs to be fairly paid for taking on varied degrees of risk.


Uniswap v1 vs v2 – Brief Introduction and Comparison

While Uniswap v1 was not the first DEX, it was the first to capture the attention of crypto enthusiasts. Before Uniswap, EtherDelta was the only DEX that had gained traction. Yet, it was built on the Order Book architecture, which isn’t seen to be the greatest answer for a decentralized exchange since it presents issues like fees, poor user experience, and a lack of liquidity.

Uniswap, unlike EtherDelta, is built on the Automated Market Maker (AMM) model. To price assets, this methodology employs a mathematical formula. AMMs depend on Liquidity Providers (LPs) that invest trade pairs in Uniswap Liquidity Pools rather than making orders.

Since Uniswap v1 only enabled ETH-ERC20 trading pairings, you could only exchange ETH for a single ERC20 token. Hence, if you wanted to exchange USDC for DAI, you had to first exchange USDC for ETH before going to the ETH-DAI pool to receive DAI.


Then came Uniswap v2, which was a much improved and more user-friendly version of Uniswap v1. The biggest issue with v1 that was solved in this new version was the lack of ERC20-ERC20 coin pools. This resulted in much greater prices and slippage for users who wished to exchange one ERC20 token for another.

To address the issue of “ETH bridging,” Uniswap v2 added ERC20-ERC20 Uniswap liquidity pools. In the core contracts, they even utilized Wrapped ETH instead of native ETH. End users might, however, continue to utilize ETH through helper contracts.


What’s Different?

Uniswap v3 differs significantly from Uniswap v2. Uniswap v3 pools, like Uniswap v2, feature two tokens and employ a constant product formula, but Uniswap v3 includes a new idea known as focused liquidity. The basic concept behind this feature is that liquidity providers may supply liquidity in a specified price range, implying that each position’s reserves are only sufficient to sustain trading inside their range. When the price falls outside of that range, the liquidity provider’s stake is completely switched into one of the two tokens, depending on whether the price is above or below the range.

Liquidity providers may now offer liquidity with up to 4000x capital efficiency compared to Uniswap v2, generating larger returns on their capital. They may also considerably raise their risk exposure to their preferred assets while decreasing downside risk.

V3 also enables LPs to trade assets by providing liquidity to a price range that is fully above or below the market price, allowing them to establish a fee-earning restriction while executing along a smooth curve. Moreover, enhanced capital efficiency enables better low-slippage transaction execution when compared to centralized exchanges and stablecoin-focused automated market makers.

The gas cost of v3 swaps on Ethereum mainnet is marginally lower than V2,” while those done on the Optism deployment should likely be much cheaper.

Major focus areas in v3 have been:

  • Concentrated Liquidity
  • Capital Efficiency
  • Active Liquidity
  • Range Orders
  • Non-Fungible Liquidity
  • Flexible Fees
  • Advanced Oracles
  • Audits and Bug Bounty


Collecting Fees on Uniswap V3

In the Uniswap V3 protocol, collecting fees from a liquidity position is based on the collecting fees code example, which may be found in the Uniswap code examples repository.

Non-fungible tokens are used to represent liquidity positions in the Uniswap V3 system. To create a liquidity position for the USDC – DAI pair, the NonfungiblePositionManager class is utilized. Next, collect any fees incurred by the position from individuals trading against the supplied liquidity. The inputs are the two tokens that will be pooled, the amount of each token that will be pooled, the Pool fee, and the maximum amount of accrued fees we wish to receive for each token.


Swapping and Adding Liquidity

You must offer two assets in a certain ratio when providing liquidity to a Uniswap v3 pool. In many circumstances, the ratio of the two assets in your contract or the user’s wallet is different. To deposit 100% of your assets, you must first swap them to the appropriate ratio before adding liquidity.

The swap may modify the pool’s balance and hence the appropriate ratio. To circumvent this, you can employ a router to do this swap-and-add liquidity action in an atomic method. The two tokens we are pooling for, the amount of each token we are pooling for, the quantity of each token to swap and add, and the Pool fee are the inputs here.


Final Word

Even if user assets are spread uniformly around the price curve in the Uniswap V2 scenario, there is very little chance that the cost will surpass the price range. As a result, only a very tiny part of the entirety of the funds is working for traders to make fees.

Uniswap V3 users, on the other hand, transfer all of their assets in the specified price bracket. Under this method, the total value of the assets placed by users (rather than just a fraction of them) generates income for them. LPs may choose the price range to which they wish to allocate their assets using V3 and get paid when the price falls within that range. This is made feasible by the focused liquidity feature provided by V3.

To know more, you can check the smart contracts for Uniswap V3 here:

Leave a comment

This website uses cookies to improve your web experience.