Self-hosted
V5-aware
Dashboard
Dry run first
dry_run and use smoke tests before allowing live transactions.- buys through the LFG.RICH Swap Router;
- sells through the LFG.RICH Swap Router;
- builds candles from LFG.RICH Uniswap V4 Hook
BuyandSellevents; - uses the LFG.RICH Uniswap V4 Hook for price and quote estimates;
- does not use PancakeSwap V2;
- does not use PancakeSwap V3;
- does not borrow, borrow more, or repay.
How the bot works
The bot monitors one or more LFG.RICH tokens fromconfig.yaml.
For each configured token, it:
Resolve the token pool through the Hook
Scan Hook Buy and Sell events
Build internal price candles
Calculate strategy indicators
Decide BUY, SELL, or HOLD
Execute through the Swap Router unless dry_run is enabled
Record trades and lots in SQLite
Requirements
Tested environment
The bot has been tested with:Required system components
The bot needs:- Python 3;
- Python virtual environment support;
pip;- SQLite;
- a BNB Smart Chain RPC endpoint with
eth_getLogssupport; - a wallet private key for live trading.
Python dependencies
Runtime dependencies are pinned in:aiohappyeyeballs==2.6.1is intentionally not used because it does not work with Python 3.8.streamlit==1.40.1is used because1.40.2was not installable in the tested Python 3.8 environment.- The dashboard uses
use_container_width=True, not newer Streamlitwidth="stretch"syntax. - The code includes Python 3.8 compatibility fixes where needed.
Installation on Linux / VPS
Use these steps on Ubuntu/Debian-style servers.1. Install system packages
For Python 3.8:2. Download or clone the project
Example:3. Create a clean virtual environment
(.venv).
4. Upgrade packaging tools
5. Install bot dependencies
6. Create local configuration files
7. Confirm the environment
which python should point inside this project:
Installation on Windows
Windows is supported for local testing, development, and community usage. Linux/VPS is recommended for long-running 24/7 operation. Use PowerShell.1. Install Python
Install Python 3.10 or 3.11 from the official Python website. During installation, enable:2. Open PowerShell and enter the project folder
Example:3. Create and activate a virtual environment
4. Install dependencies
5. Create local config files
Environment configuration
Create a.env file in the project root.
Example:
.env settings
.env to GitHub and never share your private key.
Bot configuration
The bot is configured through:watchlist.tokens[].
LFG.RICH protocol contracts
The default configuration uses the official LFG.RICH BSC contracts:Smoke test
Run the smoke test before running the full bot:Running the bot
1. Start with dry-run mode
Before live trading, keep this enabled:2. Test a small live buy
After dry-run logs look correct, use a dedicated wallet with a small amount of BNB. Enable test mode:3. Disable test mode for normal strategy trading
4. Keep the bot running with PM2
Optional Linux example:Running the dashboard
The dashboard is optional, but useful for checking open lots, PnL, trades, balances, and bot state.1. Install dashboard dependencies
2. Run the dashboard
Run this from the project root, not from inside thebot/ folder:
3. SSH tunnel option
If you do not want to expose port8501 publicly:
4. Keep the dashboard running with PM2
Optional Linux example:SQLite database and lots
The bot uses a local SQLite database:Dashboard dependency on the bot
The dashboard readsstate.db.
The dashboard does not trade by itself and does not create positions by itself. It depends on the bot to create and update trades, positions, and lots.
If the bot has not confirmed any buy transactions yet, the dashboard may have no open lots to display.
What are lots?
A lot is the bot’s local record of a buy position. When the bot confirms a successful buy transaction, it records a lot with:- current position value;
- unrealized PnL;
- realized PnL after sells;
- average entry price;
- open exposure per token.
Use the latest valid candle close
Fallback to LFG Hook getEffectivePrice(poolId)
Use zero only when both sources are unavailable
Useful SQLite commands
state.db unless you intentionally want to reset local trade history, lots, cooldowns, and candle cache.
Configuration reference
This section documents the settings inconfig.yaml.
chain
rpc
lfg
bot execution settings
bot risk and trade sizing
bot event scanner and candles
bot strategy settings
bot test mode
watchlist.tokens[]
Each token entry defines one LFG.RICH token to monitor and trade.
Troubleshooting
SyntaxError showing /usr/lib/python2.7/...
You are running Python 2.
Activate the venv and use Python 3:
ModuleNotFoundError: No module named 'web3'
Dependencies are not installed in the active environment:
ensurepip is not available
Install the venv package:
pip: command not found
Install pip:
No matching distribution found for aiohappyeyeballs==2.6.1
You are using an old/frozen dependency list from a newer Python environment.
Use the requirements.txt included in this LFG.RICH bot package.
No matching distribution found for streamlit==1.40.2
Use the included requirements-dashboard.txt, which pins:
invalid argument 0: hex string without 0x prefix
Use the latest LFG.RICH bot package. The LFG pool id and event topic handling were updated to normalize values with the required 0x prefix.
Dashboard shows lot_pnl_pct as empty or None
The dashboard needs a valid current price.
For LFG tokens, the dashboard now uses:
Use the latest valid candle close
Fallback to LFG Hook getEffectivePrice(poolId)
Use zero only when both sources are unavailable
state.db and config.yaml.
Safe operating checklist
Before running live:Use a dedicated wallet
Keep only a small amount of BNB in that wallet
Start with dry_run enabled
dry_run: true before allowing live transactions.Run the smoke test
python -m bot.smoke_test_lfg before running the bot.Confirm candles and signals look correct
Test one tiny BUY in test mode
test_mode: true, test_action: "BUY", and a tiny test_amount_bnb.Confirm the dashboard shows the lot
Only then disable test_mode

