Skip to content

InverseFinance/open-index-metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open Dashboard - DeFi Protocol Analytics

React Vite Docker Docker Compose

Open Dashboard is a fully open source DeFi analytics platform that aggregates real-time data from multiple blockchain data sources to provide comprehensive protocol metrics. Teams can easily fork, customize, and deploy their own version with their preferred protocols and metrics.

🌟 Why Open Source?

This project is designed to be completely customizable and community-driven:

  • βœ… Fork-friendly: Clone and customize for your specific protocols
  • βœ… Protocol agnostic: Add any ERC-20 protocol with governance tokens
  • βœ… Data source flexible: Integrate with your preferred APIs
  • βœ… UI customizable: Modify layouts, colors, and metrics
  • βœ… Self-hostable: Deploy on your own infrastructure
  • βœ… No vendor lock-in: Full control over your analytics stack

πŸ“ Project Structure

open-dashboard/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── protocols.js          # πŸ”§ MAIN CUSTOMIZATION FILE
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ DeFiDashboard.jsx     # πŸŽ›οΈ Main dashboard component
β”‚   β”‚   β”œβ”€β”€ Header.jsx            # Navigation header
β”‚   β”‚   └── Footer.jsx            # Footer component
β”‚   β”œβ”€β”€ hooks/                    # Data fetching hooks
β”‚   β”‚   β”œβ”€β”€ useCoinGecko.js       # CoinGecko API integration
β”‚   β”‚   β”œβ”€β”€ useDefiLlama.js       # DeFiLlama API integration
β”‚   β”‚   β”œβ”€β”€ useUniswap.js         # Uniswap subgraph data
β”‚   β”‚   β”œβ”€β”€ useCurve.js           # Curve protocol data
β”‚   β”‚   β”œβ”€β”€ useBalancer.js        # Balancer protocol data
β”‚   β”‚   β”œβ”€β”€ useSushiSwap.js       # SushiSwap protocol data
β”‚   β”‚   β”œβ”€β”€ useFraxswap.js        # Fraxswap protocol data
β”‚   β”‚   └── useEthereum.js        # Ethereum on-chain data
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── cache-client.js       # Caching and API management
β”‚   └── assets/                   # Static assets
β”œβ”€β”€ cache-service/                # Backend caching service
β”œβ”€β”€ public/                       # Public assets
β”œβ”€β”€ dist/                         # Production build
β”œβ”€β”€ .github/                      # GitHub workflows
β”œβ”€β”€ docker-compose.yml            # Docker setup
β”œβ”€β”€ Dockerfile                    # Container configuration
β”œβ”€β”€ deploy.sh                     # Deployment script
└── package.json                  # Dependencies and scripts

πŸ”§ Core Customization Files

1. src/config/protocols.js - Protocol Configuration

This is the main file you'll customize to add your protocols:

export const protocols = [
  {
    ticker: "YOUR_TOKEN",              // Token symbol (e.g., "UNI", "AAVE")
    name: "Your Protocol Name",        // Full protocol name
    govContractAddress: "0x...",       // Governance token contract address
    coingeckoId: "your-token-id",      // CoinGecko API ID
    defiLlamaSlug: "your-protocol",    // DeFiLlama protocol slug
    blockchain: "ethereum",            // Blockchain network
    mainnetLaunch: "2024-01-01",      // Launch date (YYYY-MM-DD)
    openStatus: "current",             // "current" or "proposed"
    nextEmissions: 1000000,            // Upcoming token emissions
    emissionsCatalyst: "Description"   // Emissions description
  },
  // Add more protocols here...
];

2. src/components/DeFiDashboard.jsx - Dashboard Logic

Customize the dashboard display, metrics, and calculations:

  • Add new columns: Extend the table with custom metrics
  • Modify calculations: Change ratio formulas and thresholds
  • Customize styling: Update colors, layouts, and responsive design
  • Add data sources: Integrate new APIs or on-chain data

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose
  • Git

Installation

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

# Create environment file
cp .env.example .env
# Edit .env with your API keys and configuration

