DeFi 101 – Review Uniswap – How does it work?

You may have heard of Uniswap, which has been a controversial topic in the DeFi community. Hayden Adams originally developed the Uniswap protocol after being inspired by Vitalik Buterin’s post about the market maker equation X * Y = K. Hayden took a rational approach to the problem, developing Uniswap, a protocol for automated liquidity provisioning. Let’s find out more details about Uniswap to understand how it works and what are the risks of it!

What is Uniswap?

Uniswap is a completely different form of exchange that is completely decentralized – that is, it is not owned and run by a single company – and employs a very new trading methodology known as an automatic liquidity protocol.

The Uniswap platform was established in 2018 on the Ethereum blockchain, the world’s second-largest cryptocurrency project by market capitalization, making it interoperable with all ERC-20 tokens and infrastructure such as wallet services such as MetaMask and MyEtherWallet.

Uniswap is also totally open source, which means that anyone may copy the code and use it to build their own decentralized exchanges. It even allows users to list tokens for free on the market. Normal centralized exchanges are profit-driven and demand exorbitant fees to list new coins, thus this is a significant distinction. Because Uniswap is a decentralized exchange (DEX), users have complete control over their funds at all times, as opposed to a centralized exchange, which requires traders to hand over control of their private keys so that orders can be logged on an internal database rather than executed on a blockchain, which is more time consuming and expensive.

How Uniswap works?

Uniswap is powered by two smart contracts: “Exchange” and “Factory.” These are computer programs that are programmed to conduct specific tasks when certain criteria are satisfied. The factory smart contract is used in this case to add new tokens to the platform, while the exchange contract handles all token swaps, or “trades.” On the improved Uniswap v.2 platforms, any ERC20-based token can be swapped for another.

Automated liquidity protocol

An automated liquidity protocol is used by Uniswap to tackle the liquidity problem (mentioned in the introduction) of centralized exchanges. This operates by incentivizing exchange traders to become liquidity providers (LPs): Users on Uniswap pool their funds to form a fund that is used to perform all deals on the platform. Each token listed has its own pool to which users can contribute, and the values for each token are calculated using a mathematical algorithm operated by a computer

A buyer or seller does not have to wait for the opposing party to emerge in order to conclude a transaction with this approach. Instead, they can execute any deal quickly at a known price as long as there is enough liquidity in the pool to make it possible.

Each LP receives a token that symbolizes their staked commitment to the pool in exchange for putting up their funds. For example, if you contributed $10,000 to a liquidity pool with a total value of $100,000, you would receive a token representing 10% of that pool. This token can be exchanged for a portion of the trading costs. Uniswap charges consumers a fixed 0.3% fee for each trade executed on the platform, which is instantly transferred to a liquidity reserve.

When a liquidity provider decides to withdraw, they receive a percentage of the total fees from the reserve based on the amount they staked in that pool. The token they received, which keeps track of how much money they owe, is then destroyed.

Following the Uniswap v.2 upgrade, a new protocol fee was implemented, which can be switched on or off by a community vote and essentially transfers 0.05 percent of every 0.30% trading charge to a Uniswap fund to fund future development. This charge option is currently disabled; however, if it is enabled, LPs will begin receiving 0.25% of pool trading fees.

How Does Uniswap’s Automated Liquidity Provisioning Work?

The X and Y in the “X * Y = K” equation reflect the number of available ETH and ERC20 tokens, respectively. Whereas K is a constant that can be set by the designers of the Uniswap exchange contract. K may appear to be a random constant, but it is the most important. When you multiply X by Y, the result must always be equal to K.

The graph below illustrates the function K, which is a constant. Token B (ETH) is represented on the Y-axis, whereas token A (ERC20) is represented on the X-axis. The first red dot (old position) reflects the current price for swapping this ETH-ERC20 pair based on the current ETH token balance versus ERC20 tokens.

As a result, the balance of ETH tokens falls while the balance of ERC20 tokens rises. This means that the red dot will migrate to the new location as the liquidity pool contains more ERC20 tokens and fewer ETH tokens. To put it another way, it’s a very simple pricing algorithm in which the price rate advances along with a graph.

uniswap1-min

The Difference between Uniswap V1 and V2

With Uniswap V2, many new features have been added, such as price oracles, flash swaps, and a swapping router. This is the most critical aspect to grasp in order to gain a better understanding of how Uniswap routes tokens between liquidity pools.

Uniswap V1 Swaps

Uniswap V1 always executes two trades. An initial trade to convert your ERC20 token to ETH, followed by a second trade to convert your ETH back to your desired ERC20 token. In other words, the end-user is charged twice.

This posed a couple of limitations on the use of Uniswap:

  • Higher fees
  • Uniswap strongly tied to the use of ETH
  • Not possible to swap ERC20 tokens directly with other ERC20 tokens.

For the above reasons, Uniswap V2 has been created.

Uniswap V2 Swaps

Uniswap V2 gives end-users three alternatives for exchanging tokens via the “Router Contract.

