What is a decentralized exchange?
You might have an idea about what an exchange is, in the traditional sense of it. It’s a marketplace where buyer and seller come to exchange money for goods, stocks, commodities, etc. And you might have an idea about how to run an exchange, with an order book, where people can put in their limit orders, stating that they’d like to buy or sell X for Y. Others can then come to match and manage these, in order to perform a trade. Market makers play a part in ensuring there’s liquidity available.
Decentralized exchanges tend to work a little differently. Firstly, they are represented by smart contracts, and depending on how much “admin access” is coded in to these, a decentralized exchange, or DEX for short, can be more or less decentralized. However, no matter where they are on the DeFi/CeFi scale, a DEX must incorporate some form of decentralized logic. If it does not, it is simply a traditional exchange, or a centralized exchange. There are many centralized exchanges out there, including NYSE and NASDAQ for traditional markets, and Coinbase and Kraken for crypto markets.
Decentralized exchanges operate through the use of smart contracts, as said. And they typically operate as Automated Market Makers (AMM), where, instead of an order book, you have users providing liquidity through a token pair. Say you want to provide liquidity for people trading BTC and DAI. Assuming the current BTC price is $10000, I would provide 1 BTC and 10000 DAI (because each DAI is worth $1). In return for this service you receive trading fees. Your risk as a liquidity provider is your exposure to the two tokens in the token pair. You are not a trader in this example, but you help traders by providing liquidity.
If you provide liquidity to the BTC/DAI token pair as described above, and I want to sell my BTC in return for DAI, I would add BTC and take DAI from the liquidity pool. I can’t take more of any token than what’s available, and I can’t leave any form of limit order. There is no order book. The trade is filled by the liquidity pool there and then. How many DAI I get in return for my BTC is determined by a formula which defines the constant relationship between the two tokens. On a DEX like Uniswap, this formula is x * y = k. Going with the above liquidity example, as the liquidity provider put in 1 BTC and 10000 DAI, x = 1, and y = 10000, making k = 10000. Should I then add 0.1 BTC (because I’m selling BTC), making the total liquidity of BTC 1.1, I would need to take out 909.09 DAI, in order to maintain a k = 10000. We can confirm by doing (1 + 0.1) * (10000 – 909.09) = 10000 (x = 1.1, and y = 9090.91). So I got 909.09 DAI in return for my 0.1 BTC, not including fees and slippage.
Through this system, anyone can offer any token pair. For Uniswap and other similar DEXes, there’s no admin or similar approving the on-boarding of a new token. Likewise, there is no admin feature to ban any token. While frontends, like websites and similar, might be censored, the smart contract representing the DAX can’t. There is no code available to block any particular token, no matter how much the regulator or authorities would like there to be. Likewise, there is no KYC. Anyone with an Ethereum account can provide liquidity or participate in a trade transaction. Like what was pointed out around approaches for on-chain stablecoin regulation, it is likely a more fruitful endeavor for regulators to target the on/off ramp, represented by centralized exchanges.