It would be interesting to understand how CEX works.
Couple of questions to start with:
Let's take BTC/USDT pair.
1. Do a CEX create a new BTC wallet for every client and keeps the keys with them? Or there is one wallet for the BTC/USDT pair?
2. What exactly happens when you buy/sell BTC? Where that BTC goes actually?
3. How they know who has what amount of BTC?
4. What about other pairs? Like ETH/USDT? SOL/USDT?
Thanks.
This was asked before, in a way or another, so I will be short and directly to the questions.
1. Do a CEX create a new BTC wallet for every client and keeps the keys with them? Or there is one wallet for the BTC/USDT pair?
Not at all. They probably have one BTC wallet for the whole system (actually two, one hot wallet and one cold wallet, but let's keep it simple).
And same goes for all currencies they allow to deposit and withdraw.
The BTC address you think it's yours is just a deposit address. As soon as somebody else needs a withdrawal, "your" bitcoins may be used, while your account remains credited.
Everything else happens in their internal database.
2. What exactly happens when you buy/sell BTC? Where that BTC goes actually?
In their internal database, somewhere related to your account, the numbers related one currency will decrease and for another currency they'll increase.
3. How they know who has what amount of BTC?
Their software checks their database.
4. What about other pairs? Like ETH/USDT? SOL/USDT?
Just in that same way, with the small side note that USDT may be a bit different because it can be sent on various chains, hence it may need multiple wallets, but let's not get confused by exceptions.