Skip to content

gokulnpc/Defi-Guardian

Repository files navigation

πŸ›‘οΈ DeFi Guardians: Cross-Chain Decentralized Insurance Protocol

Built with Hardhat 3 Beta & Next.js 15 - The Future of DeFi Protection

Hardhat Solidity Next.js Chainlink CCIP PYUSD Dynamic License

πŸ† Hackathon Tracks

DeFi Guardians is competing in multiple tracks:

  • πŸ”— Chainlink CCIP Best Usage ($6,000) - Revolutionary cross-chain insurance using CCIP for seamless Sepolia ↔ Hedera communication
  • πŸš€ PYUSD Most Innovative Payment ($3,500) - Novel cross-chain insurance premium splitting and claim payout automation
  • πŸ‘· Hardhat 3 Best Projects ($5,000) - Built entirely with Hardhat 3 Beta featuring 154 comprehensive tests, lightning-fast compilation, cross-chain deployment capabilities, and modern TypeScript integration demonstrating the full potential of next-generation Solidity development
  • πŸ›οΈ Hedera EVM Smart Contracts ($3,500) - Advanced smart contract deployment with CCIP enabled.
  • πŸ’Ό Dynamic Best Financial App ($3,333) - Seamless DeFi insurance platform with embedded wallet infrastructure
  • πŸ€– Nora AI Coding Best Use ($5,000) - Advanced AI-assisted Solidity development and optimization

🌟 Project Overview

DeFi Guardians is a revolutionary cross-chain decentralized insurance protocol that protects DeFi users from smart contract exploits, rug pulls, and protocol failures. This comprehensive solution combines robust smart contracts with an intuitive web interface, demonstrating the full power of next-generation blockchain development.

🎯 Key Features

  • πŸ”— Cross-Chain Architecture: Seamless operation between Sepolia (Sepolia) and Hedera Testnet using Chainlink CCIP
  • πŸ’° Liquidity Provider Rewards: 70% of premiums distributed to LPs, 30% reserved for claims
  • πŸ—³οΈ Decentralized Governance: LP-based voting system for claim validation
  • 🌐 Modern Web Interface: Built with Next.js 15, TypeScript, and Tailwind CSS
  • πŸ“± Mobile-First Design: Responsive interface optimized for all devices
  • πŸ” Dynamic Wallet Integration: Embedded wallet infrastructure with seamless user onboarding
  • πŸ’Ό One-Click Financial Operations: Simplified PYUSD insurance purchases and claim processing
  • ⚑ Real-Time Updates: Live dashboard with policy status and claim tracking

πŸ—οΈ Architecture Overview

Smart Contract Layer

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    CCIP     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Sepolia       │◄────────────►│     Hedera      β”‚
β”‚                 β”‚              β”‚                 β”‚
β”‚ β€’ PremiumVault  β”‚              β”‚ β€’ PolicyManager β”‚
β”‚ β€’ LPVault       β”‚              β”‚ β€’ ClaimManager  β”‚
β”‚ β€’ PayoutVault   β”‚              β”‚ β€’ VotingMirror  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Frontend Layer

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Next.js App                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Hero Section & Navigation             β”‚
β”‚ β€’ Coverage Purchase Widget              β”‚
β”‚ β€’ User Dashboard                        β”‚
β”‚ β€’ Governance Interface                  β”‚
β”‚ β€’ Real-time Analytics                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm
  • Git
  • MetaMask or compatible wallet

Installation

# Clone the repository
git clone https://github.com/your-username/defi-guardians.git
cd defi-guardians

# Install dependencies
pnpm install

# Add contracts submodule
git submodule add https://github.com/gokulnpc/Defi-Guardian-Contracts.git contracts-repo
git submodule update --init --recursive

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your configuration

Development Setup

# Start the development server
pnpm dev

# In another terminal, compile smart contracts
pnpm compile

# Run tests
pnpm test

# Run specific test file
pnpm test:simple

πŸ“‹ Smart Contracts

Core Contracts

Contract Network Purpose
PremiumVault Sepolia Handles premium payments and CCIP messaging
LPVault Sepolia Manages liquidity provider stakes and rewards
PayoutVault Sepolia Holds reserves and processes claim payouts
PolicyManager Hedera Issues policy NFTs and manages coverage
ClaimManager Hedera Processes claims and manages voting
VotingMirror Hedera Mirrors LP voting power from Sepolia

Contract Deployment

# Deploy to Sepolia Sepolia
pnpm deploy:sepolia

# Deploy to Hedera Testnet
pnpm deploy:hedera

# Verify contracts
pnpm verify:all

πŸŒ‰ Cross-Chain Flow

1. Policy Purchase Flow

sequenceDiagram
    participant User
    participant PremiumVault
    participant CCIP
    participant PolicyManager

    User->>PremiumVault: buyCoverage()
    PremiumVault->>PremiumVault: Split premium 70/30
    PremiumVault->>CCIP: Send policy data
    CCIP->>PolicyManager: Receive policy data
    PolicyManager->>User: Mint Policy NFT
Loading

2. Claim Processing Flow

sequenceDiagram
    participant User
    participant ClaimManager
    participant VotingMirror
    participant CCIP
    participant PayoutVault

    User->>ClaimManager: openClaim()
    ClaimManager->>VotingMirror: Get LP voting power
    Note over ClaimManager: 5-minute voting period
    ClaimManager->>CCIP: Send payout instruction
    CCIP->>PayoutVault: Process payout
    PayoutVault->>User: Transfer funds
Loading

🎨 Frontend Features

User Interface Components

  • 🏠 Hero Section: Animated landing page with protocol overview
  • πŸ’³ Coverage Widget: Simplified insurance purchase interface
  • πŸ“Š Dashboard: Personal policy management and analytics
  • πŸ—³οΈ Governance: LP voting interface for claims
  • πŸ”„ Real-time Updates: Live status tracking and notifications

Design System

  • 🎨 Modern UI: Built with Radix UI components and Tailwind CSS
  • πŸŒ™ Dark/Light Mode: Theme switching with next-themes
  • πŸ“± Responsive Design: Mobile-first approach with fluid layouts
  • β™Ώ Accessibility: WCAG compliant with keyboard navigation
  • ⚑ Performance: Optimized with Next.js 15 app router

πŸ§ͺ Testing

Smart Contract Tests

# Run all tests
pnpm test

# Run specific test suites
pnpm test:premium-vault
pnpm test:claim-manager
pnpm test:cross-chain

# Run with coverage
pnpm test:coverage

# Run in watch mode
pnpm test:watch

Frontend Tests

# Run component tests
pnpm test:frontend

# Run E2E tests
pnpm test:e2e

# Run accessibility tests
pnpm test:a11y

πŸ“Š Protocol Metrics

Coverage Pools

Protocol TVL Risk Level Premium Rate
Uniswap V3 $2.1B Low 2.5% APR
Aave V3 $1.8B Low 3.0% APR
Compound V3 $1.2B Medium 4.0% APR
GMX V2 $800M Medium 5.0% APR
Radiant Capital $400M High 8.0% APR

Supported Risks

  • πŸ’» Smart Contract Exploits: Code vulnerabilities and hacks
  • πŸƒ Rug Pulls: Team abandonment and fund theft
  • πŸ“ˆ Oracle Failures: Price manipulation attacks
  • πŸ—³οΈ Governance Attacks: Malicious proposal execution
  • πŸŒ‰ Bridge Failures: Cross-chain infrastructure risks

πŸ” Security Features

Smart Contract Security

  • πŸ›‘οΈ Access Controls: Multi-signature and role-based permissions
  • πŸ”’ Reentrancy Protection: All state-changing functions protected
  • βœ… Input Validation: Comprehensive parameter checking
  • πŸ” Audit Ready: Code optimized for security reviews

