Nemanja Grubor
18 Nov 2021
•
5 min read
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 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:
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:
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.
The efficiency or convenience where an asset can be bought or sold without influencing its market price is referred to as liquidity.
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.
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:
Bid-Ask spread is also called Bid-Offer, Buy-Sell spread.
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.
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.
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.
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.
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.
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.
In this article, we have learned about the Ethereum Uniswap protocol.
We have seen:
Nemanja Grubor
See other articles by Nemanja
Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ
108 E 16th Street, New York, NY 10003
Join over 111,000 others and get access to exclusive content, job opportunities and more!