veritail-solana
by wwwaang3
README.md
# VeriTail — Solana Long-Tail Due-Diligence & Pre-Trade Guardrail AI Agent
> **Evidence-grounded Solana long-tail token intelligence, deterministic pre-swap guardrails (`PASS` / `WARN` / `BLOCK`), autonomous DEX pool scouting, wallet auditing, and MCP server — with zero npm runtime dependencies and out-of-the-box zero-key execution.**
*Data powered by [CoinGecko API](https://www.coingecko.com/en/api) & Solana Mainnet JSON-RPC.*
---
## Why VeriTail?
Long-tail tokens on Solana launch in seconds, and traders, analysts, and autonomous swap agents face rampant execution risks every day:
- Unrenounced **SPL Mint Authorities** (infinite supply dilution) and **Freeze Authorities** (post-buy honeypot account freezing)
- Dangerous **Token-2022 extensions** (`PermanentDelegate`, `DefaultAccountState = Frozen`, `TransferFeeConfig`)
- Thin liquidity pools where a modest trade causes severe AMM slippage or **stale/manipulated quote divergence** against CoinGecko spot prices
- **Wash-traded turnover** and **extreme holder concentration**
**VeriTail** solves this with a strict **Zero-Hallucination & Machine-Verifiable Provenance** rule: every single numeric claim in its memos, guardrail decisions, and MCP responses records `[source_url, fetched_at, json_path]`. Whenever an upstream endpoint (such as public Solana RPC `getTokenLargestAccounts`) rate-limits or omits data, VeriTail reports `null` plus the exact status instead of inventing or extrapolating numbers.
---
## 3-Command Quickstart
Requires **Node.js `>= 22.18`** (uses Node's native TypeScript execution with zero `npm install` or build steps required!).
```bash
git clone https://github.com/wwwaang3/veritail-solana-agent.git
cd veritail-solana-agent
npm start
```
Open `http://127.0.0.1:3088` in your browser, or run the test suite & CLI immediately:
```bash
npm test # Unit, binary SPL Mint, MCP stdio & live API smoke tests
node src/cli.ts dd JUP # Token due-diligence memo + provenance citations
node src/cli.ts guardrail BONK 2500 # Deterministic pre-swap PASS/WARN/BLOCK guardrail
node src/cli.ts scout 25000 8 # Autonomous trending + new Solana pool scanner
node src/cli.ts move JUP # Forensic OHLCV & order-flow price-move analyzer
node src/cli.ts wallet <SOLANA_PUBKEY> # Live SPL + Token-2022 wallet exposure audit
```
---
## Live UI Walkthrough
### 1. Token Due-Diligence & Provenance Citations

### 2. Deterministic Pre-Trade Guardrail Gate (`PASS` / `WARN` / `BLOCK`)

### 3. Autonomous Long-Tail Solana Pool Scout

### 4. Solana Wallet Audit & Live MCP JSON-RPC 2.0 Playground

---
## Architecture
```mermaid
flowchart LR
U["Web UI / CLI / AI Agent (MCP Stdio)"] --> E["VeriTail Agent Engine (6 Workflows)"]
E --> CG["CoinGecko Dual-Mode Client"]
E --> RPC["Solana Mainnet JSON-RPC Client"]
CG -->|"Zero-Key Default"| PubCG["api.coingecko.com/api/v3 + api.geckoterminal.com/api/v2"]
CG -->|"When COINGECKO_API_KEY set"| ProCG["pro-api.coingecko.com/api/v3 (+ /onchain)"]
RPC -->|"Binary 82B + Token-2022 TLV"| Mainnet["Solana Mainnet RPC (getAccountInfo, getTokenLargestAccounts, getTokenAccountsByOwner)"]
E --> Prov["CitationCollector -> ProvenanceClaim[] [sourceUrl, fetchedAt, jsonPath]"]
```
### Core Modules
- [`src/coingecko/client.ts`](src/coingecko/client.ts): Dual-mode CoinGecko + GeckoTerminal client with automatic zero-key Public mode and `COINGECKO_API_KEY` Analyst/Pro auto-upgrade (`x-cg-pro-api-key`), TTL in-memory cache, request coalescing, polite rate pacing, and 429 exponential backoff.
- [`src/solana/rpc.ts`](src/solana/rpc.ts): Pure TypeScript Base58 codec + canonical **82-byte binary SPL Token Mint decoder** + **Token-2022 TLV extension parser** (`PermanentDelegate`, `DefaultAccountState`, `TransferFeeConfig`, `MintCloseAuthority`, `TransferHook`), plus `getTokenLargestAccounts` and `getTokenAccountsByOwner` wallet reader.
- [`src/agent/engine.ts`](src/agent/engine.ts): Six complete autonomous workflows (`dueDiligenceMemo`, `evaluateTradeGuardrail`, `scoutLongtailPools`, `explainPriceMove`, `auditSolanaWallet`, `listEvidenceSources`).
- [`src/mcp/server.ts`](src/mcp/server.ts): JSON-RPC 2.0 MCP stdio server (auto-detecting newline-delimited JSON-RPC and `Content-Length` framing) exposing all 6 workflows.
- [`src/server.ts`](src/server.ts) & [`public/`](public/): Fast HTTP REST + MCP server and 4-tab dark mission-control web UI.
---
## MCP Integration (`.mcp.json`)
Add VeriTail directly to **Claude Code**, **Cursor**, or **Antigravity** via stdio MCP:
```json
{
"mcpServers": {
"veritail-solana": {
"command": "node",
"args": ["src/mcp/server.ts"],
"cwd": "/path/to/veritail-solana-agent",
"env": {
"COINGECKO_API_KEY": "",
"SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com"
}
}
}
}
```
### Exposed MCP Tools
| Tool | Inputs | Output |
| :--- | :--- | :--- |
| `due_diligence_memo` | `mint_or_query` | Risk score (0–100), SPL Mint authorities, DEX pools, comparables, memo & citations |
| `evaluate_trade_guardrail` | `mint_or_query`, `trade_usd`, `quoted_price_usd?` | `PASS` / `WARN` / `BLOCK` verdict, 6 deterministic rule checks, swap router decision JSON |
| `scout_longtail_pools` | `min_liquidity_usd?`, `limit?` | Ranked Solana trending + new pools checked against on-chain Mint safety |
| `explain_price_move` | `mint_or_query` | 24h hourly OHLCV range, volume spike hour, buy/sell flow & SOL ecosystem beta comparison |
| `audit_solana_wallet` | `pubkey` | Priced native SOL + SPL/Token-2022 balances, long-tail & unpriced alerts, rebalance brief |
| `list_evidence_sources` | *(none)* | Active CoinGecko API tier, Solana slot health, cache stats & endpoint inventory |
---
## CoinGecko API Endpoint Inventory
VeriTail runs out of the box with **zero API key** (`api.coingecko.com/api/v3` + `api.geckoterminal.com/api/v2`) and automatically upgrades to **CoinGecko Analyst/Pro** (`https://pro-api.coingecko.com/api/v3` + `/onchain` with `x-cg-pro-api-key`) when `COINGECKO_API_KEY` is configured (see [`.env.example`](.env.example)):
| Workflow | Endpoint | Role |
| :--- | :--- | :--- |
| Token Resolution | `/search?query=...`, `/coins/{id}`, `/search/pools?network=solana` | Resolves tickers or obscure long-tail pairs to canonical SPL mints |
| Due Diligence | `/coins/solana/contract/{mint}`, `/coins/markets?category=solana-ecosystem` | Spot USD, market cap, FDV, rank, categories & Solana peer benchmarks |
| On-Chain DEX Pools | `/networks/solana/tokens/{mint}`, `/tokens/{mint}/pools` | Live pool reserves, spread vs CoinGecko spot, 1h/6h/24h volume & tx counts |
| Pool Scout | `/networks/solana/trending_pools`, `/networks/solana/new_pools` | Discovers high-velocity and newly launched Solana pools |
| Price-Move Forensic | `/networks/solana/pools/{pool}/ohlcv/hour` | 24h hourly candles, volatility range & volume spike attribution |
| Wallet Batch Pricing | `/networks/solana/tokens/multi/{addresses}` | Batch-prices up to 30 SPL mints per request with pool reserve depth |
| Health | `/ping` | Verifies CoinGecko API availability & active tier |
*Data powered by [CoinGecko API](https://www.coingecko.com/en/api).*
---
## Solana Mainnet JSON-RPC Integration
Default endpoint: `https://api.mainnet-beta.solana.com` (override with `SOLANA_RPC_URL` for dedicated RPCs such as Helius, QuickNode, or Triton).
- **`getAccountInfo` (`base64`)**: Decodes raw 82-byte SPL Token Mint state (`mintAuthorityOption`, `mintAuthority`, `u64 supply`, `u8 decimals`, `isInitialized`, `freezeAuthorityOption`, `freezeAuthority`) plus Token-2022 TLV extensions (`PermanentDelegate`, `DefaultAccountState`, `TransferFeeConfig`, `MintCloseAuthority`, `TransferHook`).
- **`getTokenLargestAccounts`**: Computes top-1 / top-5 / top-10 / top-20 concentration percentages against raw `BigInt` supply, gracefully reporting `null` (`rate_limited`) if the public RPC node throttles requests.
- **`getBalance` & `getTokenAccountsByOwner` (`jsonParsed`)**: Reads live native SOL + both SPL Token and Token-2022 balances for wallet risk auditing.
- **`getSlot`**: Live cluster liveness telemetry in UI and `list_evidence_sources`.
---
## License
Released under the [MIT License](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues