We need to go deeper. Let’s start from the beginning.
#DeFi — https://defipulse.com/
DeFi is just a hashtag. Remember the banks, financial institutions, world economy, regulators…? All these things are slowly becoming museum exhibits. Crypto is building its way to the future. Bitcoin enthusiasts, banks, VC funds, financial experts are working hard building the new digital economy. For a start, they are taking existing concepts from the legacy financial world and moving these models into the crypto space.
Someone may ask: is it actually a good idea to use Ethereum? The answer is: probably not, but anyway that is outside of the scope of this article. The fact is, Ethereum’s leader Vitalik is actively funding projects contributing into the success of it, and that is the key moving factor here. Ethereum has big community funding #DeFi projects.
In summary: #DeFi is short for decentralized finance. Practically it means that this year everything that ever existed in the world of finance is actively becoming Ethereum smart contracts.
Small step back in time. There was this EtherDelta project — a decentralized cryptocurrency exchange (DEX). With the traditional order book, users were placing their Bids and Asks to trade crypto outside the existing crypto exchanges. Except, despite the claims on its website, it wasn’t fully decentralized, and that is why it was effectively shut down.
Then UniSwap emerged. There is no order book, and exchange pairs are automatically adjusting.
UniSwap is a New York-based fintech startup; it is DEX.
Every DEX connects a few groups of interest:
- People who want to trade. These are the regular customers, or traders.
- Exchange owners offer the platform for customers to buy or sell tokens. In return customers pay fees to the exchange. Except, since we now live in the era of DEX, there are no exchange owners anymore. Scratch the (2), and put it into a museum.
- Liquidity providers. By design, decentralized exchange needs someone to offer liquidity. In return, liquidity providers get the exchange fees.
Let’s see what Automated Market Makers (AMM) are, or, more specifically, how does it work for the UniSwap.
Here is a user story:
You decided to become a liquidity provider (investor) for an Ethereum token (more specifically, any token within the ERC-20 standard). First, you need to buy Ethereum (ETH) and the tokens. Total value of the tokens must be equal to the total value of the ETH. Then you put it all into a special smart-contract, called exchange pool. Now your funds are locked in the blockchain.
Consider an example. Let’s say, the ETH price is now 500$, and some token T price is 100$. You buy 10 ETH for the total value of 5000$ and 50 tokens of T. You put it into (for simplicity) an empty exchange pool. In return, the pool gives you a so-called pool token, representing your stake. Stake is how much funds of the pool belong to you. Then someone else comes and invests; he also gets the pool token.
At this point, the left side of the pool contains 20 ETH with the total value of 10000 US$, and the right side contains 100T with the total value also 10000$. The pool is perfectly balanced.
Also there are two pool tokens, owned by two liquidity providers. Each token represents 50% of the total funds in the pool, meaning 10ETH and 50T. Liquidity providers can return their pool tokens any moment, and get their funds.
The first customer comes and wants to sell 5 of his T tokens. This is when the price starts to adjust automatically, and the Calculus-101 takes the action.
The magic formula M is X*Y=C
X — is the total value of ETH in the pool.
Y — is the total value of the T.
C — is just a constant, here we call it the pool constant.
Current proportion of the pool funds is 20 ETH / 100 T = 0.2 ETH per T. Let’s see the proportion after the operation.
The M-formula says: 20 ETH * 100 T = 2000 ETH T = (the pool constant) C
After the trade the pool will contain 105T and an unknown amount of ETH.
X * 105 T = C = 2000 ETH T
Leads to X = 19.047 ETH, meaning the trader will be allowed to extract 20–19.047 = 0.952 ETH from the pool for his 5 T. Exchange rate in this case is 0.952 ETH / 5 T = 0.1904 ETH per T.
Please notice, the price is calculated BEFORE the execution, but taking in account the pool state AFTER the operation. In this way the model prevents the pool from draining. The more the trader wants to extract from the pool, creating disbalance of the pool liquidity, the higher is the price. So selling 100T would lead to the price 0.05 ETH/T and the pool will pay out 5 ETH, after the trade the pool will end up having 15 ETH and 200 T.
Here we have two questions:
- How can the liquidity provider get his funds back when the pool balance has shifted?
Originally, the liquidity provider invested 10 ETH and 50T with the total value of $10k. Getting funds back the liquidity provider has to return his pool tokens. Assuming, from the previous example, our pool state is 19.047 ETH and 105 T, and the pool investor owns 50% of the pool tokens, the payout will be 9.5235 ETH and 52.5 T.
- What is the incentive here for the liquidity provider to invest in the pool? Is it profitable?
Being a liquidity provider means being a market maker. This role involves buying tokens when their price is going down, and selling them when it is going up. Liquidity providers may lose a bit of money when price deviates. This is called impermanent loss, and it will disappear when the price returns back to the original. More detailed explanation can be found here:
Someone may ask what is the point of investing in a decentralized exchange? The answer is: the trading fees. All the math above simply assumes the exchange fee is zero, but actually it is 0.3%. This means that 0.3% of each trade goes back to the pool liquidity. In the long run, with a big trading volume, when the number of exchange operations is significant and the price fluctuations are within regular limits, the market maker will make money. Investing in exchange becomes profitable.
In fact so profitable that in the end of August 2020 the SushiSwap emerged and hijacked the UniSwap.
SushiSwap is a clone of Uniswap, but with features.
The first feature is the Sushi Chef — a smart contract that offers liquidity providers of Uniswap to store their pool tokens and in return rewards them with sushi tokens of 0$ value. So, again, basically liquidity providers for Uniswap, give their pool tokens to Sushi Chef and Sushi Chef rewards them with tokens of no value. Why? This is where it is becoming interesting.
The 9th of September 2020, all the liquidity providers who kept their Uniswap pool tokens with the Sushi Chef, authorized the Sushi Chef to extract their liquidity from Uniswap pools and to move it to the SushiSwap pools. This resulted in moving approx 1B$ of liquidity from the UniSwap to SushiSwap and this is called the Vampire Attack. Welcome to the world of decentralized finance.
The second feature is the Sushi tokens. UniSwap was charging each trade with the 0.3% fee forwarded to the pool. SushiSwap puts only 0.25% of the fee to the pool, and the other 0.05% is distributed between all the sushi holders. This is important.
In summary, SushiSwap is a DEX with 3 major groups of interests:
- The exchange customers, or traders.
- Exchange liquidity providers who get 0.25% of the trading fees.
- Sushi holders. These are stakeholders or exchange investors who get 0.05% of the trading fees.
Uniswap makes $620M trades per day on average (https://www.coingecko.com/en/exchanges/uniswap#statistics). Let`s be very very conservative. Let’s say it is only $100M per day, taking 0.05% of that is $50K. By the end of the Vampire Attack there will be 110M of sushi.
- A portion of these sushi will be in circulation by traders and hodlers.
- Another portion will be locked in by the pools collecting 0.25% liquidity fee.
- The remaining sushi will be staking. Staking is when holders lock their sushi in a special smart-contract called the SushiBar. Sushi locked in the bar receive 0.05% staking fee.
Let’s make some estimates on the profitability. Assuming the extreme state of the system, when all 110M sushi are locked in the bar receiving $50k per day, each sushi is making at least $0.166 per year on the 0.05% staking fees.
This conservative scenario however is not reachable, because a reasonable portion of the sushi would be stored in exchange pools collecting the 0.25% liquidity fees, calling sushi holders to balance their sushi profile in between the pooling and the staking.
So in summary: SushiSwap is a DEX that successfully executed the Vampire Attack on the Uniswap DEX. Both work on a very simple mathematical formula from Calculus 101 automatically balancing exchange pairs; both are technologies marked by the #DeFi hashtag; and both are running in the Ethereum space. As simple as that.