Skip to content

Eras256/HookMind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

HookMind: The Protected Liquidity Protocol on Unichain

License: MIT Network Status Tests Security UF Hook API MCP HookRank npm version


⚠️ MANDATORY LEGAL DISCLAIMER

HookMind is experimental software deployed exclusively on Unichain Sepolia Testnet. Smart contracts have not been formally audited by an independent third party (audit planned Q3 2026 via UFSF). All operations use test tokens with no real monetary value.

HookMind is not financial advice. It is not an investment product. It does not guarantee yields, returns, or protection of any kind. IL insurance payouts are epoch-prorated and capped per coverage tier: Retail 500 USDC · Growth 2,500 USDC · Institutional 10,000 USDC per 7-day epoch — not a guarantee of returns.

Uniswap® and Unichain® are trademarks of Uniswap Labs. HookMind is an independent third-party Uniswap v4 hook and registered Uniswap Labs API Developer under the Uniswap Labs API Terms of Use. Swap routing is powered by the Uniswap Labs Trading API (v2 Universal Router). HookMind is not affiliated with, endorsed by, or sponsored by Uniswap Labs or the Uniswap Foundation.


HookMind is the first Protected Liquidity Protocol for Uniswap v4 on Unichain. Liquidity providers silently lose 2–15% of capital to impermanent loss every cycle — HookMind pairs off-chain AI agents (dynamic fee management) with on-chain smart contracts (impermanent loss insurance) so the damage is defended before it becomes visible. Built for the market that survived the closure of 40+ DeFi protocols this cycle: non-custodial, ECDSA-signed, IPFS-audited.

We are part of the Uniswap Foundation Acceleration Season 2026. Demo Day: May 28, 2026.


What It Does

Problem HookMind Solution
Static fees cannot price volatility AI agent adjusts fees every ~15 seconds via updateNeuralState()
LPs bleed to IL without recourse Auto-enrollment in on-chain USDC insurance at afterAddLiquidity
AI decisions are not auditable Every signal ECDSA-signed + IPFS-pinned before hitting the chain
LP management requires constant attention 24/7 autonomous agent loop with circuit breakers

Live on Unichain Sepolia — Verifiable Now


Architecture

LP Operator / Institution
        │
        ▼
  [Next.js 15 Dashboard — hookmind.xyz]
  [i18n: EN / ES / ZH  ·  11 routes  ·  100% mobile responsive]
        │
        ▼
  [REST API — Express 5  ·  Supabase  ·  12 route modules]
  ├── Auth: JWT (HS256) + API Key (SHA-256 hash) + RBAC by tier
  ├── Rate limiting: sliding window (60/100/500/∞ rpm by tier)
  ├── MPP budget enforcement (session-level spend caps)
  ├── WebSocket: real-time signal broadcast + heartbeat
  └── Webhooks: HMAC-SHA256 delivery to external systems
        │
        ▼
  [Agent Daemon — Node.js 20  ·  ~15s loop]
  ├── Pool reader (viem — Unichain Sepolia RPC + backup)
  ├── PredictiveInventoryModel (volatility score 0–10,000, inlined into HookMindCore)
  ├── LLM router: Claude Sonnet 4.6 / GPT-4.1 / Gemini 2.5 / Grok 3 / mock
  │   └── Circuit breaker: 10s timeout → volatility-based fallback fee
  ├── IPFS audit log (Pinata) — aborts cycle if pinning fails
  └── ECDSA signer → HookMindCore.updateNeuralState()
        │
        ▼
  [Uniswap v4 Hooks — Unichain Sepolia  ·  chainId 1301]
  ├── HookMindCore.sol   beforeSwap / afterSwap / afterAdd / afterRemove · inlines AgentRegistry + fee accumulator
  └── ILInsurance.sol    USDC coverage pool  ·  epoch-prorated payouts
        │
        ▼
  [Uniswap Foundation Standard Hook Events]
  HookSwap · HookFee · HookModifyLiquidity · HookBonus
        │
        ▼
  [IPFS / Pinata] — immutable audit trail per signal

Smart Contracts (Unichain Sepolia · chainId 1301)

Contract Address Purpose
HookMindCore 0x4259AC8Ff2561d7d0CCDB705E6fB0eF335dcD5c0 v4 Hook: dynamic fees, IL enrollment, inlined agent registry + fee accumulator
ILInsurance 0xd023188694C085ce30b0C204B0726797f46eC131 USDC insurance pool · epoch payouts · tiered coverage
PoolManager 0x00B036B58a818B1BC34d502D3fE730Db729e62AC Uniswap v4 PoolManager
USDC 0x31d0220469e10c4E71834a79b1f276d740d3768F Real USDC on Unichain Sepolia (16.6M supply)
WETH 0x4200000000000000000000000000000000000006 Wrapped ETH on Unichain
Pool (tickSpacing=60) 0x06d5c163592096086178db56f0ade3d22fbdba6324531c4dfa29171a30b01abb USDC/WETH ~2000, primary agent target

Verify all contracts at Unichain Sepolia Explorer.


Key Protocol Parameters

Parameter Value Notes
MIN_FEE 500 bps (0.05%) Hard floor enforced on-chain
MAX_FEE 10,000 bps (1.00%) Hard ceiling enforced on-chain
MIN_UPDATE_INTERVAL 12 seconds (1 Unichain block) On-chain guardrail. Off-chain loop runs ~15s to stay safely above this floor
IL threshold 200 bps (2%) Below this: no payout
Max payout per LP 500 / 2,500 / 10,000 USDC Retail / Growth / Institutional tier
Pool risk cap 1,500 bps (15%) Max epoch exposure
Agent activation fee 0.0015 ETH (~$5) One-time, non-refundable
IL premium 10–200 USDC Per LP position (tier-dependent)
LLM circuit breaker 10 seconds Falls back to σ-based formula

Revenue Model (Software-Only)

Stream Trigger Amount
Agent Activation Registration in AgentRegistry 0.0015 ETH (~$5)
IL Insurance Premium payPremium() / payPremiumTiered() 10–200 USDC per LP position
SaaS Growth Tier Monthly subscription $49 / month
Intelligence API Per-request signal access $0.01–$0.10 / request

Test Coverage

3 test suites · 44 tests · 100% pass rate (Foundry)

HookMindCore.t.sol  — invariant fuzz, ECDSA, rate limit, replay, registerAgent, computeExpectedFee
ILInsurance.t.sol   — IL formula, tier model, governance setters, solvency, claim flow
HookMind.t.sol      — end-to-end: dynamic fee applied via swap

CI: Foundry fuzz (10,001 runs), invariants (1,000 runs × 100,000 calls), Slither gated on --fail-high.


Frontend

  • Framework: Next.js 15 (App Router) · force-dynamic
  • Wallet: wagmi v2 · viem v2 · RainbowKit (AppKit)
  • 3D: Three.js via @react-three/fiber — lazy-loaded, skipped on mobile
  • Fonts: Self-hosted via next/font (Inter + JetBrains Mono) — no Google Fonts request
  • i18n: EN / ES / ZH via LanguageContext · institutional tone · localStorage persistence
  • Performance: 15k GPU particles (desktop only) · AVIF/WebP images · optimizePackageImports
  • Responsiveness: 100% mobile + desktop · error.tsx boundaries on all critical routes
Route Section Description
/ Landing Hero, live signal feed, tech stack, CTA
/dashboard CORE Protocol metrics, fee chart, signal feed
/agents CORE Agent console, operator status
/pools CORE Live pool analytics
/leaderboard CORE Global operator rankings
/vault PROTECTION IL insurance activation
/strategies PROTECTION Strategy marketplace
/builder PROTECTION Visual strategy builder
/docs DEVELOPER Full protocol documentation
/skills DEVELOPER MCP tools
/swap Standalone swap interface

Quick Start

# Clone
git clone https://github.com/Eras256/HookMind && cd HookMind

# Install
pnpm install

# Environment (copy and fill)
cp .env.local.example .env.local

# Frontend
pnpm --filter web dev

# Agent daemon
pnpm run dev:agent

# Smart contract tests
pnpm run test:contracts

# TypeScript check
cd apps/web && npx tsc --noEmit

Monorepo Structure

