Skip to content

Conversation

@mesaque
Copy link

@mesaque mesaque commented Sep 24, 2025

…ent support

  • Implement PoolBot class for automated DLMM pool management
  • Add WebSocket server (wsServer.js) for real-time bot communication
  • Create Vercel-compatible HTTP server (vercel-server.js) with Server-Sent Events
  • Integrate Jupiter Ultra API for automatic token-to-SOL conversion on position closure
  • Add authentication system with INTEGRATION_SECRET for secure bot access
  • Implement real-time metrics tracking (P&L, fees, rebalance counts)
  • Add automatic position rebalancing when price moves outside range
  • Support both development (WebSocket) and production (HTTP/SSE) communication modes
  • Include comprehensive error handling and graceful bot lifecycle management
  • Add Vercel deployment configuration (vercel.json) for serverless hosting
  • Remove all debug logs for production-ready deployment

…ent support

- Implement PoolBot class for automated DLMM pool management
- Add WebSocket server (wsServer.js) for real-time bot communication
- Create Vercel-compatible HTTP server (vercel-server.js) with Server-Sent Events
- Integrate Jupiter Ultra API for automatic token-to-SOL conversion on position closure
- Add authentication system with INTEGRATION_SECRET for secure bot access
- Implement real-time metrics tracking (P&L, fees, rebalance counts)
- Add automatic position rebalancing when price moves outside range
- Support both development (WebSocket) and production (HTTP/SSE) communication modes
- Include comprehensive error handling and graceful bot lifecycle management
- Add Vercel deployment configuration (vercel.json) for serverless hosting
- Remove all debug logs for production-ready deployment
- Update wsServer.js to accept connections via nginx proxy with verifyClient logging
- Add start-production.js script for production deployment with proper host binding
- Add production optimizations and proper error handling for proxy connections
- Support both local development and production nginx proxy setups
- Authentication: two-level access (user/admin) with separate secrets
- Protected administrative endpoints:
  * LIST_ACTIVE_BOTS - list all active bots
  * GET_SERVER_STATUS - server status (port, clients, uptime, memory)
  * GET_SYSTEM_METRICS - system metrics (CPU, memory, disk, load average)
  * STOP_ALL_BOTS - stop all running bots
  * GET_BOT_LOGS - get specific bot logs
- Security: mandatory admin role verification
- Monitoring: detailed server resource information
- Timeout and automatic reconnection for administrative operations
- Remove obsolete HTTP endpoints (vercel-server.js, vercel.json)
- Remove verbose authentication logging
- Remove debug connection logging
- Remove shutdown debug messages
- Keep only essential server startup message
- Clean up production and integration startup scripts
- Prepare for production deployment

Files cleaned:
- wsServer.js (removed auth, connection, shutdown logs)
- start-production.js (simplified startup messages)
- start-integration.js (simplified startup messages)
- Convert SOL initial value to USD for accurate PnL calculation in botManager
- Remove debug console.log statements from botManager.js and wsServer.js
- Implement silent error handling in monitoring loops and WebSocket operations
- Clean production-ready code for deployment
- Maintain full functionality while removing noise from logs
- Fix units consistency: initialValue in USD, currentValue in USD for correct PnL
- Replace individual getPrice calls with batch getPrices for better efficiency
- Add rate limiting and caching to prevent excessive API calls
- Configure Ultra API with proper authentication headers
- Fix existing https://lite-api.jup.ag 429 errors

Changes:
- lib/price.js: Implemented batch getPrices with cache (60s TTL) + rate limiting
- botManager.js: All metrics updates now use batch price requests (3 tokens per cycle)
- jupiter.js: Swap calculations now fetch both tokens in single batch call
- Add JUPITER_API_BASE_URL and JUPITER_API_KEY environment variable support

Benefits:
- Reduce individual API calls (SOL + tokenX + tokenY) → 1 batch call
- Cache prices for 60s to avoid repeated fetches in tight loops
- Exponential backoff on 429s to handle rate limits gracefully
- Silent error handling to avoid production log noise
- Remove cache and batch functionality for simplicity
- Switch from lite-api to Ultra API only
- Keep simple getPrice function with environment variables
- botManager.js unchanged - use getPrice calls normally
- jupiter.js unchanged - original getPrice calls

Simple change:
- price.js: lite-api -> ultra/v1/search with x-api-key authentication
- No cache, no batch optimization yet
- Basic functionality preserved
- Environment variables JUPITER_API_BASE_URL and JUPITER_API_KEY required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant