Introduction to Decentralized Exchanges
Decentralized crypto exchanges (DEX) are exchanges that allow direct, online peer-to-peer transactions without the need for an intermediary.
Decentralized exchanges face some challenges traditional centralized exchanges don’t have. Particularly the pricing is difficult because access to external price information is difficult.
There are two types of decentralized exchanges, exchanges with an automated market maker or with an order book.
Automated market makers can be either curve-based or oracle-based.
Oracle-based decentralized exchanges receive their price information from a blockchain oracle. The oracle requests other (centralized) exchanges, aggregates the prices and submits the final price to the decentralized exchange. This procedure has the advantage that the price is always close to the general market price. The downside is that the service depends on a more or less centralized oracle. If the oracle is compromised, the pricing algorithm can be influenced, and attackers can rob the exchange of its money.
Curve-based decentralized exchanges don’t rely on outside data for their pricing. Instead, they use a mathematical function to calculate the price. The only variables that go into the function are the amounts of tokens in the liquidity pool. Differences in the market price are equaled out by arbitrage traders that buy too cheap tokens and sell too expensive tokens.