Decentralized Exchanges [DeFi Series- Part 1]
Since Decentralized Finance (DeFi) has been trending lately, we decided to write a series of articles on DeFi and DeFi products to explain DeFi to our Indian Community. In this first article, we will cover Decentralized Exchanges. But before that, let’s simply understand what DeFi is.
In Centralized Finance or CeFi, transactions can occur only after you transfer assets to a trusted party. Your assets are in custody of another party. In DeFi, you have custody of your own assets. In order to transact, you don’t need to transfer your assets to a custodian or an exchange. You have the keys to your assets and they will move as you allow them to. We will elaborate more on that as we explore DEXes(Decentralized Exchanges) in this article.
Some of the prominent DEXes today are Uniswap, Kyberswap, Paraswap, Balancer, Curve.fi and Nuo Network. We also have aggregators like 1inch exchange and dex ag which scan all the DEXes and give you the best available price. DEXes, since a year have been setting new highs in volumes almost every month along with highs in no. of addresses trading on DEXes.
Curve.fi set a record recently where more than $60 million was traded in a single 24 hour period and Uniswap and Kyber both saw more than $30 million being traded in a single day in March.
Let’s take an example of trading USDC for Eth.
In an exchange like Binance, this is how a transaction works-
- You transfer USDC from your wallet to Binance provided deposit address.
- You place a limit or market order on Eth/USDC orderbook.
- Order gets executed and you now have Eth in your Binance balance.
- You now withdraw Eth to your Ethereum address.
In case of a DEX like Uniswap, all this is done in one single transaction. When you go to uniswap.exchange and select the asset you want to sell(USDC) and asset you want to buy(Eth), you will see a price which is around the same price being traded on Centralized Exchanges. When you click on ‘swap’ button, all of the above 4 steps happen in one single Ethereum transaction. That’s the beauty of DEXes.
Behind the scenes, all this works like magic made possible by Ethereum smart contracts. There is no orderbook, orderbooks are replaced by liquidity pools. And pricing of the transactions is done based on Automated Market Making.
DEXes work quite well via wallets like Trust Wallet, Meta-Mask, Kyberswap app and any wallet that has a built-in dApp browser.
- No need to transfer custody to anyone. You sell one asset and you buy another in just one single Ethereum transaction.
- You don’t have to wait for withdrawal from an exchange. Since, trade is completed in one single transaction, the asset you’re buying also gets deposited to your address in that transaction itself. As a result, no need to pay any withdrawal fees to any exchange.
- When you withdraw from an exchange, there is a chance that you lose the funds because of a mistake in withdrawal address. However, in trades on DEXes, the asset you’re buying gets deposited to the same address where you hold the asset you’re selling. So, the risk of funds going to an address not controlled by you is minimized.
- Privacy- Only your Ethereum address is used for transaction. You don’t need to create login id and password to trade. Just an Ethereum wallet is enough to trade. And no KYC.
- Arbitrage- since the pricing is based on Automated Market Making, arbitrage opportunities arise when there is a spread between the price of the asset on DEX vs. CEX. However, there are many arbitrage bots running and hence, DEX markets are getting more efficient as a result.
The Risks & Limitations
- Fees- On uniswap, the transaction fees is 0.3% per swap and additionally, there is the Ethereum network fees (or gas) to be paid.
- Imperfect pricing- By that, we are referring to pricing being better on CEXes like Binance, Huobi, etc. However, as the volumes and liquidity pool sizes on DEXes are growing, we might be closer than not to a day where we will call pricing on a CEX imperfect. A day might come when the CEX price will follow that of a DEX.
- Not all assets are supported- DEXes currently are liquid only on Ethereum. And hence, only Eth and Erc20 tokens can be traded on them. Cryptocurrencies and tokens which do not exist on Ethereum can hence not be traded on DEXes.
- Since past few months, the Ethereum network has stayed very congested resulting to high gas prices. Such high transaction fees doesn’t make it economical for small swaps to take place on DEXes. At this point, if anyone wants to swap $100 on a DEX, the transaction fees as a % of trade size is simply not acceptable and you will be better off doing the transaction on a CEX. The problem is expected to get solved with Eth 2.0 and Layer 2 scaling solutions or if Eth gas prices fall.
- DEXes work on smart contracts deployed on top of Ethereum. Though the codes are audited or interfaces are marked ‘beta’ where applicable, there still is a risk of loss of funds for liquidity pools/liquidity providers. For liquidity takers, the risk is quite less. However, if you are keeping a lot of funds in the wallet through which you use DeFi products as well, do not forget to reduce or remove the Erc20 authorizations given to smart contracts. This can be done by using tools like approved.zone.
More Interesting Things in DEXes
- Though BTC can’t be directly traded on DEXes, the Ethereum ecosystem has brought BTC on Ethereum in the form of wBTC, renBTC, sBTC, HBTC, etc. where BTC exists as Erc20 token on Ethereum and as a result, these Erc20 Bitcoins can be traded on DEXes and used in DeFi ecosystem.
- Synthetix Exchange works differently from other DEXes. On the exchange, when you exchange one sAsset with another sAsset, the asset you are selling gets burned and the asset you are buying gets minted in that transaction rather than tokens being shifted from one address to another. The exchange rate on Synthetix is set by Synthetix’s and Chainlink’s oracles. This is called P2C (Peer to Contract) trading whereas normal DEX trades are P2P (Peer to Peer or Peer to Pool).
- Curve.fi was started as a stablecoin DEX where stablecoins like USDT, BUSD, sUSD, USDC, Dai, etc. are supported. Depending on demand and supply of these stablecoins, you will get better rate for swapping one stablecoin for another than a centralized exchange at the moment. Curve can handle transactions in hundreds of thousands and million-dollar transactions as well with slippage less than centralized exchanges. Apart from stablecoin exchanges, Curve also has a pool now for BTC Erc20 tokens like wBTC, renBTC, sBTC.
- MStable is relatively new stable asset exchange. The key feature here is that stablecoins are hard pegged 1 to 1 to each other. For eg. If you exchange 1000 USDC for USDT on curve, you might get 998 USDT or 1003 USDT, depending on demand and supply. However, on mStable, 1 USDC is strictly equal to 1 USDT. All stablecoins are hard-pegged to 1$ on mStable.
- Binance DEX is also a DEX many of us might be familiar with. Binance DEX is a DEX on Binance Chain of which BNB is the native asset. It is not built on Ethereum and like we have Erc20 tokens on Ethereum, we have BEP2 tokens on Binance Chain. WRX, for eg. Is a BEP2 token issued on Binance Chain. Like we pay network fees/gas in Eth for Ethereum transactions and Ethereum DEX transactions, we pay network fees in BNB for transactions on Binance Chain. Binance has plans to open source Binance Chain and also build a smart chain.
We hope you learned new things about Decentralized Exchanges in this article. Hop on to our telegram group and let’s talk DeFi and Crypto Trading there- https://t.me/CryptoBharatCommunity.
Feedback and comments are always welcome 😊
Authored by- twitter.com/KalpeshEm for the Crypto Bharat Community.