Skip to content

elizaOS/aum-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spartan AUM - Solana Portfolio Tracker

A high-performance web application to track and analyze Solana wallet holdings across multiple addresses, providing real-time portfolio valuation and PNL (Profit/Loss) analytics.

Features

  • πŸ“Š Portfolio Overview - Aggregated view of total assets under management
  • πŸ’° Multi-Wallet Tracking - Monitor 1000+ Solana wallets simultaneously
  • πŸ“ˆ PNL Analytics - Track profit/loss across time periods (24h, 7d, 30d)
  • ⚑ High Performance - Sub-100ms response times with SQLite caching
  • πŸ”„ Real-time Prices - Live token prices with automatic refresh on dashboard load
  • πŸ–ΌοΈ Token Images - Display real token logos fetched from Jupiter Token List
  • πŸ“± Modern UI - Sleek dark theme with glass morphism design
  • πŸ” Detailed Views - Individual wallet and token detail pages

Tech Stack

  • Runtime: Bun - Fast all-in-one JavaScript runtime
  • Framework: Hono - Lightweight web framework with JSX support
  • Database: SQLite with WAL mode for concurrent reads
  • Blockchain:
  • UI: Server-side JSX with Tailwind CSS via CDN

Prerequisites

  • Bun runtime (latest version)
  • Helius RPC endpoint (required)

Installation

  1. Clone the repository:
git clone https://github.com/elizaOS/aum-tracker
cd aum-tracker
  1. Install dependencies:
bun install
  1. Set up environment variables:
cp .env.example .env
  1. Edit .env with your configuration:
# Required
HELIUS_RPC_URL=your_helius_rpc_endpoint_here

# Optional (defaults provided)
JUPITER_API_URL=https://lite-api.jup.ag/price/v2
JUPITER_TOKENS_API_URL=https://lite-api.jup.ag/tokens/v1
DATABASE_PATH=./data/portfolio.db
PORT=3000

Usage

Command Breakdown

Web Server Commands (API endpoints)

bun run dev      # Starts development server with hot reload (port 3000)
bun run start    # Starts production server (port 3000)

These start the Hono web server that serves the API endpoints.

Data Prefetch Commands (populate database)

bun run prefetch              # Fetches wallet data from blockchain
bun run prefetch:force        # Force refresh all wallet data
bun run prefetch:test         # Test with 5 wallets
bun run prefetch:test10       # Test with 10 wallets
bun run prefetch:test-force   # Test with 5 wallets + force refresh
bun run prefetch:health       # Check system health
bun run db:cleanup            # Database cleanup with batch processing

These run the data prefetch script that reads wallet addresses from CSV, fetches balance data from Solana blockchain, and populates the SQLite database.

Token Metadata Service (background processing)

bun run token-metadata:start   # Starts continuous background service
bun run token-metadata:refresh # One-time metadata refresh
bun run token-metadata:health  # Check metadata service health
bun run token-metadata:queue   # Show metadata queue status
bun run token-metadata:clear   # Clear metadata queue

These manage the background token metadata service that processes tokens one at a time to respect Jupiter API rate limits.

Typical Workflow

  1. First time setup - Populate database with wallet data:

    # Test with a few wallets first
    bun run prefetch:test
    
    # Then fetch all wallet data
    bun run prefetch
  2. Start the web server:

    # Development (with hot reload)
    bun run dev
    
    # OR Production
    bun run start
  3. Optional: Start background metadata service (in a separate terminal):

    bun run token-metadata:start
  4. View the dashboard: Open http://localhost:3000

What Each Process Does

Command Purpose Runs Once Continuous
bun run dev Web server with hot reload ❌ βœ…
bun run start Production web server ❌ βœ…
bun run prefetch Fetch wallet data βœ… ❌
bun run token-metadata:start Background metadata service ❌ βœ…

Important: The prefetch needs to be run first to populate the database, then you can start the web server to access the API endpoints.

Production

Build and run for production:

bun run build
bun run start

API Endpoints

Portfolio Endpoints

  • GET /api/portfolio/overview - Aggregated portfolio statistics
  • GET /api/portfolio/status - System health and data freshness
  • GET /api/portfolio/metrics - Performance and error metrics
  • GET /api/portfolio/pnl - Combined PNL across all wallets
  • GET /api/portfolio/pnl/timeframe/:period - PNL for specific timeframe

