Decentralized exchanges (DEX) are a type of cryptocurrency exchange that allows for peer-to-peer cryptocurrency transactions without the use of a middleman. Decentralized exchanges can also prevent price manipulation and fake trading volume through wash trading, and are more anonymous than centralized exchanges with KYC requirements. A DEX can yet have centralized components, meaning that a central authority retains some control over the exchange.
A blockchain or distributed ledger replaces the conventional third-party entities that would normally manage the security and transfer of assets in transactions done through decentralized exchanges. Smart contracts and order book relaying are two prominent means of functioning, although there are many other options available, each with varying degrees of decentralization.
DEXs interface with externally owned wallets, and trades are self-executed via smart contracts. By owning your private keys, centralized exchanges act as a custodian for your cash. Although you must give up control of your private keys, centralized exchanges provide trust and security.
DEXs employ the same "gas" cost structure as the blockchain they’re built on. In addition to paying gas fees, DEX users pay a fee of roughly 0.3% to swap tokens.