We're planting a tree for every job application! Click here to learn more

What is Ethereum Uniswap Protocol?

Nemanja Grubor

18 Nov 2021

•

5 min read

What is Ethereum Uniswap Protocol?
  • Ethereum

Introduction

In this article, we will be talking about Uniswap protocol. This article is for people who would like to learn what Uniswap protocol is in blockchain, and also, what is new in version 3, which is the newest version.

Uniswap Protocol

uniswap.jpg

Uniswap protocol is a DeFi protocol that is used to exchange cryptocurrencies. The protocol facilitates automatic transactions between cryptocurrency tokens on the Ethereum blockchain.

Uniswap protocol versions:

  • v1, November 2018.
  • v2, May 2020.
  • v3, May 2021.

Third Version

The third version of the protocol, compared to previous versions, gives liquidity providers greater capital efficiency and control, improves the accuracy and convenience of the price oracle, and offers a more flexible fee structure.

Agents who pool liquidity and make it available to traders are known as automated liquidity providers. Constant function liquidity providers are a large class of automated liquidity providers that have seen considerable application in the context of DeFi, where they are often implemented as contracts that trade tokens on a blockchain.

Only a small percentage of the assets in the pool is available at a given price in the constant product liquidity provider formula utilized by the first and second versions. This is inefficient, especially when assets are anticipated to trade at a constant price.

Building pools that use diverse functions to express the relation between reserves has been a previous attempt to address this capital efficiency issue.

The third version of the protocol provides more control over the price ranges in which their capital is used. This version adds some new features:

  • Concentrated liquidity
  • Flexible fees
  • Protocol fee governance
  • Improved price oracle
  • Liquidity oracle

Contracts of the protocol's second version are not upgradeable. Those of the third version are also not upgradeable, with some parameters controlled by Uniswap governance.

What is Liquidity?

The efficiency or convenience where an asset can be bought or sold without influencing its market price is referred to as liquidity.

What is a Liquidity Provider?

A liquidity provider quotes both, a buy and a selling price in a tradable asset kept in an inventory, hoping of profiting from the bid-ask spread. A liquidity provider's job is to help limit the price variation by establishing a limited trading price range for assets that are being traded. Liquidity providers are also called market makers.

What is a Bid-Ask Spread?

The difference between quoted prices for an immediate sale (Ask) and an immediate purchase (Bid) is known as the Bid-Ask spread. The size of the bid-ask spread is one measure of liquidity as well as the transaction cost.

Types of spreads:

  • Quoted spread. This is the simplest type of bid-ask spread. The spread is derived from quoted prices. It gives the difference between the lowest selling price and the highest bid price. This spread is often expressed as a percentage of the midpoint, i.e. the average of the lowest ask and highest bid.
  • Effective spread. Due to price improvement, i.e. a dealer giving a better price than quotes (trading inside the spread), quoted spreads sometimes overstate the spreads paid by traders. Effective spreads use trade prices to account for this issue. Because trades must be matched with quotes and reporting delays must be taken into account, the effective spread is more difficult to calculate than the quoted spread.
  • Realized spread. Traders' costs are represented by quoted and effective spreads. These costs encompass both, an asymmetric information cost (a loss to traders that are more informed) as well as immediacy cost. The realized spread measures the immediacy cost.

Bid-Ask spread is also called Bid-Offer, Buy-Sell spread.

What is a Liquidity Pool?

In the crypto world, a liquidity pool is a pool of cryptocurrencies or tokens that are locked in a smart contract and used to make transactions between assets on a decentralized exchange.

Concentrated Liquidity

The third version of the protocol is based on the concept of concentrated liquidity, i.e. liquidity bounded within a price range. In previous versions, liquidity was distributed uniformly. This is simple to implement and provides for simple liquidity aggregation but applies that a large portion of assets in a pool is never used. After considering this, allowing liquidity providers to concentrate their liquidity into smaller price ranges became sensible. To keep their liquidity active, liquidity providers can concentrate their liquidity in a tight band around the current price, adding or removing tokens as the price changes.

Flexible Fees

Every pair of tokens corresponds to a single liquidity pool in the first and second versions of the protocol, which charges a fee of 0.3 percent on all exchanges (swaps). While this fee tier served many tokens well, it is likely to be too high for some pools and too low for others. The protocol's third version adds numerous pools for each pair of tokens, each with its own swap fee. A single factory contract creates all of the pools. Pools can be formed at three fee tiers under the factory contract: 0.03, 0.5, and 1 percent. Uniswap governance can permit additional fee tiers.

Protocol Fee Governance

In previous versions, fees were deposited in the pool as liquidity. This meant that the liquidity of pools would increase over time, and that fee earnings would compound. In the protocol's third version, this is not possible. Instead, fee earnings are kept separate and preserved as tokens that are used to pay the fees.

Each pool is set up with an immutable value that reflects a fee paid by swappers in hundredths of a basis point. It also keeps track of the current protocol fee, which is set to zero by default but may be modified by Uniswap governance. This number represents the percentage of swapper fees that go to the protocol rather than to liquidity providers. There is a limited set of permitted values in the current protocol fee.

The global state additionally keeps track of two numbers that indicate the total amount of fees earned per unit of virtual liquidity during the contract's lifespan. In the protocol's third version, fees are collected in tokens rather than in liquidity. The global state also keeps track of each token's total unpaid protocol fee. The Uniswap governance can collect accumulated protocol fees.

Improved Price Oracle

The protocol's third version, like the second, keeps track of a running collector of the price at the start of each block, multiplied by the number of seconds since the last block. In the second version, a pool stores only the most recent price collector's value. In the protocol's second version, the external caller is responsible for providing the prior value of the price collector for computing average prices. With many users, everyone will either have to develop their own method for checking prior collection values or coordinate on a shared method to reduce costs.

In the protocol's third version, the pool holds a list of prior values for both the price and liquidity collector. This is accomplished by checkpointing the collector value every time the pool is used for the first time in a block, looping through an array where the oldest checkpoint is replaced by a new one. Although an array only has enough space for one checkpoint, storage slots can be added to extend an array. As a result of this, a one-time gas fee is imposed.

Liqudity Oracle

Mining contracts with external liquidity can be used to fairly allocate rewards. The protocol's third version keeps a calculated checkpoint based on a value in order to reward concentrated liquidity only when it is in range.

Conclusion

In this article, we have learned about the Ethereum Uniswap protocol.

We have seen:

  • General information on Uniswap protocol.
  • What is liquidity.
  • What is a liquidity provider.
  • What is a Bid-Ask spread.
  • What is a liquidity pool.
  • What is new in the third version of the protocol.
    • Concentrated liquidity
    • Flexible fees
    • Protocol fee governance
    • Improved price oracle
    • Liquidity oracle
Did you like this article?

Nemanja Grubor

See other articles by Nemanja

Related jobs

See all

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Related articles

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

WorksHub

CareersCompaniesSitemapFunctional WorksBlockchain WorksJavaScript WorksAI WorksGolang WorksJava WorksPython WorksRemote Works
hello@works-hub.com

Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ

108 E 16th Street, New York, NY 10003

Subscribe to our newsletter

Join over 111,000 others and get access to exclusive content, job opportunities and more!

© 2024 WorksHub

Privacy PolicyDeveloped by WorksHub