In previous version we had deposit collection flow based on amqp daemon (deposit_collection_fees, deposit_collection)
Legacy deposit process diagram:
deposit_collection daemon processing message and trying to collect deposit depending on the deposit spread.
The main problem for this approach that we don't wait till the transaction that we generated in the deposit_collection_fees daemon successfully executed and we are failing on deposit collection in the last step (it happens mostly for each erc20 deposit). Also, there is some chance that we can miss amqp message due to server instability.
We decided to remove to AMQP base deposit daemons and create a new deposit daemon that will work on deposit states changes and will prevent immediate proceeding of erc20 deposits.
New deposit process diagram:
processing deposits we are checking if plugin implement method
prepare_deposit_collection! if it doesn't we immediately process the deposit and collect deposit to the
cold wallets. If plugin implement method
prepare_deposit_collection! daemon processing of collection fees and change deposit state to
For deposits with
fee_processing state, we select each minute deposits that have
updated_at older than 5 minutes and process them. With time condition we are sure that fee transaction has already been executed.