The Core Problem

DeFi trading bots face a fundamental scalability challenge: the gap between raw blockchain data and actionable trading signals grows exponentially with the number of token pairs being monitored. A single Solana RPC stream can produce thousands of events per second — new liquidity pairs, large swaps, token mints, and rug-pull indicators. Manually curated signals don't scale, and simple rule-based filters miss edge cases.

DeFiKit's DeFiKitAutoGunSOL system solves this with a multi-agent architecture that automates the entire pipeline from RPC ingestion to execution-ready signals. The core insight: separate the signal pipeline into independent, parallelizable stages, each handled by a dedicated microservice.

The Solution: Multi-Agent Signal Architecture

DeFiKit's architecture uses a NestJS backend with four distinct agent layers:

```

RPC Scanner Agents → Risk Evaluation Agents → Strategy Agents → Execution Agents

```

Each layer runs independently and communicates through a job queue (SQS-compatible). This design allows each agent type to scale horizontally based on load — when the market heats up and swap volume spikes, more scanner agents spin up without blocking the risk eval or execution pipelines.

Architecture Overview

Layer 1: RPC Scanner Agents

The scanner layer connects to Solana RPC endpoints (configurable between devnet and mainnet) and monitors for new token pairs, large transactions, and liquidity events. Configuration is runtime-adjustable through environment variables:

```bash

Enable/disable scanners without redeploying

IS_RUN_SCANNERS=true

IS_INIT_SCANNERS=true

Blockchain provider selection

export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"

```

Each scanner agent runs as an independent Node.js process with its own RPC connection pool. This prevents a single slow RPC call from blocking the entire pipeline.

Layer 2: Risk Evaluation Agents

Every detected event passes through a risk evaluation pipeline before any trading decision is made. DeFiKit's risk agents check:

- **Liquidity depth**: Is the pool liquid enough for the target trade size?

- **Honeypot detection**: Can tokens be sold, or is the contract designed to trap buyers?

- **Rug-pull indicators**: Does the contract have mint functions, ownership renounce, or suspicious tax structures?

- **Concentration risk**: Is the top holder's share dangerously high?

```typescript

// Config-driven risk checks

const riskConfig = {

IS_CHECK_LIQUIDITY: true,

IS_CHECK_HONEY_POT: true,

MIN_LIQUIDITY_USD: 5000,

MAX_HOLDER_CONCENTRATION: 0.2,

};

```

Layer 3: Strategy Agents

The strategy layer is where marketing automation intersects with trading. Instead of making binary buy/sell decisions, DeFiKit's strategy agents generate **signal scores** — a numerical rating from 0 to 100 that indicates opportunity strength.

Signal scoring considers:

- Technical indicators (price action, volume trends)

- On-chain metrics (holder growth, whale activity)

- Sentiment from Telegram and Discord channels

- Historical pattern matching against past profitable trades

Layer 4: Execution Agents

The final layer handles signal delivery and optional auto-execution. Execution agents can:

1. Send formatted signals to Telegram channels with buy/sell recommendations

2. Auto-execute trades through DEX aggregators when signal confidence exceeds 85

3. Log all decisions to a PostgreSQL database for backtesting and audit

Step 1: Setting Up the Scanner Pipeline

DeFiKitAutoGunSOL's scanner configuration is managed through a single `config.ts` file with Zod validation:

```typescript

import { z } from 'zod';

export const scannerConfigSchema = z.object({

solanaRpcUrl: z.string().url(),

isRunScanners: z.coerce.boolean().default(true),

isInitScanners: z.coerce.boolean().default(false),

telegramBotToken: z.string().min(40),

awsRegion: z.string().default('us-east-1'),

});

export type ScannerConfig = z.infer<typeof scannerConfigSchema>;

```

This validation ensures that configuration errors are caught at startup, not at 3 AM during a live trading session.

Step 2: Telegram as the Engagement Channel

DeFiKit's marketing automation relies on Telegram as the primary user engagement channel. The `@grammyjs` bot framework powers:

- **Real-time signal updates**: Formatted messages with token address, price impact, and risk score

- **User preference management**: Each user can configure which signal types they want (high-risk alpha, conservative yield, etc.)

- **Session-aware interactions**: Persistent user state across bot conversations

- **Multi-language support**: i18n built into the bot framework for global reach

```typescript

import { Bot, session } from 'grammy';

const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!);

bot.use(session({ initial: () => ({ preferences: {}, language: 'en' }) }));

bot.command('start', async (ctx) => {

await ctx.reply('Welcome to DeFiKit Signals! Configure your alert preferences with /settings');

});

```

Results

DeFiKit's multi-agent pipeline delivers measurable improvements over single-process scanner architectures:

| Metric | Single-Process | Multi-Agent (DeFiKit) |

|--------|---------------|----------------------|

| Max token pairs monitored | 10-15 | 50+ |

| Signal latency (avg) | 45 seconds | 8 seconds |

| False positive rate | 35% | 12% (with risk agents) |

| User engagement (DAU) | 200 | 1,200+ |

| Concurrent scanner instances | 1 | 5+ (auto-scaled) |

Key Takeaways

- **Separate concerns = scalable signals**: By decoupling RPC scanning from risk evaluation from strategy from execution, each pipeline stage can scale independently

- **Risk filtering is the bottleneck, not data ingestion**: Most noise comes from garbage tokens. Invest heaviest in the risk evaluation layer

- **Telegram is the best marketing channel for DeFi bots**: Real-time push notifications with formatted data outperform dashboards and emails for trader engagement

- **Config-driven architecture enables automated scaling**: Environment variables and Zod-validated configs mean you can spin up new scanner instances without touching code

- **The same architecture works for any blockchain**: Swap Solana RPC for Ethereum or BSC RPC and the pipeline logic remains identical