A dive into DeFi, DEX, Sushi and why Morpheus Labs created ABC Swap.

By jonathan a. | Blockchain Adoption | 8 Nov 2021

Introduction to DeFi, Sushiswap.

Decentralised Finance (DeFi) has become a mainstay in the crypto industry since its boom in 2020. Decentralized finance is essentially financial applications that a centralized body would provide (Banks, Financial Institutions), but is now offered in a decentralized manner. Popular DeFi applications include Decentralized exchanges (DEXs), Lending Platforms and Liquidity mining.

In this article, I attempt to explain the key features of Sushiswap and some of the issues and how an open-source project by Morpheus Labs attempted to address some of the issues in a way that can be replicated by any enthusiast. In the next article, I document these changes.

So by reading this and the next article on the Morpheus Labs ( ABC Swap project you can build your own DeFi project!

Sushiswap 101

Sushiswap was launched in August 2020 by Chef Nomi! It is a decentralized exchange (or DEX, for short), and the first product by Sushi. Sushiswap is a fork Of UniSwap that was launched in 2018. Combined, the two online platforms held a market share of roughly 80 percent when it comes to trading on DEX platforms. The volume traded is in the tens of billions for both platforms combined. Remarkable as they have been existing for just a couple of years. 

So what is it anyway?

Sushiswap is a non-custodial distributed Defi tool, which means that—unlike centralized exchanges—Sushiswap does not need to hold your tokens in order for you to be able to trade them. Instead, Sushiswap allows users to trade 'trustless', peer-to-peer, with liquidity that is supplied by other users. This means that new projects can easily connect to their desired markets as long as some entity is willing to provide the liquidity.

As mentioned peer-to-peer is basically no middlemen. Middlemen such as cental exchange (CEX), Stockbrokers who would usually be the ones to provide liquidity (using others' money!) to undertake a trade and to supply liquidity in a specific stock. The provider of liquidity operates at both ends of monetary transactions. At specific prices, he/she sells and acquires a particular asset, usually based on a centralised order book and often collateralized by the bank they work for. The middlemen can hold the power to control the market and eventually become the market maker.

With Sushiswap this process is done automatically using the concept of a liquidity pool and an algorithm that manages the supply and demand as well as orders. This is the reason it is called an automatic market maker or AMM, The liquidity is provided by users who add or remove tokens into the liquidity pool. The mechanics are executed on the blockchain by a number of smart contracts, and that’s a story for another day.

Now to take a look at the details of sushi swap and how it can be improved in the conclusion which leads to ABC swap and existing services like Uniswap v3.

Adding liquidity

To be a liquidity provider in Sushi, holders of any token need to supply equal parts liquidity for that token (sometimes called the quote token such as ETH), and a second token (usually a stable coin like USDC). Traders access the underlying tokens in exchange for a small fee, which is then distributed proportionately to all of the liquidity providers as a percentage of what they contribute to the pool.

This reward distribution in Sushiswap is from SLP tokens which represent the LP ownership of the pool, it's their commission as a trader and can be used subsequently. These SLP tokens can be used as a utility token to be used in another feature of Sushi such as “ yield farming” where they are added to a pool and free yield farming tokens are issued over time to give a return or APR.

Using an example for MITX and USDC (stable coin): Supplying $100 of liquidity into a MITX-USDC pool requires a deposit of $100 worth of MITX and $100 USDC, so $200 in total. In return, the investor receives liquidity pool tokens which represent their proportional share of the pool and is allowed to withdraw that share at any time. 

Where do these rewards come from? When someone places a trade (see below), trading fees are deducted from the asset that the trader sends to the exchange contract and are added to the liquidity pool after the trade. For example, Sushiswap charges a 0.3% trade fee.

Example: So as a liquidity provider if your $100 MITX-USDC contribution makes up 0.005% of the pool, you’ll get 0.3% of the 0.005% as a trading fee.

So as a liquidity provider I get  0.3% trading fee which is based on the amount  I contribute to the pool. This doesn't seem much but if there are a lot of trades then it adds up. For example : 0.3% x 10 trades a day x 30 days =9% of my pool contribution.

Trading (Swapping)

Now there is liquidity in the pool it is possible to trade or “swap” with other traders in this new market. This is a core feature and one of now dozens of features of Sushi. It is core as it provides the market trading capability such as managing supply and demand and setting the price ranges.

And as a trader, I will be charged 0.3% to swap my tokens of which 0.25% is given to the LP, and the remaining 0.05% is distributed to SUSHI token holders.

As mentioned, Sushiswap is also an ‘automatic’ market maker. For more information on AMMs, kindly refer to this article and read on for an introduction to those who are new and curious.

Most DEXs face one underlying problem using AMM, which is capital inefficiency because if prices were stable, trading pairs would only be traded within a given price range. As my rewards are a percentage of my contribution to the pool I am not getting compensated efficiently. And as an investor, I would want a 1:x reward, not an inefficient 1:1 reward.

What is needed is an LP with not just plenty of liquidity but plenty of liquidity in a variety of ranges. Here's what an LP price curve looks like with an example range for USDC-ETH. This is the price traders added to the pool :

price curve

Fig. Price Curve

The price curve is uniform and calibrates the pool based on the price of the two underlying tokens happens (As more are added to the pool at different price points) and the pool is automatically recalibrated so that the quantity of those tokens conforms to the equation x*y=k, where x and y are the quantities of the two paired tokens, and k is constant. This is how supply and demand are managed automatically.

It is a uniform distribution allowing trading across the entire price interval (0, ∞) without any loss of liquidity. However, in many pools, the majority of the liquidity is never used as people trade within a specific range. And in so doing this is where the trading volume is and where the rewards come from provided as LP tokens. I will only get a reward based on the asset I provided and when people use that liquidity to trade within the range I deposited my assets into the pool. 

The liquidity outside the typical price range of a stablecoin pair is rarely touched if people are not trading in that range. Meaning poor efficiency of the liquidity pool and even unfair rewards. What if I could get my reward based on a whole range of trading pair ranges to get a better reward from my liquidity provision. And this in effect what happens by investing in different pair pools  or using Uniswap v3 concentrated range feature, click here for more details:

Risk (Impermanent loss)

Part of the unfairness or even risk is not maximising the rewards and part is when there is an impermanent loss for a trader. Impermanent loss is unfair based on the movement of the exchange pair value and also of the liquidity pool. It is part of the way the market and DEX works in this respect it is more risk for trading.

Impermanent loss comes from a price difference between the assets you placed and when you deposited them and when you intend to withdraw them  —This means that even though you supply equal parts of two tokens to the pool, the quantities you receive when you reclaim your liquidity will change relative to the difference in the change in the price of the two tokens when you remove the liquidity. 

Impermanent loss happens within a particular trade pair, which will always retain an equal value ratio of the two assets (in this example, MITX-USDC). If USDC has a rise in value, it will modify your position in MITX to keep the same ratio, and you can get an even more significant number of MITX tokens and a lesser quantity of USDC if you withdraw from the position. 

Here's an example using MITX-USDC, on is a stable coin:

  • Let’s say that the price of MITX-USDC is currently $1.00 and you provided liquidity for the range of $0.95 — $1.05. 
  • The amount of liquidity you provided is for example 100 MITX and 100 USDC and you make up the entire pool. 
  • In this contrived scenario when the price of MITX-USDC stays within the $0.95 — $1.05 range, you will just be incurring trading fees of 0.3% and accruing LP tokens based on the share of the pool.
  • However if say MITX-USDC price goes beyond $1.05, to $1.5, you will stop earning LP tokens and all your MITX will be converted to USDC because of how the pool balances
  • and this results in an impermanent loss.

The only way to ensure you avoid this loss is to withdraw your original tokens when they're at the same price that they were at when you deposited them. Tracking the initial prices of your tokens when you begin LP staking can help you avoid losses.

However, if a pool has enough liquidity and volume at various ranges then this can also reduce the chance of impermanent loss

Final Thoughts

Decentralized exchanges are still in an early development stage but despite that, they are getting more usable and have huge trading volumes. However, as centralized exchanges continue to experience security exploits and delay the listing of new cryptocurrencies, more users will elect to adopt decentralized exchanges despite their high friction. 

It is worthwhile to invest in the development and growth of the decentralized exchange ecosystem to promote liquidity in an increasingly diverse token ecosystem, greater user control of cryptocurrencies, more privacy features, and lower risk of censorship.

In the broadest sense using DEX, providing liquidity places value inside an intelligent contract. The AMM protocol performs a market breaking function in total autonomy, requiring just liquidity in the LP pool. The LP reward system decentralizes asset management by putting ownership into the peer-to-peer trader and ecosystem. 

AMMs are not perfect as they require to be operated in a particular range, and they always retain an equal value ratio of the two assets. The risk of impermanent loss is inherent and comes from a price difference between the assets you placed and when you deposited them, and becomes a “permanent” loss upon withdrawal. 

To help make the Sushiswap more usable there are of course many forks and the most notable is Uniswap v3. However, anyone with the right use cases can build one which is why Morpheus Labs implemented ABC Swap as a  fork of Sushiswap. It is a tool that allows trading between token pairs by functions including staking, swapping and yield farming. 

Using the new features of ABC Swap it is possible to set the trading pairs, limits, and view the liquidity of the pool to minimise losses resulting from the size of the pool and impermanent loss related to the external value of the token. 

The Morpheus Labs SEED platform enabled this ease of deployment and is available to anyone with the open-source of changes. This enables the whole platform to be deployed cross-chain, in this case on Polygon with low gas and fast speed which is ideal for testing and building your own DEX. And this is one reason why Sushiswap was chosen over UniSwap.

Morpheus Labs ABC Swap is open source and services not as an operational DEX but as a means to get inside the code and see how changes can be made. Have a go and build your own Defi ecosystem.


How do you rate this article?


jonathan a.
jonathan a.

Hi, I'm Jonathan, interested here in DAO, Agile, Blockchain, Defi. Building capabilities from 2020 onwards in this field. I have been in the software tech sector for 20 years.

Blockchain Adoption
Blockchain Adoption

I look at different blockchain projects and try and explain them simply to level 1 and level 2 detail. It is also a discovery process myself.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.