A decentralized exchange (DEX) is a peer-to-peer marketplace where transactions can happen between crypto traders with no intermediary.
While humans have been trading assets of value with each other for thousands of years, the first electronic trading of securities for stocks started on the Nasdaq in 1971. Since then electronic trading has flourished around the world, allowing people to trade bonds, commodities, and other assets without the need for the two parties to verify that the other party will meet the agreed upon terms of each trade such as the amount, dollar value, and settlement date. Intermediaries, also called clearinghouses in traditional finance, facilitated the exchange of payments, securities, or derivatives transactions between multiple parties. In addition, these clearinghouses ensured all legally binding terms of a trade, such as the amount, dollar value, and settlement date was fulfilled.
In 2009, Bitcoin was released, giving people a way to transfer digital money in a decentralized manner with the use of distributed ledger technology. However, Bitcoin did not allow for complex financial transactions available in traditional finance such as borrowing/lending, derivatives, exchanges to trade stocks, or insurance. Ethereum, a decentralized public blockchain released in 2015, added smart contract capability. Complex financial transactions could now be coded into decentralized applications (dApps), allowing transactions such as swaps or derivatives to be done using blockchain technology.
In 2018, Uniswap was released on the Ethereum platform. Uniswap became one of the most successful decentralized exchanges that allowed individuals to trade digital assets without the use of an intermediary. DEXs became the foundation of blockchain ecosystems, creating liquidity and a market value for many tokens that are not available on centralized exchanges (CEXs). By 2022, there was $67 billion in total value locked (TVL) in DEXs. TVL is the total market value of cryptocurrencies deposited into smart contracts.
Today, multiple ecosystems such as Cardano, Solana, and Polkadot have DEXs. On Cardano, Genius Yield has created the Genius DEX, an order-book style DEX allowing users to trade Cardano’s native tokens using Smart Swaps. Smart Swaps are similar to the order types available to you on traditional stock exchanges such as limit, stop-loss, and complex algorithmic orders.
What is a DEX?
A DEX is a decentralized peer-to-peer (P2P) marketplace where users can trade digital assets with each other without an intermediary. A DEX’s operation is essentially based on a smart contract, or self-executing code that fulfills transactions based on predetermined conditions for different parties. These smart contracts are created using programming languages like Plutus and Solidity, the languages used to create dApps on Cardano and Ethereum, respectively. The transactions of DEXs are validated and executed on the blockchain by each platform’s distributed node network. Like other transactions on decentralized blockchains, smart contract transactions enjoy the same immutability.
However, the security of each dApp is not the same as the security of the public blockchain they are built on. For example, in the Ethereum Dao hack of 2016, “the DAO” was created by start-up firm Slock.it using a smart contract. The DAO, or decentralized autonomous organization, would become a for-profit, crowdfunded investment fund, allowing users to buy “DAO tokens” with Ether. The Ether would be used by the DAO to fund business ventures that DAO tokens holders could vote on. A hacker spotted a vulnerability in the DAO’s open-source code and siphoned away around $60 million USD worth of users’ Ether that had been held by the DAO smart contract. It’s important to note that the Ethereum blockchain was never compromised in the DAO hack, only the faulty code of the DAO smart contract created by an independent developer.
The truth must be noted by all potential users of dApps on the Cardano blockchain as well. While the Cardano blockchain may be deemed sufficiently secure from manipulation, the hundreds of dApps made by multiple developers of varying experience and skill may not be secure. Being a decentralized blockchain, any person can launch a dApp on Cardano. A smart contract can only be as good as a developer's ability to make high assurance, secure code.
The Role of Liquidity Providers
In traditional stock exchanges, market makers ensure liquidity, or that traders will be able to buy or sell a stock at any time. Typical market makers are major brokerage houses that provide liquidity for stocks and profit off of the difference in bid-ask spreads. In traditional finance, these are centralized, heavily regulated and monitored entities. In DEXs, market makers are essentially replaced by liquidity providers (LPs). LPs provide liquidity to a DEX in exchange for trade fees charged to users who trade their digital assets on the DEX using the LP’s liquidity. An example would be a LP depositing 500 GENS and 1,000 ADA to the Genius DEX for the ADA / GENS trading pair. When a trader buys or sells ADA or GENS on the Genius DEX using the LP’s liquidity, some of the trading fees charged to the trader goes to the LP. Trade volume and fees are very important because they incentivize LPs to provide liquidity in the hope of high returns from trade fees. If a DEX’s or trading pair’s volume is too low, LPs will withdraw their liquidity to seek higher yield elsewhere.
Types of DEXs
- Automated Market Maker (AMM) DEX - In an AMM DEX all LPs’ funds are aggregated into one liquidity pool for each trading pair. Each trader buys or sells directly with that pool for each asset pair. As traders buy and sell, the global price, or ratio of the pool constantly updates, which becomes the price that all traders must transact at in that liquidity pool. The global price for asset pairs in an AMM DEX is determined by the constant product formula (x*y=k). In this formula, (x*y=k), x and y are the amount of the two tokens, A and B, in the liquidity pool. The formula dictates that the tokens in a liquidity pool, or k, must remain at a fixed relative value. This figure from the Genius DEX whitepaper by Genius Yield provides an illustration of the constant product formula below:
- Order-book model - While the AMM DEX model was an innovation due to the limitations of blockchains like Ethereum’s account-based model whose functionality is dependent on a global state, the order-book model has been utilized historically in traditional finance The order book refers to a list of buy and sell orders for a specific asset. A matching engine, or bot, is used to match orders from buyers with sellers for full or partial execution. More complex order types and trading strategies can be implemented when using the order-book model, such as trailing stop-loss orders or orders that utilize technical analysis such as Bollinger Bands or Relative Strength Indicators. Below is an order-book, its trades, and its market depth from Binance for the ADA/USDT trading pair.
Using a DEX exposes a user to known risks such as price risk, but some DEXs come with additional risks not seen in traditional stock trading. AMM DEXs have a unique risk caused by the constant product formula called impermanent loss, which happens when the total value of a LP’s deposited liquidity changes compared to the value the LP would have had from just holding the assets. This risk of impermanent loss is caused by the constant product formula, which changes as users buy or sell from the liquidity pool. Order-book DEXs like the Genius DEX have eliminated impermanent loss due to the benefits of Cardano’s EUTxO model, which doesn’t have a global state. Users of DEXs should be aware of the potential outcome of their decisions, as there is risk that comes with the use of any DEX.
DEXs, being non-KYC (Know-Your-Customer), allow the trading of digital assets that may not be available on traditional finance exchanges or centralized exchanges (CEXs). DEXs also provide liquidity and fair pricing of digital assets. In addition, DEXs enable other dApps such as P2P lending, where traders can utilize DEXs to do leveraged trading.
DEXs have also been used to fund new projects via initial DEX offerings (IDO), which is a new token offering run on a DEX. A IDO typically lets users lock their digital assets in exchange for the new tokens during the token generation event (TGE). The funds that are raised are added to a liquidity pool with the new token before later being returned to the new project.
Legally, DEXs face many legal conundrums that other decentralized blockchain based applications do. DEXs don't have KYC requirements, so digital assets considered illegal in some countries can still be traded on a DEX by that country’s citizens. In addition, synthetic assets, which mirror registered securities that are only allowed to trade on regulated exchanges, can also trade on DEXs. Due to regulatory pressure in 2021, Uniswap removed over 100 tokens from its main interface, many of them synthetic tokens made to mimic equities traded on stock exchanges. However, users could still trade the synthetic token by interacting directly with the token’s contract.
DEXs have the ability to allow entities to evade international economic sanctions. While centralized exchanges could block entities or people from using exchanges, DEXs can be used to avoid sanctions due to not being monitored by a central authority. Even though transactions may be recorded on the blockchain, the pseudonymity granted by exchanges can obscure transactions, making it harder for entities to enforce sanctions.