GlossaryTokens and DeFi
Decentralized exchange
Definition: A decentralized exchange (DEX) is a venue where users trade tokens from their own wallets through smart contracts, with no exchange holding their funds.
A centralized exchange, such as Kraken or Binance, matches orders in a limit order book that it manages off-chain, meaning on its own systems rather than on a blockchain (Bank for International Settlements, December 2021). On a DEX, smart contracts, a separate entry, carry out trades directly on the blockchain. The US Department of the Treasury describes DEXs as facilitating trades “through an order book exchange or liquidity pools” (Treasury, April 2023). The order book and the automated market maker, which prices trades against a pool of tokens, are separate entries. Uniswap is one DEX that uses an automated market maker (Uniswap documentation). For example, a user who wants to swap a stablecoin for another token may connect a self-custody wallet to a DEX, approve the DEX’s contract to move the stablecoin, sign the swap transaction and receive the new token at the same address. The approval step is a token approval, a separate entry.
Other traders can act on a DEX user’s trade. A 2019 study by Philip Daian and colleagues documented “the widespread and rising deployment of arbitrage bots” on DEXs, which pay high transaction fees to “frontrun, i.e., anticipate and exploit, ordinary users’ DEX trades” (Flash Boys 2.0).
The open-source Mangrove Agent adds DEX execution on the user’s machine.
In their 0x protocol whitepaper of 21 February 2017, Will Warren and Amir Bandeali wrote that existing DEXs on Ethereum placed their order books on the blockchain, so market makers, dealers who quote both buy and sell prices, had to spend gas, a separate entry, each time they posted, modified or canceled an order (0x whitepaper, archived). They argued that a DEX removes “a central party which can be hacked” or “run away with customer funds”, and proposed “off-chain order relay with on-chain settlement”: signed orders are passed around off the blockchain, and a smart contract settles each trade on it.