HookMind/
├── apps/web/              # Next.js 15 frontend (App Router)
├── packages/agent/        # AI agent daemon (Node.js 20 + tsx)
│   └── src/
│       ├── engine.ts      # Agent loop: pool → LLM → IPFS → ECDSA → chain
│       ├── signer.ts      # EIP-191 ECDSA signing
│       ├── routes/        # REST API: health, signals, pools, fees, vault, auth, mpp, webhooks
│       ├── services/      # agentService, poolService, feeService, vaultService
│       ├── ws/            # WebSocket broadcast server
│       └── providers/     # LLM adapters (Claude Sonnet 4.6, GPT-4.1, Gemini 2.5, Grok 3, mock)
├── packages/contracts/    # Foundry smart contracts (Solidity 0.8.26)
│   ├── src/               # HookMindCore, ILInsurance
│   ├── test/              # 3 test suites · 44 tests
│   └── script/            # DeployConsolidated.s.sol
├── packages/mcp/          # MCP tools integration
├── packages/sdk/          # TypeScript SDK (npm: hookmind)
└── .github/workflows/     # CI: Foundry tests + Slither (--fail-high) + Next.js build

Security Posture

  • ECDSA on-chain verification: Every agent signal verified against HookMindCore.authorizedAgents[signer]
  • Nonce replay protection: HookMindCore.agentNonces[signer] — monotonic, source of truth
  • Fee bounds: MIN_FEE=500 and MAX_FEE=10000 enforced in updateNeuralState() before state write
  • Rate limiting: MIN_UPDATE_INTERVAL=12s; first call always allowed (sentinel lastAgentUpdate=0)
  • One-time insurance wiring: setInsurance() protected by AlreadyInitialized guard
  • Custom errors throughout: All reverts use typed errors (InvalidFeeRange, NotAgentOperator, AlreadyClaimed, AlreadyInitialized, etc.)
  • No delta flags: Hook does not intercept swap amounts — automatically allowlisted by Uniswap routing
  • Slither CI: Static analysis gated on --fail-high — blocks merge on critical findings
  • JARGUS internal audit: 14/14 checks passing across 6 security pillars (May 2026)
  • Formal audit: Planned Q3 2026 via Uniswap Foundation Security Fund (UFSF application in progress)

Uniswap Foundation Compliance

All 4 standard UF hook events emitted:

  • HookSwap(PoolId, sender, amount0, amount1, hookLPfee) — emitted in _afterSwap
  • HookFee(PoolId, sender, feeAmount0, feeAmount1) — emitted in _afterSwap
  • HookModifyLiquidity(PoolId, sender, liquidityDelta) — emitted in _afterAddLiquidity + _afterRemoveLiquidity
  • HookBonus(PoolId, sender, bonusAmount0, bonusAmount1) — emitted in _afterSwap

Required for HookRank auto-indexing and The Graph protocol indexer.


Live Demo

Resource Link
Frontend https://hookmind.xyz
Dashboard https://hookmind.xyz/dashboard
IL Insurance Vault https://hookmind.xyz/vault
REST API https://hookmind-api.fly.dev
API Health Check https://hookmind-api.fly.dev/health
OpenAPI Spec openapi.yaml
SDK (npm) hookmind
Contract Explorer Unichain Sepolia Explorer
Pool (primary) 0x06d5c163592096086178db56f0ade3d22fbdba6324531c4dfa29171a30b01abb on Unichain Sepolia

To interact with the hook locally:

# Get test ETH
# Faucet: https://faucet.unichain.org (for Unichain Sepolia)

# Deploy contracts (Unichain Sepolia)
forge script script/DeployConsolidated.s.sol \
  --rpc-url https://sepolia.unichain.org \
  --broadcast

Contributing

Contributions are welcome! Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md before opening a pull request.

Key areas: invariant tests for ILInsurance.sol, i18n (FR/PT/KO), mobile UX, mainnet deployment.


License

MIT — see LICENSE.

HookMind is an independent open-source protocol. Uniswap® and Unichain® are trademarks of Uniswap Labs. HookMind is not affiliated with, endorsed by, or sponsored by Uniswap Labs or the Uniswap Foundation.


HookMind — experimental software. Not financial advice. Unichain Sepolia testnet only. Unaudited. Updated: May 12, 2026 · UF Acceleration Season 2026 · Demo Day: May 28, 2026

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors