Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .claude/scheduled_tasks.lock

This file was deleted.

52 changes: 47 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ Completed (Phase 3B — continued, Session 11; HOOK SUPERSEDED by the Session-12

Current implementation target:

- Demo script (RangeGuardDemo.s.sol) — drive the live Sepolia pool end-to-end, then frontend dashboard
- Recorded 5-minute demo (spec §15), then the full README + demo video write-up

Upcoming implementation order:

1. Sepolia hook deployment ✅ (Session 11; REDEPLOYED for Lasna in Session 12 — new hook 0xFead…a7C0)
2. ReactVM (reactive) deployment ✅ (Session 12 — Reactive Lasna 0xC0e6…B70b, live + wired + verified)
3. Demo script (RangeGuardDemo.s.sol) ← current
4. Frontend dashboard
3. Demo script (RangeGuardDemo.s.sol) ✅ (Session 13)
4. Frontend dashboard ✅ (Session 14 — frontend/, live coverage report; https://range-guard.vercel.app)
5. Recorded 5-minute demo + full README ← current

---

Expand Down Expand Up @@ -360,7 +361,34 @@ At the start of every session, Claude must:

# Current Session State

Last completed (Session 12): reactive-lib → reactive-lib-omni (Omni fork) migration + first live
Last completed (Session 14): Frontend dashboard — the LP coverage report (spec §4 Pillar 4).
React 18 + Vite + Tailwind + viem SPA in `frontend/`, NO backend — reads public Sepolia RPC only.
- TWO MODES (Option C): LIVE (default, or `?positionKey=0x…`) renders the real on-chain coverage
report for any position; `?demo=true` renders a hardcoded fork narrative from
docs/demo-run-output.md, banner-labeled "Simulated 45-day lifecycle (Sepolia fork)" — never
presented as live. Live mode is for judges/employers; demo mode is for the 4:15–4:45 recording.
- KEY DESIGN: settlement CLEARS positions[poolId][key] (strict CEI), so a closed position reads
ALL ZEROS / active=false. The coverage report is therefore reconstructed from EVENT LOGS, not
the live mapping — PositionSummary rebuilds entry/earned/payout/IL/factor from PositionRegistered
+ the settlement event. This is Pillar 4 made literal: the report lives in events.
- READS: poolState (buffer health), poolConfig (targetBufferSize/coverageApr/secondsPerYear, fee =
base+buffer), positions (live PositionState). Current tick has no getter → read via PoolManager
`extsload` at keccak256(abi.encode(poolId, 6)) (v4 StateLibrary POOLS_SLOT=6), unpack Slot0
sqrtPriceX96(160)|tick(24). Event log fetch: single eth_getLogs with topics [null,null,key]
(positionKey is topic2 on every position-scoped event), decoded by topic0; floored at
DEPLOY_BLOCK=11_005_000, chunked 9k blocks; 30s poll.
- VERIFIED live (hook 0xFead…a7C0): PositionRegistered 228.69 USDC / range $1,790–$2,208 →
Checkpoint +0.02 USDC (dt=0 baseline row skipped) → PartialPayout/COVERAGE_CAP 0.02; buffer
10,000.81 / health 10.00%. Build + dev server pass.
- DEPLOY: Vercel auto-deploy from `main` → https://range-guard.vercel.app (Framework Vite, root
`frontend`, build `npm run build`, output `dist`, no env vars; frontend/vercel.json SPA rewrites).
- TWO HONEST NOTES: live range shows $1,790–$2,208 (tick rounding) not $1,800–$2,200; live
settlement is PartialPayout/COVERAGE_CAP not ClaimSettled/IL_CAP (IL_CAP is the ?demo=true story).
-> docs/session-14-frontend.md

---

Previously completed (Session 12): reactive-lib → reactive-lib-omni (Omni fork) migration + first live
ReactVM deployment on Reactive Lasna. The whole reactive stack is live and verified; the only
remaining piece is the demo script (LP-deposit + swap tooling) to drive the round-trip end-to-end.

Expand Down Expand Up @@ -403,7 +431,7 @@ docs/reactive-lib-omni-audit.md. Session record: docs/session-12-reactive-deploy
NOT done: Phase-7 end-to-end (LP deposit → swap → PositionTracked → Checkpointed) — needs the demo
script (RangeGuardDemo.s.sol). No live LP-deposit/swap tooling exists yet for the Sepolia pool.

Current target: Demo script (RangeGuardDemo.s.sol), then frontend dashboard.
Current target: Recorded 5-minute demo (spec §15), then the full README + demo video write-up.
Carry-ins: payout recipient = v4 sender (owner=sender MVP). The Callback Proxy is PER NETWORK under
Omni — for any future host chain confirm it at dev.reactive.network/origins-and-destinations before
deploying the hook (it is NOT the legacy 0x…fffFfF).
Expand All @@ -423,3 +451,17 @@ Session 13 carry-ins (live-demo blockers found + fixed):
(proxy.depositTo{0.05 ETH}(hook)); verify `make reserves-hook`. The hook already inherits
AbstractPayer (pay()) and all reactive-callable fns take the leading RVM-id address placeholder,
so neither of those was the issue — only the reserve.

Session 14 carry-ins (frontend):
1. SPEC §11 VIEW FUNCTIONS NOT IMPLEMENTED on the deployed hook (mainnet-hardening item):
getPoolConfig/getBufferHealth/getCurrentFee/getDayCountBasis/getCoverageAPR/getPositionSnapshot/
getAccrualState/getEarnedCoverage/getEligibility/getEstimatedPayout/getCoverageProgress. The
frontend works around this by reading the public mappings directly + extsload for the live tick.
getEarnedCoverage (accrual simulated to block.timestamp) is the one worth adding — it would let an
OPEN position render live coverage without the client-side extsload/simulation.
2. README is a MINIMAL PLACEHOLDER for now (tagline + live dashboard link + "coming soon"). The full
write-up lands AFTER the demo recording, together with the demo video link.
3. Frontend is NOT auto-deployed until merged to `main` (Vercel watches main). Live-URL confirmation
in docs/session-14-frontend.md has an unchecked box to tick once the Vercel deploy is green.
4. Live demo position is CLOSED (settled) on-chain — the live coverage report is honest + sparse;
the full IL_CAP narrative is the ?demo=true view (clearly labeled simulated).
55 changes: 4 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,10 @@

> Protect your liquidity. Guard your range.

A Uniswap v4 hook providing native, on-chain impermanent loss coverage
for liquidity providers. Coverage accrues over time via a day-count
convention, is funded by dynamic fee skimming, and pays out automatically
on full withdrawal.
A Uniswap v4 hook providing native on-chain impermanent loss coverage for liquidity providers, funded by dynamic fee skimming. Integrated with the Reactive Network for autonomous cross-chain automation.

## Overview
**Live dashboard:** https://range-guard.vercel.app

- Coverage accrues only while LP position is in range
- Funded by a portion of swap fees via v4 dynamic fees
- Automatic settlement on full withdrawal
- Three-cap payout system (IL cap, coverage cap, buffer cap)
- Full coverage report generated from on-chain events
**Demo video:** coming soon

## Architecture

- Single hook contract supporting multiple pools
- Lazy accrual model (no O(N) iteration on swaps)
- Reactive Network integration for range monitoring and checkpoints
- Immutable PoolConfig per pool

## Project Status

See project-status.md for current implementation progress.

## Documentation

- spec.md — full technical specification
- context.md — architecture context and design decisions
- state-machine.md — LP position lifecycle
- invariant-mapping.md — protocol invariants
- testing-strategy.md — test philosophy and coverage goals

## Development

Built with Foundry.

\```bash

# Build

forge build

# Test

forge test

# Test with verbosity

forge test -vvv
\```

## Target

Uniswap v4 Hook Incubator — Testnet MVP (ETH/USDC demo pool)
**Documentation and full README coming soon.**
15 changes: 12 additions & 3 deletions context.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ Reactive contract LIVE on Reactive Lasna (chainId 5318007): 0xC0e6b70c8FF7596254
(tx 0xed865d…5329), funded 0.05 lREACT, wired to the new hook. See
docs/session-12-reactive-deployment.md.

Frontend dashboard (Session 14): COMPLETE. React 18 + Vite + Tailwind + viem SPA in frontend/,
no backend — renders the LP coverage report from LIVE Sepolia on-chain events for hook 0xFead…a7C0.
Two modes (Option C): live (default / ?positionKey=0x…, honest + verifiable; reconstructs closed
positions from event history since settlement clears positions[…]) and ?demo=true (hardcoded fork
narrative, banner-labeled "Simulated 45-day lifecycle"). Buffer health from poolState; current tick
via PoolManager extsload. Deployed on Vercel (auto from main): https://range-guard.vercel.app.
-> docs/session-14-frontend.md

Next implementation target:

- Frontend dashboard (coverage report rendered from Sepolia events)
- Recorded 5-minute demo (spec §15), then the full README + demo video write-up

Completed (Session 13): demo tooling — RangeGuardDemo.s.sol (Option A, fork+vm.warp, spec §14),
LiveEndToEnd.s.sol / LiveWithdraw.s.sol (Option B live broadcast), DemoLPRouter.sol (live LP whose
Expand All @@ -66,8 +74,9 @@ not contracts). -> docs/session-13-demo-script.md, docs/reactive-evidence.md

Planned next steps:

- Frontend dashboard (coverage report rendered from Sepolia events): query the live demo positionKey
0x62e2311b…462d88 on hook 0xFead…a7C0 and render PositionRegistered → AccrualUpdated → settlement.
- Record the 5-minute demo (spec §15): terminal segment (RangeGuardDemo.s.sol) + coverage-report
segment (the ?demo=true dashboard view) + reactive evidence. Then write the full README and link
the demo video.

Recent architecture update:

Expand Down
Loading
Loading