In my CEX, I have built a fair withdrawal system for my users.
Users get to choose the withdrawal options such as fast, medium, or slow each with different network fees:
* Fast ($8.89 ~ arrival in 2 blocks)
* Medium ($1.89 ~ arrival in 6 blocks)
* Slow ($0.90 ~ arrival in 25 blocks)
I set this fee based on mempool congestion, updated every 15 minutes.
Now, the problem comes into play when there are hundreds of withdrawals happening every minutes. As you know, users can choose any option to withdraw, so the problem occurs when I don't have enough UTXOs to create the transactions. As you know, when a hot wallet spends UTXOs, it sends back the remaining UTXOs, and it takes 2 block confirmations to avoid block reorg. Other people who are trying to withdraw would then need to wait 20 minutes for the UTXOs to become available again.
I consolidate the utxo's in hot wallet so that txn size can be reduced (done periodically).
Suppose I could batch transactions into fast, medium, and slow then if I spend UTXOs in the fast batch, I cannot push the medium batch until I get the UTXOs back.
So this is the problem I'm facing.