A decentralised exchange (DEX) is a peer-to-peer marketplace to trade cryptocurrencies without an intermediary to handle the transfer and custody of funds. Via smart contracts based on blockchain technology that allows the exchange of assets, DEXs replace conventional intermediaries like banks, brokers, payment processors, and other institutions.
DEXs provide full transparency on the flow of funds and mechanisms facilitating exchange, in contrast to conventional financial transactions, which are opaque and conducted via intermediaries with limited visibility into their activities. User money doesn’t transit through a third party’s cryptocurrency wallet when trading. Thus, DEXs lessen counterparty risk and potentially lower systemic centralisation issues within the crypto ecosystem.
Due to their permissionless composability, DEXs are a cornerstone of decentralised finance (DeFi) and a major “money LEGO” to develop more complex financial products.
The swift growth of DEX spot volume. Source: The Block Crypto Data.
This article describes the operation of decentralised exchanges, the categories of DEX, and the advantages and hazards they pose to the crypto sector.
How Do Decentralised Exchanges Work?
Regarding feature sets, scalability, and decentralisation, there are a variety of DEX designs, each with its pros and cons. The two most typical kinds are order book DEXs and automated market makers (AMMs). DEX aggregators, which filter through numerous DEXs on-chain to get the best pricing or lowest gas cost for the user’s intended transaction, are another popular kind.
Leveraging blockchain technology and unchangeable smart contracts to create a high level of determinism is one of the main upsides of DEXs. In contrast to centralised exchanges (CEXs), where the platform supports trading through the exchange’s internal matching engine, DEXs execute deals via smart contracts and on-chain transactions. Moreover, DEXs let users retain complete control of their funds through self-hosted wallets while trading.
Typically, DEX users must pay two sorts of costs: network fees and trading fees. Network fees are the gas cost of the on-chain transaction. In contrast, trading fees are charged by the underlying protocol, its liquidity providers, token holders, or a mix of these entities as stipulated by the protocol’s design.
Many DEXs aim to provide permissionless, end-to-end, on-chain infrastructure with no central points of failure and decentralised ownership among a community of diverse stakeholders. Typically, protocol administration rights are given to a decentralised autonomous organisation (DAO) governed by a community of protocol stakeholders who vote on crucial protocol features.
However, it’s challenging to maximise the protocol’s decentralisation while maintaining competitiveness in a crowded DEX landscape. The DEX’s core development team typically makes more informed decisions regarding mission-critical protocol functionality than a dispersed group of stakeholders. Many DEXs opt for a decentralised governance structure to boost censorship resistance and long-term resilience.
Order Book DEXs
The order book, a real-time compilation of open buy and sell orders in a market, is the linchpin of electronic exchanges. Order books enable the internal systems of exchange to match the buy and sell orders.
Historically, fully on-chain order book DEXs have been less prevalent in DeFi, since they require every order book interaction to be recorded on the blockchain. This necessitates a far larger throughput than most existing blockchains can deal with or substantial sacrifices in network security and decentralisation. Consequently, early implementations of order book DEXs on Ethereum had relatively limited liquidity and a bad user experience. Nonetheless, both exchanges showed how a DEX could promote trade via smart contracts.
Thanks to scalability improvements like layer-2 networks such as optimistic rollups and ZK-rollups and the advent of higher-throughput and app-specific blockchains, on-chain order book exchanges are now practical and attract a substantial amount of trading activity. In addition, hybrid order book designs have increased in popularity, where order book maintenance and matching operations occur off-chain, and transaction settlement happens on-chain.
The order book DEXs 0x, dYdX, Loopring DEX, and Serum are popular.
Automated Market Makers (AMMs)
Automated market makers are the most popular sort of DEX due to their ability to provide immediate liquidity, democratised access to liquidity provision, and permissionless market creation for any token. Essentially, an AMM is a money robot that preparedly quotes a price between two (or more) assets. An AMM employs a liquidity pool against which users can swap tokens, and an algorithm decides the price based on the percentage of tokens in the pool.
Since they can offer a price for a user, AMMs provide instantaneous access to liquidity in markets that may otherwise be less liquid. In the case of an order book DEX, an interested buyer must wait for their order to be matched with a seller’s order; even if the buyer places their order at the current price at the “top” of the order book, the order may never be executed.
Compare CEX with AMM DEX and Order Book. Source: Coin98
A smart contract determines the exchange rate in the event of an AMM. Users have quick access to liquidity, while liquidity providers (depositors in the AMM’s liquidity pool) generate passive revenue via trading fees. This combination of immediate liquidity and democratised access to liquidity provision has facilitated a burst of new tokens released via AMMs and unlocked innovative designs emphasising specific use cases, such as stablecoin swaps. If you want a more in-depth examination of AMMs, please read this page on how AMMs function.
AMMs can be used to support exchanges of NFTs, tokenised real-world assets, carbon credits, and much more, although most existing AMM designs deal with cryptocurrencies.
Bancor, Balancer, Curve, PancakeSwap, Sushiswap, Trader Joe, and Uniswap are prominent AMM DEXs.
What Advantages Do Decentralised Exchanges Provide?
As deterministic smart contracts govern DEX transactions, they are likely to execute precisely as the user intended without the interference of centralised parties. In contrast to the opaque execution mechanisms and the possibility of censorship prevalent in conventional financial markets, DEXs provide robust execution guarantees and enhanced transparency into the underlying trade processes.
DEXs lower counterparty risk since no custodians are involved, and consumers can participate using their self-hosted wallets. By lowering the amount of capital in the wallets of a limited number of centralised exchanges, DEXs mitigate some systemic risks in the blockchain sector. Mt. Gox was responsible for a significant amount of Bitcoin trading activity in 2014 before unexpectedly ceasing operations due to the loss of hundreds of thousands of bitcoin.
Additionally, DEXs promote financial inclusion. While some user interfaces have restricted access based on geographic location or other considerations, accessing a DEX’s smart contracts needs an Internet connection and a compatible self-hosted wallet. Unlike a centralised exchange, the onboarding procedure for a DEX is simple and nearly immediate since users can sign in quickly using their wallet address.
DEX Risks and Factors to Consider
Strong execution guarantees, enhanced transparency, and permissionless access enable DEXs to democratise access to trade and liquidity provision. The dangers associated with DEXs include, but are not limited to the following:
Smart contract risk
Blockchains are regarded as very secure for completing financial transactions. Nevertheless, the quality of a smart contract’s code is contingent on the expertise and experience of the team that built it. It is possible for smart contract faults, hackers, vulnerabilities, and exploits to arise, exposing DEX users to fund loss. Developers can decrease this risk through security audits, peer-reviewed code, and solid testing techniques, but vigilance is always necessary.
Liquidity risk
While DEXs are growing in popularity, certain DEX marketplaces have inadequate liquidity, resulting in significant slippage and a bad user experience. Due to the network effects of liquidity (high liquidity draws more liquidity, and low liquidity draws less liquidity), a substantial percentage of trading activity is still performed on centralised exchanges, which often results in reduced liquidity on DEX trading pairs.
Frontrunning risk
Due to the public nature of blockchain transactions, DEX trades are susceptible to being frontrun by arbitrageurs or maximal extractable value (MEV) bots that attempt to drain wealth from unaware users. Similar to high-frequency traders in conventional markets, these bots attempt to exploit market inefficiencies by paying higher transaction fees and optimising network latency to profit from the DEX transactions of regular users.
Centralisation risk
While many DEXs strive to increase their decentralisation and censorship resistance, centralisation dangers might still exist. These include, among others, the DEX’s matching engine being located on centralised servers, the development team having administrative access to the DEX’s smart contracts, and the use of low-quality infrastructure for token bridging.
As the exchange of assets is mediated by a blockchain, utilising a DEX may be costly or impossible if the network encounters congestion or outage, exposing DEX users to market fluctuations.
Token risk
As many DEXs provide permissionless market formation – the potential for anybody to launch a market for any token — the risk of purchasing low-quality or malicious tokens is greater than on controlled exchanges. Hence, DEX users must evaluate the risks connected with early-stage project participation.
In addition to the above, some users find having complete control over their private keys intimidating. While having full control over one’s assets is one of the primary advantages of the Web3 vision, many opt to entrust their assets to a third party. However, robust security and essential management procedures enable more people to experience the advantages of preserving complete control over their assets while gaining access to an advanced ecosystem of open-source financial services.
How Do DEXs Improve Security and Unlock Advanced Features?
Using Chainlink oracle services, DEXs strengthen the robustness of their protocol and provide complex functionality familiar to users from centralised infrastructure.
Chainlink Price Feeds provide precise, secure, and dependable financial market data on cryptocurrencies, commodities, FX, indices, and more, securing tens of billions of dollars for DeFi applications throughout the multi-chain ecosystem. Using Chainlink’s decentralised oracle networks, dApps obtain and perform actions based on off-chain pricing data in a simple, safe, and decentralised way.
DEX protocols can use Chainlink Price Feeds for reliable price conversions, correct price display on the frontend, and secure stakeholders’ computation of staking rewards and fee distributions. Price Feeds guarantee the proper pricing of collateral assets and the appropriate processing of liquidations on DEXs involving margin or futures contracts.
Chainlink Price Feeds can also be used by DEXs seeking to strengthen the resiliency of their protocol against anomalous market occurrences, which a battle-tested source of price data can assist in protecting against. Secure pricing infrastructure also enhances the security and accuracy of infrastructure for price monitoring and financial research and facilitates the creation and management of arbitrage schemes across several decentralised exchanges.
Chainlink Keepers, a decentralised automation solution, is ordinary in the DeFi ecosystem in the deployment of advanced features through end-to-end smart contract automation. Chainlink Keepers use decentralised and trustworthy off-chain computing to monitor user-defined circumstances and run on-chain functions when those criteria are met.
Chainlink Keepers can activate limit orders when asset prices reach predetermined price thresholds, giving traders greater granular control over their portfolios and freeing up development teams’ time and resources to improve the protocol’s fundamental business logic. Additionally, Keepers can be used to automate the periodic distribution of trading fees and staking rewards.
Conclusion
DEXs are a fundamental component of the cryptocurrency ecosystem, enabling peer-to-peer trading of digital assets without the need for intermediaries. In recent years, DEXs have gained popularity because they provide quick liquidity for freshly issued tokens, a simple onboarding process and democratised access to trading and liquidity provision.
It is unknown if the bulk of trading activity will transfer to DEXs and whether existing DEX designs will sustain long-term growth and institutional acceptance. However, it is expected that DEXs will continue to serve as an essential component of the crypto ecosystem’s underlying infrastructure, with advancements in transaction scalability, smart contract security, governance infrastructure, and user experience.