The Router Contract is simply a contract that has routing logic to route your tokens to the appropriate swapping contract. In other words, the router contract is aware of every Uniswap V2 swapping contract.

Here are the three exchanging options:

  • A straight exchange of two ERC20 pairs. Two stablecoins, for example, DAI/USDC, might be highly handy for traders.
  • Traditional ETH swap, where you pay costs twice.
  • Custom path swaps allow you to create a more complex switching path to convert your DAI to USDC, such as DAI/ETH, ETH/BAT, BAT/USDT, and USDT/USDC. Traders are frequently presented with intriguing arbitrage chances as a result of this.

Uniswap Flash Swaps: Are They Safe?

Flash swaps, sometimes known as flash loans, were coined by Marble Protocol’s Max Wolff in 2018. He called his innovation a “smart contract bank” at the time because it allows for zero-risk loans.

However, we’ve recently observed a surge in flash loan assaults across a variety of protocols, including bZx, in which an attacker flees with thousands of tokens obtained for free via flash loans.

A flash loan attacker takes advantage of market inefficiencies and then repays the initial loan while keeping the surplus acquired from trading those market imbalances.

Some industry executives claim that this poses a severe risk to the DeFi area; however, others blame the incidence of flash loan assaults on the bZx protocol’s lack of security.

Conclusion

It is indisputable that automated liquidity provisioning has given the DeFi space a significant boost, resulting in many new and more sophisticated trading opportunities. However, only time will tell whether swaps were the right decision for the crypto industry. Here’s a quick rundown of the benefits and drawbacks of using Uniswap.

Pros

  • Decentralized
  • Any new token can gain direct liquidity by submitting their token for exchange to the Uniswap V2 routing contract.
  • Trades are less expensive as compared to a DEX or centralized exchange.
  • Contributing liquidity to liquidity pools can benefit liquidity providers.

Cons

  • Flash switch assaults are a possibility.
  • It continues to rely on arbitrage trading to correct market imbalances. However, arbitrage trading occurs in any natural market to quickly eliminate imbalances.
  • Forgery of token listings
  • Currently, rising gas costs due to the huge amount of trades make Uniswap trading a more expensive activity.

If you have any questions, comments, suggestions, or ideas about the project, please email ventures@coincu.com.

DISCLAIMER: The Information on this website is provided as general market commentary, and does not constitute investment advice. We encourage you to do your own research before investing.

KAZ

Coincu Ventures

DeFi 101 – Review Uniswap – How does it work?

You may have heard of Uniswap, which has been a controversial topic in the DeFi community. Hayden Adams originally developed the Uniswap protocol after being inspired by Vitalik Buterin’s post about the market maker equation X * Y = K. Hayden took a rational approach to the problem, developing Uniswap, a protocol for automated liquidity provisioning. Let’s find out more details about Uniswap to understand how it works and what are the risks of it!

What is Uniswap?

Uniswap is a completely different form of exchange that is completely decentralized – that is, it is not owned and run by a single company – and employs a very new trading methodology known as an automatic liquidity protocol.

The Uniswap platform was established in 2018 on the Ethereum blockchain, the world’s second-largest cryptocurrency project by market capitalization, making it interoperable with all ERC-20 tokens and infrastructure such as wallet services such as MetaMask and MyEtherWallet.

Uniswap is also totally open source, which means that anyone may copy the code and use it to build their own decentralized exchanges. It even allows users to list tokens for free on the market. Normal centralized exchanges are profit-driven and demand exorbitant fees to list new coins, thus this is a significant distinction. Because Uniswap is a decentralized exchange (DEX), users have complete control over their funds at all times, as opposed to a centralized exchange, which requires traders to hand over control of their private keys so that orders can be logged on an internal database rather than executed on a blockchain, which is more time consuming and expensive.

How Uniswap works?

Uniswap is powered by two smart contracts: “Exchange” and “Factory.” These are computer programs that are programmed to conduct specific tasks when certain criteria are satisfied. The factory smart contract is used in this case to add new tokens to the platform, while the exchange contract handles all token swaps, or “trades.” On the improved Uniswap v.2 platforms, any ERC20-based token can be swapped for another.

Automated liquidity protocol

An automated liquidity protocol is used by Uniswap to tackle the liquidity problem (mentioned in the introduction) of centralized exchanges. This operates by incentivizing exchange traders to become liquidity providers (LPs): Users on Uniswap pool their funds to form a fund that is used to perform all deals on the platform. Each token listed has its own pool to which users can contribute, and the values for each token are calculated using a mathematical algorithm operated by a computer

A buyer or seller does not have to wait for the opposing party to emerge in order to conclude a transaction with this approach. Instead, they can execute any deal quickly at a known price as long as there is enough liquidity in the pool to make it possible.

Each LP receives a token that symbolizes their staked commitment to the pool in exchange for putting up their funds. For example, if you contributed $10,000 to a liquidity pool with a total value of $100,000, you would receive a token representing 10% of that pool. This token can be exchanged for a portion of the trading costs. Uniswap charges consumers a fixed 0.3% fee for each trade executed on the platform, which is instantly transferred to a liquidity reserve.

When a liquidity provider decides to withdraw, they receive a percentage of the total fees from the reserve based on the amount they staked in that pool. The token they received, which keeps track of how much money they owe, is then destroyed.

Following the Uniswap v.2 upgrade, a new protocol fee was implemented, which can be switched on or off by a community vote and essentially transfers 0.05 percent of every 0.30% trading charge to a Uniswap fund to fund future development. This charge option is currently disabled; however, if it is enabled, LPs will begin receiving 0.25% of pool trading fees.

How Does Uniswap’s Automated Liquidity Provisioning Work?

The X and Y in the “X * Y = K” equation reflect the number of available ETH and ERC20 tokens, respectively. Whereas K is a constant that can be set by the designers of the Uniswap exchange contract. K may appear to be a random constant, but it is the most important. When you multiply X by Y, the result must always be equal to K.

The graph below illustrates the function K, which is a constant. Token B (ETH) is represented on the Y-axis, whereas token A (ERC20) is represented on the X-axis. The first red dot (old position) reflects the current price for swapping this ETH-ERC20 pair based on the current ETH token balance versus ERC20 tokens.

As a result, the balance of ETH tokens falls while the balance of ERC20 tokens rises. This means that the red dot will migrate to the new location as the liquidity pool contains more ERC20 tokens and fewer ETH tokens. To put it another way, it’s a very simple pricing algorithm in which the price rate advances along with a graph.

uniswap1-min

The Difference between Uniswap V1 and V2

With Uniswap V2, many new features have been added, such as price oracles, flash swaps, and a swapping router. This is the most critical aspect to grasp in order to gain a better understanding of how Uniswap routes tokens between liquidity pools.

Uniswap V1 Swaps

Uniswap V1 always executes two trades. An initial trade to convert your ERC20 token to ETH, followed by a second trade to convert your ETH back to your desired ERC20 token. In other words, the end-user is charged twice.

This posed a couple of limitations on the use of Uniswap:

  • Higher fees
  • Uniswap strongly tied to the use of ETH
  • Not possible to swap ERC20 tokens directly with other ERC20 tokens.

For the above reasons, Uniswap V2 has been created.

Uniswap V2 Swaps

Uniswap V2 gives end-users three alternatives for exchanging tokens via the “Router Contract.

The Router Contract is simply a contract that has routing logic to route your tokens to the appropriate swapping contract. In other words, the router contract is aware of every Uniswap V2 swapping contract.

Here are the three exchanging options:

  • A straight exchange of two ERC20 pairs. Two stablecoins, for example, DAI/USDC, might be highly handy for traders.
  • Traditional ETH swap, where you pay costs twice.
  • Custom path swaps allow you to create a more complex switching path to convert your DAI to USDC, such as DAI/ETH, ETH/BAT, BAT/USDT, and USDT/USDC. Traders are frequently presented with intriguing arbitrage chances as a result of this.

Uniswap Flash Swaps: Are They Safe?

Flash swaps, sometimes known as flash loans, were coined by Marble Protocol’s Max Wolff in 2018. He called his innovation a “smart contract bank” at the time because it allows for zero-risk loans.

However, we’ve recently observed a surge in flash loan assaults across a variety of protocols, including bZx, in which an attacker flees with thousands of tokens obtained for free via flash loans.

A flash loan attacker takes advantage of market inefficiencies and then repays the initial loan while keeping the surplus acquired from trading those market imbalances.

Some industry executives claim that this poses a severe risk to the DeFi area; however, others blame the incidence of flash loan assaults on the bZx protocol’s lack of security.

Conclusion

It is indisputable that automated liquidity provisioning has given the DeFi space a significant boost, resulting in many new and more sophisticated trading opportunities. However, only time will tell whether swaps were the right decision for the crypto industry. Here’s a quick rundown of the benefits and drawbacks of using Uniswap.

Pros

  • Decentralized
  • Any new token can gain direct liquidity by submitting their token for exchange to the Uniswap V2 routing contract.
  • Trades are less expensive as compared to a DEX or centralized exchange.
  • Contributing liquidity to liquidity pools can benefit liquidity providers.

Cons

  • Flash switch assaults are a possibility.
  • It continues to rely on arbitrage trading to correct market imbalances. However, arbitrage trading occurs in any natural market to quickly eliminate imbalances.
  • Forgery of token listings
  • Currently, rising gas costs due to the huge amount of trades make Uniswap trading a more expensive activity.

If you have any questions, comments, suggestions, or ideas about the project, please email ventures@coincu.com.

DISCLAIMER: The Information on this website is provided as general market commentary, and does not constitute investment advice. We encourage you to do your own research before investing.

KAZ

Coincu Ventures

Visited 1 times, 1 visit(s) today