# Start development environment
./scripts/dev.sh

The dashboard will be available at http://localhost:3000

Adding Your First Protocol

  1. Open src/config/protocols.js
  2. Add your protocol to the protocols array:
{
  ticker: "MYTOKEN",
  name: "My DeFi Protocol",
  govContractAddress: "0x1234567890123456789012345678901234567890",
  coingeckoId: "my-token",
  defiLlamaSlug: "my-protocol",
  blockchain: "ethereum",
  mainnetLaunch: "2024-01-01",
  openStatus: "current",
  nextEmissions: 500000,
  emissionsCatalyst: "Liquidity mining rewards"
}
  1. Save and the dashboard will automatically update!

πŸ“Š Data Sources

The dashboard integrates with multiple APIs to provide comprehensive metrics:

Data Source Usage Configuration
CoinGecko API Market data, prices, volumes coingeckoId in protocols.js
DeFiLlama API Protocol TVL data defiLlamaSlug in protocols.js
Uniswap Subgraph DEX liquidity and volume govContractAddress for token lookups
Curve API Curve pool data Auto-detected by token address
Balancer Subgraph Balancer pool metrics Auto-detected by token address
SushiSwap Subgraph Sushi pool data Auto-detected by token address
Fraxswap API Frax DEX data Auto-detected by token address

🎨 Customization Examples

Adding a New Metric Column

  1. Extend the protocol data structure in protocols.js:
{
  // ... existing fields
  customMetric: 1000000,  // Your new field
}
  1. Add the column header in DeFiDashboard.jsx:
<SortableHeader 
  column="customMetric" 
  currentSort={sortConfig} 
  onSort={handleSort} 
  dataSource="Custom"
>
  Your Metric
</SortableHeader>
  1. Add the data cell in the ProtocolRow component:
<Td>
  <Text fontSize="sm">{protocol.customMetric}</Text>
</Td>

Modifying Color Thresholds

Update the getColorForMetric function in DeFiDashboard.jsx:

case 'yourMetric':
  return getColorScale(value, { 
    low: 10,      // Red threshold
    medium: 50,   // Yellow threshold  
    high: 100     // Green threshold
  }, false);      // false = higher is better

Adding Protocol-Specific Logic

Handle special cases for specific protocols:

// Special handling for your protocol
if (protocol.ticker === 'MYTOKEN') {
  // Custom calculation logic
  const customValue = (marketCap * specialMultiplier) / totalSupply;
  // Use in your metrics
}

🐳 Docker Deployment

The Open Dashboard provides separate Docker configurations for development and production environments.

πŸ› οΈ Development Environment

For local development with external Redis and API proxy:

# Option 1: Use helper script (recommended)
./scripts/dev.sh

# Option 2: Manual setup
docker-compose -f docker-compose.dev.yml up -d --build

Development Environment Features:

πŸš€ Production Environment

For production deployment (e.g., Digital Ocean App Platform):

# Option 1: Use helper script (recommended)
./scripts/prod.sh

# Option 2: Manual setup
docker-compose up -d --build

Production Environment Features:

  • Uses Dockerfile and nginx.conf
  • API routing handled by platform (Digital Ocean App Platform)
  • External Redis connection
  • Optimized for production deployment

πŸ“‹ Environment Variables

Create a .env file in the root directory:

# Cache Service Configuration
PORT=4000
REDIS_URL=redis://your-redis-host:6379

# API Keys (secure backend-only)
COINGECKO_API_KEY=your_coingecko_api_key
THE_GRAPH_API_KEY=your_thegraph_api_key

# Ethereum RPC URLs
ETH_RPC_URL=https://mainnet.infura.io/v3/your_key
ETH_RPC_URL_FALLBACK=https://rpc.ankr.com/eth

