Uniswap: what is this decentralized exchange and how does it work
It is a decentralized exchange that allows the exchange of cryptocurrencies and tokens that are within the Ethereum blockchain development. Although it is identified as a DEX, it is really an automated liquidity protocol. Uniswap eliminates the need for a centralized order book or actor to make trades. The platform allows users to trade in a decentralized and censorship-resistant manner.
Uniswap is an open-source decentralized exchange. This means that anyone can read the code of smart contracts and audit it. This allows making proposals for improvements or using them as a basis for other projects.
Uniswap is based on a model in which there are liquidity providers that generate liquidity reserves. There is a decentralized pricing mechanism, without the need for an order book. Note that only ERC-20 tokens can be exchanged, it does not support the exchange with Bitcoin, Litecoin, or Dogecoin.
As it is based on a decentralized system, there is no listing process. This means that any ERC-20 token can be made available on Uniswap, as long as there is a liquidity reserve. Additionally, Uniswap does not charge commissions for the listing of new tokens. It is quite close to what a P2P exchange would be but without the need to contact and get to know the other user.
Who created Uniswap
Decentralized exchanges, or at least their basic idea, was posted by Vitalik Buterin on the Ethereum Research forum . Specifically, this idea is called “Improving front running resistance of x*y=k market makers”. There he exposes how Ethereum and smart contracts could be used to develop financial systems for market makers.
There are many comments in this thread, highlighting the one by Hayden Adams. Note that Hayden Adams was a fairly young developer in the Ethereum community. He indicates to Buterin that he would be working on the development of a market maker like the one indicated by Buterin.
The solution that Adams was developing would eventually lead to the first version of Uniswap development, which would be deployed for the first time in October 2018 . For those who are interested, the first development version of Uniswap is available on GitHub.
Uniswap has gone through several renewal and transformation processes. In May 2020 Uniswap V2 was released and in May 2021 Uniswap V3 was released. It is clear that Hayden Adams still believes in the project and has a very good team of developers and a strong community behind it.
How Uniswap works
It is not a simple decentralized exchange platform, it is a more advanced version. Development of Uniswap operates as an Automated Market Maker (AMM) system. Quite simply, the platform allows users to create marketplaces that can benefit third parties.
These markets are self-sustaining, allowing the protocol to generate revenue that can be used to incentivize the injection of liquidity in exchange for a small interest to investors. These markets are called pools, which are where investors add tokens to offer their liquidity. The use of these tokens by third parties generates commissions that are used to maintain Uniswap and to reward investors. The generation of these pools also allow the rapid exchange of assets.
Uniswap development is an exchange platform that works through smart contracts. On the basis of a decentralized exchange, a reward system has been built. Additionally, a decentralized governance system and other important complementary functions for decentralized finance (DeFi) have been generated.
Pool liquidity control
It is the base mechanism on which the Uniswap decentralized exchange is created. The creation and management of liquidity pools are the basis for it to be able to provide all the services for which it has been created. At the same time, these liquidity pools serve as an attraction for investors, which allows passive profits to be made.
The reward for investors is generated by the use of the tokens by other users, either by making trades or other operations that generate commissions within Uniswap. These commissions are divided between the users who inject liquidity and the developers , for the maintenance of the development. Therefore, the greater the use of the platform, the greater the earnings of the users and the capital for the maintenance of the platform.
All this construction is based on the economic control mechanism called Constant Product Market Maker (CPMM). This mechanism is based on the formula: x * y = K
The parts of this formula are:
X: are the total coins of a token A
Y: are the total coins of a token B
K: Constant resulting from the multiplication of said tokens
Through this formula, what is called the market curve is created, which is the basis of the first two versions of Uniswap. Uniswap V3 leaves this model aside and changes it to a more dynamic model, which allows a better adjustment with the reality of the market. Above all, it focuses on the aspects of high liquidity and volatility.
For Uniswap V3 pools, the concentration of funds within custom price ranges is sought. This offers greater liquidity for desired prices. It allows pools to create their own price curves, adapted to their reality.
This allows Uniswap Ve to have the ability to offer new features to make the use of capital more efficient. At the same time, it allows to generate a higher volume of profits and reduce the impermanent losses (impermanent loss) that are seen in AMM models based on the formula described above.
Oracles and commissions
For the correct functioning of the platform, a mechanism is needed that provides information on the price of the tokens. Uniswap has the function of oracles that perform a weighting of the average price over time (TWAP, for its acronym in English).
Oracles have the ability to offer information on Uniswap tokens in real time. This allows the system to be fed, allowing the price of the protocol to be recognized and modified. This element is fundamental, since the system of commissions and rewards depends on the oracles.
For Uniswap V3, the oracles have been kept, but have been greatly refined and made highly configurable. They have been made more efficient in order to reduce the cost of Gas. Additionally, a mechanism has been included that allows flexible commissions. It is passed to a system of three types of commissions per pair, being 0.05%, 0.3% and 1%. This allows to better match the volatility of the pairs with the operating costs.
Creation of pools and markets
The most important element in Uniswap is the pools and the creation of them as exchange points. The pools of this DEX can only be made up of ERC-20 tokens from the Ethereum blockchain. These exchanges also add a commission for the exchange, which a part goes to the one that provides liquidity and another for the maintenance of the platform.
It is precisely at this point where the oracles come into operation, allowing the exchange with the correct price of both assets. Additionally, pool creators can generate so-called "price ranges", a new functionality within Uniswap V3.
Price ranges allow you to specify a percentage or customizable price, adjusted taking into account the price offered by the oracles. A useful tool for investors, who can obtain higher returns. Note that the abuse of this mechanism can lead to bankruptcy of the pool. This could happen if there are other liquidity pools with lower prices for the tokens.
Uniswap adjusts for this by offering investors good returns from the start. Above all, it focuses on offering a high usability of the pools. This boils down to:
If the token “A is very bought, there is a decrease in supply and therefore the price of the token increases
If token “B” is oversold, there is a noticeable increase in supply and thus the price drops
What is “Impermanent Lost” on Uniswap
Liquidity providers earn commissions for providing tokens, or what is the same, for providing liquidity. They will earn commission as long as traders make use of the tokens they have leveraged. But interestingly, there is the possibility of an effect called "impermanent lost". We are going to put an example.
Note: always remember the formula “x * y = K”
We are going to add liquidity to the pool, deciding to add 10 UNI and 100 USDT. We assume that each 1 UNI equals 10 USDT. There are other users who do the same, leaving a reserve of 100 UNI and 10,000 USDT. Our participation in the pool represents 10% and the total liquidity of the pool (k) will be 100,000.
Let's say that the price of 1 UNI rises to 40 USDT. The liquidity of the reserve always remains constant, remember that. If now each UNI is worth 40 USDT, we have that the average amount of UNI and USDT have changed. Now in the reserve we have 50 UNI and 20,000 USDT (note that "k" is still 100,000)
The reason for this change is because arbitrage traders have added USDT to the pool and withdrawn UNI tokens. What they have done is balance the average of the reserve so that the total liquidity does not suffer variations.
Our initial investment was equivalent to 200 USD spread over 10 UNI and 100 USDT. If we now withdraw our liquidity, we will receive 10% of the pool, which is what we have contributed. What we will obtain will be 5 UNI and 200 USDT, which is equivalent to 400 USD, double what was contributed. We have made a handsome profit by simply leaving our funds there.
Really, if we had made a HODL with our 10 UNI and the 100 USDT, by quadrupling the price of the 10 UNI, we would have 500 USD in exchange. As we can see, we really do not have a profit of 200 USD, but a loss of 100 USD. Precisely this difference between what we could have earned by HODL and what we have earned by providing liquidity is the “impremanent loss”. Quite simply, what happens is that when we deposit the funds in Uniswap we lose other opportunities to increase our wealth.
We must bear in mind that the opposite effect can also occur. If the price of the UNI token falls below the moment we make the deposit, the losses could be increased.
There is another factor to take into account and that is that by having the 10 UNI and the 100 USDT in the pool, we obtain benefits. If we make a long-term reservation, the «impermanent lost» will most likely be mitigated. The usual thing is that when we really withdraw the funds we get even more than doing HODL, which is the "funny" of this.
What is Uniswap Token
Initially this decentralized exchange lacked its own token , but with the appearance of platforms like Sushiswap and its own token, they decided to develop their own token. The Uni token was launched on September 16, 2020, which is based on three fundamental aspects.
Adds a new reward element for participation in platform pools and services
It serves as a reward for those who supported the project from the first moment
Implement an even more decentralized governance system
What has been called the genesis issue of 1 billion UNI tokens was developed. These tokens will be accessible for the next 4 years and are distributed as follows:
600,000,000 UNI allocated to members of the Uniswap community (60%)
212,660,000 UNI for Uniswap developers and future workers during the 4-year vesting period (21.266%)
180,440,000 UNI for investors to acquire rights over a period of 4 years (18,044%)
6,990,000 UNI for project advisors (0.69%)
After the 4-year period, the UNI token follows an issuance pattern with perpetual inflation at 2% per year. It seeks to compensate those who are added to the ecosystem as it grows.
This token also allows the creation of a kind of treasure reserve to continue the development of the DEX. For this, 43% of the community tokens will be retained. The funds will be used to give grants to all those who contribute to the development, support community initiatives, incentivize liquidity mining and other projects that promote the development of Uniswap. This 43% will be distributed over a period of four years as follows:
First year: Distribution of 172 million UNI tokens (40% of the total)
Second year: Distribution of 129 million UNI tokens (30% of the total)
Third year: Distribution of 86 million UNI tokens (20% of the total)
Fourth year: : Distribution of 43 million UNI tokens (10% of the total)
What is Uniswap V2
The Uniswap decentralized exchange was launched in November 2018, but the biggest update did not come until May 2020 with Uniswap V2 . It was in this update that direct exchanges of ERC-20 tokens to ERC-20 tokens were implemented. Thus, the need for a WETH token was eliminated, whenever possible. Additionally, incompatible ERC-20 tokens such as OmniseGo (OMG) and Tether (USDT) were added. Naturally, a series of technical improvements were implemented to facilitate usability.
Gradually liquidity mining and yield farming were gaining popularity. Uniswap in 2020 managed to gain a lot of interest thanks to DeFi platforms , which allowed providers to obtain liquidity. Additionally, these liquidity providers made a profit on their tokens.
Note that liquidity providers earn 0.3% of trading fees. This made Uniswap a very popular token launch platform for DeFi projects. This is how Uniswap has become one of the main platforms for DeFi thanks to the total value locked (TVL). This is just a way of measuring the value of all the assets that are locked on the platform.
What is Uniswap V3
Due to the great success with Uniswap V2 and the emergence of new markets, the platform has been updated again. Uniswap V3 is an improved version with new features compared to the previous version of the platform. These improvements are as follows:
Increased capital efficiency
The AMM is often characterized by being highly inefficient in terms of capital . For the most part, a large part of the funds stored at a given moment do not have movements, they are not used. This is properly due to the formula explained above “x * y = k”. In short, the greater the liquidity in the reserve phase, the greater the number of orders that the system will be able to support.
In contrast, liquidity providers (LPs) of reserves, provide liquidity at a price curve that goes from zero to infinity. All assets are reserved, in the event that they must be used. In addition, the reserved capital remains there in case it were the case that some of the reserved assets were multiplied by 5, 10 or 100.
In the event that something like this were to happen, the idle assets guarantee an existence of liquidity in that area of the price curve. Which means that only a small part of the reserve liquidity is in the area where there is more activity.
The possibility is now added for liquidity providers to generate custom price ranges to which they want to provide liquidity. This allows liquidity to be concentrated in the area where the greatest activity is taking place.
Uniswap V3 establishes a rudimentary order book creation mechanism on the Ethereum network. Market makers can now decide to provide liquidity at the price ranges they consider. This change favors professional market makers to the detriment of retail and less knowledgeable participants. The strength of the MMA is that anyone can contribute liquidity and that their funds generate profits.
The integration of this more complex mechanism results in less knowledgeable LPs earning lower asset trading commissions in favor of professionals who optimize their strategy on a regular basis.
LP positions now have NFT configuration
We happen to say that each LP position within Uniswap will be unique, since each participant can establish the price range they want. We therefore have an LP space in this DEX that will no longer be fungible. As a direct consequence, each LP will have a representation in NFT format.
These Uniswap LP as a fungible token represent the possibility of being used by the DeFi ecosystem. Uniswap V2 LPs could be used as escrow in Aave and MakerDAO, for example. Within Uniswap V3 this is no longer possible, because each position is unique. Although this loss of malleability may seem negative, it could lead to new types of by-products.
Layer 2 for Uniswap
We have seen on several occasions how the cost of the commission of a transaction in the Ethereum network has skyrocketed. This has made Uniswap and any DEX totally economically unviable for small investors.
Uniswap V3's solution has been to create a “Layer 2” scalability solution that has been called “Optimistic rollup” . It allows the scalability of smart contracts without giving up the security of Ethereum. This should offer a significant increase in transaction processing capacity, as well as having really low fees for users.
Final Words on Uniswap
Uniswap V3 is what is known as a third generation decentralized exchange, by adding the liquidity pools and other elements. What they seek for this type of DEX is to offer liquidity through automated smart contracts , in which users "give" their tokens so that the exchange can operate. Thus, traders can easily exchange tokens without a centralized authority requiring them to pass a series of identity checks. Come on, everything is done in a decentralized way and with a great degree of privacy.
The easiest way to use Uniswap is to connect the Metamask wallet, something very simple, and start trading as you like. We can bet on adding liquidity to the exchange and earning a liability or simply trading. It is not even necessary to access Uniswap to trade, we can do it directly from Metamask, since this wallet for exchanges accesses the prices of tokens from different exchanges, including Uniswap.
It is true that decentralized exchanges, whether they are Uniswap or alternatives such as 0x, Sushiswap or Pancakeswap, have drawbacks. The most important is that there is no possibility to buy Bitcoin, Dogecoin or Litecoin, only the native cryptocurrency of the blockchain on which they are deployed. Uniswap only allows you to exchange ERC-20 tokens for ether, ether for ERC-20 tokens, and ERC-20 tokens for ERC-20 tokens. However, there are some ERC-20 tokens that are priced parity with other cryptocurrencies, such as wBTC, which is priced parity with Bitcoin.
#erc20 token development, #ethereum token development #erc20 token creator