Skip to main content
Glama
Pacioli Solana & CoinGecko Veritas

Pacioli Solana & CoinGecko Veritas

README.md
# βš–οΈ Pacioli Solana & CoinGecko Veritas (`v1.0.0`)

**Zero-Float Exact-Rational ($\mathbb{Q}$) Treasury Analytics Dashboard & Streamable HTTP MCP Server for Solana + CoinGecko**

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-emerald.svg)](./LICENSE)
[![Data: Powered by CoinGecko API](https://img.shields.io/badge/Data-Powered_by_CoinGecko_API-8dc63f)](https://www.coingecko.com/en/api)
[![Network: Solana Mainnet-Beta](https://img.shields.io/badge/Solana-Mainnet_JSON--RPC-9945ff)](https://solana.com)
[![Protocol: MCP Streamable HTTP](https://img.shields.io/badge/MCP-Streamable_HTTP_2025--06--18-gold)](./pacioli_veritas/mcp_server.py)

> **Superteam Earn Γ— CoinGecko `Long Tail` Hackathon Declaration (`Analytics, Data & Media` Track):**
> `100%` of this standalone repository (`pacioli-solana-veritas`) was designed and built **from scratch starting December 4, 2026** (within the Dec 1 – Dec 15, 2026 build window) under the open-source **Apache-2.0** license. Market & on-chain pool data are proudly **[Powered by CoinGecko API](https://www.coingecko.com/en/api)**.
>
> - **🌐 Live Production Dashboard:** https://pacioli-solana-veritas-952479300704.europe-west1.run.app
> - **πŸ€– Live Streamable HTTP MCP Server:** `https://pacioli-solana-veritas-952479300704.europe-west1.run.app/mcp` (`/.well-known/mcp.json`)

![Pacioli Solana & CoinGecko Veritas β€” Live Mainnet Treasury & DEX Audit](./docs/dashboard-live-mainnet.png)

---

## 🎯 The Problem: Silent IEEE-754 Floating-Point Drift & Unverified Analytics in DeFi / AI

Standard crypto dashboards and AI agents parse market prices and token balances using IEEE-754 `float64` numbers (`0.1 + 0.2 != 0.3`). Across multi-hop Solana swaps, large SPL treasury valuations (`lamports` at $10^9$ scale), and CEX-vs-DEX basis checks:
1. **IEEE-754 rounding errors** accumulate silently, breaking double-entry accounting identities ($\text{Assets} - \text{Liabilities} - \text{Equity} \neq 0$).
2. **AI agents hallucinate or misread liquidity depth**, falling prey to thin Solana DEX pools or Spot-vs-DEX price divergence.
3. **Analytics outputs lack cryptographic provenance** β€” screenshots and raw JSON responses can be altered with zero audit trail.

---

## πŸ’Ž Our Solution: End-to-End Exact-Rational ($\mathbb{Q}$) Analytics + Cryptographic Receipts

1. **Zero-Float Ingestion (`parse_float=str` β†’ `fractions.Fraction`):**
   Even Python's JSON parser is configured with `json.loads(raw, parse_float=str)` so CoinGecko spot prices, 24h volumes, market caps, and DEX pool reserves **never touch IEEE-754 binary floating-point**. Every figure enters `fractions.Fraction` ($p/q \in \mathbb{Q}$) with exact base-10 precision.
2. **Live Solana Mainnet On-Chain Verification + Wallet Signature Proof:**
   - Queries confirmed native `SOL` (`lamports`) and major SPL token accounts (`USDC`, `USDT`, `JUP`, `RAY`, `BONK`, `JTO`, `PYTH`, `MSOL`, `JLP`, `WIF`) directly via Solana JSON-RPC (`getBalance` + `getTokenAccountsByOwner`).
   - Connects natively to **Phantom / Solflare** in the browser and verifies 64-byte **Solana Ed25519 (`RFC 8032`) ownership signatures** in pure zero-dependency Python.
3. **CoinGecko Global Spot VWAP vs. Solana On-Chain DEX Spread Detector:**
   Cross-verifies CoinGecko `/simple/price` (`precision=full`) against top Solana DEX liquidity pools (CoinGecko Onchain `/onchain/networks/solana/tokens/{mint}/pools` / GeckoTerminal) in **exact rational basis points (`bps`)**, flagging thin reserves (`<$25k`) or basis divergence (`>35 bps` / `>150 bps`).
4. **RFC 6962 Merkle Audit Trees + `<300B` Compact MTC Attestation:**
   Every treasury and market audit is sealed into a domain-separated **RFC 6962 Merkle Tree** (`0x00` leaf, `0x01` internal node), signed with **Ed25519**, and accompanied by a compact `<300-byte` SHA-384 Merkle Tree Credential (`MTC`) verifiable offline in `< 2 ms`.
5. **Streamable HTTP Model Context Protocol (`POST /mcp`) Server:**
   Any MCP-compatible AI client (Claude, Gemini, Cursor, Antigravity) can connect directly to `/mcp` with zero auth to invoke 4 deterministic read-only analytical tools.

---

## πŸ—οΈ Architecture

```
+-----------------------+       +-----------------------------------+
|   CoinGecko API v3    |       |    Solana Mainnet-Beta JSON-RPC   |
| Spot VWAP + 24h Vol + |       | getBalance (Slot & Lamports) +    |
| Onchain Solana Pools  |       | getTokenAccountsByOwner (SPL)     |
+-----------+-----------+       +-----------------+-----------------+
            |  json.loads(..., parse_float=str)   |
            +------------------+------------------+
                               v
        +----------------------------------------------+
        |   Pacioli Exact-Rational Engine (p/q in Q)   |
        | - Assets - Liabilities - Equity == 0/1       |
        | - Exact Portfolio Weights (sum w_i == 1/1)   |
        | - HHI Concentration & 24h Slippage bps       |
        | - IEEE-754 Float64 Drift Benchmark           |
        +----------------------+-----------------------+
                               v
        +----------------------------------------------+
        |  Cryptographic Notary (Pure-Stdlib Python)   |
        | - RFC 6962 Binary Merkle Inclusion Proofs    |
        | - RFC 8032 Ed25519 Signature + Solana Base58 |
        | - Compact <300B SHA-384 MTC Token            |
        +-----------+----------------------+-----------+
                    |                      |
                    v                      v
     +---------------------------+  +--------------------------+
     | Interactive Web Dashboard |  | Streamable HTTP /mcp     |
     | Phantom/Solflare Connect  |  | 4 Zero-Float Agent Tools |
     +---------------------------+  +--------------------------+
```

---

## πŸš€ Quickstart (30 Seconds)

```bash
# 1. Install lightweight dependencies (or reuse any Python 3.11+ virtualenv with FastAPI & httpx)
pip install -r requirements.txt

# 2. Optional: Set your complimentary CoinGecko Analyst Pro API key (falls back cleanly to public v3 if unset)
export COINGECKO_PRO_API_KEY="your_analyst_key_here"
# Or Demo key: export COINGECKO_DEMO_API_KEY="..."
# Optional custom Solana RPC: export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"

# 3. Run unit & cryptographic test suite
pytest -v

# 4. Start the Analytics Dashboard + REST API + /mcp Server
uvicorn pacioli_veritas.app:app --reload --port 8080
```

Then open **http://localhost:8080** in your browser!

---

## πŸ”Œ MCP Server Tools (`POST /mcp`)

Connect any MCP client to `http://localhost:8080/mcp`:
1. `audit_solana_wallet_treasury` β€” Live zero-float Pacioli double-entry balance sheet + Merkle & Ed25519 receipt for any Solana wallet.
2. `audit_coingecko_solana_dex_spread` β€” Exact rational basis-point (`bps`) cross-check between CoinGecko global VWAP and Solana DEX pool reserves.
3. `quantify_ieee754_float_drift` β€” Exact rational vs IEEE-754 `float64` multi-hop drift benchmark.
4. `verify_pacioli_cryptographic_receipt` β€” Deterministic 6-point verification of any sealed Pacioli receipt.

---

## πŸ“œ Attribution & License

- **Market & DEX Data:** [Powered by CoinGecko API](https://www.coingecko.com/en/api)
- **Author:** David Porto BaraldΓ©s ([Homo Universalis](https://homouniversalis.ai))
- **License:** Apache License 2.0 (`LICENSE`)