Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CrosFi - Cross-Currency Lending Protocol on Celo

Next.js TypeScript Tailwind CSS Celo Solidity

A comprehensive DeFi lending and borrowing platform built on the Celo blockchain, featuring cross-currency lending, AI-powered yield optimization, and automated yield farming strategies.

๐ŸŒŸ Overview

CrosFi is a next-generation DeFi protocol that enables users to lend and borrow across multiple currencies on the Celo network. The platform combines traditional lending mechanics with innovative AI-driven yield optimization and automated strategies to maximize returns for users.

๐ŸŽฏ Key Features

Core Lending Protocol

  • Cross-Currency Lending - Lend and borrow across CELO, cUSD, USDC, cEUR, cREAL, and eXOF
  • Dynamic Interest Rates - Algorithmic interest rate models based on supply and demand
  • Collateral Management - Flexible collateral system with multiple supported assets
  • Liquidation Protection - Automated liquidation system to maintain protocol health
  • Real-time Oracle Integration - Chainlink-powered price feeds for accurate valuations

AI-Powered Yield Generator ๐Ÿค–

  • Intelligent Recommendations - AI analyzes market data to suggest optimal lending strategies
  • Risk Profiling - Personalized recommendations based on user risk tolerance
  • Market Trend Analysis - Real-time analysis of DeFi trends and yield opportunities
  • Yield Forecasting - Predictive models for future yield potential
  • NVIDIA Nemotron Integration - Advanced AI model for market analysis

Automated Yield Strategies

  • Mento Yield Strategy - Automated yield farming through Mento protocol
  • Multi-Token Vault - Unified vault for managing multiple token positions
  • Strategy Optimization - Dynamic strategy adjustments based on market conditions
  • Gas Optimization - Efficient transaction batching and optimization

User Experience

  • Modern UI/UX - Beautiful, responsive interface with dark/light themes
  • Real-time Updates - Live data feeds and instant transaction updates
  • Mobile-First Design - Optimized for all devices and screen sizes
  • Wallet Integration - Support for MetaMask, WalletConnect, and other popular wallets
  • Transaction Management - Comprehensive transaction history and status tracking

๐Ÿ—๏ธ Architecture

Smart Contracts

  • LendingPool - Core lending and borrowing logic
  • MultiTokenVault - Unified vault for yield farming strategies
  • InterestModel - Dynamic interest rate calculations
  • OracleAdapter - Price feed integration and management
  • CollateralManager - Collateral tracking and liquidation logic
  • DebtTokens - Individual debt token contracts for each supported currency

Frontend Stack

  • Next.js 16 - React framework with App Router
  • TypeScript - Full type safety and developer experience
  • Tailwind CSS 4 - Utility-first styling framework
  • Framer Motion - Smooth animations and transitions
  • Recharts - Data visualization and analytics
  • Ethers.js - Ethereum/Celo blockchain interaction

Backend Services

  • Node.js/Express - API server for off-chain data
  • WebSocket - Real-time data streaming
  • Prisma - Database ORM for user data
  • Cron Jobs - Automated maintenance tasks

AI & Analytics

  • OpenRouter API - AI model integration
  • CoinGecko API - Market data aggregation
  • DeFiLlama API - DeFi protocol analytics
  • Custom ML Models - Yield prediction and optimization

๐Ÿ“‹ Contract Addresses

Celo Sepolia Testnet

Core Protocol Contracts

Debt Token Contracts

Token Contracts

Deployment Information

Contract Verification Instructions

To verify the smart contracts, judges can:

  1. Click on any contract address in the list above to view it on CeloScan Sepolia

  2. Check the "Contract" tab to view the verified source code

  3. Verify the contract matches the expected functionality:

    • LendingPool: Core lending and borrowing logic
    • MultiTokenVault: Yield farming vault with multi-token support
    • InterestModel: Dynamic interest rate calculations
    • OracleAdapter: Price feed integration
    • CollateralManager: Collateral tracking and liquidation
    • DebtTokens: Individual debt token contracts
    • MentoYieldStrategy: Automated yield farming strategy
  4. Verify deployment details:

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18.0 or later
  • npm or yarn or pnpm
  • Git
  • MetaMask or compatible Web3 wallet

Installation

  1. Clone the repository

    git clone https://github.com/your-username/crosfi.git
    cd crosfi
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    cp .env.example .env.local

    Configure your .env.local:

    # Celo Network Configuration
    NEXT_PUBLIC_CELO_RPC_URL=https://sepolia-forno.celo-testnet.org
    NEXT_PUBLIC_CELO_CHAIN_ID=44787
    
    # Contract Addresses (Sepolia Testnet)
    NEXT_PUBLIC_LENDING_POOL=0x46e9007E67ac1fd5F63Ec817809FA15aE65F62B5
    NEXT_PUBLIC_VAULT=0x32D94e8c16370b718041246C18ee914283DFEAa7
    NEXT_PUBLIC_INTEREST_MODEL=0x292677b28485D8d2dDF9F93D44361704C546ca4f
    NEXT_PUBLIC_ORACLE_ADAPTER=0xFE175E3377051Bd38E97b2ea2668f59214c06Db6
    NEXT_PUBLIC_COLLATERAL_MANAGER=0x519B3d3b3493707F4F335cbbF98B13e80C0d65B2
    
    # AI Configuration
    NEXT_PUBLIC_OPENROUTER_API_KEY=your_openrouter_api_key
    
    # Backend Configuration
    NEXT_PUBLIC_API_URL=http://localhost:3001
  4. Start the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  5. Start the backend server (optional)

    npm run backend
    # or run both frontend and backend
    npm run dev:full
  6. Open your browser Navigate to http://localhost:3000

Getting Testnet Tokens

  1. Celo Faucet: Visit Celo Faucet
  2. Chainlink Faucet: Chainlink Faucet
  3. Add to MetaMask: Use the contract addresses above to add tokens to your wallet

๐Ÿ“ Project Structure

crosfi/
โ”œโ”€โ”€ app/                          # Next.js App Router
โ”‚   โ”œโ”€โ”€ (lending)/               # Lending pages
โ”‚   โ”‚   โ”œโ”€โ”€ borrow/              # Borrowing interface
โ”‚   โ”‚   โ””โ”€โ”€ lend/                # Lending interface
โ”‚   โ”œโ”€โ”€ ai-yield/                # AI Yield Generator
โ”‚   โ”œโ”€โ”€ analytics/               # Protocol analytics
โ”‚   โ”œโ”€โ”€ api/                     # API routes
โ”‚   โ”œโ”€โ”€ dashboard/               # User dashboard
โ”‚   โ”œโ”€โ”€ markets/                 # Market overview
โ”‚   โ”œโ”€โ”€ positions/               # User positions
โ”‚   โ”œโ”€โ”€ rates/                   # Interest rates
โ”‚   โ”œโ”€โ”€ vault/                   # Yield farming vault
โ”‚   โ””โ”€โ”€ ...                      # Other pages
โ”œโ”€โ”€ components/                   # React components
โ”‚   โ”œโ”€โ”€ ai/                      # AI-related components
โ”‚   โ”‚   โ”œโ”€โ”€ RecommendationCard.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ MarketTrendAnalyzer.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ YieldForecastChart.tsx
โ”‚   โ”‚   โ””โ”€โ”€ RiskProfileSelector.tsx
โ”‚   โ”œโ”€โ”€ currency/                # Currency components
โ”‚   โ”œโ”€โ”€ lending/                 # Lending components
โ”‚   โ”œโ”€โ”€ vault/                   # Vault components
โ”‚   โ”œโ”€โ”€ ui/                      # UI components
โ”‚   โ””โ”€โ”€ ...                      # Other components
โ”œโ”€โ”€ contracts/                    # Smart contracts
โ”‚   โ”œโ”€โ”€ lending/                 # Lending contracts
โ”‚   โ”œโ”€โ”€ vault/                   # Vault contracts
โ”‚   โ”œโ”€โ”€ libraries/               # Contract libraries
โ”‚   โ”œโ”€โ”€ mocks/                   # Mock contracts
โ”‚   โ”œโ”€โ”€ oracles/                 # Oracle contracts
โ”‚   โ””โ”€โ”€ strategies/              # Yield strategies
โ”œโ”€โ”€ lib/                         # Utility libraries
โ”‚   โ”œโ”€โ”€ contracts/               # Contract interactions
โ”‚   โ”œโ”€โ”€ token-icons.ts           # Token icon configuration
โ”‚   โ”œโ”€โ”€ currency-config.ts       # Currency configuration
โ”‚   โ”œโ”€โ”€ api-client.ts            # API client
โ”‚   โ””โ”€โ”€ ...                      # Other utilities
โ”œโ”€โ”€ backend/                     # Backend services
โ”‚   โ”œโ”€โ”€ src/                     # Backend source code
โ”‚   โ”œโ”€โ”€ prisma/                  # Database schema
โ”‚   โ””โ”€โ”€ scripts/                 # Backend scripts
โ”œโ”€โ”€ keeper/                      # Keeper service
โ”‚   โ”œโ”€โ”€ src/                     # Keeper source code
โ”‚   โ””โ”€โ”€ tasks/                   # Automated tasks
โ”œโ”€โ”€ scripts/                     # Deployment scripts
โ”œโ”€โ”€ public/                      # Static assets
โ””โ”€โ”€ ...                          # Configuration files

๐ŸŽจ Design System

Color Palette

/* Primary Colors */
--celo-green: #35D07F
--celo-gold: #FBCC5C
--celo-blue: #4285F4

/* Semantic Colors */
--success: #10B981
--warning: #F59E0B
--error: #EF4444
--info: #3B82F6

Typography

  • Font Family: Inter (Google Fonts)
  • Headings: Bold, responsive sizing
  • Body Text: Regular weight, optimized for readability
  • Code: JetBrains Mono for technical content

Components

  • Buttons: Primary, secondary, outline, and ghost variants
  • Cards: Consistent padding, borders, and hover effects
  • Forms: Accessible inputs with proper validation
  • Navigation: Responsive header with mobile menu
  • Token Icons: Official token icons with fallback support

๐Ÿ”ง Development

Available Scripts

# Frontend Development
npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint

# Backend Development
npm run backend      # Start backend server
npm run dev:full     # Start both frontend and backend

# Smart Contract Development
npx hardhat compile  # Compile contracts
npx hardhat test     # Run tests
npx hardhat deploy   # Deploy contracts
npx hardhat verify   # Verify contracts on block explorer

Smart Contract Development

  1. Install Hardhat dependencies

    npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
  2. Compile contracts

    npx hardhat compile
  3. Run tests

    npx hardhat test
  4. Deploy to Alfajores

    npx hardhat run scripts/deploy-alfajores.js --network sepolia

Code Style

  • ESLint - Code linting and error detection
  • Prettier - Code formatting
  • TypeScript - Type checking
  • Conventional Commits - Commit message format

๐Ÿš€ Deployment

Frontend Deployment (Vercel)

  1. Connect repository to Vercel
  2. Configure build settings:
    • Build Command: npm run build
    • Output Directory: .next
  3. Set environment variables in Vercel dashboard
  4. Deploy - Automatic deployments on push

Smart Contract Deployment

  1. Set up environment variables

    PRIVATE_KEY=your_private_key
    CELO_RPC_URL=https://sepolia-forno.celo-testnet.org
    CELOSCAN_API_KEY=your_celoscan_api_key
  2. Deploy contracts

    npx hardhat run scripts/deploy-alfajores.js --network sepolia
  3. Verify contracts

    npx hardhat verify --network sepolia <CONTRACT_ADDRESS>

Backend Deployment

The backend can be deployed to any Node.js hosting platform:

  • Railway
  • Heroku
  • DigitalOcean App Platform
  • AWS EC2

๐Ÿ“Š Features Deep Dive

AI Yield Generator

The AI Yield Generator uses advanced machine learning to analyze market conditions and provide personalized yield recommendations:

  • Market Analysis: Real-time analysis of DeFi protocols, yield rates, and market trends
  • Risk Assessment: Comprehensive risk profiling based on volatility, liquidity, and market conditions
  • Yield Forecasting: Predictive models for future yield potential using historical data
  • Personalization: Recommendations tailored to user risk tolerance and investment goals

Cross-Currency Lending

CrosFi enables seamless lending and borrowing across multiple currencies:

  • Multi-Asset Support: CELO, cUSD, USDC, cEUR, cREAL, eXOF
  • Dynamic Interest Rates: Algorithmic rates based on supply and demand
  • Flexible Collateral: Use any supported asset as collateral
  • Liquidation Protection: Automated liquidation system with health factor monitoring

Automated Yield Strategies

  • Mento Integration: Automated yield farming through Mento protocol
  • Strategy Optimization: Dynamic adjustments based on market conditions
  • Gas Optimization: Efficient transaction batching and optimization
  • Risk Management: Automated risk assessment and position management

๐Ÿ”’ Security

Smart Contract Security

  • OpenZeppelin Libraries - Battle-tested security patterns
  • Reentrancy Protection - Protection against reentrancy attacks
  • Access Control - Role-based access control for administrative functions
  • Oracle Integration - Secure price feed integration with Chainlink
  • Liquidation Logic - Robust liquidation system to maintain protocol health

Frontend Security

  • Input Validation - Comprehensive form validation
  • XSS Protection - Content Security Policy implementation
  • HTTPS Only - Secure connections enforced
  • Wallet Security - Secure wallet integration with proper error handling

๐Ÿงช Testing

Smart Contract Testing

# Run all tests
npx hardhat test

# Run specific test file
npx hardhat test test/LendingPool.test.js

# Run tests with coverage
npx hardhat coverage

Frontend Testing

# Run component tests
npm run test

# Run E2E tests
npm run test:e2e

๐Ÿ“ˆ Performance

Optimizations

  • Image Optimization - Next.js Image component with WebP support
  • Code Splitting - Automatic route-based splitting
  • Lazy Loading - Components loaded on demand
  • Bundle Analysis - Optimized bundle sizes
  • Caching - Proper cache headers and service worker

Metrics

  • Lighthouse Score: 95+ across all categories
  • Core Web Vitals: Excellent performance
  • Bundle Size: Optimized for fast loading
  • Accessibility: WCAG 2.1 AA compliant

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes
    git commit -m 'Add amazing feature'
  6. Push to the branch
    git push origin feature/amazing-feature
  7. Submit a pull request

Contribution Guidelines

  • Follow the existing code style
  • Write meaningful commit messages
  • Add documentation for new features
  • Test your changes thoroughly
  • Update README if needed

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Celo Foundation - For the amazing blockchain platform
  • Next.js Team - For the excellent React framework
  • Tailwind CSS - For the utility-first CSS framework
  • OpenZeppelin - For secure smart contract libraries
  • Chainlink - For reliable oracle services
  • NVIDIA - For AI model integration
  • shadcn/ui - For the component library

๐Ÿ“ž Support

๐Ÿ”ฎ Roadmap

Phase 1 โœ…

  • Core lending protocol
  • Multi-token vault
  • Basic UI/UX
  • Smart contract deployment

Phase 2 โœ…

  • AI Yield Generator
  • Advanced analytics
  • Mobile optimization
  • Backend services

Phase 3 ๐Ÿšง

  • Governance token
  • Advanced strategies
  • Cross-chain integration
  • Mobile app

Phase 4 ๐Ÿ“‹

  • Institutional features
  • Advanced AI models
  • Layer 2 integration
  • Global expansion

Built with โค๏ธ for the Celo ecosystem

CrosFi - Revolutionizing cross-currency lending in DeFi

Releases

Packages

Contributors

Languages