dex – Finematics https://finematics.com decentralized finance education Mon, 21 Sep 2020 11:51:21 +0000 en-GB hourly 1 https://wordpress.org/?v=5.8.1 https://finematics.com/wp-content/uploads/2017/09/cropped-favicon-32x32.png dex – Finematics https://finematics.com 32 32 A Short Story of Uniswap and UNI Token. DeFi Explained https://finematics.com/uniswap-uni-token-explained/?utm_source=rss&utm_medium=rss&utm_campaign=uniswap-uni-token-explained&utm_source=rss&utm_medium=rss&utm_campaign=uniswap-uni-token-explained https://finematics.com/uniswap-uni-token-explained/#respond Mon, 21 Sep 2020 11:50:22 +0000 https://finematics.com/?p=958

So what’s the story behind Uniswap – one of the most important protocols in DeFi? And why was the UNI token probably one of the best-distributed tokens ever? You’ll find answers to these questions in this article.

Uniswap

Uniswap is clearly one of the most important and the most discussed projects in the defi space. At its core, Uniswap is a protocol for decentralized exchange of tokens on the Ethereum blockchain. The Uniswap protocol is deployed as a set of smart contracts and it’s completely decentralized, permissionless and censorship-resistant. 

Uniswap is built on the concept of liquidity pools and automated market makers or, to be precise, a constant product market maker. If you’d like to learn more about the mechanics of the protocol, check out my article on liquidity pools which uses Uniswap as an example. You can read it here

Back to the main story.

Uniswap V1

The initial version of Uniswap was published to the Ethereum mainnet on 2nd Nov 2018. This was the culmination of over a year’s worth of work by its creator Hayden Adams. 

What is super interesting, is the fact that Hayden, who used to work as a mechanical engineer, started Uniswap without any prior programming knowledge. He learnt how to write smart contracts while working on the initial version of the Uniswap protocol. 

The initial idea for implementing an automated market maker came from Hayden’s friend, Karl, who was impressed by one of Vitalik Buterin’s blog posts describing a theory behind a constant product market maker. 

At the time of building the first version of the Uniswap protocol, EtherDelta was pretty much the only decentralized exchange with some traction.  EtherDelta, although quite popular at that time, was based on the order book model that doesn’t fit very well into the Layer 1 blockchain protocol like Ethereum. Besides that, EtherDelta had a really unintuitive UX that resulted in very poor user experience and lack of liquidity. 

While working on optimising smart contracts and preparing for a potential mainnet launch, Hayden applied for an Ethereum Foundation grant that was later accepted in July 2018. The money from the grant allowed for auditing Uniswap’s smart contracts by a company called Runtime Verification. The initial audit by Runtime Verification resulted in adding extra safety checks and re-working some of the math operations to minimise the rounding error. 

On top of that, a full formal verification was also underway. Before fully launching the protocol, Hayden decided to rebuild the user interface for even better user experience.

The first version of the protocol was launched on the last day of the Devcon 4 conference with $30,000 worth of the initial liquidity across 3 different tokens. 

The protocol quickly gained a lot of traction which resulted in an initial seed investment that allowed Uniswap’s team to work on the second version of the protocol.

Uniswap V2

In May 2020, Uniswap launched a second version of the protocol called Uniswap V2.

The main feature was the addition of the ERC20/ERC20 liquidity pools. Before V2, each liquidity pool had to consist of ETH as one of the currencies, so, for example, to trade from USDC to DAI, the user would have to trade their USDC for ETH and ETH for DAI which usually resulted in higher gas fees and more slippage. 

Offering ERC20/ERC20 pools was also better for liquidity providers who didn’t want to supply ETH and expose themselves to impermanent loss. V2 had also a few other features including on-chain price feeds and flash swaps. 

An interesting fact is that all of the V2 smart contracts were written in Solidity. This can be compared to V1 which was entirely written in Vyper. Uniswap V1 was actually one of the first projects entirely written in Vyper. 

Due to its decentralized and permissionless nature, the first version of the protocol was still actively used alongside V2 for some time, regardless of the Uniswap team encouraging liquidity providers to migrate their liquidity to V2. This also shows the true power of unstoppable code. 

In August 2020 the Uniswap team raised $11M in series A from a few notable VCs including Andreessen Horowitz, USV, Paradigm and Version One. The funds were used to grow the team and build Uniswap V3 which will dramatically increase the flexibility and capital efficiency of the protocol.

SushiSwap Competition

In May 2020, with an increased interest in DeFi, the trading volume on Uniswap started picking up. It was not unusual anymore to see over $1M in daily volume and around $10-20M in provided liquidity. 

In August, with all the yield farming craze going on, we were looking at around $150M in daily volume and around $300M in provided liquidity – a truly exponential growth. The Uniswap volume started getting closer and closer to the volume of top centralized exchanges, overtaking some of the most popular ones such as Kraken. 

SushiSwap also came into play at the end of August. SushiSwap was aiming at directly competing with Uniswap by forking the project, adding a reward for Uniswap’s liquidity providers and eventually stealing Uniswap’s liquidity into the SushiSwap platform. You can learn more about this process, also called a vampire attack, in my other article here

The SushiSwap yield farming resulted in Uniswap’s liquidity going from around $300M to almost $2B in a matter of days. On top of that, the daily trading volume was ranging between $500M and $1B, at some point overtaking Coinbase’s daily volume. This was an incredible achievement, especially considering that Uniswap had only around 10 employees compared to over 1000 employees at Coinbase. 

Before the liquidity migration from Uniswap to SushiSwap started, there was still around $800M worth of Uniswap’s liquidity staked on the SushiSwap platform. This was also the time when Hayden hinted at a potential Uniswap token. 

Although the SushiSwap migration resulted in Uniswap’s total liquidity dropping from almost $2B to as low as $0.5B, the remaining liquidity was still higher than a couple of weeks earlier before the SushiSwap project even started. The trading volume also remained strong at around $300-500M per day.

UNI Token

On 16th September, Uniswap announced a launch of their new token – UNI. The most surprising part of the launch was how some of the tokens were retrospectively allocated. Everyone who had used Uniswap, even once before 1st September, was eligible to claim their 400 UNI tokens that were worth around $1200 on the day of the announcement. 

A couple of days later, the UNI tokens were actively traded across both centralized and decentralized exchanges with the token price going as high as $8 making the initial 400 UNI reward worth around $3200. The UNI tokens were distributed to around 50,000 Ethereum addresses making them one of the most widely distributed tokens in the space. 

On top of that, the liquidity providers of the protocol were also retrospectively rewarded with extra UNI tokens.  

A total of 1 billion UNI tokens was allocated in the following way. 

After 4 years, there will be a perpetual inflation rate of 2% per year to ensure continued participation and contribution to Uniswap at the expense of passive UNI holders. 

On top of that, Uniswap announced 4 incentivised liquidity pools that will be rewarding liquidity providers with extra UNI tokens. This resulted in attracting millions of dollars of new liquidity. At the time of writing this article, there is over $2B worth of liquidity locked in the protocol. UNI holders can also vote to add more incentivised pools after an initial 30-day governance grace period is over. 

By launching a token, the Uniswap team wanted to further decentralize the protocol making it a publicly-owned and self-sustainable financial infrastructure while still continuing to protect its indestructible and autonomous qualities and working on Uniswap V3. 

The token holders will be able to participate in Uniswap’s governance by voting on different proposals or delegating their votes to a third party. 

And, as with pretty much all of the governance tokens, there is a lot of speculation on the potential future revenue share from the protocol with the UNI holders. 

So what do you think about Uniswap’s UNI token and the way that it was distributed?

If you enjoyed reading this article you can also check out Finematics on Youtube and Twitter.

]]>
https://finematics.com/uniswap-uni-token-explained/feed/ 0
What is Bancor V2? Chainlink Integration and Dynamic Automated Market Maker Explained. https://finematics.com/bancor-v2-explained/?utm_source=rss&utm_medium=rss&utm_campaign=bancor-v2-explained&utm_source=rss&utm_medium=rss&utm_campaign=bancor-v2-explained https://finematics.com/bancor-v2-explained/#respond Mon, 10 Aug 2020 13:45:31 +0000 https://finematics.com/?p=797

Intro

What is the latest update to the Bancor protocol called Bancor V2? Will Bancor V2 outcompete other decentralized exchanges such as Uniswap, Curve and Balancer? Also, why are Bancor V2 pools integrated with Chainlink? We’ll be going through all of this in this article.

