AI-Powered On-Chain Risk Assessment for DeFi Portfolios
Built for Polygon Buildathon: From Launch to Fundraising
- Live Application: https://portfolioguardian.coinsspor.com/
- Demo Video: YouTube Demo
- Network: Polygon PoS Mainnet (Chain ID: 137)
- Registry Contract:
0x35d818492803865b20804C8D60a149519B215b37
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.
- Risk Analysis Time: < 3 seconds
- On-chain Attestation: 1-click process
- Data Sources: Covalent + Polygonscan APIs
- Smart Contract: Gas-optimized, EIP-712 compatible
- 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
- 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
- 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
- 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
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
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/
- Node.js 18+ and npm
- MetaMask wallet
- Polygon (POL) for gas fees
- Clone the repository
git clone https://github.com/yourusername/AI-Portfolio-Guardian.git
cd AI-Portfolio-Guardian- Setup Backend
cd backend
cp .env.example .env
# Edit .env with your API keys
npm install
npm run build
npm start- Setup Frontend
cd ../frontend
cp .env.local.example .env.local
# Edit .env.local
npm install
npm run build
npm start- Access the application
Open https://localhost:3000
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_KEYNEXT_PUBLIC_BACKEND_URL=https://portfolioguardian.coinsspor.com/api
NEXT_PUBLIC_REGISTRY=0x35d818492803865b20804C8D60a149519B215b37
NEXT_PUBLIC_CHAIN_ID=137Our proprietary risk scoring algorithm evaluates three key dimensions:
- Herfindahl-Hirschman Index (HHI) based calculation
- Measures portfolio diversification
- Higher concentration = Higher risk
- Percentage of portfolio in stable assets
- Identifies stablecoins (USDC, USDT, DAI, etc.)
- Lower stable ratio = Higher risk
- Recent transaction frequency
- 7-day activity window
- Inactive wallets = Higher risk
riskScore = (concentration * 0.4) + (100 - stableRatio) * 0.35 + activityScore * 0.25- 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)
function attestOpen(
address wallet,
bytes32 modelId,
uint16 version,
uint16 score,
uint16 confidence,
uint16 concentration,
uint16 stable,
uint16 activity,
string calldata tag
) external payable;Our project is fully production-ready and supports all Phase 1 waves:
- β Polygon mainnet integration live
- β
Smart contract deployed:
0x35d818492803865b20804C8D60a149519B215b37 - β Technical infrastructure operational
- β Product-market fit validated with live users
- β 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
- β Demo video published
- β VC pitch deck prepared
- β Live product demonstration available
- β Metrics and traction documented
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
- 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
- TAM: $50B+ DeFi TVL requires risk management
- SAM: $5B in actively managed DeFi portfolios
- SOM: 10,000 power users in first year
- β Launch on Polygon Mainnet
- β Core risk analysis engine
- β On-chain attestation system
- π Mobile app development (in progress)
- AI model improvements with ML training
- Multi-chain expansion (Ethereum, Arbitrum)
- B2B API launch with tiered pricing
- Series A fundraising ($3-5M target)
- Governance token launch
- Advanced analytics dashboard
- Institutional features
- Global expansion to Asian markets
- 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
- 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
MIT License - see LICENSE file for details
- Polygon Team: For ecosystem support and mentorship
- AKINDO: For organizing the Buildathon
- Covalent & Polygonscan: For reliable blockchain data APIs
- Community: For feedback and testing
- Live Demo: https://portfolioguardian.coinsspor.com/
- GitHub: AI-Portfolio-Guardian
- Email: coinsspor@gmail.com
- Twitter: @coinsspor
Built with β€οΈ for Polygon Buildathon
From Launch to Fundraising - Building the Future of DeFi Risk Management