Understanding Uniswap: A Guide

zildfinance

ZILD

Posted on November 23, 2020

Understanding Uniswap: A Guide

DeFi projects — projects and protocols for decentralized finance — became one of the most popular trends in the cryptocurrency industry, which changed the ICO era. The basis of the DeFi concept is a decentralized opportunity for exchange, investment and lending, freely in practice and absolutely democratic in structure, with full control of their funds, which are entrusted not to specific persons, but to smart contracts and algorithms.

Today we’ll talk about one of the most interesting projects in this area — Uniswap, a protocol for decentralized exchange of tokens.

Interestingly, the development of Uniswap was facilitated by Vitalik Buterin’s idea for a decentralized exchange (DEX), which would involve an automated market maker. Actually, the developer of the protocol, Hayden Adams, at first just wanted to practice developing on Solidity, and after a while this hobby brought him several grants and $100,000 from the Ethereum fund.

Now the project has gone far beyond just entertainment and has become one of the most important components of the entire DeFi industry. And this glory has a downside — during the last tests of the market for strength, alas, the algorithms of the majority of the participants gave up before the collapse of the market sentiment and skillful loners who used the vulnerabilities and borderline nuances of the functioning of complex financial systems to enrich themselves.

What is Uniswap?

Uniswap is an exchange-like protocol that allows users to securely exchange ERC20 tokens without having to use the traditional exchange-order model. Uniswap bundles tokens into special smart contracts, creating pools of liquidity within which other participants can trade. Anyone can exchange tokens, add tokens to the pool to receive a commission, or create a new trading pair.

This guide is intended to help beginners understand how Uniswap works and what goes on behind the scenes. Despite the fact that the interface may seem simple, a lot still remains behind the scenes.

ERC20 tokens

ERC20 tokens on Ethereum are the most popular and fungible tokens, which means there is no distinction between the same tokens of this standard. For example, if I have in my hand 100 metal balls of the same size and color, it doesn’t matter which one I give you. Likewise, if I have 100 of the same ERC20 tokens, it doesn’t matter which one I send you. In turn, NFT tokens of the ERC721 standard are non-fungible, you may have heard about them from the Cryptokitties collectible game.
ERC20 can be thought of as the simplest unit of account for a variety of use cases including currency, loyalty points, lending, interest bearing bonds, and more. They support almost unlimited division and can be sent in fractional parts. Since tokens of this type are very popular, it is important to develop an easy way to exchange between them.

Uniswap smart contracts overview

When browsing the Uniswap website, it is important to remember that it is much more than just an interface. With a suite of smart contracts, Uniswap standardizes the ERC20 token exchange mechanism. Anyone can create an interface that connects to these contracts and immediately exchange with anyone using Uniswap.

There are two different types of contracts that make up Uniswap. The first is known as an Exchange Contract. Exchange contracts contain a pool of a specific token and Ether that users can exchange with. The second type of contract is the Factory, which is responsible for creating new exchange contracts and linking the ERC20 token address to its personal exchange contract.

There is no charge for listing a new instrument on Uniswap. Anyone can call a function in the Factory contract to register a new token. The figure below shows an example of adding DAI to Uniswap. Someone first called the createExchange function in the Factory contract with the DAI contract address. Factory then checks the registry to see if an Exchange contract was previously created for this token. If not already, Factory creates an Exchange contract and writes its address to the registry.

Liquidity providers

When an Exchange contract is first created for a token, both pools (token and ether) are empty. The first person to make a deposit to the contract determines the ratio between token and ether. If they bring in a ratio different from the current market rate, then an arbitrage opportunity is presented. If liquidity is added to an already existing pool, it is necessary to add a proportional amount of both ETH and token.

If this is not done, the liquidity in the pool is exposed to arbitrage risk.

In addition, large pools of liquidity are beneficial to users as they allow for large trades without deviating the token-to-ETH ratio too far along the curve. Uniswap encourages users to add liquidity to pools by rewarding providers with the fees the protocol charges. A fee of 0.3% is charged for the exchange between ether and token, and about 0.6% when exchanging tokens for tokens.

Finally, special tokens known as liquidity tokens are generated at the provider’s address in proportion to how much liquidity has been poured into the pool. Liquidity tokens are burned when a user wants to receive the liquidity provided to them plus the fees that were accumulated while their funds were locked.

Check our website zild.finance.

💖 💪 🙅 🚩
zildfinance
ZILD

Posted on November 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Understanding Uniswap: A Guide
blockchain Understanding Uniswap: A Guide

November 23, 2020