soltail-sentinel
README.md
# SolTail Sentinel
> **Grounded, zero-hallucination AI Agent & MCP toolkit for Solana long-tail token due diligence, "Why did it move?" anomaly attribution, new-pool scouting, DAO treasury runway monitoring, and pre-trade swap price guardrails.**
>
> **Data by [CoinGecko API](https://www.coingecko.com/en/api)** · Built for the **Superteam Earn × CoinGecko "Long Tail" Hackathon on Solana (AI Agents Track)**
[](LICENSE)
[](https://nodejs.org/)
[](tsconfig.json)
[](https://www.coingecko.com/en/api)
---
## Why SolTail Sentinel?
AI agents analyzing or acting on Solana's long tail routinely break down in two places:
1. **Hallucinated numbers**: LLMs invent or distort liquidity, market cap, slippage, or holder figures when summarizing market data.
2. **Off-chain blind spots**: Price feeds alone cannot tell whether an SPL token's `mintAuthority` or `freezeAuthority` is still live at the latest Solana slot.
**SolTail Sentinel** fuses **live CoinGecko API + Onchain Solana DEX telemetry** with **live Solana RPC on-chain state inspection** behind a strict **Evidence Citation Ledger (`[CG-01]`, `[SOL-01]`)** and a **Zero-Hallucination Numeric Grounding Verifier**. Every number written into every agent memo is programmatically verified against SHA-256 hashed raw API & RPC responses before output—and can be anchored directly onto **Solana Devnet via Memo Program v2** at `$0` cost.
---
## Key Capabilities (5 Grounded Autonomous Workflows)
| Workflow | CLI Command | MCP Tool | What It Does |
| :--- | :--- | :--- | :--- |
| **1. Token Due Diligence** | `soltail dd JUP` | `solana_token_due_diligence` | Live CoinGecko price/FDV/liquidity/top pools + Solana RPC `mintAuthority`, `freezeAuthority`, Token-2022 detection & Top-10 concentration -> `0–100` transparent risk score & cited memo |
| **2. "Why Did It Move?"** | `soltail why JUP` | `solana_why_did_it_move` | Compares 5m/1h/6h/24h token action against SOL market beta, DEX buy/sell order flow, pool turnover & 1h OHLCV candles to classify the exact move driver |
| **3. New & Trending Pool Scout** | `soltail scout` | `solana_scout_pools` | Screens Solana trending & newly created pools against liquidity, 24h volume, FDV/liquidity & live Solana RPC authority revocation rules, dropping rug risks with explicit reasons |
| **4. DAO Treasury Runway Guard** | `soltail treasury <wallet>` | `solana_treasury_guard` | Reads live SOL + SPL + Token-2022 balances from Solana RPC, values holdings via CoinGecko, monitors stablecoin runway & single-asset exposure, and auto-drafts a liquidity-sized **Squads v4 rebalance proposal JSON** |
| **5. Pre-Trade Swap Price Guardrail** | `soltail guard ...` | `solana_swap_price_guard` | Execution gate for trading agents: compares DEX swap quotes against live CoinGecko spot prices and returns **`ALLOW` / `WARN` / `BLOCK`** with exact basis-point (`bps`) deviation |
Plus:
- **Autonomous Watchlist Daemon (`soltail watch`)**: Periodic surveillance loop with deduplicated alerts, Server-Sent Events (`/api/events`), and optional Discord/Telegram webhooks.
- **Solana Actions / Blinks Endpoint (`GET /api/actions/dd/:mint`)**: Ready-to-integrate Actions JSON metadata for any Solana mint.
- **Accessibility First**: Every risk tier and verdict combines explicit text badges (`[OK]`, `[WARN]`, `[HIGH]`, `[CRIT]`) with tier names—never relying on color alone.
---
## Screenshots (Captured from Live CoinGecko & Solana RPC Runs)
### 1. Interactive Web Dashboard — Grounded Token Due Diligence & Evidence Citation Ledger

### 2. "Why Did It Move?" Attribution (1h Live OHLCV + SOL Beta) & Solana Pool Scout

### 3. DAO Treasury Runway Guard (Auto-Drafted Squads v4 Proposal) & Pre-Trade Swap Price Guardrail

### 4. CLI, MCP JSON-RPC Server & Solana Devnet Memo v2 Evidence Attestation

---
## Architecture
```text
Web Dashboard (HTTP + SSE) │ CLI (`soltail`) │ MCP stdio Server │ Solana Actions API
└──────────┬─────────────────────────────┘
▼
SolTailAgent Engine
(Due Diligence · Move Attribution · Pool Scout · Treasury · Swap Guard)
┌─────────────┴─────────────┐
▼ ▼
CoinGeckoClient SolanaRpcClient
- Public $0 & Analyst/Pro API - Mainnet-Beta JSON-RPC
- Token markets, pools, OHLCV - Mint/Freeze/Supply & Holders
- Multi-token pricing & search - SPL + Token-2022 Treasury Read
- Trending & New Solana pools - Devnet Memo v2 Attestation ($0)
└─────────────┬─────────────┘
▼
EvidenceLedger & Zero-Hallucination Verifier
[CG-01], [SOL-01] SHA-256 Digest -> Numeric Grounding Check -> Verified Output
```
For full architectural details, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
---
## Quickstart (One-Command Run — `$0`, No API Key Required)
> **Prerequisites**: Node.js `>= 20` and npm. Zero external database, zero Docker, zero paid keys needed to start.
```bash
# 1. Clone and install
git clone https://github.com/95xp4qk8y5-code/soltail-sentinel.git
cd soltail-sentinel
npm install
# 2. Optional: copy .env.example if you want to add a CoinGecko Analyst/Pro API key
cp .env.example .env
# 3. Run the full automated unit, grounding, MCP & HTTP E2E test suite
npm test
# 4. Launch the interactive Web Dashboard + REST API + Autonomous Monitor
npm start
# Open http://127.0.0.1:3456
```
### Run Live CLI & Solana Devnet Verification Commands
```bash
# End-to-end live demo across Due Diligence, Move Attribution & Swap Guardrail
npm run demo:live
# Real live integration test against CoinGecko API + Solana Mainnet/Devnet RPC
npm run test:live
# Anchor a SHA-256 due-diligence evidence digest onto Solana Devnet via Memo Program v2
npm run demo:devnet
# Individual CLI commands
npm run cli -- dd JUP
npm run cli -- why BONK
npm run cli -- scout --min-liq 25000 --min-vol 5000
npm run cli -- treasury 6mpcrWq2RC4wzFMDFJoUqNTLnBcX4AWB8LeNBXvRKHVe --burn 25000 --min-runway 6
npm run cli -- guard --in SOL --out USDC --amount-in 10 --quoted-out 500 --max-bps 150
npm run cli -- watch --tokens JUP,BONK,WIF --once
```
---
## Plug Into Claude Code, Cursor, Codex, or Hermes via MCP
SolTail Sentinel ships a native **Model Context Protocol (MCP) JSON-RPC 2.0** server over `stdio` exposing all 5 grounded tools:
```json
{
"mcpServers": {
"soltail-sentinel": {
"command": "node",
"args": ["/absolute/path/to/soltail-sentinel/dist/src/cli/index.js", "mcp"],
"env": {
"COINGECKO_API_KEY": "",
"COINGECKO_API_TIER": "public"
}
}
}
}
```
Verify the MCP server directly from your shell:
```bash
printf '{"jsonrpc":"2.0","id":1,"method":"tools/list"}\n' | npm run -s mcp
```
---
## How CoinGecko API is Used
CoinGecko API is the live market intelligence backbone driving every single workflow in SolTail Sentinel:
1. **Dual-Tier Automatic Routing (`src/providers/coingecko.ts`)**:
- **Out-of-the-box `$0` Public Mode**: Works immediately with zero configuration using CoinGecko v3 (`/simple/price`, `/coins/{id}`, `/search`) paired with CoinGecko Onchain / GeckoTerminal v2 (`/networks/solana/tokens/{mint}?include=top_pools`, `/networks/solana/tokens/{mint}/info`, `/networks/solana/pools/{pool}/ohlcv/hour`, `/networks/solana/trending_pools`, `/networks/solana/new_pools`, `/simple/networks/solana/token_price/{addresses}`).
- **Hackathon Analyst / Pro Upgrade Mode**: Setting `COINGECKO_API_KEY` + `COINGECKO_API_TIER=pro` automatically switches to `https://pro-api.coingecko.com/api/v3` and `https://pro-api.coingecko.com/api/v3/onchain` with `x-cg-pro-api-key` headers (500 RPM, zero public pacing delay, extended historical depth).
2. **Concrete Usage Per Workflow**:
- **Due Diligence**: Real-time price, 24h delta, FDV, market cap, market-cap rank, categories, GT score, and top Solana DEX pools with reserve depth & volume.
- **"Why Did It Move?"**: Multi-window pool price changes (`5m`, `1h`, `6h`, `24h`), live `buys`/`sells` order flow counts, 1h OHLCV candles, and CoinGecko SOL/USD 24h benchmark for beta-adjusted spread calculation.
- **Pool Scout**: Live trending and newly launched Solana pools filtered on liquidity, volume, and FDV/liquidity stretch before on-chain authority checks.
- **DAO Treasury Guard**: Batch valuation of SOL + SPL holdings and top-holding DEX reserve depth to compute safe multi-tranche Squads rebalance sizing.
- **Swap Price Guardrail**: Real-time reference spot pricing to quantify unfavorable quote slippage/MEV in basis points and gate execution (`ALLOW` / `WARN` / `BLOCK`).
3. **Security & Attribution**:
- API keys are never committed (`.env` gitignored; `.env.example` contains placeholders only) and are automatically scrubbed (`REDACTED`) from evidence logs.
- Every dashboard view, Markdown memo, CLI output, HTTP header (`X-Data-Attribution`), MCP tool description, and Solana Actions description displays **`Data by CoinGecko API`**.
---
## How Solana is Used
Solana is used directly across **Mainnet-Beta** (read-only on-chain forensics) and **Devnet** (cryptographic evidence attestation), with zero mainnet capital required:
1. **SPL & Token-2022 Mint Forensics (`src/providers/solana.ts`)**:
- Calls Solana Mainnet-Beta JSON-RPC `getAccountInfo` (`jsonParsed`) to verify whether `mintAuthority` and `freezeAuthority` are revoked (`null`) or still active, inspect supply/decimals, detect SPL Token vs Token-2022 (`TokenzQd...`), and anchor every report to the exact Solana slot.
- Calls `getTokenLargestAccounts` to calculate Top-1 / Top-5 / Top-10 holder concentration (with transparent graceful reporting if public RPC rate-limits large-supply accounts).
2. **Live Wallet & Squads DAO Treasury Inspection**:
- Reads native SOL (`getBalance`) plus all SPL Token and Token-2022 holdings (`getTokenAccountsByOwner`) for any Solana wallet or Squads multisig vault, outputting a Squads v4-compatible rebalance proposal JSON when runway or concentration limits breach policy.
3. **Solana Devnet Memo Program v2 Attestation (`src/solana/attestation.ts`)**:
- Uses `@solana/web3.js` to build, Ed25519-sign, locally verify, and optionally broadcast a real Solana Devnet transaction invoking the official **Memo Program v2 (`MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`)** carrying the report's SHA-256 evidence digest (`SOLTAIL|v1|dd|JUP|LOW:4|sha256:...|DataByCoinGeckoAPI`).
4. **Solana Actions / Blinks Endpoint (`src/server/index.ts`)**:
- Serves `/actions.json` and `/api/actions/dd/:mint` returning Solana Actions-compliant metadata and attestation trigger links.
---
## Project Structure
```text
soltail-sentinel/
├── src/
│ ├── agent/ # SolTailAgent (5 workflows) + AutonomousMonitor daemon
│ ├── cli/ # Full CLI (`dd`, `why`, `scout`, `treasury`, `guard`, `attest`, `watch`, `serve`, `mcp`, `demo`)
│ ├── engine/ # EvidenceLedger, Zero-Hallucination Grounding Verifier & Scoring engines
│ ├── mcp/ # Model Context Protocol (MCP) JSON-RPC 2.0 stdio server
│ ├── providers/ # Dual-mode CoinGecko API client + Solana RPC client + offline fixtures
│ ├── server/ # Zero-dep HTTP server, SSE live stream, Solana Actions API & Web Dashboard UI
│ └── solana/ # Solana Devnet Memo Program v2 evidence attestation builder/submitter
├── test/ # Unit, grounding, MCP, HTTP API & live CoinGecko/Solana integration tests
├── docs/ # Architecture documentation & 4 live-captured screenshots
└── .env.example # Clean environment template (no real keys)
```
---
## License
MIT License — see [LICENSE](LICENSE).
Market and DEX telemetry: **Data by [CoinGecko API](https://www.coingecko.com/en/api)**.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues