Skip to content

nickyharpor/AutoSomnia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ™ AutoSomnia

Close your eyes and let AutoSomnia trade for you.

An AI-powered Web3 trading bot that manages your cryptocurrency portfolio while you sleep.

Python FastAPI Web3 Telegram


๐Ÿš€ Overview

AutoSomnia is a comprehensive Web3 trading automation platform that combines AI-powered market analysis with seamless account management. Built for the Somnia blockchain ecosystem, it provides users with intelligent trading suggestions and automated portfolio management through an intuitive Telegram bot interface.

Dashboard

๐Ÿค– Telegram Bot

https://t.me/autosomnia_bot

๐Ÿ’ป Pitch Deck

https://gamma.app/docs/AutoSomnia-x3lbsffz3yuwgkn

๐ŸŽฏ Key Features

  • ๐Ÿค– AI-Powered Trading Suggestions: Leverages Google Gemini AI for intelligent market analysis
  • ๐Ÿ’ผ Web3 Account Management: Create, import, and manage EVM-compatible wallets
  • ๐Ÿ’ธ Automated Transactions: Send SOMI and ERC-20 tokens with MAX amount support
  • ๐Ÿ“Š Real-time Market Data: Integration with CoinGecko API for live price feeds
  • ๐Ÿ” Secure Storage: MongoDB-based account management with encrypted private keys
  • ๐Ÿ“ฑ Telegram Interface: User-friendly bot commands for all operations
  • ๐ŸŒ Web Interface: Web panel for more advanced portfolio management
  • ๐ŸŒ Translation Ready: Multi-language support with translation files ready

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Telegram Bot  โ”‚โ”€โ”€โ”€โ”€โ”‚   FastAPI App   โ”‚โ”€โ”€โ”€โ”€โ”‚   Blockchain     โ”‚
โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                  โ”‚
โ”‚ โ€ข User Commands โ”‚    โ”‚ โ€ข REST API      โ”‚    โ”‚ โ€ข Somnia         โ”‚
โ”‚ โ€ข AI Responses  โ”‚    โ”‚ โ€ข Account Mgmt  โ”‚    โ”‚ โ€ข EVM Chains     โ”‚
โ”‚ โ€ข Notifications โ”‚    โ”‚ โ€ข Transactions  โ”‚    โ”‚ โ€ข Smart Contractsโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚ โ€ข Gateway       โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ โ€ข AI Settings   โ”‚              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚ โ€ข Data Export   โ”‚              โ”‚
โ”‚    Web UI       โ”‚โ”€โ”€โ”€โ”€โ”‚ โ€ข Tasks         โ”‚              โ”‚
โ”‚                 โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚ โ€ข Dashboard     โ”‚             โ”‚                       โ”‚
โ”‚ โ€ข Portfolio     โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚ โ€ข Trading       โ”‚    โ”‚    Database     โ”‚              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚                 โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ โ€ข MongoDB       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚ โ€ข User Accounts โ”‚
โ”‚    Plugins      โ”‚โ”€โ”€โ”€โ”€โ”‚ โ€ข Transaction   โ”‚
โ”‚                 โ”‚    โ”‚   History       โ”‚
โ”‚ โ€ข Magento       โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ€ข WooCommerce   โ”‚
โ”‚ โ€ข E-commerce    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Backend:

  • FastAPI - High-performance async web framework
  • Web3.py - Ethereum blockchain interaction
  • MongoDB - Document database for account storage
  • Pydantic - Data validation and serialization

AI & External APIs:

  • Amazon Bedrock AI - Advanced language models for trading analysis
  • CoinGecko API - Real-time cryptocurrency market data
  • Telegram Bot API - User interface and notifications

Blockchain:

  • Somnia Network - Primary blockchain integration
  • EVM Compatibility - Support for Ethereum-based chains
  • Web3 Standards - ERC-20 tokens, standard transactions

๐ŸŽฎ Bot Commands

๐Ÿ’ผ Account Management

/new_account          - Create a new Web3 wallet
/account_info         - View your account details and balances
/withdraw_funds <to>  - Send all SOMI to specified address
/withdraw_funds <to> <token> - Send all tokens to address

๐Ÿ“ˆ Trading Features

/suggest_exchange     - Get AI-powered trading recommendations
/buy_usd <amount>     - Manually buy USDT
/sell_usd <amount>    - Manually sell USDT
/auto_exchange_on     - Enable automated trading
/auto_exchange_off    - Disable automated trading

โ„น๏ธ General

/start               - Welcome message and bot introduction
/help                - Show available commands

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.9+
  • MongoDB instance
  • Telegram Bot Token
  • AWS Access Key and Secret for Amazon Bedrock
  • CoinGecko API Key

1. Clone the Repository

git clone https://github.com/nickyharpor/AutoSomnia.git
cd AutoSomnia

2. Install Dependencies

pip install -r requirements.txt

3. Environment Configuration

Copy .env.example to .env in the root directory and fill in the values.

4. Start the Services

Start the FastAPI Backend:

python app/main.py

Start the Telegram Bot:

cd bot
python bot.py

5. Interact with the Bot

  1. Find your bot on Telegram
  2. Send /start to begin
  3. Use /new_account to create your first wallet
  4. Try /suggest_exchange for AI trading advice

