Skip to content

Sub-apps Flask application. Celery, queue with RabbitMQ and Redis cache. For crypto-exchanges project.

License

Notifications You must be signed in to change notification settings

MikhailChupakhin/Flask-Web3-cryptocollector

Repository files navigation

Cold Wallet funds accumulator

The project implements part of the business logic of cryptocurrency exchanges related to the unreliability of constantly storing funds in the UserWallet. Therefore, funds credited to the UserWallet are transferred to the so-called Cold Wallet.

Read description

ModuleBlockAnalyzer is a main sub-application that retrieves unverified blocks from the blockchain network (here - EVM). After catching up with the network, new blocks continue to be received via WebSocket.

ModuleRegularTXProcessor and ModuleTokenTXProcessor - sub-applications perform long-time tasks, generated by ModuleBlockAnalyzer.

ModuleBlockAnalyzer performs the following detections in the blockchain:

  1. Crediting funds from GAS_KEEPER to UserWallet addresses. Upon detection, transaction information is saved in the Redis cache.

  2. Crediting funds to UserWallet addresses:

    • Network cryptocurrencies: upon detection, a task to collect funds to COLD_WALLET is queued in RabbitMQ.
    • Tokens: upon detection, a Celery task chain for collection is initiated, which includes the following stages:
      • Estimation of quantity and gas collection - transaction from GAS_KEEPER to UserWallet.
      • Periodic search for this transaction in the cache (see I).
      • Token collection from UserWallet to COLD_WALLET, saving in the database.
      • Monitoring GAS_KEEPER funds level (on low level - logging/alerting).

[WARNING!] Critical data (UserWallet) is stored on a "central node." Within the framework of the repository, it is a conditional second database (EXTERNAL DB). Implementation with a microservices architecture (instead of sub-applications) is a much better choice.

# for dependecies pip install poetry # for migrations alembic revision --autogenerate -m "MIGRATION_DESCRIPTION


Сборщик средств на хододный кошелек

Проект реализует часть бизнес-логики криптовалютных бирж, связанной с ненадежностью постоянного хранения средств на UserWallet - в связи с чем средства, зачисляемые на UserWallet, перечисляются на т.н. холодный кошелек COLD_WALLET.

Читать описание

ModuleBlockAnalyzer - суб-аппликация, выполняющая получение еще не проверенных блоков в блокчейн-сети(здесь - EVM). После ликвидации отставания от сети - новые блоки продолжают получаться через WebSocket.

ModuleRegularTXProcessor and ModuleTokenTXProcessor - суб-приложения, выполняющие долгие задачи, сгенерированные в.

ModuleBlockAnalyzer выполняет поиск в блокчейне:

  1. Зачислений средств с GAS_KEEPER на адреса UserWallet. При обнаружении информация о транзакции сохраняется в кэш Redis.

  2. Зачислений средств на адреса UserWallet:

    • Криптовалюты сети: при обнаружении задача по сбору средств на COLD_WALLET ставится в очередь RabbitMQ.
    • Токены: при обнаружении запускается Celery цепочка задач по сбору, включающая следующие этапы:
      • Оценка количества и сбор газа - транзакция с GAS_KEEPER на UserWallet.
      • Периодический поиск данной транзакции в кэше (см. п. 1).
      • Сбор токенов с UserWallet на COLD_WALLET, сохранение в базе данных.
      • Мониторинг уровня средств на GAS_KEEPER (при недостатке - логирование/оповещение).

[ВНИМАНИЕ!] Критические данные (UserWallet) хранятся на "центральном узле". В рамках репозитория это условная вторая база данных (EXTERNAL DB). Реализация с микросервисной архитектурой (вместо суб-приложений) является гораздо лучшим выбором.

# for dependecies pip install poetry # for migrations alembic revision --autogenerate -m "MIGRATION_DESCRIPTION

About

Sub-apps Flask application. Celery, queue with RabbitMQ and Redis cache. For crypto-exchanges project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published