What is decentralized exchange | How DEX works?
What are decentralized exchanges, how do DEXs work, and why you should use a decentralized exchange? To better understand what a decentralized exchange is, it’s important to first understand what is a centralized exchange and how centralized exchanges work?
Centralized exchange
A centralized exchange such as Binance or Coinbase is a place where people can buy, sell, or trade cryptocurrencies and tokens listed on that exchange. If you want to buy some Bitcoin then, you need to go to an exchange, sign up by providing some banking details and identifying information, and deposit some cash. Sometimes this process takes days, which accounts for one of the drawbacks of centralized exchanges. Such exchange will tell you the price based on an “order book” of people buying and selling at different amounts and you can make the transaction at your convenience.
Once you make a purchase, the exchange will show those Bitcoins in your account, and you can trade for other tokens on the exchange. Actually, you don’t really hold them, because you’re entrusting the exchange to act as a custodian on your behalf and any trading you do, like swapping Bitcoin for Ethereum occurs within the exchange database instead of occurring on a blockchain.
Further, the Centralized exchanges pool keeps cryptocurrencies in wallets which are often claimed as “hot” wallets connected to the internet and are fully controlled by the exchange. The exchange even controls your private keys but there are ways around this. As exchanges allow you to transfer your tokens to a private wallet, this adds an extra step.
The four core functions of any exchange are capital deposits, order books, order matching, and asset exchange. In order to create a fully decentralized exchange or DEXs, each of these functions must be decentralized.
Typically on cryptocurrency exchanges, the asset exchange part is decentralized by default as the assets are cryptocurrencies. The other three functions and especially deposits are usually centralized due to knowing your customer feature and anti-money laundering regulations exchanges are required to seek users identities for any capital deposits and is stored on a centralized server that contains your personal information.
What is a decentralized exchange?
A decentralized exchange (DEX) is a platform where users can trade cryptocurrencies without having to go through a mediator. Unless the entire chain is shut down, the decentralized system cannot keep anyone out. This is significant since many countries have completely banned or severely limited the usage of cryptocurrencies. Citizens of these countries require applications that their governments cannot shut down in order to access the ecosystem. If you use a centralized exchange to access the crypto world, your ability to access cryptocurrencies is no longer free or independent, and the government may still capture your assets. Uniswap, SushiSwap, Kyber, dYdX, 0x, IDEX, Balancer, DEX.ag, Airswap, Totle, 1inch, and Paraswap are some of the DEXs.

