An AI-powered trading bot for Extended Exchange on Starknet, featuring multi-agent support with various AI models (Anthropic Claude, Google Gemini, OpenAI).
- Features
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Endpoints
- Docker Deployment
- Development
- Project Structure
- Testing
- Multi-Agent Support: Run multiple trading agents simultaneously with different AI models
- AI Model Flexibility: Support for Anthropic Claude, Google Gemini, and OpenAI models
- Extended Exchange Integration: Full integration with Extended Exchange on Starknet
- RESTful API: Simple HTTP API to control the bot
- Docker Support: Production-ready Docker configuration
- TypeScript: Fully typed codebase for better DX and reliability
- Real-time Trading: Automated trading with configurable intervals
Before you begin, ensure you have the following installed:
- Node.js >= 20.x
- pnpm >= 9.x (or use
corepack enable pnpm) - Docker (optional, for containerized deployment)
- Extended Exchange Account with API credentials
- AI Model API Keys (Anthropic, Google, or OpenAI)
git clone https://github.com/your-org/extended-war.git
cd extended-war# Enable pnpm if not already available
corepack enable pnpm
# Install dependencies
pnpm installCopy the example environment file:
cp .env.example .envEdit .env and configure:
# Starknet Configuration
STARKNET_RPC_URL="https://starknet-mainnet.public.blastapi.io"
# LangSmith Configuration (Optional - for tracing and monitoring)
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT="https://eu.api.smith.langchain.com/"
LANGSMITH_API_KEY="lsv2_pt_..."
LANGSMITH_PROJECT="your-project-name"Copy the example config file:
cp config/extended-war.config.example.json config/extended-war.config.jsonEdit config/extended-war.config.json:
{
"accounts": [
{
"name": "Agent 1",
"extended": {
"apiUrl": "https://api.starknet.extended.exchange",
"apiKey": "YOUR_EXTENDED_API_KEY",
"privateKey": "0xYOUR_STARKNET_PRIVATE_KEY"
},
"model": {
"provider": "anthropic",
"name": "claude-sonnet-4-20250514",
"apiKey": "sk-ant-api03-..."
}
}
]
}Supported AI Providers:
anthropic: Claude models (claude-sonnet-4, claude-opus-4, etc.)gemini: Google Gemini models (gemini-2.5-flash, gemini-2.0-pro, etc.)openai: OpenAI models (gpt-4-turbo, gpt-4o, etc.)
pnpm run buildpnpm run devThe server will start on http://localhost:5002.
# Build first
pnpm run build
# Start the server
pnpm startThe bot exposes the following RESTful API endpoints:
GET /health
Check if the service is running.
Response:
{
"success": true,
"message": "Service is healthy",
"data": {
"status": "ok",
"uptime": 123.456,
"timestamp": "2025-11-07T14:30:00.000Z"
}
}POST /start-war
Initialize and start all trading agents.
Response:
{
"success": true,
"message": "War started successfully",
"data": {
"status": "started",
"startedAt": "2025-11-07T14:30:00.000Z"
}
}POST /end-war
Stop all trading agents.
Response:
{
"success": true,
"message": "War stopped successfully",
"data": {
"status": "stopped",
"stoppedAt": "2025-11-07T14:35:00.000Z"
}
}GET /trade-history
Retrieve trading history for all configured accounts.
Response:
{
"success": true,
"message": "Trade history retrieved successfully",
"data": {
"accounts": [
{
"account": { "name": "Agent 1", ... },
"balance": { ... },
"openOrders": [ ... ],
"positions": [ ... ],
"trade": [ ... ]
}
],
"timestamp": "2025-11-07T14:30:00.000Z"
}
}A complete Postman collection is available in postman_collection.json.
Import Steps:
- Open Postman
- Click Import
- Select
postman_collection.json - The collection includes all endpoints with example responses
# Build and start
docker-compose up -d extended-war
# View logs
docker-compose logs -f extended-war
# Stop
docker-compose down# Start development container
docker-compose up -d extended-war-dev
# View logs
docker-compose logs -f extended-war-devdocker build -t extended-war:latest .docker run -d \
--name extended-war \
-p 5002:5002 \
--env-file .env \
-v $(pwd)/config:/app/config:ro \
extended-war:latestpnpm run dev- Start development server with hot reloadpnpm run build- Build TypeScript to JavaScriptpnpm run start- Start production serverpnpm run check-types- Type check without emitting filespnpm run lint- Lint code with ESLintpnpm run format- Format code with Prettierpnpm run format:check- Check code formattingpnpm run test- Run tests with Jestpnpm run clean- Remove dist and node_modules
This project uses:
- TypeScript for type safety
- ESLint for code linting
- Prettier for code formatting
- Husky for git hooks
- Jest for testing
Husky runs the following before each commit:
- Type checking
- Linting
- Format checking
extended-war/
├── src/
│ ├── prompt/ # AI prompts
│ ├── tools/ # Trading tools
│ ├── types/ # TypeScript type definitions
│ │ └── api.types.ts # API response types
│ ├── utils/ # Utility functions
│ │ ├── config-loader.ts # Configuration management
│ │ ├── model.utils.ts # AI model initialization
│ │ └── extended/ # Extended Exchange SDK
│ ├── war/ # Trading bot core
│ │ ├── war.graph.ts # LangGraph workflow
│ │ ├── war.manager.ts # Bot manager
│ │ └── war.types.ts # War-specific types
│ ├── index.ts # Application entry point
│ └── server.ts # Express server
├── config/
│ ├── extended-war.config.json # Your config (gitignored)
│ └── extended-war.config.example.json # Config template
├── dist/ # Compiled JavaScript (gitignored)
├── Dockerfile # Production Docker image
├── Dockerfile.dev # Development Docker image
├── docker-compose.yml # Docker Compose configuration
├── postman_collection.json # Postman API collection
├── package.json
├── tsconfig.json
└── README.md
pnpm run testpnpm run test -- --watch| Variable | Description | Required |
|---|---|---|
STARKNET_RPC_URL |
Starknet RPC endpoint | Yes |
LANGSMITH_TRACING |
Enable LangSmith tracing | No |
LANGSMITH_ENDPOINT |
LangSmith API endpoint | No |
LANGSMITH_API_KEY |
LangSmith API key | No |
LANGSMITH_PROJECT |
LangSmith project name | No |
NODE_ENV |
Environment (production/development) | No |
If port 5002 is already in use:
# Find the process
lsof -i :5002
# Kill it
kill -9 <PID>
# Or change the port in docker-compose.yml or when running
PORT=5003 pnpm run devIf Docker build fails with TypeScript errors:
# Clean and rebuild locally first
pnpm run clean
pnpm install
pnpm run build
# Then try Docker build again
docker build -t extended-war:latest .Ensure the ask-starknet MCP server is available:
# Check the path in war.manager.ts line 101
# Default: '../ask-starknet/packages/mcp/build/index.js'
# Update to match your local setup- Never commit
.envorconfig/extended-war.config.jsonfiles - Store API keys securely
- Use environment variables for sensitive data
- Review all trading decisions before deploying to production
MIT
For issues and questions:
- GitHub Issues: Create an issue
- Discord: Join our community
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
Built with ❤️ using TypeScript, LangChain, and Starknet