Technical Deep Dive

Architecture

A Uniswap v4 hook that creates impact-differentiated liquidity via milestone-gated fee routing. Seven hook callbacks, five funding channels, five contracts across three chains, and an autonomous AI verification agent.

ImpactHook.solUnichain Sepolia
Core Hook

afterSwap fee routing, LP fee skim via afterAddLiquidity, donate skim via afterDonate, milestone tracking, 3 verification paths, loyalty discounts, heartbeat expiration, project templates

0xC8A18E4A64224D2785D505c77923ed8c1d4F2557
MilestoneArbiter.solUnichain Sepolia
Alkahest Escrow Gate

Implements IArbiter from the Zellic-audited Alkahest escrow protocol. Gates grant release on verified milestone state from ImpactHook.

0xF51197176Fc8B8D4F780Dc67E431a90E85Fc52Fb
MilestoneReactor.solReactive Lasna
Reactive Network RSC

Subscribes to MilestoneSubmitted events on origin chain. Emits cross-chain callbacks to ImpactHook on Unichain. No bridges needed.

0x19D5bfa64Ff4992e917FC627B246eBdDf6A7d872
MilestoneOracle.solEthereum Sepolia
Origin Chain Event Source

Deployed on any supported origin chain. Emits MilestoneSubmitted events that Reactive Network relays to Unichain.

0xDd5c349fb1dcc3Daf60cC7a5ff73175ef9567cBc
ImpactSwapRouter.solUnichain Sepolia
Custom Swap Router

Clean swap(key, zeroForOne, amountIn, minAmountOut) interface with slippage protection. Handles afterSwapReturnDelta internally so callers don't need to.

0x66452162B01442d92fc77d607EE2Cff3e76043c2
Cross-Chain Milestone Verification via Reactive Network
Origin Chain              Reactive Network           Destination Chain
(any supported)           (ReactVM)                  (Unichain Sepolia)

MilestoneOracle    -->    MilestoneReactor    -->    ImpactHook
  emits event              subscribes &               verifyMilestoneReactive()
  MilestoneSubmitted       emits Callback             updates milestone state

Authorization: Reactive Network overwrites the first callback argument with the ReactVM ID. The hook checks msg.sender == callbackProxy and rvmId == project.verifier.

Three verification paths

Direct

Verifier calls verifyMilestone() directly on Unichain. Simple, gas-efficient. Works for EOAs, multisigs, DAOs, and AI agents.

Reactive Cross-Chain

MilestoneOracle on origin chain emits event. MilestoneReactor on Reactive Network subscribes and triggers verifyMilestoneReactive() on Unichain. No bridges.

EAS Attestation

Verifier creates an Ethereum Attestation Service attestation with evidence. Anyone can then call verifyMilestoneEAS() permissionlessly. Credibly neutral.

Hook callbacks

Seven Uniswap v4 hook callbacks: beforeInitialize, afterSwap + afterSwapReturnDelta, afterAddLiquidity + afterAddLiquidityReturnDelta, afterRemoveLiquidity + afterRemoveLiquidityReturnDelta, afterDonate.

afterSwap() — Swap Fee Capture
// Fee on TOP of LP fee — LPs earn full yield
uint16 feeBps = _getCurrentFeeBps(poolId);
uint256 feeAmount = (uint256(uint128(outputAmount))
    * feeBps) / 10_000;

// Take fee from pool manager
poolManager.take(feeCurrency, address(this), feeAmount);
accumulatedFees[poolId][feeCurrency] += feeAmount;

// Return delta — reduces swapper output
return (this.afterSwap.selector,
    int128(int256(feeAmount)));
afterAddLiquidity() — LP Fee Skim
// LP collects fees -> hook skims a %
function afterAddLiquidity(
    ..., BalanceDelta feesAccrued, ...
) {
    return _skimLpFees(key, feesAccrued);
}

// Swap pricing stays identical
// Routers have no reason to skip this pool
// LPs opt in, swappers don't pay extra

Fee model

The hook charges a fee on top of the standard Uniswap v4 LP fee via afterSwapReturnDelta. LP yield is completely unaffected. Fee rate is determined by the current verified milestone's projectFeeBps. Maximum capped at 5% (500 BPS).

Example progression
Project registered0%
Phase 1 complete2%
Phase 2 complete3%
Self-sustaining1%

LP Fee Skim (Dual Funding Model)

Key Innovation

Pools can skim a percentage of LP fees for the impact project via afterAddLiquidity and afterRemoveLiquidity return deltas. When LPs collect accrued fees, the hook transparently routes a configurable share to the project.

How it works
  • Swap pricing stays identical to regular pools
  • Routers have no reason to skip or avoid these pools
  • LPs opt in by providing liquidity to the pool
  • Swappers don't pay any extra fees
  • Configurable per pool, max 50% skim rate
Why it matters

Traditional impact funding hooks add a swap fee that makes the pool uncompetitive for routers. LP fee skimming funds impact projects without touching swap pricing at all. The pool looks identical to any other v4 pool from the router's perspective, so it gets normal trade flow.

Native v4 Donate Skim

The afterDonate hook intercepts PoolManager.donate() calls. When users tip LPs via the native v4 donate mechanism, a configurable percentage is routed to the impact project.

