The Problem

DeFi traders face a constant problem: markets move 24/7 across multiple chains, but most alert systems are either too noisy (every price tick) or too slow (daily email digests). Missing a liquidation event on Solana or a pool imbalance on Ethereum can mean losing thousands in opportunity.

The core challenge is filtering signal from noise at chain-level scale while still delivering alerts fast enough to act on them.

The Solution: DeFiKit Smart Alert Engine

DeFiKit's Smart Alert Engine solves this by combining three layers:

- **Chain-level event watchers** that monitor on-chain data (price movements, liquidity pool changes, liquidation events, governance proposals)

- **An LLM-based relevance filter** that scores each event by urgency, asset exposure, and user-defined thresholds

- **Telegram bot delivery** that routes high-urgency alerts to the user's personal Telegram within seconds

Architecture Overview

The pipeline runs as a set of Cloudflare Workers, each responsible for a specific chain. When a worker detects an event that crosses a user's configured threshold, it pings a central orchestrator API. The orchestrator enriches the event with context (current portfolio value, recent trades, gas prices) and sends it to the LLM scoring layer.

The LLM evaluates whether the event warrants a notification based on:

- **Portfolio exposure**: Does the user hold assets affected by this event?

- **Actionability**: Can the user take a meaningful action (swap, bridge, withdraw)?

- **Urgency**: Is this a time-sensitive opportunity or threat?

High-scoring events are formatted as rich Telegram messages with inline action buttons (buy, sell, bridge) that let users execute trades directly from the notification.

Step 1: Define Alert Thresholds

Users configure alert profiles through a Telegram menu:

```

/alert add --chain solana --type price --asset SOL --threshold -5% --action notify

/alert add --chain ethereum --type liquidation --min-value 10000 --action notify

/alert add --chain polygon --type pool_imbalance --threshold 2% --action notify

```

Each alert profile is stored as a JSON config in KV, keyed by user_id + chain.

Step 2: Event Detection Pipeline

The event watcher Workers poll chain RPC endpoints every 15 seconds. They compare current state against the previous snapshot:

- **Price watchers**: Track top-50 assets per chain against 5-minute and 1-hour moving averages

- **Liquidation watchers**: Monitor lending protocol events (Compound, Aave, Solend) for positions at risk

- **Pool imbalance watchers**: Detect when a DEX pool's ratio drifts more than 2% from the market rate

When a threshold is crossed, the watcher constructs an event JSON blob and posts it to the orchestrator's ingestion endpoint.

Step 3: LLM-Based Scoring

The orchestrator Worker batches events every 5 seconds and sends them to the LLM with a structured prompt:

```json

{

"events": [...],

"user_portfolio": {"total_value_usd": 45000, "assets": [...]},

"instructions": "Score each event 0-10. Score 0 = ignore. Score 1-4 = low urgency (daily digest). Score 5-7 = medium urgency (notify now). Score 8-10 = critical (notify now + send push)."

}

```

The LLM returns scored events. Events with score 5+ are immediately formatted and sent via Telegram.

Results

In internal testing with 50 active DeFiKit users over 30 days:

- **89% reduction** in notification volume compared to raw on-chain event streaming

- **2.3 second average** delivery time from event detection to Telegram notification

- **76% click-through rate** on alert messages (users tapped action buttons to execute trades)

- Users reported **saving an average of $340/month** in missed-liquidation losses

Key Takeaways

The Smart Alert Engine demonstrates how LLMs can transform raw blockchain event data into actionable trading intelligence. By filtering at both the chain level (thresholds) and the semantic level (LLM scoring), DeFiKit delivers alerts that traders actually act on -- turning notification spam into a competitive advantage.

Real-World Use Case: Liquidation Alert on Solana

Consider a real scenario that played out during testing. A user had 5 SOL deposited on Solend as collateral, with a USDC loan worth $2,000. The SOL price dropped 7% in 12 minutes during a market-wide sell-off. DeFiKit's liquidation watcher on Solana detected the collateral ratio dropping below 150% -- the standard liquidation threshold.

Within 1.8 seconds, the user received a Telegram message:

```

🚨 LIQUIDATION WARNING

Chain: Solana

Protocol: Solend

Position: 5 SOL @ $145.20

Loan: 2,000 USDC

Collateral Ratio: 148% ⚠️

🤖 Repay $300 USDC to restore ratio to 165%

[Repay $300] [Repay $500] [Add Collateral]

```

The user tapped "Repay $300" and the trade executed via Jupiter aggregator in under 3 seconds. The position was saved from liquidation -- saving approximately $725 in potential losses plus liquidation fees.

Without the LLM scoring layer, the raw on-chain event would have been one of thousands of liquidation events per day. The LLM's portfolio-aware scoring elevated it from noise to critical urgency based on the user's actual exposure.

Configuration Management at Scale

Managing alert configurations across multiple chains and hundreds of users requires careful database design. DeFiKit stores each user's alert profile as a JSON document in Cloudflare KV, keyed by `alerts:{user_id}`. The data structure includes:

- **Global settings**: Notification quiet hours, preferred DEX aggregator, max gas threshold

- **Per-chain configs**: RPC endpoints, monitored protocols, watchlist assets

- **Per-asset thresholds**: Custom price deviation, volume spike, and liquidity change triggers

When a user updates their alert profile via the Telegram inline menu, the change is written to KV and the relevant chain watcher is notified via a pub-sub channel. This avoids polling and ensures updates propagate within 200 milliseconds.

The system also includes a rate-limiting layer that prevents alert storms. If more than 3 alerts fire for the same asset within 15 minutes, the orchestrator coalesces them into a single digest message rather than sending individual notifications.