What are DEXs and AMMs?
An intro to Decentralized Exchanges and Automated Market Makers
Most crypto users use Centralized Exchanges (CEXs) to buy and sell crypto-assets. They provide more liquidity, have larger trading volume and have fast transaction speeds. These same factors contribute to their weaknesses.
Centralized exchanges have a single point of failure: they could be hacked and exploited. Take a look at latest big CEX hacks: BitMart lost $196M, Ascendex $77M, Kucoin $45M. They can halt trading and block users from withdrawing their funds. Centralized power can be abused.
Decentralized Exchanges are growing faster than any other crypto exchanges. As the technology and user experience advances i think it’s inevitable that they will eventually replace CEXs as the most popular exchange type.
What exactly is a DEX?
A DEX (aka decentralized exchange) is a platform that enables trading your tokens without an intermediary (e.g. centralized exchange). You don’t need to go verify yourself with KYC, nor you have to deal with the CEXs restrictions like withdrawal limits. There are two main types of DEXs: Order book based and Liquidity pool based.
Order Book Based DEX
An order book based DEXs operate similarly to CEXs, where users can buy and sell orders at their chosen prices. The main difference is that in a DEX the assets are held in the users wallets, not in exchange wallets.
Order books DEXs can be either on or off-chain. Off-chain order book are more efficient, trades remain off-chain (e.g. on a server) until they are matched and executed on-chain. dYdX, DeversiFi, Serum are some of the most popular DEXs of this type.
Liquidity Pool Based DEXs
To understand LP Based DEXs, first we need to understand what a liquidity pool is. Liquidity pools are pools of tokens that sit in a smart contract ready to be exchanged for their pair tokens.
Typically an LP holds 2 tokens and each pool has a market for that pair of tokens. Gravely simplified: when you want to swap ETH to USDC on Uniswap, you take out USDC and give ETH to the ETH/USDC pool. If you want to dive deeper into liquidity pools i recommend you watch this video:
Most liquidity pool-based DEXs use Automated Market Makers (AMM) which predefines asset prices algorithmically. AMM is one of the most innovative inventions of DeFi as it achieves high efficiency. The majority of DEXs are AMM-based like Uniswap, Curve, Balancer, Bancor, TerraSwap and Raydium.
Automated Market Makers (AMM)
AMMs makes it possible that traders can have their orders executed seamlessly without the need for a centralized market maker providing liquidity on a CEX. Orders are executed automatically via a smart contract that will calculate trade prices.
AMM is a mathematical function to price assets algorithmically based on liquidity pools. There are several AMM formulas, but we will focus on Constant Product Market Maker, as it is the most widely used.
Constant Product Market Maker
x * y = k
Popularized by Uniswap, x and y represent the quantity of two tokens in the liquidity pool, and k represents the product. The formula helps create a range of prices for the two tokens depending on the available quantities. To maintain k as constant, when the supply of x increases, the supply of y must decrease. Let’s see how it would work in action:
There are 22,538 WETH and 88,378,445 USDT in Uniswap’s WETH/USDT liquidity pool as of 19 December 2021. The ratio implies that ETH’s price is at 88,378,445 / 22,538 = 3921 USDT.
Let’s assume ETH’s price would drop to 3821 USDT on another protocol like SushiSwap. Arbitrageurs will take advantage of the price difference by buying cheap ETH on an exchange like SushiSwap and selling it for a profit on Uniswap. Arbitrageurs repeat this until the price is equal on both exchanges. This brings price stability across DeFi protocols.
Popular Automated Market Makers
Uniswap
The pink unicorn’s journey started when Uniswap version 1 was deployed on Ethereum in November 2018. From their launch to today they remained one of the top AMMs. Uniswap popularized the Constant Product Market Maker formula (x * y = k). On 2021 May 5, they launched their latest iteration, Uniswap version 3, which introduced new features such as concentrated liquidity and multiple fee tiers. Uniswap is the second largest DEX by Total value locked (TVL), only to be dethroned by Curve Finance.
Curve Finance
Curve is a DEX designed for efficient trading between similar assets. This is useful for the ecosystem as there are plenty of wrapped or synthetic tokens that need their prices to be the same as their mimicked asset. Curve uses the Stableswap Invariant AMM formula and was the first to introduce base pools and metapools. Currently Curve Finance has the largest TVL among all DEXs.
Risks to be aware of when using AMMs
Impermanent Loss
Impermanent loss is the loss of profit compared to holding the token versus providing liquidity. Your loss becomes permanent when you remove your tokens from the pool. If you want a deeper dive into impermanent loss, watch this informative video:
Price slippage and Front running
Price slippage is the difference between the expected price and the price when the trade is executed. Slippage is the highest when there’s little amount of liquidity in the pool and when a large order is executed. Low liquidity + Large orders = Bad news aka High Price Slippage. You can set your slippage tolerance in most DEXs, the lower (<1%) the better.
Orders made on an AMM are broadcasted to the blockchain for everyone. Front-runner bots make a profit by picking orders and front-running them by placing a higher transaction fee to have their order mined faster than yours, raising the price you have to pay for the asset and then selling it after you bought for a higher price. This is known as a Sandwich Attack. There are some DEXs now that offer protection against this attack like CowSwap.
Conclusion
Every day thousands of new people get into Decentralized Finance. DEXs are a crucial part of the ecosystem, as they determine the value of crypto assets relative to each other. DEXs are only going to get bigger, it’s only a matter of time when they will replace the centralized exchanges of our times.
Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing
Also, Read
- Exness Review | MoonXBT Vs Bitget Vs Bingbon
- How to Start Earning Passive Income With Crypto Lending
- Cryptocurrency Savings Accounts | Crypto Trading Bots
- BigONE Exchange Review | CEX.IO Review | Swapzone Review
- Best Bitcoin Margin Trading| Bityard Margin Trading
- Crypto Margin Trading Exchanges | Earn Bitcoin
- WazirX vs CoinDCX vs Bitbns | BlockFi vs CoinLoan vs Nexo
- BlockFi Credit Card | How to buy Bitcoin on Binance
- Huobi Trading Bot | How to buy ADA | Geco.One Review
- Crypto Copy Trading Platforms | Top 5 BlockFi Alternatives
- CoinLoan Review | Crypto.com Review | Huobi Margin Trading
- Bybit vs Binance | StealthEX Review | Probit Review
- Top paid cryptocurrency and blockchain courses
- How to use BitMEX in the USA? | BitMEX Review