A comprehensive portfolio tracker for Solana liquidity pools with pool-specific alert system, real-time monitoring, and AI-powered assistance.
- Multi-DEX Support: Automatically tracks positions across Orca, Raydium, Meteora, and Drift
- Real-time Portfolio Stats: Total balance, P&L, APY, fees earned
- Position Monitoring: Track in-range/out-of-range status for all positions
- Historical Analysis: View performance over 24h, week, month, and all-time
- Individual Pool Monitoring: Enable alerts for specific pools or all pools at once
- Smart Threshold Detection:
- 25/75 token imbalance alerts
- Out-of-range position notifications
- Price deviation warnings (5% default)
- Multi-Channel Notifications:
- In-app pop-up alerts
- Telegram bot integration (configurable)
- Email notifications (configurable)
- Customizable Settings: Adjust alert thresholds per your risk tolerance
- Real-time Alerts: Instant notifications when rebalancing is needed
- Notification Settings Modal: Configure Telegram chat ID and email preferences
- Alert Severity Levels: Critical, high, and medium priority alerts
- Auto-Dismiss: Notifications auto-remove after 30 seconds
- Direct Action: Click to open pool on respective DEX for manual rebalancing
-
5 Monitoring Methods:
- Wallet transaction history
- Specific pool monitoring
- Real-time WebSocket updates
- Current position tracking
- Bitquery GraphQL backup
-
Enhanced Transaction Data:
- Operation types (swap, add/remove liquidity, collect fees)
- Token balance changes
- Fee breakdowns
- Price impact calculations
- GPT-4o Integration: Get intelligent DeFi advice
- Context-Aware: Understands your portfolio and positions
- Strategy Suggestions: Rebalancing, yield optimization, risk management
- Transaction parsing and enhancement
- Real-time WebSocket subscriptions
- Account monitoring
- Price feeds
- Orca Whirlpools: Direct integration with CLMM positions
- Position Calculation: Accurate position values and ranges
- Fee Tracking: Real-time fee accrual monitoring
- GraphQL queries for historical data
- Cross-DEX transaction aggregation
- Alternative data source for reliability
DeFairy uses a comprehensive, transparent P&L calculation that provides complete visibility into your liquidity provision performance:
P&L = Fees Earned + Impermanent Loss/Gain + Price Appreciation
The same comprehensive formula is applied consistently across all time periods:
- 1 Hour (1h): Real-time short-term performance
- 24 Hours (24h): Daily performance tracking
- 7 Days (7d): Weekly trend analysis
- 30 Days (30d): Monthly performance overview
- Trading fees collected from your liquidity provision
- Calculated based on your share of pool trading volume
- Represents the primary income from LP positions
- Calculated using the standard IL formula:
2 * sqrt(ratio) / (1 + ratio) - 1 - Measures gain/loss from token price ratio changes
- Positive values indicate impermanent gain, negative indicate loss
- Value change from underlying token price movements
- Calculated as:
Current Position Value - Historical Position Value - Reflects the USD value change of your token holdings
- Info Icons: Click the ℹ️ icon next to any P&L value for detailed breakdown
- Time Period Tabs: Switch between 1h, 24h, 7d, and 30d views in the modal
- Color Coding: Green for gains, red for losses
- Real-time Updates: All calculations update automatically with new data
- Consistent Methodology: Same calculation logic across all DEXes (Orca, Raydium, Meteora)
- Historical Price Data: Fetches historical prices for accurate period calculations
- Fallback Systems: Multiple data sources ensure calculation reliability
- Performance Optimized: Efficient caching and batch processing
SOL/USDC Pool (24h):
├── Fees Earned: +$18.76
├── Impermanent Loss: -$2.31
├── Price Appreciation: +$107.00
└── Total P&L: +$123.45
This transparent approach gives you complete insight into:
- How much you're earning from fees
- Whether price movements are helping or hurting your position
- The net effect of all factors on your LP performance
- Node.js 16+ and npm
- Solana wallet (Phantom recommended)
- API Keys (optional, included defaults for demo)
# Clone the repository
git clone https://github.com/Defairy/DeFairy-WebApp.git
cd defairy
# Install dependencies
npm install
# Run locally
npm run devThe app is configured for easy deployment on Vercel:
# Deploy to Vercel
vercel deploy --prod- Enter Wallet Address: Simply paste any Solana wallet address
- Connect Wallet: Click "Connect Phantom" for wallet integration
- Automatic Loading: Portfolio data loads automatically from all DEXes
- Enable Pool Alerts: Toggle the switch in the "Alerts" column for each pool
- Select All Pools: Use the master toggle to enable alerts for all pools at once
- Configure Notifications: Click "Notification Settings" to set up:
- Telegram bot notifications (requires chat ID)
- Email alerts (requires email address)
- In-app notifications (enabled by default)
- Customize Thresholds: Set imbalance ratio and price deviation alerts
Access advanced monitoring features:
- Navigate to "Pool Activity Monitor" section
- Select monitoring type:
- Monitor Wallet: Track all DEX activity for a wallet
- Monitor Pool: Watch specific pool transactions
- Real-time: Live WebSocket updates
- Choose DEX (Orca, Raydium, Meteora)
- Click "Start Monitoring"
- Click the robot icon in the bottom right
- Ask questions about:
- Portfolio optimization
- Rebalancing strategies
- Yield farming tips
- Market analysis
- Get personalized recommendations
- Pure HTML/CSS/JavaScript: No framework dependencies
- Responsive Design: Mobile-friendly interface
- Real-time Updates: WebSocket integration
- Magical Animations: Smooth, delightful UI
- Serverless Functions: Vercel edge functions
- API Routes:
/api/openai: AI assistant endpoint/api/webhook: Helius webhook handler/api/notifications/telegram: Telegram bot integration/api/notifications/email: Email notification service
- Helius API: Primary data provider
- Orca SDK: Direct program integration
- Jupiter API: Token prices
- Bitquery: Backup data source
Create a .env file or set in Vercel:
OPENAI_API_KEY=your_openai_api_key
HELIUS_API_KEY=your_helius_api_key
BITQUERY_API_KEY=your_bitquery_api_key (optional)
TELEGRAM_BOT_TOKEN=your_telegram_bot_token (optional)
SENDGRID_API_KEY=your_sendgrid_api_key (optional)Default API keys are included for demo purposes. For production:
- Get your own Helius API key
- Get your own OpenAI API key
- Set up Telegram Bot for notifications
- Configure SendGrid for email alerts
- Update in Vercel dashboard or
.envfile
- Create a bot via @BotFather
- Get your bot token
- Get your chat ID by messaging @userinfobot
- Configure in notification settings
- Sign up for SendGrid
- Create an API key
- Verify your sender email
- Configure in notification settings
defairy/
├── index.html # Main application
├── styles/
│ └── main.css # Styling with notification UI
├── scripts/
│ ├── main.js # App initialization
│ ├── wallet.js # Wallet connection
│ ├── api.js # API management
│ ├── helius.js # Helius integration
│ ├── orca.js # Orca program integration
│ ├── poolMonitor.js # Pool monitoring system
│ ├── poolMonitorUI.js # Monitoring UI
│ ├── defairyIntegration.js # DEX integration
│ ├── ui.js # UI management with notification modal
│ ├── openai.js # AI assistant
│ └── autoRebalancing.js # Pool-specific alert system
├── api/
│ ├── openai.js # OpenAI serverless function
│ ├── webhook.js # Webhook handler
│ └── notifications.js # Notification endpoints
├── vercel.json # Vercel configuration
└── package.json # Dependencies
- Individual Control: Enable/disable alerts per pool
- Smart Detection: Monitors token imbalance, out-of-range positions, price deviations
- Configurable Thresholds: Customize when alerts trigger
- Multiple Notification Channels: In-app, Telegram, email
- Persistent Settings: Configuration saved in localStorage
- No manual steps required
- Loads data from all supported DEXes automatically
- Real-time monitoring starts on wallet connection
- Seamless position aggregation
- Identifies operation types (swap, liquidity changes)
- Calculates token balance changes
- Tracks fees and price impact
- Historical position calculation
- Current position values
- In/out of range detection
- APY calculations
- Fee tracking
- P&L analysis
- WebSocket connections for live data
- Account change notifications
- Price update alerts
- Transaction monitoring
Due to Solana's security model:
- Manual Approval Required: Each transaction needs wallet signature
- No Pre-Authorization: Cannot execute transactions automatically
- Alert-Based System: Provides notifications for manual action
The alert system is designed to notify users when rebalancing is optimal, but execution requires manual wallet approval for security.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
- Helius for enhanced Solana APIs
- Orca for liquidity pool infrastructure
- OpenAI for GPT-4o integration
- Telegram for bot API
- SendGrid for email services
- Solana community for the amazing ecosystem
Built with 💜 by the DeFairy Team