Gating
Same milestone verification
Safety
Heartbeat and pause checks
Config
donateSkimBps per template

Safety and accountability

Heartbeat Expiration

Projects must send periodic proof-of-life transactions. If the heartbeat interval passes without a signal, fee collection stops automatically until the project proves it is still active.

Per-Project Pause

Any individual project can be paused without affecting other projects on the same hook. Paused projects stop accumulating fees immediately.

Sequential Milestones

Milestones must be verified in order. A project cannot skip ahead or verify out of sequence. Each milestone can only be verified once.

Checks-Effects-Interactions

All state-changing functions follow the checks-effects-interactions pattern. Static analysis with Slither confirms no reentrancy or state ordering issues.

Behavior-customizable templates

Templates define lpSkimBps, donateSkimBps, heartbeatInterval, and swapFeeEnabled per project type. One hook deployment serves different impact verticals with appropriate defaults.

TemplateLP SkimHeartbeatSwap FeesUse Case
Climate10%30 daysEnabledLong-term environmental
Emergency Relief20%7 daysDisabledCrisis response, router-competitive
Open Source0%NoneEnabledTraditional swap-fee dev grants

Evidence storage and impact records

Storacha / Filecoin Pin

Milestone evidence (reports, images, data) uploaded to Filecoin/IPFS via Storacha or Filecoin Pin. CIDs stored onchain via setMilestoneEvidence().

Hypercerts

Verified milestones mint Hypercerts on Ethereum, creating composable, tradeable impact certificates. Metadata auto-populated from onchain state: project name, milestone, contributors, evidence CIDs.

Triple persistence

Evidence persists in three places: ImpactHook contract (Unichain), Hypercert metadata (Ethereum), and EAS attestation data (Unichain). Each independently verifiable.

Autonomous verification agent

AI-Powered Milestone Verification

A standalone Bun service that monitors EvidenceAttached events, retrieves evidence from Storacha/IPFS, analyzes it with Claude, and submits verifyMilestone() when confidence exceeds the threshold. Reports stored permanently on Filecoin. Agent memory persists on Storacha across sessions.

Evidence uploaded        Agent detects          Claude analyzes        Report stored
to Storacha/IPFS    -->  EvidenceAttached   -->  evidence vs         -->  on Filecoin Pin
                         event onchain          milestone criteria      (Calibration)
                                                      |
                                          confidence >= 70%?
                                           yes /        \ no
                                              /          \
                              verifyMilestone()    store report,
                              submitted onchain    defer to human
Storacha Memory

Agent state, past verifications, and project knowledge persist on Storacha. On restart, the agent loads its memory from the latest CID and resumes where it left off.

Filecoin Reports

Every verification produces a structured JSON report stored on Filecoin via Synapse SDK. Reports include per-criterion analysis, confidence scores, and reasoning.

Alkahest Integration

When the agent verifies a milestone, MilestoneArbiter.checkObligation() returns true, automatically releasing gated escrow funds. Fully autonomous funding cycle.

Guardrails

Confidence threshold gating (only auto-verifies above 70%), dry-run mode for analysis without onchain transactions, structured execution logs, budget-aware operation.

Quality

Test coverage

174
tests passing
0 failed, 0 skipped
35Core Hook
  • + Registration
  • + Fee routing (both dirs)
  • + Milestone progression
  • + Withdrawal
  • + Impact tracking
  • + LP fee skim
28Access & Safety
  • + Verifier auth
  • + Recipient auth
  • + Callback proxy
  • + Owner checks
  • + Heartbeat expiry
  • + Per-project pause
26Integrations
  • + MilestoneArbiter (3)
  • + Reactive callbacks (5)
  • + Oracle events (4)
  • + EAS verification (7)
  • + Evidence storage (7)
30Features & Fuzz
  • + Loyalty discounts (6)
  • + Templates (7)
  • + Donations (8)
  • + Fuzz tests
  • + HookMiner (7)
  • + Edge cases
5
Contracts
3
Chains
7
Hook Callbacks
5
Funding Channels

Deployed contracts

ContractChainAddress
ImpactHookUnichain Sepolia0xC8A18E4A64224D2785D505c77923ed8c1d4F2557
MilestoneArbiterUnichain Sepolia0xF51197176Fc8B8D4F780Dc67E431a90E85Fc52Fb
MilestoneOracleEthereum Sepolia0xDd5c349fb1dcc3Daf60cC7a5ff73175ef9567cBc
MilestoneReactorReactive Lasna0x19D5bfa64Ff4992e917FC627B246eBdDf6A7d872
ImpactSwapRouterUnichain Sepolia0x66452162B01442d92fc77d607EE2Cff3e76043c2
EAS Schema UID0xe4614a0cea117a9a198431d54972835ab8d84b8d6e3d18e482032377af9bfb52
Live hook statusLive
Contract0xC8A18E...4F2557
Owner-
Callback Proxy-
EAS Schema-
Key Addresses (Unichain Sepolia)
PoolManager0x00B036B58a818B1BC34d502D3fE730Db729e62AC
Callback Proxy0x9299472A6399Fd1027ebF067571Eb3e3D7837FC4
EAS0x4200000000000000000000000000000000000021
SchemaRegistry0x4200000000000000000000000000000000000020