# The Graph Subgraph IDs
UNISWAP_V3_SUBGRAPH_ID=5zvR82QoaXuFYDNKBfRU5N3q
UNISWAP_V2_SUBGRAPH_ID=ELUcwgpm14LKPLrBRuVvPvNKHQ9HvwmtKgKSH6123456
SUSHI_SUBGRAPH_ID=4bb7e6e1-b60d-4e1e-9f0d-123456789abc
SUSHI_V2_SUBGRAPH_ID=0x4bb7e6e1-b60d-4e1e-9f0d-123456789abc
CURVE_SUBGRAPH_ID=3C5-qE3-wVf-6Pw-dS2-aB8-x9K-mN4
FRAXSWAP_SUBGRAPH_ID=8H2-nF9-sW3-7Qs-eR5-cD6-y1L-mK8
BALANCER_V2_SUBGRAPH_ID=C4ayEZP2yTXRAB8Tf0h8bKaLqr

πŸ”§ Service Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚  Cache Service  β”‚    β”‚  External APIs  β”‚
β”‚   (React/Vite)  │◄──►│   (Node.js)     │◄──►│   (CoinGecko,   β”‚
β”‚   Port: 3000    β”‚    β”‚   Port: 4000    β”‚    β”‚   DeFiLlama,    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚   The Graph)    β”‚
         β”‚                       β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Nginx       β”‚    β”‚      Redis      β”‚
β”‚   (Proxy/CDN)   β”‚    β”‚     (Cache)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Health Checks

Monitor your deployment:

# Check application status
curl http://localhost:3000/api/health

# Check Redis connection
curl http://localhost:3000/api/admin/redis-info

# View container logs
docker-compose logs -f app
docker-compose logs -f cache-service

πŸ”„ Updating Deployment

# Pull latest changes
git pull origin main

# Rebuild and restart (development)
docker-compose -f docker-compose.dev.yml down
./scripts/dev.sh

# Rebuild and restart (production)
docker-compose down
./scripts/prod.sh

πŸ”„ Data Flow

graph LR
    A[protocols.js] --> B[DeFiDashboard.jsx]
    B --> C[Custom Hooks]
    C --> D[API Services]
    D --> E[Cache Layer]
    E --> F[External APIs]
    F --> G[Dashboard Display]
Loading
  1. Configuration loaded from protocols.js
  2. Dashboard component processes protocol list
  3. Custom hooks fetch data for each protocol
  4. Cache service optimizes API calls
  5. External APIs provide real-time data
  6. UI components display formatted results

πŸ› οΈ Advanced Customization

Custom Data Sources

Add your own data sources by creating new hooks:

// src/hooks/useCustomAPI.js
export function useCustomAPI(protocolAddress, options = {}) {
  return useQuery({
    queryKey: ['customAPI', protocolAddress],
    queryFn: () => fetchCustomData(protocolAddress),
    ...options
  });
}

Protocol-Specific Components

Create specialized components for unique protocols:

// Handle special protocols
if (protocol.ticker === 'SPECIAL') {
  return <SpecialProtocolRow protocol={protocol} />;
}

Custom Styling

Modify themes in the main app or component files:

const customTheme = {
  colors: {
    brand: {
      primary: '#your-color',
      secondary: '#your-color'
    }
  }
};

πŸ“ˆ Performance Optimization

  • Staggered Loading: Protocols load incrementally to prevent API rate limits
  • Caching Layer: Reduces redundant API calls with intelligent caching
  • Lazy Loading: Components load data only when needed
  • Memoization: Expensive calculations are cached
  • Virtual Scrolling: Handles large protocol lists efficiently

🀝 Contributing

We welcome contributions! This project thrives on community involvement:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contribution Ideas

  • πŸ“Š Additional metrics (governance participation, yield farming)
  • 🎨 UI improvements (charts, graphs, mobile optimization)
  • πŸ”Œ API integrations (new data sources, real-time price feeds)
  • πŸ§ͺ Testing (unit tests, integration tests)

πŸ†˜ Support & Community

  • Issues: GitHub Issues
  • Discussions: GitHub Discussions
  • Documentation: This README and inline code comments
  • Examples: Check the examples/ directory for common customizations

This project is maintained by the community for the community. Star ⭐ the repo if you find it useful!

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages