Bitcoin Forum
June 24, 2024, 06:54:34 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How CEXs work?  (Read 150 times)
a298b112 (OP)
Member
**
Offline Offline

Activity: 141
Merit: 36


View Profile
November 03, 2022, 03:01:38 PM
Merited by DdmrDdmr (3)
 #1

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.

OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3514
Merit: 6176



View Profile
November 03, 2022, 03:11:32 PM
Merited by DdmrDdmr (3), bitmover (2), ABCbits (1), hosseinimr93 (1)
 #2

1. They give one or multiple addresses for each user for the different coins there are and yes, they do keep the private keys.
2. It's just 1's and 0's moving around in their database. You're not broadcasting a bitcoin transaction when you're trading your BTC for another coin.
3. A deposit address is unique and connected to your account (user ID), no two people can have the same deposit address.
4. It's the same concept for all coins. They'll just subtract and add from/to your account's balance from their database.

Also:

- When you deposit to your BTC address, for example, the funds may not stay there (if you check the blockchain) and can be sent elsewhere (sent to the exchange's other hot wallets, or to somewhere else) which means that when you request a withdrawal, the funds will be coming from another address, and not the same you used to deposit.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NeuroticFish
Legendary
*
Offline Offline

Activity: 3710
Merit: 6432


Looking for campaign manager? Contact icopress!


View Profile
November 03, 2022, 03:16:13 PM
 #3

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.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
mk4
Legendary
*
Offline Offline

Activity: 2800
Merit: 3855


Paldo.io 🤖


View Profile
November 03, 2022, 03:16:21 PM
 #4

1. They generate a wallet (whereas the have access to the keys, of course) every time a user creates an account (hence generates a wallet address)

2. The BTC doesn't necessarily move. The exchange just keeps a database(a digital list) of which user owns which coins/tokens and what amount. Exchanges doing an on-chain transaction every time someone makes a transaction would make it too expensive for them

3. Through the usage of a well-managed database

4. Same exact process for 99.9% of coins/tokens



The deposit process is usually like this in the back end:

Deposit to user-specific generated address -> exchange automatically moves deposited funds to a central hot wallet

^ But your exchange balance stays the same, because you're sort of "entitled" to the funds, despite the funds not existing anymore on the deposit address.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bitmover
Legendary
*
Offline Offline

Activity: 2338
Merit: 6024


bitcoindata.science


View Profile WWW
November 03, 2022, 03:17:24 PM
 #5

Just to add to OmegaStarScream answer.  Nothing happens in the blockchain until you deposit / withdrawal funds.

All transactions and trades that happen in a centralized exchange never leave their wallet (except withdrawal )

You are literally trusting your money to them all the time , and all trades are off chain.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
a298b112 (OP)
Member
**
Offline Offline

Activity: 141
Merit: 36


View Profile
November 03, 2022, 03:18:11 PM
 #6

1. They give one or multiple addresses for each user for the different coins there are and yes, they do keep the private keys.
2. It's just 1's and 0's moving around in their database. You're not broadcasting a bitcoin transaction when you're trading your BTC for another coin.
3. A deposit address is unique and connected to your account (user ID), no two people can have the same deposit address.
4. It's the same concept for all coins. They'll just subtract and add from/to your account's balance from their database.

If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3514
Merit: 6176



View Profile
November 03, 2022, 03:25:04 PM
Last edit: November 03, 2022, 03:43:09 PM by OmegaStarScream
Merited by ABCbits (1), mk4 (1)
 #7

If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?

When you first make an account, they assign an address to you. Imagine the following table in their database (let's say we already have funds in our accounts):

Code:
+-----------------+-------------+---------+
|      User       | btc_address | Balance |
+-----------------+-------------+---------+
| OmegaStarScream | bc1q123     | 5 BTC   |
| a298b112        | bc1q789456  | 2.5 BTC |
+-----------------+-------------+---------+

So now, whenever you trade your BTC to USDT for example, all they need to do is update your record based on how much you bought or sold without having to touch the bitcoin or ethereum networks. So if you sold 1 BTC for 20K USDT,  it would be something like this:

Code:
UPDATE users_table
SET btc_balance = btc_balance - 1
WHERE user= 'a298b112'

Code:
UPDATE users_table
SET usdt_balance = usdt_balance + 20,000
WHERE user= 'a298b112'

So as I mentioned above, It's only when you request a withdrawal that they broadcast the transaction to the network.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bitmover
Legendary
*
Offline Offline

Activity: 2338
Merit: 6024


bitcoindata.science


View Profile WWW
November 03, 2022, 03:26:49 PM
 #8


If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?

There are no transactions to broadcast when you trade.
Let's suppose user A deposit 1 btc in the address Aaaaa and the user B deposit 2 btc at the address Bbbbbb

If the user B sells 1 btc to the user A, there is no btc moving to the adresss Aaaaa. The balance that you see inside user A account is not related to the blockchain, but an internal cex database.

If the user A decide to withdrawal 2 btc, it will get 1 btc from the cex hot wallet  and one from the address Aaaaaa... or maybe broth btc from the hot wallet.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
mk4
Legendary
*
Offline Offline

Activity: 2800
Merit: 3855


Paldo.io 🤖


View Profile
November 03, 2022, 03:27:03 PM
 #9

If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?

Again, centralized exchanges doesn't necessarily make on-chain transactions once a user makes a trade. It mostly only happens on withdrawals, or with them moving funds to a central hot/cold wallet in the back end.

But yea, exchanges do cause a lot of on-chain transactions in it's entirety due to previously said reasons alone.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
hosseinimr93
Legendary
*
Online Online

Activity: 2436
Merit: 5401



View Profile
November 03, 2022, 03:34:37 PM
Last edit: November 03, 2022, 03:48:03 PM by hosseinimr93
 #10

If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?
Note that the deposit address they give you isn't owned by you. The address is owned by the exchange and they give it to you, so you can make a deposit. You have no control over that address.
So, when you sell your bitcoin to someone in the exchange, there is no need to make a transaction from your deposit address to someone else deposit address. All deposit addresses are owned by the exchange and they have full control over the funds, whether it's in your deposit address, another user deposit address or their hot wallet.

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
MainIbem
Sr. Member
****
Offline Offline

Activity: 1386
Merit: 400


Defend Bitcoin and its PoW: bitcoincleanup.com


View Profile
November 03, 2022, 11:27:06 PM
 #11

There is also something I understand, while trading in cex for instance; Mr A wants to buy btc from Mr B, what happened then A has btc while B has usdt what does that mean, they stand as a middle men or an escrow to release your btc and then gives you usdt so it's to other pairs. In term of address just like few people already narrated here, your registration email is your authentic deposit address for any coin or token listed on that exchange for example big exchange like binance does it and once your account is being created all addresses is being assigned to you and it doesn't interacts with others nor associated with another users address.
But there's something i don't like about cex is that whenever you made a mistake send token or coin to the wrong address they fails to help you retrieve your token why then they don't allow us own each private keys of those coin in the exchange?
Yes because they believe everyone is liable to his mistake and for that no more request to retrieve funds mistakenly sent to the wrong. This is the place I don't like cex.

▄▄▄███████▄▄▄
▄█████████████████▄▄
▄██
█████████▀██▀████████
████████▀
░░░░▀░░██████████
███████████▌░░▄▄▄░░░▀████████
███████
█████░░░███▌░░░█████████
███
████████░░░░░░░░░░▄█████████
█████████▀░░░▄████░░░░█████████
███
████▄▄░░░░▀▀▀░░░░▄████████
█████
███▌▄█░░▄▄▄▄█████████
▀████
██████▄██
██████████▀
▀▀█████████████████▀▀
▀▀▀███████▀▀
.
BitcoinCleanUp.com


















































████████████████████████████████████████████████████████████████████████████████
.
.
████████████████████████████████████████████████████████████████████████████████
███████████████████████████████████████
███████████████████████████████
███████████████████████████████
███████▀█████████▀▀▀▀█▀████████
███████▌░▀▀████▀░░░░░░░▄███████
███████▀░░░░░░░░░░░░░░▐████████
████████▄░░░░░░░░░░░░░█████████
████████▄░░░░░░░░░░░▄██████████
███████▀▀▀░░░░░░░▄▄████████████
█████████▄▄▄▄▄▄████████████████
███████████████████████████████
███████████████████████████████
███████████████████████████████████████
████████████████████████████████████████████████████████████████████████████████
.
#EndTheFUD
.

████████████████████████████████████████████████████████████████████████████████
██████████
██
██
██
██
██
██
██
██
██
██
██
██████████
noorman0
Hero Member
*****
Offline Offline

Activity: 1764
Merit: 695


[Nope]No hype delivers more than hope


View Profile WWW
November 04, 2022, 01:32:10 AM
 #12

-snip-
then they don't allow us own each private keys of those coin in the exchange?
Yes because they believe everyone is liable to his mistake and for that no more request to retrieve funds mistakenly sent to the wrong.
However, what do you want to do with the private key in that situation? Transactions are generally cannot be canceled. There is also the possibility that users will import addresses in other wallets whose activities are not recorded.
If you mean internal transactions, they just don't want to mess with user activity logs which may have an overall impact.

This is the place I don't like cex.
If you can access the private key, then it's not CEX anymore.

This space for rent.
Available in mid January 2024 - PM me
a298b112 (OP)
Member
**
Offline Offline

Activity: 141
Merit: 36


View Profile
November 04, 2022, 10:18:16 AM
 #13

If everyone has a unique BTC address, how come that they can avoid broadcasting the transaction? Lots of people trading in all those CEX/DEX, the network should be full of those transactions, no?

When you first make an account, they assign an address to you. Imagine the following table in their database (let's say we already have funds in our accounts):

Code:
+-----------------+-------------+---------+
|      User       | btc_address | Balance |
+-----------------+-------------+---------+
| OmegaStarScream | bc1q123     | 5 BTC   |
| a298b112        | bc1q789456  | 2.5 BTC |
+-----------------+-------------+---------+

So now, whenever you trade your BTC to USDT for example, all they need to do is update your record based on how much you bought or sold without having to touch the bitcoin or ethereum networks. So if you sold 1 BTC for 20K USDT,  it would be something like this:

Code:
UPDATE users_table
SET btc_balance = btc_balance - 1
WHERE user= 'a298b112'

Code:
UPDATE users_table
SET usdt_balance = usdt_balance + 20,000
WHERE user= 'a298b112'

So as I mentioned above, It's only when you request a withdrawal that they broadcast the transaction to the network.

Thanks a lot for this, now it makes sense
tranthidung
Legendary
*
Offline Offline

Activity: 2310
Merit: 4090


Farewell o_e_l_e_o


View Profile WWW
November 04, 2022, 10:37:49 AM
 #14

1. Do a CEX create a new BTC wallet for every client and keeps the keys with them?
Centralized exchanges create wallets for their clients and they have private keys of client's wallets. That means they give you custodial wallets, not non-custodial wallets that are better ones.

Quote
Or there is one wallet for the BTC/USDT pair?
No, if there is such separate wallet for each trading pair, exchanges (centralized) will have to create so many wallets for their users because there are so many trading pairs for BTC, btc to stable coins, btc to altcoins. That will increase their cost to maintain wallets, consolidate inputs, proceed withdrawals and more technical things.

Quote
2. What exactly happens when you buy/sell BTC? Where that BTC goes actually?
After you create your account, click on get an address, they will create a wallet and an address for you in Funding account. Then when you want to trade, you must move your fund to Spot or Trading account. The procedure from Funding to Spot/ Trading account (their names can be different by exchanges) is almost similar over exchanges.

The amount you trade (buy or sell) is just a number that is credited by an exchange to your account. Only when you make a withdrawal request, they will approve it and broadcast that transaction for you from their 'hot wallet'. If you pay attention, you will see transactions broadcasted by exchanges usually have so many inputs. Those inputs are not from your deposit transactions but also from other users too.

Quote
3. How they know who has what amount of BTC?
They credit that wallet, that address and the trading amount to your account, so they have full access to your trading history.

Learning resources

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!