Skip to content

raulalexe/lp-notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LP Notifier Bot

A Telegram bot for monitoring Uniswap V3 liquidity positions across multiple chains and notifying users when positions go out of range.

Features

  • πŸ”— Multi-Chain Support: Monitor LP positions on Ethereum, Polygon, Arbitrum, Sui, and Solana
  • πŸ“Š Real-time Monitoring: Check position status and range deviations
  • πŸ”” Smart Notifications: Get alerted when positions go out of range
  • πŸ‘› Wallet Management: Add and manage multiple wallet addresses
  • βš™οΈ Customizable Settings: Configure notification preferences and thresholds
  • πŸ“ˆ Position Analytics: View detailed position information and status

Supported Chains

  • Ethereum (ETH): Mainnet with Uniswap V3
  • Polygon (MATIC): Polygon network with Uniswap V3
  • Arbitrum (ARB): Arbitrum One with Uniswap V3
  • Sui (SUI): Mainnet with Cetus, Turbos, and Kriya protocols
  • Solana (SOL): Mainnet with Orca, Raydium, and Meteora protocols

Installation

Prerequisites

  • Python 3.8 or higher
  • Telegram Bot Token (get from @BotFather)
  • RPC endpoints for supported chains

Setup

  1. Clone the repository

    git clone <repository-url>
    cd lp-notifier
  2. Install dependencies

    # Create virtual environment
    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
    # Install all dependencies including Solana/Sui packages
    pip install -r requirements.txt
  3. Configure environment variables

    cp .env.example .env
    # Edit .env with your configuration
  4. Set up your environment variables

    # Required
    BOT_TOKEN=your_telegram_bot_token_here
    
    # EVM Chain RPC URLs
    ETHEREUM_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
    POLYGON_RPC_URL=https://polygon-rpc.com
    ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
    
    # NEW: Non-EVM Chain RPC URLs
    SUI_RPC_URL=https://fullnode.mainnet.sui.io:443
    SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
    
    # Optional: Customize monitoring settings
    LP_CHECK_INTERVAL=300
    PRICE_DEVIATION_THRESHOLD=0.05
    RANGE_DEVIATION_THRESHOLD=0.10
  5. Run the bot

    python main.py

Usage

Bot Commands

Command Description
/start Start the bot and see welcome message
/help Show help and available commands
/addwallet Add a new wallet address to monitor
/removewallet <address> Remove a wallet from monitoring
/wallets List all your registered wallets
/check Check current status of all your LP positions
/status Get a quick overview of your positions
/settings Configure notification preferences and enabled chains

Quick Start

  1. Start the bot: Send /start to begin
  2. Add your wallet: Use /addwallet and follow the prompts
  3. Check positions: Use /check to see your LP status
  4. Configure settings: Use /settings to customize notifications

Adding Wallets for Different Chains

Ethereum/Polygon/Arbitrum Wallets

/addwallet
0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6

Then provide a label: Main DeFi Wallet

Sui Wallets

/addwallet
0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb123456789012345678901234567890123456789012345678901234567890

Then provide a label: Sui Trading Wallet

Solana Wallets

/addwallet
So11111111111111111111111111111111111111112

Then provide a label: Solana DeFi Wallet

Example Usage

/start
/addwallet
0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
Main DeFi Wallet
/check

Sample Bot Output

Position Check Results

πŸ“Š LP Position Report

Total Positions: 8
Out of Range: 2

⚠️ ALERT: Some positions are out of range!

πŸ”— Main DeFi Wallet
0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6

  πŸ“ Ethereum: 2 positions (1 out of range)
    ⚠️ ETH/USDC (ID: 12345)
       Deviation: 12.5%

  πŸ“ Polygon: 1 position

πŸ”— Sui Trading Wallet
0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb...

  πŸ“ Sui: 3 positions (1 out of range)
    ⚠️ SUI/USDC (Cetus - ID: cetus_123)
       Deviation: 8.7%

πŸ”— Solana DeFi Wallet
So11111111111111111111111111111111111111112

  πŸ“ Solana: 2 positions
    β€’ Orca: 1 position
    β€’ Meteora: 1 position

Out-of-Range Notifications

⚠️ LP Position Alert

Wallet: Sui Trading Wallet
0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb...

Out of Range Positions: 1

1. SUI/USDC (Cetus - Sui)
   Position ID: cetus_position_123
   Deviation: 15.2%
   Current Tick: 2000
   Range: 1800 - 2200

Use /check to see all your positions.

Configuration

Environment Variables

Variable Description Default
BOT_TOKEN Telegram bot token (required) -
ETHEREUM_RPC_URL Ethereum RPC endpoint Infura default
POLYGON_RPC_URL Polygon RPC endpoint Polygon RPC
ARBITRUM_RPC_URL Arbitrum RPC endpoint Arbitrum RPC
SUI_RPC_URL Sui RPC endpoint Sui mainnet
SOLANA_RPC_URL Solana RPC endpoint Solana mainnet
LP_CHECK_INTERVAL Position check interval (seconds) 300
PRICE_DEVIATION_THRESHOLD Price deviation alert threshold 0.05 (5%)
RANGE_DEVIATION_THRESHOLD Range deviation alert threshold 0.10 (10%)
ENABLE_NOTIFICATIONS Enable/disable notifications true
MAX_NOTIFICATIONS_PER_HOUR Rate limit for notifications 10

User Preferences

Users can configure:

  • Enabled chains for monitoring
  • Notification frequency
  • Price deviation thresholds
  • Range deviation thresholds

Architecture

Core Components

  • telegram_bot.py: Main bot implementation with command handlers
  • lp_monitor.py: LP position monitoring and range checking
  • database.py: SQLite database for user data and preferences
  • config.py: Configuration management and chain settings

Database Schema

  • users: User information and preferences
  • wallet_addresses: Registered wallet addresses per user
  • lp_positions: Cached LP position data
  • notifications: Notification history and rate limiting
  • user_preferences: User-specific settings

Development

Project Structure

lp-notifier/
β”œβ”€β”€ main.py              # Main entry point
β”œβ”€β”€ telegram_bot.py      # Telegram bot implementation
β”œβ”€β”€ lp_monitor.py        # LP monitoring logic
β”œβ”€β”€ database.py          # Database operations
β”œβ”€β”€ config.py            # Configuration management
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ .env.example         # Environment variables template
β”œβ”€β”€ README.md           # This file
└── lp_notifier.db      # SQLite database (created automatically)

Adding New Chains

To add support for a new chain:

  1. Add chain configuration to config.py
  2. Update SUPPORTED_CHAINS dictionary
  3. Implement chain-specific logic in lp_monitor.py
  4. Update documentation

Testing

# Run basic tests
python -m pytest tests/

# Run with coverage
python -m pytest --cov=. tests/

Security Considerations

  • Private Keys: Never store private keys in the bot
  • RPC Endpoints: Use secure, private RPC endpoints in production
  • Rate Limiting: Implement rate limiting for API calls
  • Data Privacy: User data is stored locally in SQLite

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Common Issues

"Invalid address format"

  • Ethereum/Polygon/Arbitrum: Use 40 hex characters after 0x (e.g., 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6)
  • Sui: Use 64 hex characters after 0x (e.g., 0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb123456789012345678901234567890123456789012345678901234567890)
  • Solana: Use Base58 encoded public key (e.g., So11111111111111111111111111111111111111112)

"No positions found"

  • Verify the wallet has LP positions on the specified chain
  • Check if the RPC endpoints are working
  • Ensure the wallet address is correct

"Connection failed"

  • Check your RPC URLs in the .env file
  • Verify internet connection
  • Try different RPC endpoints

Testing

# Test basic functionality
python test_bot.py

# Test new chain integrations
python test_sui_solana.py

# Test specific components
python -c "from sui_monitor import SuiMonitor; print('Sui monitor OK')"
python -c "from solana_monitor import SolanaMonitor; print('Solana monitor OK')"

Logs and Debugging

# View bot logs
tail -f lp_notifier.log

# Check database
sqlite3 lp_notifier.db ".tables"
sqlite3 lp_notifier.db "SELECT * FROM users LIMIT 5;"

Docker Deployment

Using Docker Compose

# Build and run
docker-compose up -d

# View logs
docker-compose logs -f lp-notifier-bot

# Stop
docker-compose down

Manual Docker Build

# Build image
docker build -t lp-notifier-bot .

# Run container
docker run -d \
  --name lp-notifier-bot \
  --env-file .env \
  -v $(pwd)/data:/app/data \
  lp-notifier-bot

Support

For support or questions:

  • Create an issue on GitHub
  • Contact the bot administrator
  • Check the /help command in the bot

Roadmap

  • Add support for Sui blockchain
  • Add support for Solana blockchain
  • Multi-protocol support (Cetus, Orca, Raydium, Meteora, etc.)
  • Add support for more chains (BSC, Optimism, etc.)
  • Implement detailed position analytics
  • Add historical performance tracking
  • Web dashboard for advanced users
  • Mobile app companion
  • Advanced notification filters
  • Integration with other DEX protocols

About

A notifier app for LPs going in and out of range

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published