In an exchange website we just book trades in our database and just when user want to withdraw his BTC balance we make a real transaction in bitcoin network for him. Consider a scenario that a user deposits 2 BTC and after some trades he now owns 5 BTC. His public address balance is 2 BTC and server must send 5 BTC to user's address. So server need to do more than one transaction: 2 BTC from his own deposit address and the rest 3 BTC from another address that server manages. In this scenario we must pay fee for at least 2 transaction. We usually in withdrawal take fee just for one transaction from user. The problem is now server must pay the other fees? What is the solution for this problem?
In BTC scenario I want to use blockchain.com's wallet app api. As I understood, we can have lots of publuic address corresponding to one extended public key of wallet. So we assign each user to a different public address in time of deposit. In time of withdraw, we can pay from blockchain's wallet to withdraw address of user. Am I right about this approach? I can generate new address of blockchain wallet with "http://localhost:3000/merchant/$guid/new_address" url. But this url just generte BTC address. How an I generate new address for ethereum and bitcoin cash in block chain.com api?
Is it possible to use such this solution for ethereum, litecoin and ...
If not, how can I manage the problem of many users deposits and withdraw in an exchange site?
Excuse me for number of questions
Thank you in advance