AI-Trading bot for ETH and USDC using AgentKit and ChatGPT maximum profit
This project is an advanced automated trading system built on Base Sepolia testnet that combines real-time price feeds, algorithmic trading strategies, and secure wallet management. At its core, it's a TypeScript-based trading bot that: Price Monitoring System Continuously monitors ETH/USD price pairs using Pyth Network's oracle Maintains a rolling price history for technical analysis Updates in real-time with configurable intervals (default 10 seconds) Trading Strategy Engine Implements a moving average crossover strategy Uses a 5-period moving average as the primary indicator Features built-in risk management with: 2% profit target for taking gains 1% stop-loss for risk management Dynamic position sizing based on available balances Asset Management Trades between ETH and USDC pairs Maintains precise balance tracking for both assets Implements gas management with automatic buffers Uses the official USDC contract on Base Sepolia (0x876852425331a113d8E432eFFB3aC5BEf38f033a) Simulation Environment Features a complete simulation mode for strategy testing Mirrors real market conditions without actual transactions Provides detailed P&L tracking and performance metrics Allows strategy validation without risking real assets Error Handling & Safety Comprehensive balance checks before trades Multiple fallback mechanisms for price feeds Graceful error recovery for network issues Detailed logging system for monitoring
Core Technology Stack TypeScript/Node.js: The entire system is built in TypeScript for type safety and better developer experience AgentKit SDK: Leverages Coinbase's developer platform for secure wallet operations Pyth Network Integration: Used for reliable price oracle data Base Sepolia: Chosen for its low-cost testnet environment and EVM compatibility Notable Technical Implementations a) Smart Balance Management Implements multiple regex patterns for robust balance parsing Uses BigInt for precise numerical calculations Maintains separate balance tracking for simulation mode Automatically converts between token decimals (18 for ETH, 6 for USDC) b) Price Feed System Direct integration with Pyth Network's price feeds Implements caching mechanism for price feed IDs Uses efficient data structures for price history management Multiple fallback patterns for price feed reliability c) Trading Logic Moving average calculation using efficient array reduction Position state management with clear entry/exit conditions Dynamic trade sizing based on available balances Precise profit/loss calculations Partner Technologies Benefits a) Coinbase Developer Platform (CDP) Provides secure wallet infrastructure Handles transaction signing and broadcasting Manages network connections and state Simplifies API key management b) Pyth Network Offers high-frequency price updates Provides multi-validator consensus for accuracy Reduces latency in price discovery Built-in redundancy for reliability c) Base Network Enables fast transaction confirmations Provides EVM compatibility Offers low-cost testnet environment Maintains stable network conditions Notable Technical Solutions a) Balance Parsing Innovation ; This cascading regex system ensures robust balance parsing across different response formats. b) Gas Management System ; Implements a dynamic gas buffer system to prevent transaction failures. c) Price Feed Optimization Caches price feed IDs to reduce API calls Implements update throttling Uses efficient data structures for history management Multiple fallback mechanisms for reliability This project demonstrates a sophisticated approach to automated trading, combining multiple technologies and careful consideration of real-world trading challenges, while maintaining a focus on reliability and risk management.