Skip to main content
Glama
README.md
# ExitGuard

**What can you *really* exit with?** ExitGuard is an agent that audits long-tail Solana token positions and answers the question a price chart cannot: *if I sell this bag now, how many dollars actually come out?*

**๐ŸŸข Live demo (no install, works on phone): https://bgbug22.github.io/exitguard/** โ€” the real dashboard replaying captured audits (snapshot data, timestamped; run locally for live data).

**โ–ถ Demo video (2 min): https://youtu.be/fXBSAFK2MeA**

> **Powered by CoinGecko API** โ€” all market, pool, holder and trade data: *Data by Coingecko API*.

Built for the **Long Tail: CoinGecko API x Solana** hackathon (track: AI Agents). Built since **1 Dec 2026**. MIT licensed.

![ExitGuard desktop: paper value vs realizable exit and the Illiquidity Trap Score](docs/screenshots/desktop-audit.png)

*Real audit, 5 Dec 2026: a $10,000 paper position in the long-tail token BB84 is worth about $5,284 on exit (live Jupiter quote) โ€” Illiquidity Trap Score 97/100. Data by Coingecko API.*

## Run it in one command

Requirements: **Node.js โ‰ฅ 20** (developed on v24) and a CoinGecko API key. **Zero dependencies โ€” no `npm install`, no build step.**

```bash
git clone https://github.com/BGBug22/exitguard.git && cd exitguard && COINGECKO_API_KEY=<your-key> npm start
```

Then open **http://127.0.0.1:8787** and tap one of the **1-click real examples** (a $10,000 paper position in a token that is trending right now).

Prefer a config file? Copy the template (it contains **no real key**) and fill in your own:

```bash
cp .env.example .env      # set COINGECKO_API_KEY=... inside; .env is git-ignored
npm start
```

| Variable | Default | Purpose |
|---|---|---|
| `COINGECKO_API_KEY` | *(required)* | Your CoinGecko API key. On-chain endpoints (top holders, trades, megafilter) need a paid plan such as Analyst. |
| `COINGECKO_BASE_URL` | `https://pro-api.coingecko.com/api/v3` | API root. |
| `SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Read-only RPC for wallet mode. |
| `JUPITER_QUOTE_URL` | `https://lite-api.jup.ag/swap/v1/quote` | Live swap quotes. |
| `EXITGUARD_FEE_BPS` / `PORT` | `30` / `8787` | Assumed pool fee for the AMM model / web port. |

**Key safety.** The key is read from the environment on the server side only. It is sent as the `x-cg-pro-api-key` header, never placed in a URL, never sent to the browser, never written to any output. `npm run scan` checks the working tree and the whole git history for key patterns.

## What it does

For any Solana token position (or a whole wallet, read-only) ExitGuard produces, from live data only:

1. **Paper Value vs Realizable Exit Value** โ€” price ร— amount versus what a sale would really return (live Jupiter quote; constant-product AMM model as cross-check and fallback).
2. **Illiquidity Trap Score (0โ€“100)** โ€” a transparent, documented score (formula below).
3. **Whale-Shock Stress Test** โ€” what your exit is worth if the top 1 / 3 / 10 holders sell before you.
4. **Split-Exit Plan** โ€” how many chunks, how far apart, and the estimated slippage per chunk versus selling at once.
5. **Evidence for every number** โ€” each section cites the exact API call (endpoint, URL, fetch timestamp) plus Solscan / GeckoTerminal links. If a data point cannot be fetched the output says `unavailable`; ExitGuard never fills in a number.

## Three ways to use it

### Web dashboard

`npm start`, then open http://127.0.0.1:8787. Two modes: **Token position** (paste a mint or use a 1-click example / Quick pick) and **Wallet (read-only)** (paste any public Solana address). Mobile-first; works at 390 px wide.

| Whale-Shock + Split-Exit (desktop) | Audit (phone) | Wallet with native SOL (phone) |
|---|---|---|
| ![Whale-Shock stress test and Split-Exit plan](docs/screenshots/desktop-whale-split.png) | ![Phone view of an audit](docs/screenshots/mobile-audit.png) | ![Phone view of a wallet audit including native SOL](docs/screenshots/mobile-wallet.png) |

*All screenshots are real audits on live data (5 Dec 2026). Powered by CoinGecko API.*

The suggestion lists (Quick pick and 1-click examples) hide tickers with profane, sexual, hateful or religious names; any mint can still be audited by pasting its address.

### CLI

```bash
node bin/exitguard.js trending                                   # live long-tail picks + ready-to-run examples
node bin/exitguard.js audit --mint <MINT> --amount <TOKENS>      # human-readable report
node bin/exitguard.js audit --mint <MINT> --amount <TOKENS> --json
node bin/exitguard.js audit --wallet <ADDRESS> [--top 5] [--json] # read-only wallet audit
node bin/exitguard.js whale-shock --mint <MINT> --amount <TOKENS>
node bin/exitguard.js split-exit  --mint <MINT> --amount <TOKENS>
```

(`npm link` makes the `exitguard` command available globally.)

### MCP server (stdio) โ€” for other AI agents

```json
{ "mcpServers": { "exitguard": { "command": "node", "args": ["/absolute/path/to/exitguard/bin/exitguard.js", "mcp"],
  "env": { "COINGECKO_API_KEY": "<your key>" } } } }
```

Tools: `exitguard_audit`, `exitguard_whale_shock`, `exitguard_split_exit`, `exitguard_wallet_audit`, `exitguard_trending`. Each returns a text report plus the full JSON (with evidence), so an agent can decide on its own whether a position is safe to exit and how.

A minimal client that performs the handshake, lists the tools and calls one is included:

```bash
node examples/mcp-client.mjs <MINT> <TOKENS>
```

### Hosted snapshot demo (GitHub Pages)

https://bgbug22.github.io/exitguard/ is the same dashboard (`web/index.html`) built by `node scripts/build-demo.mjs` into `docs/index.html`. Instead of calling the server it replays real ExitGuard responses saved in `docs/demo-data/*.json` (four token audits and one wallet audit, each with its original fetch timestamps and evidence links). The hosted page makes no CoinGecko calls and contains no API key; a banner states the capture time. To audit any other mint or wallet, run ExitGuard locally with your own key.

### Tests

```bash
npm test         # 30 offline unit tests (AMM math, score, whale-shock, split plan, safe-name filter, engine on recorded real responses)
npm run smoke    # live end-to-end: 2 trending long-tail tokens + 1 wallet (incl. native SOL), CLI, MCP, web server
npm run scan     # scans the working tree and the whole git history for key patterns
```

## How Coingecko API is used

CoinGecko's on-chain data is the backbone of ExitGuard: every figure in an audit is computed from it, and nothing works without it. **Data by Coingecko API.**

| Endpoint (`/onchain/...`) | Used for |
|---|---|
| `networks/solana/tokens/{mint}` | price, FDV, 24h volume, decimals โ†’ **Paper Value**; also the SOL price for native balances |
| `networks/solana/tokens/{mint}/pools` | every DEX pool and its USD reserve โ†’ **exit liquidity** and the AMM model |
| `networks/solana/tokens/{mint}/top_holders` | top holders (with LP labels) โ†’ **Whale-Shock stress test** |
| `networks/solana/tokens/{mint}/trades` | recent trades โ†’ real trading pace for the **Split-Exit plan** |
| `networks/solana/tokens/{mint}/info` | holder count, top-10 concentration, mint/freeze authority, GT score |
| `networks/solana/tokens/multi/{mints}` | pricing every token found in a wallet |
| `networks/solana/trending_pools` | Quick-pick list and the 1-click real examples |
| `pools/megafilter` | discovery of thin-liquidity, high-volume long-tail pools |

Every call is recorded as **evidence** (endpoint, canonical URL without the key, fetch timestamp) and each section of a report cites the evidence ids it was computed from. If a call fails, that section says `unavailable` โ€” ExitGuard never fills in a number. A `429` stops the audit instead of retrying around the limit.

## How Solana is used

