The majority of us started the crypto space journey firstly from a centralized exchange like Binance, Coinbase or Kraken. You probably know the process you need to go through in order to buy a token or to trade on these platforms but let’s see the advantages of decentralized exchanges and why more and more people decide to migrate to them. The best approach would be to do a comparison between CEX (Centralized Exchange) and DEX (Decentralized Exchange).
What are the differences between CEX and DEX?
A CEX is ruled by a central entity and the whole activity takes place on their database, but the whole idea behind blockchain is eliminating the intermediaries, isn’t it? Once you start using a CEX, in most cases you must give personal and banking information in order to be allowed to make a deposit, so the user activity is not in anonymity contradicting one of the blockchain’s fundamental features. Probably all of us met an opportunity at one point in time and we were not able to take advantage of it because of KYC (Know Your Customer)/ AML (Anti-Money Laundering) processes or because of an exchange suffering downtime which made you unable to trade in spite of your desire. You have also heard for sure at least once about a CEX being hacked or even worse, the case when the CEX’s team ran away with the funds. All these are the risks when using a CEX and the reason why people prefer using a DEX, these being on the list of DEX’s advantages.
Most centralized exchanges have user-friendly interfaces that allow even more options and functionalities than decentralized exchanges. This offers a more pleasant experience without headaches. Other two important advantages of a CEX would be the order book system and the fact that the trades and the orders are executed off-chain, without needing to get validated by nodes. In this case the users’ balances are allocated internally through dedicated servers and security processes that are specific to every exchange. In consequence, you are able to trade tokens that are issued on different networks almost instantly and by using the most used CEXs you are even able to avoid the liquidity problems often met on DEXs.
The major difference between CEX and DEX is the back-end part. DEX’s back-end is built directly on blockchain, as open source smart contracts which can be verified. There is no third party in this case and the private keys and the responsibility for your funds are all yours. DEXs as Maiar Exchange, allow anybody to create a liquidity pool, which permits projects and small businesses to avoid going through the expensive, intricate and often unsuccessful listing process on a centralized exchange.
Back to security, we must be aware that in a decentralized environment in which anybody can build and integrate the technology, security breaches might occur in the source code. Most exploits & hacks happen because it is almost impossible to test all the possible scenarios and the complexity of a code is vast, millions of code lines written in different time periods. These add bugs/problems in the code, design problems and make it difficult to formally respect the initial brief. The Smart Contracts’ security is very important because any action on blockchain is irreversible, mistakes can not be fixed. One of the solutions that are meant to solve this problem is the set of formal tools based on K Framework developed by Runtime Verification, one of Elrond Partners that is specialized in formal methods. These formal methods used for software development involve adequate mathematical analysis (these are special mathematical methods with applicability to graphs) that focus on the reliableness and robustness of designs. Basically, the application’s code blocks and functions are described using a mathematical language and their links are checked mathematically/ formally. So, having the Smart Contracts verified since the design phase, Elrond will have a great reputation, without hacks or exploits, being even more attractive to major businesses and use cases.
How does Maiar Exchange work?
AMM or Automated Market Maker tech have turned since 2018 trading from a game in which just one entity has something to win into an ecosystem in which anybody can participate and generate revenue based on personal contribution and exchange usage. AMM allows users to change digital assets as EGLD or BUSD in an automated manner without needing to ask permission from an intermediary.
The concept that lays at the base of AMM is the Liquidity Pool (LP) in which Liquidity Providers add tokens. Through these pools the order book system is replaced and the users trade within the pool.
The prices of 2 tokens of a pool is calculated based on a mathematical formula and it is not decided by intermediaries as in the case of CEXs that follow the buy/sell orders.
The most famous and most used AMM model is the one that uses the x * y= k formula, where x represents the number of A tokens from a pool, y represents the number of B tokens of the same pool and k represents the multiplication between the two which remains constant.
So, for example, if in a pool we have 100 A tokens and 100 B tokens, the exchange ratio is 1:1 and k = 10 000. If somebody wants to exchange 10 A tokens into B tokens the formula will look like this.
We can notice according to this calculation that for 10 A tokens we got 9.09 B tokens. We will explain why we did not get 10 B tokens for 10 A tokens a bit later in the article.
What does the Maiar Exchange user experience look like?
Using the protocol of an AMM is pretty simple, you need just one address that can interact with the AMM’s smart contracts set, in this case an address created on Elrond Network. Connection to its front-end can be done using a json file+password, a Ledger device or through Maiar’s Wallet Connect.
In order to swap, all you need to do is choose the tokens pair that you are interested in, then introduce the number of A tokens you want to exchange and confirm the transaction. After the transaction confirmation, the swap function of the smart contract is called and it sends your introduced number of A tokens into the pool and using the mathematical formula that was previously explained calculates the number of B tokens you will get. For every swap one has to pay a fee that represents a fixed percentage of the trade (i.e. 0.3%). The fees go into the liquidity pool and are distributed proportionally to all the Liquidity Providers.
The risk associated with swapping is called Price Slippage. This phenomenon occurs when the initial price is different from the price when the trade is executed. The smaller the liquidity in the pool related to the swap, the bigger the Price Slippage is because the initial price is basically the best offer for one unit and the more units we want to exchange, the more we need to pay for every unit. Another cause of Price Slippage could be the latency: from the moment we confirm the transaction until it gets validated by nodes there are chances to have other trades ahead of ours that will consecuently modify the prices from our trade.
Most AMM allow the option to set maximum Slippage for swaps in order to avoid unpleasant situations.
We can notice the importance of liquidity (or Total Value Locked - TVL) from the previous explanations, this being basically the catalyzer of this type of system. A higher TVL level attracts more trading volume due to the lower Price Slippage risk and generates more fees to be added in the pool and distributed further to Liquidity Providers proportionally. In this way a healthy cycle is born as new Liquidity Providers are attracted.
As a Liquidity Provider you have to remember the way a deposit is made for liquidity. In most of the pools the deposit comprises 2 value equally parts of the 2 tokens. For example, if 1 EGLD = 200 BUSD, your deposit has to respect this ratio (i.e. 3.5 EGLD = 700 BUSD). After you deposit into a pool you get LP Tokens that attests the fact that you own a share of that pool and based on it you get your share of the fees. Usually the LP Tokens can be further staked in order to get even more revenue besides fees increasing our passive yield.
Everything sounds great so far. We offer liquidity and we get rewards and shares of the generated fees, but is there any risk involved? As we have seen, AMMs work on a mathematical formula that calculates the ratio between the tokens of a pool, and consequently the price. While it allows the market to work it is also responsible for the Impermanent Loss phenomenon.
Impermanent Loss: Is it as bad as it sounds?
At first sight Impermanent Loss does not look so bad, it makes us think about a loss that is temporary and that can be fixed in time. In reality, things are a bit more complicated. Impermanent Loss is actually the opportunity cost between 2 strategies, LP and buy & hold, but you can’t just relate to this cause it is quite erroneous because it starts from the idea that you hold for the whole period of liquidity providing, which is rarely the case as most of us are tempted to trade in order to accumulate even more and that is why results vary a lot. Furthermore, when people compare the two, they compare just the profit and omit to think about risks too, which is as important as profit.
Let’s take the easiest example to observe how IL can influence us. Let’s consider the EGLD/ BUSD pool on Maiar Exchange, where Liquidity Providers have to deposit the same value from both tokens. Fees will not be considered for this example.
Let’s assume that a Liquidity Provider has just deposited 10 EGLD + 1000 BUSD (50–50 value ratio) in the EGLD/BUSD pool. He has 1% of the LP (1000 EGLD +100000 BUSD) and 1 EGLD price is 100 BUSD. Now let’s start from the x y k formula.
In this formula x is the number of EGLD from the pool, y the number of BUSD from the pool, and k the multiplication between the two which always remains constant no matter how the price changes. (k is changed only when liquidity is added/withdrawn but to keep example simple it will stay constant).
After a while EGLD price has an increase of 10% on Binance reaching 110 BUSD. At this moment there is an opportunity to make profit from arbitrage by buying from the pool and selling further on Binance. Let’s see how much one should buy in order to take advantage of the arbitrage until the price from the pool reaches the one from Binance.
From these we get that the arbitrage opportunity consists of buying 46.5375 EGLD (1000 - 953.4625) which costs 4,880.848 BUSD (104,880.8848 - 100,000) with profit being 238.2402$ (46.5375 * 110 - 4,880.8848) or put in words, it consists in the possibility to sell each EGLD bought with 105 BUSD for 110 BUSD on Binance.
Comparing the 2 strategies, LP and buy & sell, we get to the following result:
LP: 1% of 953.4625 and 104,880.8848 = 9,5346 EGLD and 1048.8088 BUSD. Turning EGLD into BUSD to see clearly the difference we get a total of 2097.61 BUSD
HOLD: 10 EGLD and 1000 BUSD results in 2100 BUSD
The 2.39$ is the relative loss from LP against buy & sell caused by Impermanent Loss.
If the Liquidity Provider would not withdraw his liquidity at that moment, and the prices would go to the initial value from the deposit moment, there would be no loss anymore. This loss materializes just when the Liquidity Provider withdraws the liquidity and there is a price divergence between deposit and withdrawal.
Keeping this divergence and the 10% (100 → 110) growth in mind, let’s see what is the Impermanent Loss formula in order to calculate the relative loss at different price divergences.
What is interesting in the previous example is that at the withdrawal moment we will have less tokens from the one that is more appreciated and more from the one that is less appreciated.
If we consider just one parameter, the profit, analysing the previous formula we can notice that no matter in which direction the price evolves, the Impermanent Loss ratio is always >0 meaning that LP strategy will always be linked to Hold if there is a price divergence. So why would anybody choose a strategy that performs worse than buy & hold in both directions? Well, the answer is earnings from fees and rewards which should cover the risks caused by Impermanent Loss.
On the other hand, considering the other parameter, the risk, expectations and results might not coincide. While using a buy & hold strategy, an asset can start to rise and be more appreciated than the other at the same time the risk of a position starts to rise. As for LP, the volatility impact remains constant because the $ value of each asset remains constant too. In other words, we can see Impermanent Loss impact in a simpler way — while an asset becomes more appreciated, profit is taken and on the other side, while an asset depreciates it is accumulation time at lower prices. In fact, this concept is familiar to all the traders, it is basically what everybody aims: Buy low & Sell high.
Tips & Tricks
1. One must see further than the APR offered by the passive yield when choosing the pool you want to provide liquidity in. The pools that have well correlated pairs in terms of volatility have lower Impermanent Loss risk and the pools that have volatile assets and stable assets are definitely going to lead to Impermanent Loss.
2. Before depositing in a Liquidity Pool you must know that at the withdrawal moment you will have more of the token that performed worse and less of the token that performed better.
3. After reading point 2, we can say that the deposit timing is important. If your goal is to increase the balance of a token, you can deposit in a pool in which the desired token is relatively at a high compared to the other token of the pool.
4. Impermanent Loss does not grow in a linear way, you have to always add the earnings against the IL and that is why it is essential to choose good AMMs & Pools, that have returns covering the IL risk.
Note: the article was written before Maiar Exchange launch and the interface of the exchange and the technical details presented might be subject to change.
Special thanks to all the writers of the articles below:
- https://vitalik.ca/general/2017/06/22/marketmakers.html
- https://coinmarketcap.com/alexandria/article/hedging-against-impermanent-loss-a-deep-dive-with-finnexus-options#toc-how-to-hedge-against-impermanent-loss-with-options
- https://pintail.medium.com/uniswap-a-good-deal-for-liquidity-providers-104c0b6816f2
You can check if you are not dealing with a scam
Check now