How Decentralized Exchange Works?
As decentralized exchanges use smart contracts and users get to keep custody of their funds. Every trade incurs a transaction fee along with the trading fee and in the same essence, traders interact with smart contracts on the blockchain to use DEXs. A decentralized exchange (DEX) works to handle this in one of three ways.
1. Order Book Mechanism
Decentralized exchanges compile records of all open orders to buy and sell assets for specific asset pairs. Buy orders show a trader’s willingness to buy or bid for an asset at a certain price, whereas sell orders signify a trader’s willingness to sell or ask for the asset in consideration at a specific price. The spread between these two prices determines the depth of the order book and the market price on the exchange in their initial days. The order book on decentralized exchanges is typically slow, offered limited liquidity, and typically required traders to deposit their tokens to a smart-contract controlled address to ensure orders could be automatically executed.
Many would argue made them partially centralized however, things have come along in leaps and bounds. Now there is a wide variety of decentralized order book-based exchanges in operation. As well as potentially dozens more in development. Many of these are now able to settle trades in a non-custodial and trustless manner. The order book DEX has two types: on-chain order books and off-chain order books.
2. Automated Market Maker (AMM)
The automated market maker (AMM) category now includes the vast majority of popular DEXs. AMMs assign prices to assets using a basic mathematical formula and organize them into liquidity pools, which are rebalanced when users add or remove liquidity from one side of the pool by trading further. AMMs don’t have an order book and, in general, do not handle more complicated order types such as limit, take profit, and stop-loss orders. However, they usually allow users to contribute their assets to liquidity pools in return for a share of the fees generated by trades that use these pools as a source of liquidity.
Some of the popular examples of AMM protocol-driven DEXs are Uniswap, Balancer, and Curve. The exchanges are often ranked according to the number of funds locked in their smart contracts, called total value locked (TVL). The AMM model has a downside when there is not enough liquidity in the pool. This is what we call a slippage problem, and occurs when a lack of liquidity on the platform results in the buyer paying above-market prices on their order. Further, investors are also exposed to problems like an impermanent loss.
3. DEX aggregators
These use several different protocols and mechanisms to solve problems associated with the liquidity of the network. Essentially, these platforms aggregate liquidity from several different DEXs to minimize slippage on large orders, optimize swap fees and token prices. Also, offer traders the best price possible in the shortest possible time. Further, protecting users from the pricing effect and decreasing the likelihood of failed transactions are two other significant goals of DEX aggregators. Some DEX aggregators use liquidity from centralized platforms to provide users with a better experience while remaining non-custodial by leveraging specific integrations with specific centralized exchanges.
Advantages of decentralized exchange
1. Anonymity
When users exchange one cryptocurrency for another, their anonymity is preserved on DEXs.
2. Token availability
centralized exchanges have to individually vet tokens and ensure they comply with local regulations before listing them. Decentralized exchanges can include any token minted on the blockchain they are built upon, meaning that new projects will likely list on these exchanges before being available on their centralized counterparts
3. Faster Cheaper transactions
DEX’s can facilitate faster and cheaper transactions as code does all of the validation. There is no broker that pays workers to check each transaction and earn from each transaction. The code does its job, giving you the lowest price and the most control over your trading.
Decentralized exchanges also require the user to be 100% responsible for controlling their funds. For some people, this might be a negative not everyone wants to be in charge of the safety of their assets but by shouldering the responsibility on your own your funds are as secure as you want them to be. Several million dollars of cryptocurrency have been stolen from users using a centralized exchange.
4. Reduced security risk
The appeal of decentralized exchanges (DEXs) is the security they provide, as a centralized exchange can limit your access to your crypto, restrict or halt your ability to trade it, or even fall vulnerable to hackers, on the other hand, centralized exchanges are generally far easier to use for newcomers. They can often offer fast trading because they’re not beholden to respective blockchain infrastructure.
Because these exchanges do not handle your funds, so experienced cryptocurrency users who custody their assets are at a lower risk of getting hacked when utilizing DEXs. If the platform gets hacked, only liquidity providers will face risk, not traders.
Using DEXs your currency is your responsibility and a corporation’s security vulnerabilities won’t affect you. Of course, the DEX’s code can still have vulnerabilities or be compromised. So proceed with caution, attempt to educate yourself as much as possible about the platform you’re utilizing, and take extra precautions to protect your personal assets as much as possible.
Disadvantages of decentralized exchanges
1. Smart contract vulnerabilities
In past vulnerabilities have cost millions to platforms in the crypto world, DEXs are no exception. Though there are security audits done in a decentralized exchange.
2. Technical knowledge demand
DEXs are accessible using cryptocurrency wallets that can interact with smart contracts and not only do users have to know how to use these wallets. They must also understand security-related ideas in order to keep their assets safe. As a result, users who lack basic technical knowledge may make a range of mistakes, potentially resulting in the loss of their money.
3. No Customer Service
Centralized exchanges work in a way similar to banks. They have customers whom they want to keep happy and provide dedicated service in doing so. But in a truly decentralized exchange, there is no actor on the other end. The developers who created the protocol don’t have the same relationship with users. You only have a DEX community to discuss faced difficulties. You’re responsible for your own money while dealing with a decentralized exchange.
4. Scam token listings
Anyone can list a new token on a decentralized exchange and provide liquidity by pairing it with other coins. This can leave investors vulnerable to scams. This risk is very high in DEXs as compared with centralized exchanges. DEXs are not recommended to buy newly launched tokens. They are good for established cryptocurrencies holding. Read Tips For Picking Best Cryptocurrency to Invest.
Conclusion
There are pros and cons to using a decentralized exchange. Buying newly launched tokens is risky using DEXs but instead, use it for top cryptocurrencies. After the Hardware Wallets, the second option for long-term crypto holding is DEXs and for short-term trading, centralized exchanges are recommended.