Member-only story
Decentralized Exchanges (DEX) are a key foundation for the DeFi ecosystem. They give you the ability to trade and swap one cryptocurrency for another peer-to-peer, without the need for third parties such as a centralized exchange or traditional financial institutions.
Still, we have to ask: Why worry about implementing decentralized exchanges if we already have their centralized counterparts? How do DEXes actually work, and more importantly, why are they important for the DeFi space?
Decentralizing exchanges
If you are familiar with centralized exchanges (CEX), you will have no trouble understanding how decentralized exchanges work. In a centralized exchange, a central entity or corporation (see Coinbase) facilitates the trades between their users through a centralized order book which tracks every order in the platform. CEXes are responsible for aggregating these orders, matching them, and executing the actual buy and sell transactions on behalf of users.
The fact that users need to delegate the execution of transactions to the exchange translates into them not having full ownership of their keys, as CEXes need to be able send transactions on traders’ behalf to execute their orders. In practice, what CEXes do is pool users’ cryptocurrencies in a number of “hot” wallets…