Vega is an autonomous AI-powered trading agent for GMX perpetual futures on Arbitrum/Avalanche networks. Built with the Daydreams AI framework, it implements sophisticated scalping strategies with advanced risk management and AI-driven market intelligence.
- Autonomous Trading: AI-driven decision making with Claude Sonnet 4
- Multi-Network Support: Arbitrum and Avalanche GMX markets
- Advanced Risk Management: Comprehensive failsafe validations and position sizing
- Intelligent Market Analysis: Synth AI integration with multi-timeframe momentum analysis
- Real-time Execution: Sequential transaction queue with nonce management
- Failsafe Validations: Price direction validation for all take profit/stop loss orders
- Error Prevention: Pre-validation eliminates common trading mistakes
- Dynamic Leverage Management: Adjusts position sizes based on market volatility
- Synth AI Integration: Decentralized AI miner predictions for BTC/ETH/SOL
- Percentile-Based Mean Reversion: Simplified strategy using exact percentile interpolation within 24h price distributions
- 4-Tier Volatility System: VERY_LOW/LOW/MEDIUM/HIGH volatility regimes with different entry thresholds
- 7-Snapshot Averaging: Robust 24h lookback using 7 snapshots around 24h mark to avoid cherry-picking
- Strict Error Handling: Requires all 7 snapshots for trading decisions, ensuring data integrity
- Dynamic Levels: Prediction-based stops and targets (not arbitrary percentages)
- Smart Setup Detection: WAIT vs actionable signals with trade quality grading (A-D)
- Scalable Design: Single codebase supports BTC, ETH, SOL with easy expansion
- Dynamic Market Detection: Automatically handles new assets through ASSETS configuration
- Unified Processing: Same intelligence system works across all trading pairs
- Asset-Agnostic Logic: Add new cryptocurrencies by simply updating the ASSETS array
- Advanced Caching System: 5-minute TTL cache with promise deduplication prevents redundant API calls
- Smart Data Loading: Context-based data loading with cache-first architecture
- Request Deduplication: Prevents concurrent duplicate API calls at cache level
- Transaction Queue: Sequential execution prevents nonce errors
- Optimized Trading Cycles: Event-driven architecture with intelligent triggers
- Bun Runtime: Fast JavaScript runtime and package manager
- Funded Wallet: Arbitrum/Avalanche wallet with trading capital and ETH for gas
- API Keys: Anthropic, OpenAI, Synth AI, Supabase
# Clone repository
git clone <repository-url>
cd agent-gmx
# Install dependencies
bun installCreate a .env file with required API keys and wallet configuration:
# Required API Keys
ANTHROPIC_API_KEY=your_anthropic_key
OPENAI_API_KEY=your_openai_key
SYNTH_API_KEY=your_synth_key
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key
# GMX Configuration
GMX_NETWORK=arbitrum # or avalanche
GMX_CHAIN_ID=42161 # 43114 for avalanche
GMX_RPC_URL=your_rpc_url
GMX_ORACLE_URL=your_oracle_url
GMX_SUBSQUID_URL=your_subsquid_url
GMX_WALLET_ADDRESS=0x... # 40 hex chars
GMX_PRIVATE_KEY=0x... # 64 hex chars# Start the autonomous trading agent
bun run start
# Or run directly
bun run agent-gmx.ts
# Development mode
bun run devget_portfolio_balance- Complete portfolio analysis with token balancesget_positions- Position analysis with PnL, liquidation prices, risk metricsget_orders- Pending orders with execution probability analysisget_trading_history- Performance metrics and trade analysisget_synth_analysis- Advanced AI analysis for BTC/ETH/SOL with regime detectionget_technical_analysis- Technical indicator analysis for all supported assets
open_long_market/open_long_limit- Long position entry (market/limit orders)open_short_market/open_short_limit- Short position entry (market/limit orders)close_position- Complete position closure with optimal executioncancel_orders- Cancel pending limit orders
set_take_profit- Take profit orders with failsafe validationset_stop_loss- Stop loss orders with direction and distance validationswap_tokens- Token swaps for capital management
- agent-gmx.ts - Main agent with Vega personality and trading cycle
- gmx-actions.ts - All trading actions with GMX SDK integration
- gmx-queries.ts - Market data queries and Synth AI analysis
- gmx-cache.ts - High-performance caching system with 5-minute TTL and promise deduplication
- gmx-utils.ts - Financial calculations and BigInt precision utilities
- gmx-wallet.ts - Wallet initialization and network configuration
- synth-utils.ts - Synth AI integration for volatility and predictions
- transaction-queue.ts - Sequential transaction execution management
- gmx-types.ts - TypeScript type definitions for GMX data structures
- AI-First Data Formatting: All data returned as AI-readable strings
- Cache-First Architecture: Minimizes API calls with intelligent caching
- Sequential Transaction Execution: Prevents nonce errors and race conditions
- Failsafe Validations: Comprehensive error prevention in risk management
- Modular Actions: Consistent structure for easy extension and maintenance
Vega leverages decentralized AI miners for market predictions across all supported assets:
- Current Price Percentile: Calculates exact position of current price within 24h ago distribution
- 4-Tier Volatility Classification:
- VERY_LOW (0-25th percentile): Tightest entry thresholds
- LOW (25-50th percentile): Conservative entry points
- MEDIUM (50-75th percentile): Moderate risk tolerance
- HIGH (75-100th percentile): Widest entry bands for volatile conditions
- 7-Snapshot Robustness: Uses timestamps 22h, 23h, 24h, 25h, 26h from current time
- Anti-Cherry-Picking: Requires ALL 7 snapshots to be available, preventing data selection bias
- Exact Interpolation: Precise percentile calculation using sorted price arrays
- Multi-Asset Analysis β Compares opportunities across BTC/ETH/SOL for optimal allocation
HIGH RISK - REAL MONEY TRADING: This is a live trading system that uses real cryptocurrency.
- Only use funds you can afford to lose completely
- Cryptocurrency trading involves significant financial risk
- Past performance does not guarantee future results
- This software is for educational/research purposes
- Not financial advice - trade at your own risk
- Test with small amounts before deploying significant capital
- Monitor the agent continuously during operation
# No formal testing framework - relies on TypeScript strict mode
# Test manually with small amounts first
bun run agent-gmx.ts- CLAUDE.md - Comprehensive development guide and architecture documentation
- agent-gmx.ts - Main entry point and agent configuration
- gmx-actions.ts - All trading logic and risk management
- gmx-queries.ts - Market data and AI analysis functions
- gmx-cache.ts - High-performance caching system for optimal data access
MIT License - Copyright (c) 2025 zkorp
Built with:
- GMX SDK - Decentralized perpetual futures
- Daydreams AI - AI agent framework
- Anthropic Claude - Advanced AI reasoning
- Synth AI - Decentralized market predictions
- Supabase - Database and vector storage
Built by zkorp
Powered by Daydreams AI