If you want to learn about what is the decentralize exchange then first of all you have to learn about what is the centralize exchange.Here i basically talking about the coinbase and the craking and other centralize exchanges.
centralize exchanges mainly covers the broad area of the exchanges they are user friendly and easy to understand to the user also.It also has the good liquidity but what is this liquidity .Let consider you have the two properties one of it is in the mumbai and other one is in the small village away from the mumbai and you want to sell both of this properties.So which properties is easy to sell.Yes mumbai's property is easy to sell in the today world. Why it is happen because of mumbai possess the very small amount of the land for the human to live so in the above example mumbai carries the high liquidity than the village land.so right now you know why the centralize exchange carries this much big volume in the cryptocurrency.
now we go further and study how the centralize exchange mainly work. So first we need the traders and other things such as a server of the exchange.Then that trader have to fund their account with some crypto to transfer it to the other address of the extension such as ether or any other cryptocurrency.After this that particular crypto does not belong to them they belong to that particular exchange before any trading. After that we need some liquidity on the that particular exchange.But that traders create some limit order also.In that limit order you have to specify a couple of things such as a which market you want to trade example bitcoin,USD or any other.Then you have to specify buy or sell then you have to specify your limit price so if you are buying then it going to the max buying price and if you are sell then it going to minimum selling price.Finally you have to specify the amount that you want to trade and after it is going to be put in the database that we called an the old book.So that old book mainly have the two columns that buy order and sell order columns.
This order book mainly solid from the prices so for the sell order they are solid from the lower prices to the highest.Here we use the two prices because the best sell orders have a low limit price and for the buy orders that's the country that sorted from the highest price to the lowest price because the best buy order are the one with a high limit price and at this point you have the database that carries all the summery of the intentions of the traders.But at this point you don't done any type of the trading if you want to try to happen the particular trading you need another thing called as the market order that market order is not the account order where you have to specify the bucket in which you want to be trade then you have to specify if buyer or the seller then you have to specify the amount that you want to trade but you don't specify any price in the market order. you just say that hey i want to trade this much at whatever price and what happen is that after you send your order to the centralize exchange is going to be matched in the order book with the counterparty so for the example if you want to sell an asset it is going to matched against buy limit order and it uses what we call the price limit matching algorithm so that means first is going to start from the best price so if you have a cell of the best price at highest price and after that in priority is going to take the oldest order it's going to consume the liquidity of this order and if you order is too big then the algorithm is going to move on the next order so maybe if we have another order at the same level but that was created after that's going to be the second one that can be used etc and maybe that if your order is too big it is going to use all the liquidity for this price level so after that you are going to move on the next price with the help of the algorithm until that you have fullfill your order or after you get ready you went to your crypto asset then you can easily transfer the crypto to another address easily and here the centralized exchange is done.