Skip to content

iwbinb/usdc-explorer

Repository files navigation

USDC Explorer

A production-grade, browser-only intelligence dashboard for monitoring USDC across mainnets and Arc Testnet, with an AI Agent Command Center built for the Agora Agents Hackathon.

Live multi-chain USDC supply, RPC health, wallet behavior, transfer tape, and transaction decoding — fused into deterministic agent recommendations. No backend, no wallet signing, no API keys.

stack stack stack stack tests


English

Why this exists

The Agora Agents Hackathon asks: what does it look like when AI agents make markets in USDC? This project answers that with a single screen an operator (or an agent) can use to see live USDC state, route settlement, and export deterministic intents — all from public RPC data.

Highlights

  • Live multi-chain supply for Arc Testnet plus Ethereum, Base, Arbitrum One, OP Mainnet, Polygon PoS, Avalanche C-Chain, and Solana.
  • Per-chain failure isolation — one slow public RPC never blocks the whole app.
  • ⌘K command palette — paste an EVM/Solana address or a 0x tx hash and the right view loads with that input wired up.
  • Cross-view session — risk profile, scenario, capital, and active address travel between Overview / Wallets / Agents / Operations.
  • Wallet driving cab — balances + activity + a Wallet Habit Agent that profiles the address (persona, cadence, ticket size, risk label).
  • Transfer tape — recent USDC Transfer events with min-amount filter, CSV export, and one-click "decode this tx".
  • Transaction decoder — paste a hash, see USDC legs derived from the live receipt.
  • AI Agent Command Center — 4 deterministic agents (Settlement Router, Liquidity Scout, RPC Guardian, Treasury Rebalancer) plus swarm pipeline, scenario simulator, and JSON memo export.
  • RPC manager — per-chain auto / pinned / custom RPC endpoints, persisted in localStorage.
  • Hackathon panel — Arc readiness, chain id, gas token, contract directory, faucet link.
  • All static: builds to dist/ and ships to any static host.

Tech stack

React 19 · TypeScript 5.8 (strict) · Vite 6 · TanStack Query 5 · viem 2 · Recharts · lucide-react. Tests: Vitest + Testing Library.

Quick start

npm install
npm run dev            # http://localhost:5173

Production build:

npm run check          # tsc -b
npm run build          # static bundle in dist/
npm run preview        # http://localhost:4173

Tests:

npm test               # one-shot
npm run test:watch
npm run coverage

Project layout

src/
├─ App.tsx                  # Composition root; reads overview/price, picks the active view
├─ main.tsx                 # React + QueryClient bootstrap
├─ data/chains.ts           # Registry of supported chains + USDC addresses
├─ state/session.tsx        # SessionContext (reducer) + stable SessionActionsContext
├─ hooks/
│  ├─ useRpcSettings.ts     # localStorage-backed RPC mode selector
│  └─ useUsdcData.ts        # fetchOverview + useTransfers / useWalletActivity / useWalletBalancesFor / useTransactionDecoder
├─ lib/
│  ├─ evm.ts                # viem client + USDC readers + activity / decoder
│  ├─ solana.ts             # JSON-RPC reader for SPL USDC
│  ├─ rpcSettings.ts        # RpcSettings → ordered URL list
│  ├─ format.ts             # USD/number/age/latency/error formatters
│  ├─ exports.ts            # CSV/JSON export pipelines + explorerUrl()
│  └─ habit.ts              # buildHabitProfile (uses demo fallback when sparse)
├─ components/
│  ├─ AppShell.tsx          # Top bar, sidebar nav, session summary
│  ├─ CommandBar.tsx        # ⌘K palette (address/tx-hash/chain/action commands)
│  └─ primitives.tsx        # Panel, Metric, Segmented, Chip, Field, buttons, etc.
├─ views/
│  ├─ OverviewView.tsx      # Metrics + supply chart + latency chart + network ledger + drawer
│  ├─ WalletsView.tsx       # Address workbench (balances/activity/habit) + tape + decoder
│  ├─ AgentsView.tsx        # 4 agent cards + swarm pipeline + scenario simulator + intents
│  └─ OperationsView.tsx    # Hackathon panel + contracts + RPC manager + health + concentration
├─ test/                    # Vitest setup + shared providers wrapper
└─ styles.css               # Circle-blue light theme (~36 kB)

Data sources

Security & data handling

  • Read-only. The app never asks for a signature, private key, seed phrase, or token approval.
  • No backend, no API key. All requests go directly from the browser to public RPC + DefiLlama.
  • Local persistence. Only two keys in localStorage: usdc-explorer-rpc-settings and usdc-watchlist. Both are defended against malformed payloads.
  • Per-chain isolation. A failing RPC degrades that chain only; the rest of the dashboard remains live.
  • Bounded queries. Transfer log scans use adaptive lookback windows (W, W/2, W/4, …) so public RPC limits are respected.

Agents

Agent Inputs Output
Settlement Router live rows, latency ceiling per risk mode recommended chain to settle the next agent flow
Liquidity Scout mainnet supply distribution preferred reference liquidity venue
RPC Guardian slow/stale/offline counts whether to keep auto-fallback or pin RPCs
Treasury Rebalancer risk profile, capital, USDC price size of capital to allocate this cycle

All four scores are closed-form functions of the inputs. The same inputs produce the same JSON memo — exportable as usdc-agent-memo-YYYY-MM-DD.json.

Verification

  • npm run checktsc -b clean
  • npm test110 tests, 13 files, all passing
  • npm run build → 35.80 kB CSS / 254.71 kB JS gzipped
  • Arc Testnet RPC returns chain id 5042002
  • Arc USDC contract returns symbol=USDC, decimals=6

See docs/REVIEW.md for the full code-review report and docs/requirements.md for the requirements traced.

Hackathon-specific notes

  • Arc is wired in as a first-class network at every layer (overview, ledger, RPC manager, balances, activity, tape, decoder, hackathon panel).
  • The settlement router prefers Arc when it is live and within the risk-mode latency ceiling.
  • Agent memos and CSV exports are designed to be consumable by downstream agents or judging tools.

License

Private hackathon submission. Do not redistribute without permission.


中文 (简体)

这是什么

为 Agora Agents Hackathon 打造的生产级、纯浏览器端 USDC 多链情报看板,覆盖 Arc Testnet 与 7 条主流链。把链上 USDC 状态、RPC 健康度、钱包行为、转账流和交易解码,融合成一套可解释、可复现的 AI Agent 推荐结果。

无后端、无钱包签名、无任何 API key。

核心能力

  • 多链实时供应:Arc Testnet + Ethereum、Base、Arbitrum One、OP Mainnet、Polygon PoS、Avalanche C-Chain、Solana。
  • 逐链故障隔离:单条公共 RPC 慢/挂掉不影响其他链。
  • ⌘K 命令面板:粘贴 EVM/Solana 地址或 0x 交易哈希,直接跳到对应视图并预填。
  • 跨视图会话状态:风险档位、场景、资金、地址在 Overview / Wallets / Agents / Operations 之间共享。
  • 钱包驾驶舱:余额 + 活动 + Habit Agent(画像、节奏、单笔规模、风险标签)。
  • 转账 Tape:近期 USDC Transfer 事件,可设最低金额、导出 CSV、一键 decode。
  • 交易解码器:粘贴 hash,从实时 receipt 解出 USDC 流向。
  • AI Agent 指挥中心:4 个确定性 Agent(结算路由、流动性侦察、RPC 守护、库存再平衡)+ 群体流水线 + 场景模拟 + JSON Memo 导出。
  • RPC 管理器:每条链支持 自动 / 钉选 / 自定义 三种模式,本地持久化。
  • Hackathon 面板:Arc 就绪度、Chain ID、gas token、合约目录、Faucet。
  • 完全静态:构建产物在 dist/,可部署到任意静态主机。

技术栈

React 19 · TypeScript 5.8(strict)· Vite 6 · TanStack Query 5 · viem 2 · Recharts · lucide-react。测试:Vitest + Testing Library。

快速开始

npm install
npm run dev            # http://localhost:5173

生产构建:

npm run check          # tsc -b
npm run build          # 静态产物输出到 dist/
npm run preview        # http://localhost:4173

测试:

