Skip to main content
Glama
geckoguard-solana
by oppo2357
README.md
# GeckoGuard — Autonomous Solana Pre-Trade Risk Guardrail & MCP Agent

> **Data by [CoinGecko API](https://www.coingecko.com/en/api)** · Verified on-chain via **Solana Mainnet JSON-RPC**

**GeckoGuard** is a zero-dependency **Model Context Protocol (MCP) server**, autonomous policy engine, CLI, and security control plane that protects Solana AI trading agents and DAO/Squads treasuries from sandwiched quotes, honeypot SPL authorities, spoofed-liquidity traps, and concentration risk.

Built from scratch starting December 1, 2026 for the **Superteam × CoinGecko Long Tail Hackathon (AI Agents Track)**. Every decision is deterministic, SHA-256 fingerprinted, and grounded in live CoinGecko API and Solana Mainnet RPC citations — zero hallucinated numbers.

---

## Live Screenshots

### 1. Pre-Trade 7-Gate Swap Guardrail (Live Sandwich/Overpay BLOCK + SHA-256 Receipt)
Intercepts proposed agent swaps before signing, comparing the quote against live CoinGecko spot prices & pool reserves while verifying SPL `mintAuthority`, `freezeAuthority`, and Top-10 holder concentration directly on Solana mainnet.

![GeckoGuard Pre-Trade Swap Guardrail](docs/screenshots/01-swap-guardrail.png)

### 2. Citation-Grounded Token Due-Diligence Agent
Generates structured research memos for any Solana ticker or mint address where every single number is traced directly to CoinGecko Onchain API endpoints and Solana RPC slots.

![GeckoGuard Token Due Diligence](docs/screenshots/02-token-due-diligence.png)

### 3. Autonomous Squads Multisig & Treasury Policy Watchdog
Enumerates live SOL, SPL Token, and Token-2022 vault holdings via Solana RPC, values them with CoinGecko API, evaluates stablecoin runway & single-asset concentration caps, and drafts liquidity-sized TWAP rebalance legs.

![GeckoGuard Squads Treasury Watchdog](docs/screenshots/03-squads-treasury.png)

### 4. Autonomous Solana New-Pool Scout
Screens newly launched & trending Solana pools from CoinGecko against on-chain SPL authority, liquidity depth, and buy/sell order-flow gates — automatically dropping thin/spoofed traps and exporting a clean Markdown digest.

![GeckoGuard New-Pool Scout](docs/screenshots/04-new-pool-scout.png)

---

## Quick Start

### Prerequisites
- Node.js **>= 20** (zero external runtime dependencies)

### 1. Install & Run Deterministic Test Suite
```bash
git clone https://github.com/oppo2357/geckoguard-solana.git
cd geckoguard-solana
cp .env.example .env
npm install
npm test
```

### 2. Start the Security Control Plane Web UI
```bash
npm run dev
# Open http://localhost:3090
```

Works out of the box in zero-key public mode. Supply a CoinGecko Analyst/Pro key via `.env` (`COINGECKO_API_KEY`, `COINGECKO_API_TIER=pro`) or the in-memory **API Key** modal to unlock 500 RPM.

### 3. Connect as a Native MCP Server (Claude Code / Cursor / Codex / Gemini CLI)
```json
{
  "mcpServers": {
    "geckoguard-solana": {
      "command": "node",
      "args": ["dist/src/mcp.js"],
      "env": {
        "COINGECKO_API_KEY": "",
        "COINGECKO_API_TIER": "public",
        "SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com"
      }
    }
  }
}
```

Exposed MCP tools (`2024-11-05` JSON-RPC 2.0 stdio):
- `guard_solana_swap` — 7-gate pre-trade `ALLOW | WARN | BLOCK` decision with SHA-256 receipt
- `due_diligence_solana_token` — citation-grounded token DD memo
- `audit_solana_treasury` — live SOL/SPL/Token-2022 vault audit + liquidity-sized Squads rebalance proposal
- `scout_new_solana_pools` — automated new-pool trap filter & surviving candidates digest

### 4. Run the Headless CLI
```bash
npm run cli -- dd --token JUP
npm run cli -- guard --out JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN --amount 1000 --quote 3800
npm run cli -- treasury --wallet <SOLANA_MULTISIG_OR_WALLET>
npm run cli -- scout --minTvl 15000
```

---

## How CoinGecko API is Used

All pricing, pool liquidity, order flow, and new-pool feeds run through `src/clients/coingecko.ts` (supporting CoinGecko Analyst/Pro `x-cg-pro-api-key`, Demo `x-cg-demo-api-key`, and zero-key public fallback), recording an explicit `DataCitation` for every request:

| CoinGecko Onchain Endpoint | Agent Module | Purpose |
|---|---|---|
| `/simple/networks/solana/token_price/{addresses}` | Swap Guardrail, DD, Treasury | Ground-truth live USD spot pricing to detect quote overpayment (bps) and value vault NAV |
| `/networks/solana/tokens/{address}/pools` | Swap Guardrail, DD, Treasury | Cross-DEX pool depth, spoofed-reserve anomaly detection, and TWAP chunk sizing |
| `/search/pools?network=solana` | Token Due Diligence | Resolves tickers (including Solana `xStocks` like `NVDAx`) to verified Solana mints & pools |
| `/networks/solana/new_pools` & `/trending_pools` | New-Pool Scout | Streams brand-new Solana pool launches for automated trap rejection |

Every view, Markdown memo, CLI output, and MCP receipt includes **Data by CoinGecko API** attribution.

---

## How Solana is Used

1. **On-Chain SPL & Token-2022 Mint Security (`getAccountInfo` `jsonParsed`)**: Directly inspects live `mintAuthority` and `freezeAuthority` on Solana mainnet to block supply-inflation and wallet-freeze honeypots before an agent signs a swap.
2. **Live Holder Concentration (`getTokenLargestAccounts`)**: Measures real Top-1 and Top-10 holder share directly from Solana mainnet supply.
3. **Full Treasury & Squads Vault Enumeration (`getBalance` + `getTokenAccountsByOwner`)**: Reads native SOL, classic SPL Token (`Tokenkeg...`), and Token-2022 (`TokenzQd...`) holdings live from Solana mainnet.
4. **Browser Wallet Connect & Solana Actions**: Supports Phantom/Solflare wallet selection in the Treasury Watchdog plus `/actions.json` and `/api/actions/guard-check?mint=<address>`.

---

## License

MIT License — see [LICENSE](LICENSE). Built from scratch starting December 1, 2026.