- Everything audited lives on Solana: SPL / Token-2022 tokens and Solana DEX pools (PumpSwap, Meteora, Raydium, Orca, โ€ฆ).
- **Wallet mode** reads straight from Solana RPC, read-only: `getBalance` for native SOL and `getTokenAccountsByOwner` (both token programs) for SPL balances. No wallet connection, no signature, no private key.
- Native SOL and wSOL / USDC / USDT are counted as exit assets at their CoinGecko price; long-tail SPL positions are exit-tested one by one.
- **Jupiter** (Solana's swap aggregator) provides a live executable quote for the exact amount, token โ†’ USDC, as the primary Realizable Exit Value.
- Every token, pool, holder and wallet links to **Solscan** for independent verification.

## The maths (deterministic, no LLM in the loop)

**Exit liquidity.** Only pools pairing the token against SOL, USDC or USDT are "exit-grade". Pools against another long-tail token are listed but not counted.

**AMM model.** Exit-grade pools are merged into one virtual constant-product pool: hard-asset side `Y = ฮฃ reserve_usd / 2`, token side `X = Y / price`. Selling `a` tokens returns `Yยทa' / (X + a')` with `a' = aยท(1 โˆ’ fee)`. Fee assumed 30 bps (`EXITGUARD_FEE_BPS`), because the API does not expose pool fees.

**Realizable Exit Value.** The live Jupiter quote (USDC counted as $1) when available; otherwise the AMM model, clearly labelled. Both are shown with the gap between them.

**Illiquidity Trap Score** = sum of four components (100 points):

| Component | Weight | Formula |
|---|---|---|
| Exit haircut | 45 | `45 ร— min(1, haircut / 0.40)`, haircut = 1 โˆ’ realizable / paper |
| Position vs 24h volume | 20 | `20 ร— min(1, (paper / volume_24h) / 0.25)` |
| Whale overhang | 20 | `20 ร— modelled price drop if the top-10 non-LP holders sell` |
| Thin exit liquidity | 15 | `15 ร— clamp((6 โˆ’ log10(exit_reserve_usd)) / 2, 0, 1)` |

Bands: 0โ€“24 Liquid ยท 25โ€“49 Caution ยท 50โ€“74 High exit risk ยท 75โ€“100 Illiquidity trap. If an input is unavailable, its component is dropped, the rest is rescaled to 100 and the score is flagged `partial`.

**Whale-Shock.** From the top holders, exclude pool accounts, addresses labelled LP / burn / lock / bonding curve / vesting, and (in wallet mode) the audited wallet itself. The top 1 / 3 / 10 remaining holders sell their full balance into the virtual pool; your sale is then priced against the depleted pool.

**Split-Exit.** Chunk size is the largest sale that keeps price impact under 1% (escalating to 2%, then 5%; max 24 chunks). The interval is the time real trading flow โ€” the slower of the 24h average and the recent-trades pace โ€” needs to trade 5ร— the chunk's value. Reported: sell-at-once, split best case (pool fully recovers between chunks), split worst case (no recovery = same as selling at once), and a live Jupiter quote for one chunk. Per-chunk "impact" includes the assumed fee.

## Honest limitations

- **The AMM model is an estimate.** Real pools include concentrated-liquidity designs (Meteora DLMM, Orca Whirlpools) and different fees; the 50/50 constant-product assumption can over- or under-state depth. That is why the live Jupiter quote is preferred and the gap is always shown.
- Whale-Shock and the Split-Exit best case are **model scenarios**, not predictions. Holders may not sell; pools may not recover.
- A Jupiter quote is a quote at one instant, not an executed trade (no MEV, no failed transactions, 50 bps slippage setting).
- Top-holder labels come from the API; an unlabelled locked/team wallet would be counted as a potential seller.
- Wallet mode prices up to 90 tokens and deep-audits the largest 3 / 5 / 10 long-tail positions; smaller positions are not exit-tested and stay at paper value in the wallet total. Native SOL is counted at its CoinGecko price (network fees and rent are not deducted).
- The name filter for suggestions is a word list; it can miss a new offensive ticker or hide a harmless one.
- The public Solana RPC is rate-limited and can time out on very large wallets; set `SOLANA_RPC_URL` to your own endpoint for heavy use.
- **Not financial advice.** ExitGuard is read-only and never asks for keys or signatures.

## Project layout

```
bin/exitguard.js     CLI entry            src/core/      amm.js, score.js, whale.js, split.js, cleanname.js
src/audit.js         engine + evidence    src/sources/   coingecko.js, jupiter.js, solana.js
src/server.js        web server           src/mcp.js     MCP stdio server
web/index.html       dashboard            test/, scripts/  unit tests, live smoke test, secret scan
examples/            MCP client example   docs/screenshots/  real screenshots
```

## Attribution

**Powered by CoinGecko API** โ€” Data by [Coingecko API](https://www.coingecko.com/en/api). Swap quotes by Jupiter. Explorer links to Solscan.