My question is how cryptocurrency exchanges like Binance or Coinbase record users trade into blockchain technically. For example when Mr.X buys BTC/USDT pair from Mr.Y, how does the exchange record these two Transactions into the blockchain. as far as I know, We have two transactions now, Mr.X has to sign a USDT transaction to Mr. Y's account & Mr.Y has to sign a transaction for Mr. X's BTC wallet on that exchange. I was wondering how exchanges manage network fees? & how they record these trades into blockchain I also know Mr.X order will probably fulfill with different accounts but I just want to simplify my question thank you.
As far as I know both of them are centralized entities so what happens is:
Mr X and Mr Y send their crypto to the exchange controlled wallets. The exchanges keep the record in their own DB/ledger who owns what. Then when Mr Y and Mr X make a trade the exchanges record that trade in their own DB/ledger and nothing is recorded on public blockchain. Now Mr X withdraws the crypto from one of the exchanges and it gets recorded on public blockchain (If he withdraws BTC then it will be recorded on BTC blockchain). So Mr X and Mr Y can do thousands of trades without paying network fees as everything happens in the exchange's internal system (they may have per trade fee)
DeFi - I have no idea how it works, as didn't dig into it :)