Skip to content

feat(nip): Narrative Insurance Protocol — coverage and underwriting UI#35

Open
Eli5DeFi wants to merge 1 commit intomainfrom
feature/narrative-insurance-protocol
Open

feat(nip): Narrative Insurance Protocol — coverage and underwriting UI#35
Eli5DeFi wants to merge 1 commit intomainfrom
feature/narrative-insurance-protocol

Conversation

@Eli5DeFi
Copy link
Owner

@Eli5DeFi Eli5DeFi commented Feb 17, 2026

Summary

Implements the full frontend for the Narrative Insurance Protocol (NIP) from Innovation Cycle #47. Readers can buy coverage against feared story outcomes. Underwriters can stake USDC to back characters they believe will survive.


Files Changed

New Files (17)

File Description
src/types/insurance.ts Type definitions, enums, helpers
src/lib/insurance-mock-data.ts Mock data (6 events, demo positions)
src/app/insurance/page.tsx Main /insurance page
src/app/api/insurance/events/route.ts GET events with filters
src/app/api/insurance/events/[id]/route.ts GET single event
src/app/api/insurance/policies/route.ts POST buy coverage
src/app/api/insurance/underwrite/route.ts POST stake capital
src/app/api/insurance/stats/route.ts GET platform stats
src/app/api/insurance/user-positions/route.ts GET user policies + stakes
src/components/insurance/InsuranceStats.tsx 4-metric platform overview
src/components/insurance/InsuranceEventCard.tsx Event card with CTAs
src/components/insurance/BuyCoverageModal.tsx 3-step coverage purchase flow
src/components/insurance/UnderwriteModal.tsx 3-step stake flow
src/components/insurance/SurvivalMeter.tsx Animated survival probability
src/components/insurance/RiskBadge.tsx Risk tier indicator
src/components/insurance/UserPositions.tsx User policies + stakes panel

Modified Files (1)

File Change
src/components/landing/Navbar.tsx Added Insure nav link

Key Features

For Readers (Policyholders)

  • Browse insurable events by risk tier (Low / Medium / High / Extreme)
  • Live survival probability implied by premium rates
  • Buy coverage in 3 steps with premium breakdown
  • View active policies, coverage amounts, status

For Underwriters

  • Stake USDC into risk pools
  • See estimated APY per risk tier
  • Risk-reward transparency: payout scenarios shown upfront
  • Earn proportional share of premiums

Platform-Wide

  • 4-metric stats bar: total coverage, underwriter capital, open events, claims ratio
  • Risk-tier filters
  • Auto-refresh every 60 seconds
  • Mobile-responsive grid layout

Testing

  • TypeScript compiles: 0 errors
  • Build succeeds: 56/56 static pages, all 6 API routes
  • Zero ESLint warnings
  • Mobile responsive: grid collapses 3 -> 2 -> 1 columns
  • 3-step modal flows: configure -> confirm -> success/error
  • Error states: validation, capacity check, deadline check
  • Loading skeletons on all data-fetching components

Architecture

Mock-first approach: API routes return mock data. To go live:

  1. Add Prisma models: InsuranceEvent, InsurancePolicy, UnderwriterStake
  2. Run prisma migrate dev
  3. Replace mock data with Prisma queries
  4. Wire modals to wagmi wallet connection
  5. Add smart contract calls via NarrativeInsuranceClient.ts

POC Smart Contract: poc/narrative-insurance/NarrativeInsurance.sol is ready for deployment.


Deployment

No environment variables needed (mock data). For real contract:

NEXT_PUBLIC_NIP_CONTRACT_ADDRESS=0x...
NEXT_PUBLIC_USDC_ADDRESS=0x...

Page is statically renderable — no server-side DB dependency.

Innovation Cycle #47 — The Living Story Protocol

## What's included

### Types & Mock Data
- `src/types/insurance.ts` — Complete type definitions for events, policies,
  stakes, API contracts, and helper utilities (formatUSDC, calcPremium, etc.)
- `src/lib/insurance-mock-data.ts` — Realistic mock dataset with 6 events
  across 3 stories, demo user positions for dev/demo mode

### API Routes (6 total)
- `GET /api/insurance/events` — List open events w/ filters + pagination
- `GET /api/insurance/events/[id]` — Single event details
- `POST /api/insurance/policies` — Buy coverage (mock → real tx hook ready)
- `POST /api/insurance/underwrite` — Stake as underwriter w/ APY estimate
- `GET /api/insurance/stats` — Platform-wide insurance statistics
- `GET /api/insurance/user-positions` — User's policies & stakes

### UI Components (7 total)
- `InsuranceStats` — 4-metric platform overview with auto-refresh
- `RiskBadge` — Risk tier indicator (LOW/MEDIUM/HIGH/EXTREME)
- `SurvivalMeter` — Animated probability bar with color gradient
- `InsuranceEventCard` — Full event card with coverage + underwrite CTAs
- `BuyCoverageModal` — 3-step flow: configure → confirm → success/error
- `UnderwriteModal` — 3-step flow: stake amount → confirm → success/error
- `UserPositions` — Tabbed view of user's active policies and stakes

### Page
- `/insurance` — Full page with hero, stats, risk-tier filters, event grid,
  FAQ explainer, and My Positions panel

### Navigation
- Added 🛡️ Insure link to Navbar

## Design system compliance
- Follows Ruins of the Future palette (gold, drift-teal, drift-purple)
- Font: Cinzel (display), Space Grotesk (body), JetBrains Mono (numbers)
- Glassmorphism cards with proper hover states
- Fully responsive (mobile-first grid layout)
- Framer Motion animations on all cards and modals

## Architecture decisions
- Mock-first: Data layer uses realistic mock until DB migration runs
- API routes are stub-ready: Replace mock with prisma queries + contract calls
- Modals handle full error/loading/success state machine (3-step flow)
- useCallback + proper deps to satisfy react-hooks/exhaustive-deps

## Revenue potential (from proposal)
- Year 1: $45K → Year 3: $1.5M → Year 5: $15M
- Moat: 54 months (first-mover, data flywheel, underwriter lock-in)
@Eli5DeFi Eli5DeFi changed the title feat(nip): Narrative Insurance Protocol — Protect Characters You Love, Earn Yield on What You Know feat(nip): Narrative Insurance Protocol — coverage and underwriting UI Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants