Decentralized exchange

Decentralized exchanges (DEX) are a type of cryptocurrency exchange which allows for direct peer-to-peer cryptocurrency transactions to take place online securely and without the need for an intermediary.

Overview
In transactions made through decentralized exchanges, the typical third party entities which would normally oversee the security and transfer of assets (e.g. banks, stockbrokers, online payment gateways, government institutions, etc.) are substituted by a blockchain or distributed ledger. Some common methods of operation include the use of smart contracts or order book relaying, although many other variations are possible and with differing degrees of decentralization.

Because traders on a decentralized exchange often do not need to transfer their assets to the exchange before executing a trade, decentralized exchanges reduce the risk of theft from hacking of exchanges, but liquidity providers do need to transfer tokens to the decentralized exchange. Decentralized exchanges can also prevent price manipulation or faked trading volume through wash trading, and are more anonymous than exchanges which implement know your customer (KYC) requirements.

There are some signs that decentralized exchanges have been suffering from low trading volumes and market liquidity. The 0x project, a protocol for building decentralized exchanges with interchangeable liquidity attempts to solve this issue.

Drawbacks
Due to a lack of KYC process, and no way to revert a transaction, users are at a loss if they are ever hacked for their passwords or private keys.

Although liquidity pool DEX are the most widely used, they may have some drawbacks. The most common problems of liquidity pool DEXes are price slippage and front running.

Price slippage occurs because of the AMM (Automated Market Makers) nature itself — the larger the deal, the stronger impact it has on the price. For example, if the constant product AMM is in use, every deal must keep the product xy = k constant, where x and y are quantities of two cryptocurrencies (or tokens) in the pool. So the larger is the input amount Δx, the lower is the final ratio y / x that gives an exchange price. The problem is mostly significant for large deals or small liquidity pools.

Front running is a special type of attack in public blockchains when some participant (usually a miner) seeing an upcoming trading transaction puts his own transaction ahead (playing with a transaction fee for example), making the initial transaction less profitable or even reverted.

Ideas of improving front running resistance of the constant product AMM were first discussed in a post by Vitalik Buterin.

Degrees of decentralization
A decentralized exchange can still have centralized components, whereby some control of the exchange is still in the hands of a central authority. A notable example being IDEX blocking New York State users from placing orders on the platform.

In July 2018, decentralized exchange Bancor was reportedly hacked and suffered a loss of $13.5M in assets before freezing funds. In a Tweet, Charlie Lee, the creator of Litecoin spoke out and claimed an exchange cannot be decentralized if it can lose or freeze customer funds.

Operators of decentralized exchanges can face legal consequences from government regulators. One example is the founder of EtherDelta, who in November 2018 settled charges with the U.S. Securities and Exchange Commission over operating an unregistered securities exchange.

Uniswap, which is built upon the Ethereum blockchain, has the largest trading volume of any DEX. It deployed its V3 to the Ethereum mainnet on May 5th 2021.