npm test               # 一次性
npm run test:watch
npm run coverage

项目结构

src/
├─ App.tsx                  # 组合根;订阅 overview/price,选择当前视图
├─ main.tsx                 # React + QueryClient 启动
├─ data/chains.ts           # 链注册表 + USDC 合约地址
├─ state/session.tsx        # SessionContext(reducer)+ 稳定的 SessionActionsContext
├─ hooks/
│  ├─ useRpcSettings.ts     # localStorage 持久化的 RPC 模式
│  └─ useUsdcData.ts        # fetchOverview + 各 useXxx hook
├─ lib/
│  ├─ evm.ts                # viem 客户端 + USDC 读取 + 活动 / 解码
│  ├─ solana.ts             # 原生 JSON-RPC 读取 SPL USDC
│  ├─ rpcSettings.ts        # RpcSettings → 有序 URL 列表
│  ├─ format.ts             # USD/数字/年龄/延迟/错误格式化
│  ├─ exports.ts            # CSV/JSON 导出 + explorerUrl()
│  └─ habit.ts              # buildHabitProfile(数据少时落到清晰标注的 demo)
├─ components/
│  ├─ AppShell.tsx          # 顶栏 + 侧栏导航 + 会话摘要
│  ├─ CommandBar.tsx        # ⌘K 命令面板(地址 / 交易哈希 / 链 / 动作)
│  └─ primitives.tsx        # Panel / Metric / Segmented / Chip / Field / 按钮等
├─ views/
│  ├─ OverviewView.tsx      # 指标 + 供应图 + 延迟图 + 网络明细 + 详情抽屉
│  ├─ WalletsView.tsx       # 地址工作台 + Tape + 解码器
│  ├─ AgentsView.tsx        # 4 个 Agent 卡 + 群体流水线 + 场景模拟 + 意图
│  └─ OperationsView.tsx    # Hackathon + 合约 + RPC 管理 + 健康信号 + 集中度
├─ test/                    # Vitest 配置 + 共享 Provider 封装
└─ styles.css               # Circle 蓝浅色主题(约 36 kB)

数据源

安全与数据

  • 只读。不索要签名、私钥、助记词、token approval。
  • 无后端、无 API key。所有请求直接从浏览器发往公共 RPC + DefiLlama。
  • 本地持久化localStorage 只写两把键:usdc-explorer-rpc-settingsusdc-watchlist,均做了 shape 校验。
  • 逐链隔离。任一 RPC 失败只降级该链,其余面板照常。
  • 窗口收敛。Transfer 日志扫描使用自适应窗口(W, W/2, W/4, …),不撞公共 RPC 限速。

Agent 详解

Agent 输入 输出
结算路由 Settlement Router 在线链、延迟上限(按风险档) 下一笔 Agent flow 应在哪条链结算
流动性侦察 Liquidity Scout 主网供应分布 参考流动性场所
RPC 守护 RPC Guardian 慢/陈旧/离线计数 是否保留自动 fallback 或改为钉选
库存再平衡 Treasury Rebalancer 风险档、资金、USDC 价格 本轮策略可分配资金量

四个分数都是输入的闭式函数。相同输入产出相同 JSON memo,可一键导出为 usdc-agent-memo-YYYY-MM-DD.json

验证

  • npm run checktsc -b 通过
  • npm test110 个测试,13 个文件,全部通过
  • npm run build → 35.80 kB CSS / 254.71 kB JS(gzip)
  • Arc Testnet RPC 返回 chain id 5042002
  • Arc USDC 合约返回 symbol=USDCdecimals=6

完整代码评审报告见 docs/REVIEW.md,需求追溯见 docs/requirements.md

Hackathon 备注

  • Arc 在每个层级都作为一等公民接入(Overview、明细表、RPC 管理、余额、活动、Tape、解码器、Hackathon 面板)。
  • 当 Arc 在线且延迟低于风险档上限时,结算路由优先推荐 Arc。
  • Agent Memo 与 CSV 导出格式刻意设计为可被下游 Agent / 评委工具消费。

许可

私有 Hackathon 项目。未经允许请勿转发。

About

Multi-chain USDC operations dashboard for the Agora Agents Hackathon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors