1. Home
  2. Knowledge Base
  3. Educational
  4. Explainers
  5. Decentralized Exchanges

Decentralized Exchanges

Decentralized Exchanges (DEXs) are a subset of DeFi protocols where a variety of digital assets can be traded. As any DeFi protocol, DEXs are simply software programs that run “on top of” a blockchain, and users can employ them to conduct a variety of economic activities and financial transactions.

An important aspect to recognize is that unlike the traditional financial system that requires users to provide personal information for a third party to make transactions on their behalf, DEXs are public software that anyone can directly interact with and do not require them to share personal information to issue a transaction. Furthermore, because transactions are done via smart contracts, DEXs are non-custodial and users do not have to trust a third party with their assets.

There are two kinds of DEXs that are popularly used, the first uses an on-chain order book much like in a traditional stock exchange to match buyers and sellers. However, as the name implies, the matching process occurs on-chain – i.e., on the blockchain – through smart contracts and without intermediaries. Essentially, matching is performed automatically through the software  identifying compatible orders and organizing transaction information to broadcast it to the blockchain, targeting the smart contract that handles the order book’s settlement.

Another popular DEX is known as an automated market maker (AMM) and that uses the ratio of two assets in a special-purpose smart contract called a liquidity pool in which users (known as liquidity providers) deposit assets for others to trade and in return receive a portion of the trading fees. The AMM uses the ratio to determine the relative price of two assets. In this formula, x and y represent the assets and k represents the constant product value. The AMM calculates the prices of each asset based on their supply and demand: as x increases in supply, its price decreases to maintain a constant product value of k. As the transactions are validated by the underlying blockchain, new prices are calculated in real-time.

The price determination is the key difference between the two types of DEXs: while on-chain order books determine price based on what is set between buyers and sellers, AMMs determine price based on the ratio formula above.

How can we help?