Skip to content

Repository files navigation

MRQ.CryptoBot

Automated trading bot for Binance Smart Chain (BSC) with a Windows Forms UI and a layered architecture.

Overview

MRQ.CryptoBot is a desktop app built with .NET 6 / C# that automates buying and selling tokens on BSC through PancakeSwap. It monitors prices in real time, executes orders based on configurable rules, and keeps a local history of operations.

Key features

  • Automated buy/sell of BSC tokens (PancakeSwap)
  • Real-time price and liquidity monitoring
  • Control of slippage, gas limit, and balance limits
  • Locally encrypted wallet (secure login/logout)
  • Moralis integration for market data
  • BSCScan integration for current token values
  • Telegram notifications (planned)
  • Latency checks against the blockchain and the internet
  • Local persistence with SQLite via Entity Framework Core
  • Log of executed operations to a local file

Architecture

The solution uses a layered architecture with clear separation of concerns:

┌──────────────────────────────────────────────────┐
│ 0 - Client (WinForms) │
└──────────────────────┬───────────────────────────┘
│
┌──────────────────────▼───────────────────────────┐
│ 1 - Core │
│ ┌─────────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Application │→ │ Business │→ │ Domain │ │
│ └─────────────┘ └──────────┘ └──────┬──────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ Shared │ │
│ └─────────────┘ │
└──────────────────────────────────────────────────┘
│
┌──────────────┼──────────────┐
│ │ │
┌───────▼──────┐ ┌─────▼──────┐ │
│ 2 - Adapter │ │ Repository │ │
│ (Nethereum, │ │ (EF Core) │ │
│ Moralis) │ └────────────┘ │
└──────────────┘ │
│ │
┌───────▼─────────────────────────── ▼──┐
│ 3 - Infra (DI / IoC) │
└───────────────────────────────────────┘

Module dependencies

ModuleDepends on
MetaMask.ClientApplication
MetaMask.ApplicationBusiness
MetaMask.BusinessDomain, Integration, Repository
MetaMask.DomainShared
MetaMask.Shared
MetaMask.IntegrationDomain
MetaMask.RepositoryDomain

Full details: Dependencia.md and Arquitetura.md.


Technologies

TechnologyRole
.NET 6 / C#Main platform
Windows FormsDesktop UI
NethereumBSC contract interaction
MoralisToken price/balance data
Entity Framework Core + SQLiteLocal persistence
Microsoft.Extensions.DependencyInjectionDependency injection
BSCScan APICurrent token values

Prerequisites

  • .NET 6 SDK
  • Windows (the UI targets net6.0-windows / Windows Forms)
  • Visual Studio 2022 or later (recommended)
  • External library MRQ.ReturnContent — must be available at ..\Library\MRQ.ReturnContent\ relative to the repository root

How to run

  1. Clone the repository:
git clone <repository-url>cd MRQ.CryptoBot
  1. Ensure the MRQ.ReturnContent library is on the expected path (..\Library\MRQ.ReturnContent\).

  2. Restore packages and build the solution:

dotnet restore MRQ.CryptoBot.sln
dotnet build MRQ.CryptoBot.sln
  1. Run the client project:
dotnet run --project "0 - Client/MetaMask.Client/MRQ.CryptoBot.Client.csproj"

Or open MRQ.CryptoBot.sln in Visual Studio and press F5.


Directory layout

MRQ.CryptoBot/
├── 0 - Client/
│ └── MetaMask.Client/ # WinForms project (UI)
├── 1 - Core/
│ ├── MRQ.CryptoBot.Application/
│ ├── MRQ.CryptoBot.Business/
│ ├── MRQ.CryptoBot.Domain/
│ └── MRQ.CryptoBot.Shared/
├── 2 - Adapter/
│ ├── MRQ.CryptoBot.Integration/ # Nethereum, Moralis, PancakeSwap
│ └── MRQ.CryptoBot.Repository/ # EF Core + SQLite
├── 3 - Infra/ # DI / IoC wiring
├── 4 - Tests/
│ └── PancakeSwapAdapterTest/
├── Arquitetura.md # API sketch and orchestrators
├── Dependencia.md # Module dependency graph
└── MRQ.CryptoBot.sln

Tests

dotnet test MRQ.CryptoBot.sln

Tests live under 4 - Tests/PancakeSwapAdapterTest/.


Conventions

  • Methods should return via ReturnContent (pattern from the external library).
  • Asynchronous operations follow Async / await.
  • Business rules live in Business only; external adapters belong in Integration.

About

Crypto trading bot in C# with Hexagonal Architecture — PancakeSwap, wallet encryption, Telegram alerts, BSCScan integration

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages