The DeFiChain Decentralized Exchange
DeFiChain's Tokens and Exchange
DeFiChain's Tokens and Exchange
You may have heard of the terms "DEX" and "liquidity mining." It's thrown around a lot in the crypto world, but do you know what they are? This tutorial will explain what it is and why it is a necessary process, benefitting everyone in the ecosystem.
A "DEX" is short for "decentralized exchange." As a decentralized network designed for finance, one of the most crucial features we need is a decentralized exchange. The DeFiChain DEX allows users to exchange DFI to assets like dBTC, DUSD (DeFiChain's stablecoin), and dSPY (one of DeFiChain's tokenized stocks) in a decentralized way.
Before we go deeper into exploring the mechanics of DeFiChain's DEX, we need to first discuss DeFiChain's tokens. They are known as DeFi Standard Tokens or for short, DSTs.
There are two types of tokens within this DST classification: DeFi Asset Tokens (DATs) and DeFi Custom Tokens (DCTs). We really only need to focus on the former, the latter can be created by anyone for a refundable fee and in general only serve a purpose for the related people who mint and use them. DATs are DeFiChain tokens that represent some sort of real-world asset like BTC, SPY, QQQ, or USDC. They have a "d-" prefix in order to distinguish the actual asset from the tokenized asset. As tokenized assets should be, 1 unit of a tokenized asset should be equal to 1 unit of the real asset.
So these tokens are not the real asset, but they trade and act as one, and are backed up in order to make sure the token is not without value. Users cannot simply mint them out of thin air. It's important to note, the crypto-representative tokens cannot be sent outside of DeFiChain. You cannot send dETH to an ETH wallet like Metamask, you will lose it and there is no way to retrieve it.
Now let's go into more detail about the DATs.
DATs that represent a crypto asset are minted and backed by Cake, a company founded by the same people who founded DeFiChain, Dr. Julian Hosp and U-Zyn Chua, as we are still testing ways to bridge the real asset and the tokenized asset, allowing people to redeem 1 unit of the tokenized asset for 1 unit of the real asset. The community is working towards backing it up securely with other methods to help decentralize crypto tokens. Already, it's possible to back up stock tokens in a decentralized way, which will be talked about next.
In the DeFiChain ecosystem, users can take out a loan if they have the appropriate minimum collateral amount, which is $1.50 in collateral for every $1 in loans. These loans are what allow stock tokens to be minted. The only other way these tokens can be minted is through future swaps, which will be discussed later in Chapter 5.
DeFiChain, including two tokenized stablecoins, dUSDC and dUSDT, has its own stablecoin called DUSD. As tokenized stocks can be minted, DUSD can also be minted in the same way, which exposes it to the same potential problem. However, it's important to note that while DUSD tends to fluctuate with more volatility than other stablecoins, it is not a result of the minting processes. Instead, DUSD will be a freely floating stablecoin based on free market dynamics instead of being pegged to $1 like other stablecoins aspire to do; there is no arbitrage loop that can be made through DUSD. This can also be an advantage as deviations of +/- a couple percent would not cause mass panic among investors like it could with USDT or USDC.
Let's talk about the decentralized exchange. The DeFiChain DEX is unlike a typical centralized exchange you might see. For example, there is no orderbook like you would see in a traditional exchange. Instead, users provide liquidity, pooling their own assets, creating a "liquidity pool" or LP which users can use to swap. Initially during creation of a LP a user sets the price of the two assets by adding the assets in whatever price ratio they want. They can, for example, add 1 BTC and 1 USDT, or 0.0001 BTC and 50,000 USDT if they wanted. However, other investors will see the mismatch between the fictional above prices and the real price that they will start to arbitrage the difference. In a LP, when you swap, you are adding assets you want to sell to the LP and the system (known as an automated market maker or AMM) will remove the appropriate amount of asset you want to buy and send it to your wallet. If you want to know the exact formula and specifics to calculate swap results, you can check out this information page after reading this tutorial: DeFiChain Fees and read the Swapping Fees section up until future swaps, which is not relevant.
In summary:
Users add assets to liquidity pool.
People add/remove certain assets (buying/selling), which causes the ratio of assets in the LP to change (price movement).
Just like in a traditional exchange, the more liquidity, the less slippage you incur. If there are more assets in the LP, you will be able to add and remove the same amount of assets with less significant changes for the pool's ratio (price).
As mentioned earlier, investors must add liquidity for others to be able to swap, and this is incentivized through various rewards. The term "liquidity mining" (also known as "LM" for short) comes from the fact that users add liquidity to "mine" for rewards. However, liquidity mining is a unique form of getting cashflow, and with it comes various risks.
In DeFiChain, users are incentivized with two different types of rewards. Firstly, a 0.2% fee is applied on all swaps, which is distributed proportionally by how much liquidity is provided by each liquidity provider. This is known as a commission. They are variable and for some of the pools the commissions are small relative to the amount of liquidity, so masternode owners voted in a proposal to give a share of their block rewards to liquidity miners. Nowadays, liquidity miners receive mid-double-digit APRs (as of August 2022) as a result of this block reward allocation.
There is one major risk in liquidity mining, the infamous impermanent loss (called "IL" for short). It is a result of the ratio of pool assets changing. If you would profit from holding the two assets, you will have less profit by adding them into the liquidity pool. If you would lose from holding the two assets, you will have more losses by adding them into the liquidity pool. Think of it this way: as people arbitrage the difference between an LP and an exchange price, they need to have made money from somewhere. This "somewhere" is the LP and its providers. You only avoid impermanent loss if the price of the two assets have the same ratio when you added and removed liquidity.
When you add liquidity, the assets now belong to the liquidity pool. You instead receive tokens called LP tokens that show how much of the liquidity pool you own. So when users remove assets that are more valuable and add assets that are less valuable, imagine if one asset goes to zero. You will have tons of worthless tokens, as all of the other token has been removed by other investors (aka drained of the liquidity) over time.
You can check out an IL calculator here (simple). For a more advanced and better calculator, you can use this one made by Geearf. Use these to experiment with potential price changes to see how IL (with rewards, commissions, compounding, and taxes in Geearf's calculator) can affect your position.
Now that you have read about liquidity mining and the rewards and risks, let's talk about how to actually liquidity mine.
What you will need:
Knowledge of which pair (example: dBTC/DFI) you want to provide liquidity to
Of the two assets in the pair, you will need half of the capital you want to liquidity mine with on each side. For example, if you want to liquidity mine with $100,000 in the pair dBTC/DFI, you will need $50,000 of DFI and $50,000 of dBTC. You'll be showed how to get tokens by swapping in the mini-tutorial below.
Your DeFiChain wallet, if you haven't already downloaded it, visit https://defichain.com/downloads.
Expectation that the amount of rewards will be greater than any impermanent losses incurred. (This is subjective.)
Now, let's get to the tutorials!
1. Your DFI needs to be in your wallet as shown below.
The "Portfolio" page. This page shows all of the assets that you have available. When you load the app, this is the default page.
2. Swap your DFI to the token of your choice.
The "DEX" or decentralized exchange page. For the purposes of this tutorial, we're going to swap the DFI to DUSD.
Enter the amount you want to swap. I am swapping 0.00004149 DFI, but for simplicity, there is a "50%" button to swap half of your tokens and a "MAX" button to swap all of your tokens.
Confirm the details and click the purple button at the bottom to continue. Enter the password to initiate the swap. Within 5 minutes, your transaction should be finished.
3. Add your liquidity.
Click the "+" button and tell the wallet how much liquidity you want to add. The app automatically calculates how much of the other token you will need to add.
In this case, I want to add as much liquidity as possible, so I clicked on "MAX" for DUSD. Unfortunately, I did not have enough DFI to add so I had to click on "MAX" for DFI. This situation occurs nearly all of the time, you will not have an exact 50/50 split but more like of a 50.1/49.9 split due to various fees and changes including slippage and price changes.
Then, scroll down and click the purple button, enter your password, and you will have your liquidity added within minutes.
1. Navigate to the "DEX" tab. Select the token you want to swap and select the token you want to swap to. Remember to unlock your wallet by clicking the lock icon in the top left corner of the screen, above the version number display.
2. Next, with your newly acquired tokens, visit the "Liquidity" tab and select the tokens you want to liquidity mine with.
3. Make sure your wallet is unlocked, your transaction details are correct, and click "Continue." Your liquidity will be added in minutes.
That's all for this tutorial! If you're eager for another, check out Vaults.