Frontend Security

  • πŸ” Wallet Security: Secure wallet connection via Dynamic Labs
  • πŸ›‘οΈ Data Protection: Client-side encryption for sensitive data
  • 🌐 HTTPS Only: Secure communication protocols
  • πŸ”’ Content Security: CSP headers and XSS protection

🌍 Deployment

Testnet Deployments

Contract Sepolia Sepolia Hedera Testnet
PremiumVault 0x8CDBf091e385D0D4A7e8bf7D9AE11d69647bF499 -
LPVault 0xEC1f7B099c0a984badF83222aeb61f1e4cd7dB97 -
PayoutVault 0x6f5421f96786F69609b3f2d15A268A5c4cbD6dEc -
PolicyManager - 0xd1b6BEa5A3b3dd4836100f5C55877c59d4666569
ClaimManager - 0x9D4646f64dF7D98c6a83D60a9Af06c67a9eE0215
VotingMirror - 0xe1C31E56De989192946f096eBA8Ed709C2Ec9003

Mainnet Readiness

  • βœ… Comprehensive test coverage (100%)
  • βœ… Gas optimization completed
  • βœ… Security review ready
  • βœ… Frontend production build tested
  • ⏳ External audit pending
  • ⏳ Mainnet deployment planned

πŸ’‘ Use Cases

For DeFi Users

  • πŸ›‘οΈ Risk Protection: Insure your DeFi positions against smart contract risks
  • πŸ“Š Portfolio Safety: Comprehensive coverage across multiple protocols
  • πŸ”„ Easy Claims: Streamlined claim submission and processing

For Liquidity Providers

  • πŸ’° Yield Generation: Earn from insurance premiums
  • πŸ—³οΈ Governance Power: Vote on claims and protocol decisions
  • πŸ“ˆ Diversified Returns: Risk-adjusted yields from insurance activities

For Protocols

  • πŸ” User Confidence: Offer insurance to attract more users
  • πŸ“Š Risk Analytics: Access detailed risk assessment data
  • 🀝 Partnership: Integrate insurance into your protocol

πŸ† Why DeFi Guardians Wins

🎯 Market Need

  • $200B+ DeFi Market: Massive addressable market for insurance
  • $2B+ Losses: Annual losses from exploits and failures
  • Low Coverage: <1% of DeFi assets currently insured

πŸ”§ Technical Innovation

  • Cross-Chain First: Built for multi-chain DeFi ecosystem
  • Hardhat 3 Powered: Leveraging cutting-edge development tools
  • Modern Stack: Next.js 15, TypeScript, Tailwind CSS
  • Real-time Sync: Instant cross-chain state synchronization

🌟 Competitive Advantages

  • Lower Costs: No intermediaries, pure smart contract automation
  • Faster Claims: 5-minute voting periods vs weeks in traditional insurance
  • Transparent: All operations visible on-chain
  • Composable: Easily integrated into existing DeFi protocols

πŸ‘₯ Team Members

DeFi Guardians Core Team:

πŸ™ Acknowledgments

  • Hardhat Team for building the incredible Hardhat 3 development environment
  • Chainlink for providing robust CCIP cross-chain infrastructure
  • OpenZeppelin for battle-tested smart contract libraries
  • Hedera for high-performance distributed ledger technology
  • Dynamic Labs for seamless wallet connectivity
  • Vercel for hosting and deployment infrastructure

πŸ† Built with Hardhat 3 & Next.js 15 - The Future of DeFi Protection

DeFi Guardians represents the convergence of cutting-edge blockchain development and modern web technologies. We're not just building insurance; we're building the foundation for a safer, more secure DeFi ecosystem.

Ready to revolutionize DeFi insurance? Let's build the future together! πŸš€


For questions, feedback, or collaboration opportunities, please open an issue or reach out to our team.

About

DeFi Guardians is a revolutionary cross-chain decentralized insurance protocol that protects DeFi users from smart contract exploits, rug pulls, and protocol failures. This comprehensive solution combines robust smart contracts with an intuitive web interface, demonstrating the full power of next-generation blockchain development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors