Skip to content

coinsspor/AI-Portfolio-Guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Portfolio Guardian (APG) πŸ›‘οΈ

AI-Powered On-Chain Risk Assessment for DeFi Portfolios
Built for Polygon Buildathon: From Launch to Fundraising

Live Demo Watch Video Polygon License

πŸš€ Live Product

🎯 Executive Summary

AI Portfolio Guardian revolutionizes DeFi risk management by providing real-time, AI-driven risk assessment for any Polygon wallet. Our solution generates a transparent 0-100 risk score based on portfolio diversification, stable asset allocation, and trading activity - all verifiable on-chain through our innovative attestation system.

Key Metrics

  • Risk Analysis Time: < 3 seconds
  • On-chain Attestation: 1-click process
  • Data Sources: Covalent + Polygonscan APIs
  • Smart Contract: Gas-optimized, EIP-712 compatible

✨ Core Features

πŸ€– AI-Powered Risk Analysis

  • Composite Risk Scoring: Advanced algorithm combining concentration metrics (HHI-based), stable hedge ratios, and activity signals
  • Real-time Analysis: Instant portfolio evaluation for any Polygon address
  • Multi-dimensional Assessment: Concentration, stability, and activity components

πŸ“Š Advanced Visualization

  • Interactive Donut Chart: USD-based asset breakdown with drill-down capabilities
  • Risk Radar Chart: Multi-axis visualization of risk components
  • Trend Sparklines: Historical risk score evolution
  • Responsive Design: Mobile-first, production-ready UI

πŸ”— On-Chain Attestation

  • Verifiable Records: Permanent, transparent risk scores on Polygon blockchain
  • Self-Sovereign: Users control their own risk attestation
  • EIP-712 Support: Secure, gas-efficient signature scheme
  • Public Access: Open protocol for ecosystem integration

πŸ›‘οΈ Security & Trust

  • Self-Attestation Only: Prevents score manipulation by third parties
  • Contract Guards: Public mode, pause mechanism, fee management
  • Version Control: Automatic versioning for score updates
  • Audit-Ready: Clean, documented smart contract code

πŸ—οΈ Technical Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    User Interface (Next.js)              β”‚
β”‚  - Wallet Connection (Wagmi)                            β”‚
β”‚  - Real-time Analysis                                   β”‚
β”‚  - Interactive Charts (Chart.js)                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Backend API (Node.js)                  β”‚
β”‚  - Risk Calculation Engine                              β”‚
β”‚  - Data Aggregation (Covalent + Polygonscan)            β”‚
β”‚  - Caching Layer                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Smart Contract (RiskRegistry V3)            β”‚
β”‚  - On-chain Attestation                                 β”‚
β”‚  - Version Management                                   β”‚
β”‚  - Access Control                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Repository Structure

AI-Portfolio-Guardian/
β”œβ”€β”€ backend/                 # Risk analysis engine
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.ts        # Express server
β”‚   β”‚   β”œβ”€β”€ analyze.ts      # Core risk algorithm
β”‚   β”‚   β”œβ”€β”€ covalent.ts     # Covalent API integration
β”‚   β”‚   └── polygonscan.ts  # Polygonscan integration
β”‚   └── .env.example
β”‚
β”œβ”€β”€ frontend/               # Next.js application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx       # Landing page
β”‚   β”‚   β”œβ”€β”€ analyze/       # Analysis dashboard
β”‚   β”‚   └── providers.tsx  # Web3 providers
β”‚   └── .env.local.example
β”‚
└── contracts/             # Smart contracts
    β”œβ”€β”€ contracts/
    β”‚   └── RiskRegistry.sol
    β”œβ”€β”€ scripts/
    β”‚   β”œβ”€β”€ deploy.ts
    β”‚   └── enablePublic.ts
    └── abi/

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MetaMask wallet
  • Polygon (POL) for gas fees

Installation

  1. Clone the repository
git clone https://github.com/yourusername/AI-Portfolio-Guardian.git
cd AI-Portfolio-Guardian
  1. Setup Backend
cd backend
cp .env.example .env
# Edit .env with your API keys
npm install
npm run build
npm start
  1. Setup Frontend
cd ../frontend
cp .env.local.example .env.local
# Edit .env.local
npm install
npm run build
npm start
  1. Access the application
Open https://localhost:3000

πŸ”§ Configuration

Backend Environment Variables

PORT=4000
CORS_ORIGIN=https://portfolioguardian.coinsspor.com
RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
COVALENT_KEY=YOUR_COVALENT_API_KEY
POLYGONSCAN_KEY=YOUR_POLYGONSCAN_API_KEY

Frontend Environment Variables

NEXT_PUBLIC_BACKEND_URL=https://portfolioguardian.coinsspor.com/api
NEXT_PUBLIC_REGISTRY=0x35d818492803865b20804C8D60a149519B215b37
NEXT_PUBLIC_CHAIN_ID=137

πŸ“Š Risk Score Algorithm

Our proprietary risk scoring algorithm evaluates three key dimensions:

1. Concentration Risk (40% weight)

  • Herfindahl-Hirschman Index (HHI) based calculation
  • Measures portfolio diversification
  • Higher concentration = Higher risk

2. Stable Hedge Ratio (35% weight)

  • Percentage of portfolio in stable assets
  • Identifies stablecoins (USDC, USDT, DAI, etc.)
  • Lower stable ratio = Higher risk

3. Activity Score (25% weight)

  • Recent transaction frequency
  • 7-day activity window
  • Inactive wallets = Higher risk
riskScore = (concentration * 0.4) + (100 - stableRatio) * 0.35 + activityScore * 0.25

πŸ”— Smart Contract

RiskRegistry V3 Features

  • Public Attestation: attestOpen() for self-sovereign risk reporting
  • Allowlist Support: attest() for authorized attestors
  • EIP-712 Signatures: attestSigned() for backend attestation
  • Version Management: Automatic versioning for updates
  • Fee Mechanism: Optional fee collection (currently 0)

Key Functions

function attestOpen(
    address wallet,
    bytes32 modelId,
    uint16 version,
    uint16 score,
    uint16 confidence,
    uint16 concentration,
    uint16 stable,
    uint16 activity,
    string calldata tag
) external payable;

🌊 Polygon Buildathon Alignment

πŸ“ˆ Current Wave Support: Wave 1-5 COMPLETE

Our project is fully production-ready and supports all Phase 1 waves:

βœ… Wave 1-2: Foundation & Setup (COMPLETE)

  • βœ… Polygon mainnet integration live
  • βœ… Smart contract deployed: 0x35d818492803865b20804C8D60a149519B215b37
  • βœ… Technical infrastructure operational
  • βœ… Product-market fit validated with live users

βœ… Wave 3-4: Build & Optimize (COMPLETE)

  • βœ… Full feature set implemented (risk analysis + on-chain attestation)
  • βœ… User acquisition started (live at portfolioguardian.coinsspor.com)
  • βœ… Business model defined (B2B SaaS + Premium features)
  • βœ… UI/UX optimized with interactive visualizations

βœ… Wave 5: Pitch & Raise (READY)

  • βœ… Demo video published
  • βœ… VC pitch deck prepared
  • βœ… Live product demonstration available
  • βœ… Metrics and traction documented

πŸš€ Phase 2 Readiness

We're prepared for immediate Phase 2 expansion based on funding outcomes:

  • Scale existing AI risk analysis across multiple chains
  • Expand into predictive analytics and automated alerts
  • B2B enterprise integrations

Business Model

  • B2B SaaS: Risk API for DeFi protocols ($99-999/month)
  • Premium Features: Advanced analytics, historical data, alerts
  • Token Integration: Future governance token for protocol decisions

Market Opportunity

  • TAM: $50B+ DeFi TVL requires risk management
  • SAM: $5B in actively managed DeFi portfolios
  • SOM: 10,000 power users in first year

🎯 Roadmap

Q1 2025 (Current)

  • βœ… Launch on Polygon Mainnet
  • βœ… Core risk analysis engine
  • βœ… On-chain attestation system
  • πŸ”„ Mobile app development (in progress)

Q2 2025

  • AI model improvements with ML training
  • Multi-chain expansion (Ethereum, Arbitrum)
  • B2B API launch with tiered pricing
  • Series A fundraising ($3-5M target)

Q3 2025

  • Governance token launch
  • Advanced analytics dashboard
  • Institutional features
  • Global expansion to Asian markets

🀝 Team

  • Project Lead: DeFi risk analysis expert with 5+ years experience
  • Full-Stack Development: Next.js, Node.js, Solidity specialist
  • Polygon Integration: Mainnet optimization and scaling expert

πŸ›‘οΈ Security

  • Smart contract reviewed for security best practices
  • Self-attestation mechanism prevents score manipulation
  • No custody of user funds or private keys
  • Fully open-source for transparency

πŸ“ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

  • Polygon Team: For ecosystem support and mentorship
  • AKINDO: For organizing the Buildathon
  • Covalent & Polygonscan: For reliable blockchain data APIs
  • Community: For feedback and testing

πŸ“ž Contact & Support


Built with ❀️ for Polygon Buildathon

From Launch to Fundraising - Building the Future of DeFi Risk Management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors