Decentralized exchange, also known as “DEX”, is a peer-to-peer marketplace where cryptocurrency traders make transactions directly without handing over management of their funds to an intermediary or custodian. These transactions are facilitated through the use of self-executing agreements written in code called Smart Contracts.
Decentralized exchanges were created to remove the requirement for any intermediary to oversee and authorize trades. DEXs allow users to trade directly from their wallets by interacting with the smart contracts behind the trading platform. Traders guard their funds and are responsible for losing them if they make mistakes such as losing their private keys or sending funds to the wrong addresses.
How Do Decentralized Exchanges Work?
For every buyer, there must be a seller –
Decentralized exchanges function by pairing buyers and sellers together to execute trades at a given price. The way that orders are matched can be done in a few different ways, using order books or by taking an “automated market maker” (AMM) approach.
Order books are how most traditional exchanges fulfill orders. When a person decides they want to buy or sell an asset, that person specifies the price at which they are willing to complete the transaction. This price and quantity are then entered into a queue of orders and then a match is found, the trade is executed. Most centralized crypto exchanges utilize order books as it is a fairly efficient way to pair buyers and sellers together.
In contrast, there are relatively few decentralized exchanges that utilize order books to fulfill orders. For a DEX to use order books, the order book itself would have to be stored on the blockchain which is cost-prohibitive given the amount of data required. This type of data storage also referred to as “on-chain” has become quite expensive as fees have risen over the past two years leading many DEXes to opt for an Automated Market Making (AMM) approach.
– and for every seller, a buyer.
Automated Market Making DEXs
In DEXs that utilize Automated Market Making, liquidity providers act as the counterparty for every trade. If someone is selling coins, the liquidity provider acts as the buyer. Likewise, when someone buys coins, the liquidity provider acts as the seller. In exchange for the service they provide to the exchange, liquidity providers are compensated with incentives such as trading fees and additional cryptocurrency rewards. This concept can be best understood by looking at an example.
Let’s say there are two crypto tokens, MIDAS and FTM. A user of a decentralized exchange wishes to become a liquidity provider and deposits 100 “MIDAS” tokens and 100 “FTM” tokens into a liquidity pool. The pool determines the price of the tokens by looking at the ratio of tokens in the pool. With a balance of 100 MIDAS and 100 FTM, the pool would value tokens as 1 “MIDAS” token = 1 “FTM” token.
When a trader interacts with a liquidity pool, they are effectively changing the balance of tokens in the pool – and thus the price ratio between the tokens. Let’s take a look at another example to understand how trades change the underlying balance of liquidity.
A trader decides to exchange 10 FTM for 10 MIDAS through the pool. Effectively, they are adding 10 FTM tokens to the pool and removing 10 MIDAS tokens. The new balances of the pool are 110 “FTM” and 90 “MIDAS”. Since the DEX uses the ratio of tokens to determine the price of each respective token, the price is no longer 1:1 (since the ratio is no longer 1:1). The ratio is now something like 1.22 “FTM” for every 1 “MIDAS”.
Automated Market Makers are beneficial because of low transaction costs and constantly available liquidity. Drawbacks would be for liquidity providers, whose underlying token balances can change drastically with moving market conditions. Order books are far less efficient, but users have far more control over the price at which they are buying and selling.
How To Use Decentralized Exchanges
To get started using decentralized exchanges, you must first install a web3 provider. In most cases – this is a browser-based crypto wallet that you will use to connect to decentralized apps (including DEXes)! Metamask is a good choice. If you haven’t used MetaMask before, read our guide on installing it.
Next, we have to choose which blockchain network we would like to trade on. MetaMask comes pre-loaded with the Ethereum network, but it’s pretty slow and expensive to use. Some other networks with good applications built on them are Fantom and Polygon. In this example, let’s use the Fantom network, where the MIDAS token is based.
First, we’ll have to add the Fantom network to our MetaMask. Fantom has a really good guide that walks you through each step. It’s pretty simple.
Now you’re ready to connect to a DEX and get started trading! Good Decentralized Exchanges on the Fantom network are SpiritSwap and BombSwap. Just click the “Connect” button in the top right corner and start making swaps or provide liquidity to earn rewards from Yield Farming.