Bancor

Let’s start with a quick recap of what Bancor actually is.

Bancor is an on-chain liquidity protocol that enables automated, decentralized token exchange on Ethereum and across blockchains. Launched in 2017 with one of the biggest ICOs in the space, the protocol is made up of a series of smart contracts designed to pool liquidity and perform peer-to-contract trades in a single transaction with no counter-party. Users add liquidity to automated market makers (AMMs) in exchange for trading fees, staking rewards and future voting rights in the BancorDAO. If you need a quick recap on liquidity pools and automated market-making you can read this article.

Why Was Bancor V2 Created?

Although Bancor was one of the first protocols that implemented liquidity pools it didn’t get as much traction as some of their competitors. There were a few reasons for this, mainly the requirement to use an additional BNT token to provide liquidity to every pool, high gas fees to execute contracts and a harder process to list new tokens. Some of these problems were already addressed even before launching V2, for example, the Bancor community created permissionless interfaces for listing new coins.

On top of the above problems, the Bancor Team identified a few key obstacles that they believe are stopping AMM from wider adoption. These include exposure to “impermanent loss”, exposure to multiple assets, capital inefficiency and the opportunity cost of providing liquidity.

To tackle each one of them Bancor V2 implemented a bunch of new features.

The biggest one is the introduction of a new AMM called a dynamic automated market maker or DAMM that addresses the first 2 obstacles impermanent loss and exposure to multiple assets.

Before we jump into the mechanics behind the DAMM, let’s make sure we understand what impermanent loss actually is.

Impermanent Loss

In essence, impermanent loss is a temporary loss of funds occurring when providing liquidity. It’s very often explained as a difference between holding an asset versus providing liquidity in that asset. Impermanent loss is usually observed in standard liquidity pools where the liquidity provider (LP) has to provide both assets in a correct ratio and one of the asset’s value is volatile in relation to the other, for example, in a DAI/ETH 50/50 liquidity pool.

If ETH goes up in value, the pool has to rely on arbitrageurs constantly making sure the pool price reflects the real-world price to maintain the same value of both tokens in the pool. This basically leads to a situation where profit from the token that appreciated in value is taken away from the liquidity provider. At this point, if the LP decides to withdraw their liquidity the impermanent loss becomes permanent. The full explanation of impermanent loss is outside of the scope of this article, but I’ll try to make another one just on this fairly complicated topic.

Dynamic Automated Market Maker

We can see the main driver for impermanent loss is the fixed ratio between the tokens. But what if we didn’t have to always rely on a fixed ratio between the tokens in a pool? What if we could dynamically balance the ratio of the tokens in a pool? This is where DAMM comes into play.

DAMMs make use of price oracles to determine if the balance between tokens in the pool should be changed. Price oracles such as Chainlink provide external prices to smart contracts in a decentralized and reliable way. They can, for example, provide a current price of LINK/ETH.

Before we go through a quick example, let’s introduce a concept of the staked and current balance.

Stake balance is the balance provided by the liquidity provider. This is basically the balance that the LP should be allowed to withdraw when they decide to finish providing liquidity. Current balance is a balance of the tokens in the pool also sometimes called the “reserve balance”. Bancor V2 DAMMs always incentivize market participants to bring the current balance as close to the staked balance as possible, making sure that the LPs can withdraw the number of tokens they provided to the pool and mitigate impermanent loss. One of the ways to achieve this is by using dynamic fees. So if the current balance diverges from the staked balance, the fees can be adjusted to incentive market participants to bring both balances closer together.

A V2 pool is always initialized in a balanced state so that the price offered by the pool (“pool price”) is equal to an external reference “market price” provided by price oracles. The V2 pools are designed to always push the pool price to equal the market price.

Let’s see how the balancing mechanism works.

We start with a liquidity provider supplying equal value of 2 assets to the pool. Let’s assume the pool hold 2 assets LINK and BNT.

This is how our pool looks like after the initial supply was added.

So far so good, the state of the pool is not much different from the V1 pools or the Uniswap pools.

The second step is when the magic happens. Let’s assume that the LINK price went up to $12 across multiple exchanges and the price is not reflected yet in our LINK/BNT pool. Normally it’d create an instant arbitrage opportunity that would be most likely taken by a market participant and result in impermanent loss for the liquidity provider. This is because the ratio between the tokens remains fixed.