Wallet Endpoints

  • GET /api/wallets/balance/:address - Individual wallet data
  • POST /api/wallets/balances - Batch wallet data
  • GET /api/wallets/history/:address - Historical balance data
  • GET /api/wallets/pnl/:address - Individual wallet PNL
  • GET /api/wallets/pnl/:address/:period - Wallet PNL for specific timeframe
  • GET /api/wallets/all - All wallet balances (paginated)

Token Endpoints

  • GET /api/tokens/prices - Current token prices
  • POST /api/tokens/prices/refresh - Force price refresh
  • GET /api/tokens/aggregated - Aggregated token holdings with real-time prices
  • GET /api/tokens/holders/:mint - Get all wallets holding a specific token
  • GET /api/tokens/pnl - Top gainers and losers

Admin Endpoints

  • POST /api/admin/refresh - Trigger full data refresh
  • GET /api/admin/logs - View recent error logs
  • POST /api/admin/snapshot - Create manual portfolio snapshot

Health Endpoints

  • GET /api/health - Service health check

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Main server entry point
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── api.ts           # API route definitions
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ database.ts      # SQLite operations
β”‚   β”‚   β”œβ”€β”€ solana.ts        # Blockchain integration
β”‚   β”‚   └── csv.ts           # CSV parsing
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ModernDashboard.tsx  # Modern dashboard UI
β”‚   β”‚   β”œβ”€β”€ ModernLayout.tsx     # Dark theme layout
β”‚   β”‚   β”œβ”€β”€ WalletDetail.tsx     # Individual wallet view
β”‚   β”‚   └── TokenDetail.tsx      # Individual token view
β”‚   └── scripts/
β”‚       └── prefetch.ts      # Data prefetching script
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ wallets.csv          # Wallet addresses
β”‚   └── portfolio.db         # SQLite database (created at runtime)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CLAUDE.md                 # Development guidelines
β”œβ”€β”€ PRD.md                    # Product requirements
β”œβ”€β”€ README.md
β”œβ”€β”€ bun.lock
β”œβ”€β”€ package.json
└── tsconfig.json

Performance

  • Response Times: <100ms for cached data
  • Data Freshness: Real-time price updates on dashboard load
  • Rate Limits:
    • Premium Helius RPC: 1000+ requests/minute
    • Jupiter API: 600 requests/minute
  • Batch Processing: 50 wallets per batch (optimized for premium endpoints)
  • Token Metadata: Cached with images from Jupiter Token List
  • Database: SQLite with WAL mode for concurrent read performance
  • Caching: 5-minute cache freshness with automatic refresh

Environment Variables

Variable Description Required Default
HELIUS_RPC_URL Helius RPC endpoint Yes -
JUPITER_API_URL Jupiter price API URL No https://lite-api.jup.ag/price/v2
JUPITER_TOKENS_API_URL Jupiter tokens API URL No https://lite-api.jup.ag/tokens/v1
DATABASE_PATH SQLite database path No ./data/portfolio.db
PORT Server port No 3000

Note: Only HELIUS_RPC_URL is currently required. Other environment variables are defined in .env.example but may use hardcoded defaults in the current implementation.

Development

Additional Scripts

All available development scripts:

# Development & Production
bun run dev                    # Development server with hot reload
bun run start                  # Production server
bun run build                  # Build for production

# Data Management
bun run prefetch               # Fetch all wallet data
bun run prefetch:force         # Force refresh all data
bun run prefetch:test          # Test with 5 wallets
bun run prefetch:test10        # Test with 10 wallets
bun run prefetch:test-force    # Test with 5 wallets + force refresh
bun run prefetch:health        # Check system health
bun run db:cleanup             # Database cleanup with batch processing

# Token Metadata Management
bun run token-metadata:start   # Start continuous token metadata service
bun run token-metadata:refresh # Refresh stale metadata once
bun run token-metadata:health  # Check metadata service health
bun run token-metadata:queue   # Show metadata queue status
bun run token-metadata:clear   # Clear metadata queue

# Testing
bun run test                   # Run tests (not configured yet)

Architecture & Guidelines

See CLAUDE.md for detailed development guidelines and architecture information.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •