A dApp to calculate the Herfindahl-Hirschman Index (HHI) for token distribution on the Solana blockchain.
This application provides a way to measure token concentration by calculating the Herfindahl-Hirschman Index, which is a common economic measure used to determine market concentration. Higher HHI values indicate higher concentration (less distributed ownership).
The app uses Helius API to fetch token balances and provide accurate HHI calculations.
- Node.js
- Express.js
- TypeScript
- SOLID Architecture
- React
- TypeScript
- Tailwind CSS
- Recharts (for visualization)
- Helius (https://www.helius.xyz/)
- Node.js (v14+)
- npm or yarn
- Navigate to the backend directory:
cd solana-hhi-calculator/backend
- Install dependencies:
npm install
- Create a
.envfile in the backend directory with:
PORT=3001
HELIUS_API_KEY=your_helius_api_key
CORS_ORIGIN=http://localhost:3000
- Start the development server:
npm run dev
- Navigate to the frontend directory:
cd solana-hhi-calculator/frontend
- Install dependencies:
npm install
- Start the development server:
npm start
- Calculate HHI for any Solana token by providing the mint address
- Visualize token holder distribution with an interactive pie chart
- See concentration level categorization (Low, Moderate, High)
- View total supply and holder count statistics
GET /api/hhi?mint={mint}- Get HHI calculation for a token
The application follows SOLID principles:
- Single Responsibility: Each class has one job
- Open/Closed: Code is open for extension but closed for modification
- Liskov Substitution: Service implementations are interchangeable
- Interface Segregation: Service interfaces are focused and specific
- Dependency Inversion: Dependencies are injected, not hard-coded
HHI is calculated using the formula:
HHI = ∑(market share percentage^2) * 10000
Where market share is calculated as:
Market Share = (holder's balance / total supply)
MIT