๐Ÿ”ง API Documentation

The FastAPI backend provides comprehensive REST endpoints:

๐Ÿ”— Interactive API Docs

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

๐Ÿ“‹ Key Endpoints

Account Management:

  • POST /account/create - Create new Web3 account
  • GET /account/balance/{address} - Get ETH balance
  • GET /account/portfolio/{address} - Get complete portfolio
  • POST /account/send-eth - Send ETH transactions
  • POST /account/send-token - Send ERC-20 tokens
  • DELETE /account/remove/{address} - Remove single account
  • DELETE /account/remove-user/{user_id} - Remove user and all their accounts

Exchange Operations:

  • GET /exchange/weth-address - Get WETH token address
  • GET /exchange/factory-address - Get factory contract address
  • POST /exchange/quote - Get quote for token pairs
  • POST /exchange/amounts-out - Calculate swap outputs
  • POST /exchange/swap-exact-tokens-for-tokens - Execute token swaps

Exchange Operations:

  • GET /exchange/amounts-out - Calculate swap outputs
  • GET /exhange/quote - Get quote for token pairs
  • POST /exchange/swap-exact-tokens-for-tokens - Execute token swaps
  • POST /exchange/swap-exact-eth-for-tokens - Execute SOMA to token swaps
  • POST /exchange/swap-exact-tokens-for-eth - Execute token to SOMA swaps

Health & Monitoring:

  • GET /health - Application health check
  • GET /account/health - Account service status monitoring
  • GET /exchange/health - Exchange service status monitoring

๐Ÿง  AI Trading Intelligence

AutoSomnia's AI system analyzes multiple market factors:

๐Ÿ“Š Data Sources

  • Real-time Prices - Live cryptocurrency prices from CoinGecko
  • Market Trends - 24-hour price changes and volume data
  • Technical Indicators - Price momentum and volatility analysis

๐ŸŽฏ AI Analysis

  • Market Sentiment - Evaluates current market conditions
  • Risk Assessment - Considers volatility and market risks
  • Timing Recommendations - Suggests optimal entry/exit points
  • Portfolio Balance - Advises on asset allocation strategies

๐Ÿ’ก Trading Suggestions

The AI provides actionable recommendations:

  • Buy Signals - When to acquire specific assets
  • Sell Signals - When to take profits or cut losses
  • Hold Advice - When to maintain current positions
  • Risk Warnings - Alerts about high-risk market conditions

๐Ÿ”’ Security Features

๐Ÿ›ก๏ธ Account Security

  • Encrypted Storage - Private keys stored securely in MongoDB
  • Mnemonic Generation - BIP-39 compliant seed phrases
  • Address Validation - Comprehensive input validation
  • Transaction Verification - Multi-layer transaction checks

๐Ÿ” API Security

  • Request Validation - Pydantic models for all inputs
  • Error Handling - Secure error responses without data leakage
  • Rate Limiting - Protection against API abuse
  • CORS Configuration - Controlled cross-origin access

๐Ÿšจ Best Practices

  • Never store private keys in logs
  • Validate all blockchain addresses
  • Implement proper error handling
  • Use secure random number generation

๐Ÿ† Highlights

๐ŸŽฏ Innovation Points

  • AI-Driven Trading - First Web3 bot with integrated AI market analysis
  • Seamless UX - Complex blockchain operations simplified to chat commands
  • Multi-Chain Ready - Built for Somnia with broader EVM compatibility
  • Production Ready - Comprehensive error handling and security measures

๐Ÿ› ๏ธ Technical Excellence

  • Modern Architecture - Async FastAPI with proper separation of concerns
  • Robust Database - MongoDB with optimized queries and indexing
  • Comprehensive API - Full REST API with interactive documentation
  • Quality Code - Type hints, validation, and extensive error handling

๐ŸŒ Real-World Impact

  • Accessibility - Makes DeFi accessible to non-technical users
  • Automation - Reduces manual trading effort and human error
  • Education - Teaches users about market dynamics through AI insights
  • Community - Telegram-based interface encourages user engagement

๐Ÿ”ฎ Future Roadmap

Phase 1: Core Enhancement

  • Advanced portfolio analytics
  • Copy trading
  • Custom trading strategies
  • Enhanced security features

Phase 2: Ecosystem Expansion

  • Multi-chain support (Polygon, BSC, Arbitrum)
  • DeFi protocol integrations
  • Social trading features

Phase 3: Enterprise Features

  • Team account management
  • Advanced analytics dashboard
  • API for third-party integrations
  • White-label solutions

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

๐Ÿ› Bug Reports

  • Use GitHub Issues to report bugs
  • Include detailed reproduction steps
  • Provide environment information

๐Ÿ’ก Feature Requests

  • Suggest new features via GitHub Issues
  • Explain the use case and benefits
  • Consider implementation complexity

๐Ÿ”ง Development

# Fork the repository
git clone https://github.com/nickyharpor/AutoSomnia.git

# Create a feature branch
git checkout -b feature/amazing-feature

# Make sure all tests pass
pytest -s -v

# Make your changes and commit
git commit -m "Add amazing feature"

# Push to your fork and create a Pull Request
git push origin feature/amazing-feature

๐Ÿ“ž Support

About

AI-powered Web 3 portfolio manager and trading bot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published