In Bancor v2, price oracles would pick up on that price change and adjust the weights of each token in the pool accordingly. When the LINK price increases, the target weight of LINK in the BNT/LINK pool will grow and there will be no opportunity for arbitrage.

Let’s see how the pool looks like after the price oracle picks up the 20% increase in the LINK price.

As we can see the weights of both LINK and BNT tokens in the pool got adjusted automatically and this is one of the main features of Dynamic Automated Market Makers.

Exposure to Multiple Assets

The mechanism that we just described is also really useful when it comes to tackling another problem – exposure to multiple assets.

In the standard liquidity pool, liquidity providers’ chunk of liquidity is tracked by LP tokens that represent both assets that were provided to the pool. In Bancor V2 liquidity can be supplied to only one of the assets in the pool. So for example, if you have a BNT/LINK pool and you only want to get exposure to LINK, you can just supply LINK and there is no obligation to supply BNT. Because of the DAMMs and the integration with price oracles the V2 liquidity pool will be able to adjust the ratio between the tokens in the pool.

Additionally, for each V2 pool, the liquidity providers receive separate LP tokens for each of the assets provided to the pool.

If we go to our previous example we can see what would happen if someone supplied more LINK to our BNT/LINK pool.

Let’s start with the same initial balances in the pool as before. Now, instead of the increase in the price of LINK, let’s say a new liquidity provider adds 10 more LINK to the pool.

Again we can see that the token weights in the pool got adjusted automatically.

Tackling Capital Inefficiency

To tackle another problem that is capital inefficiency, Bancor V2 introduces a more efficient bonding curve that reduces slippage. Let’s see what it means.

Bonding curves represent a relation between the token supply and price. Standard bonding curves present in constant product market makers such as Uniswap incur quite a lot of slippage as the size of a trade increases in relation to the size of the pool. The Curve Protocol was created to accommodate this problem. The Curve pools are able to provide lower slippage as they consist of assets that should have a very similar price, for example, stable coins like USDC and USDT or different flavours of Bitcoin such as wBTC and renBTC.

Bancor V2, thanks to the integration with price oracles, can provide more efficient bonding curves even for pools where the price of one asset is volatile in relation to the other asset. Bancor V2 bonding curves, even though not exactly as efficient as Curve’s bonding curves for stable assets, are still quite impressive and they provide less slippage and better capital efficiency. According to the Bancor Team, the new DAMM pool can provide similar slippage to the standard liquidity pools with 20x less capital in the pool.

Opportunity Cost of Providing Liquidity

To address the opportunity cost of providing liquidity, Bancor V2 enables the creation of DAMMs that are integrated with lending protocols such as Aave. Essentially, a part of staked liquidity in the pool can be simultaneously lent out which allows liquidity providers to generate lending interest on top of trading fees and maximize their profitability.

Summary

These are pretty much all the new features of Bancor V2. At the time of writing this article, Bancor started their V2 release by creating a LINK/BNT pool that was, for now, max capped at $500k, so the team can verify if everything works as expected before removing the cap.

One extra thing to add is the fact that a V2 pool can only be created if there is a reliable price oracle for the assets that are traded in the pool. So V2 pools may not be the best choice for unpopular and less liquid tokens.

It’s also worth noting that similarly to Bancor V1, Bancor V2 still relies on having BNT in each liquidity pool. So, for example, to trade from ETH to DAI we would have to trade through ETH/BNT and DAI/BNT pools.

When it comes to competing with other Dexes, Bancor V2 can potentially steal some of Uniswap’s volume especially when it comes to the most popular trading pairs. So far, it doesn’t look like Bancor V2 would be a competitor to Curve as they still provide lower slippage for stable assets, also it’s impossible to create a pool such as USDC/USDT in Bancor V2. Also, V2 pools are limited to only 2 assets so Balancer with multiple assets in one pool still provides a unique value proposition.

So what do you think about Bancor V2? Does it have a chance to dethrone Uniswap and attract more liquidity providers? Share your thoughts below.

If you enjoyed reading this article you can also check out Finematics on Youtube and Twitter.

]]>
https://finematics.com/bancor-v2-explained/feed/ 0