Skip to main content
The LFG.RICH Community Trading Bot is a Python trading bot example for BNB Smart Chain that trades official LFG.RICH launchpad tokens through the official LFG.RICH protocol contracts.

Self-hosted

Run the bot on your own machine or VPS with your own wallet and configuration.

V5-aware

The bot resolves Hook/Router context and uses the official V5 interaction flow.

Dashboard

Review positions, lots, trades, realized/unrealized PnL, and strategy state locally.

Dry run first

Start in dry_run and use smoke tests before allowing live transactions.
This version is compatible with LFG.RICH only:
  • buys through the LFG.RICH Swap Router;
  • sells through the LFG.RICH Swap Router;
  • builds candles from LFG.RICH Uniswap V4 Hook Buy and Sell events;
  • 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.
This is community trading software. Use a dedicated wallet, start with small amounts, and test everything before running with real funds.

How the bot works

The bot monitors one or more LFG.RICH tokens from config.yaml. For each configured token, it:
1

Resolve the token pool through the Hook

The bot uses V5 pool context instead of guessing an old pair or pool.
2

Scan Hook Buy and Sell events

Event data is used to build local market history.
3

Build internal price candles

Candles power the strategy indicators and dashboard.
4

Calculate strategy indicators

EMA, RSI, trend, pump, dump, and bleed conditions are evaluated locally.
5

Decide BUY, SELL, or HOLD

The strategy makes a decision from configured rules and current state.
6

Execute through the Swap Router unless dry_run is enabled

Live trades use the official LFG.RICH Swap Router.
7

Record trades and lots in SQLite

Confirmed fills are persisted for accounting, dashboard, and later sells.
The bot must resolve and use the token’s LFG.RICH pool data. It should not assume a legacy pair address or a PancakeSwap-style pool.

Requirements

Tested environment

The bot has been tested with:
Recommended Python versions for new users:
Python 3.8 is still supported by the pinned dependency versions included in the bot package. Do not run the bot with Python 2. If you see an error path like this:
you are using the wrong Python version.

Required system components

The bot needs:
  • Python 3;
  • Python virtual environment support;
  • pip;
  • SQLite;
  • a BNB Smart Chain RPC endpoint with eth_getLogs support;
  • a wallet private key for live trading.

Python dependencies

Runtime dependencies are pinned in:
Dashboard dependencies are pinned separately in:
Important compatibility notes:
  • aiohappyeyeballs==2.6.1 is intentionally not used because it does not work with Python 3.8.
  • streamlit==1.40.1 is used because 1.40.2 was not installable in the tested Python 3.8 environment.
  • The dashboard uses use_container_width=True, not newer Streamlit width="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:
If your server uses another Python 3 version, install the generic venv package instead:

2. Download or clone the project

Example:
If you are using a ZIP instead, upload/unzip it and then enter the project directory.

3. Create a clean virtual environment

Your terminal should now show (.venv).

4. Upgrade packaging tools

5. Install bot dependencies

6. Create local configuration files

7. Confirm the environment

Expected 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

If PowerShell blocks activation, run:
Then activate again:

4. Install dependencies

5. Create local config files

Environment configuration

Create a .env file in the project root. Example:

.env settings

Never commit .env to GitHub and never share your private key.

Bot configuration

The bot is configured through:
Start by copying the example:
The default example token is LFGBULL:
If you created your own token on LFG.RICH, replace the symbol and token address in watchlist.tokens[].

LFG.RICH protocol contracts

The default configuration uses the official LFG.RICH BSC contracts:
Do not change these unless LFG.RICH officially deploys new protocol contracts.

Smoke test

Run the smoke test before running the full bot:
On Windows PowerShell:
A successful smoke test should print values similar to:
The quote values come from the LFG.RICH Hook. Token amounts and BNB amounts use 18 decimals.

Running the bot

1. Start with dry-run mode

Before live trading, keep this enabled:
Run the bot:
In dry-run mode, the bot scans events, builds candles, calculates signals, and logs intended trades, but it does not send transactions.

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:
Run:
After the test buy succeeds, check the dashboard and verify that the lot was created.

3. Disable test mode for normal strategy trading

Then run:

4. Keep the bot running with PM2

Optional Linux example:
Check logs:

Running the dashboard

The dashboard is optional, but useful for checking open lots, PnL, trades, balances, and bot state.

1. Install dashboard dependencies

On Windows:

2. Run the dashboard

Run this from the project root, not from inside the bot/ folder:
On Windows local usage:
Open in the browser:
For local usage:

3. SSH tunnel option

If you do not want to expose port 8501 publicly:
Then open:

4. Keep the dashboard running with PM2

Optional Linux example:

SQLite database and lots

The bot uses a local SQLite database:
It is created automatically in the project root when the bot runs.

Dashboard dependency on the bot

The dashboard reads state.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:
The dashboard uses open lots to calculate:
  • current position value;
  • unrealized PnL;
  • realized PnL after sells;
  • average entry price;
  • open exposure per token.
For LFG tokens, the dashboard prices open lots using this priority:
1

Use the latest valid candle close

This is the preferred current price source when candle data is available.
2

Fallback to LFG Hook getEffectivePrice(poolId)

If candle data is unavailable, the dashboard reads the protocol effective price.
3

Use zero only when both sources are unavailable

A zero price means the dashboard could not find a safe current price source.

Useful SQLite commands

Do not delete state.db unless you intentionally want to reset local trade history, lots, cooldowns, and candle cache.

Configuration reference

This section documents the settings in config.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:
Then recreate the venv:

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:
1

Use the latest valid candle close

This is the preferred current price source when candle data is available.
2

Fallback to LFG Hook getEffectivePrice(poolId)

If candle data is unavailable, the dashboard reads the protocol effective price.
3

Use zero only when both sources are unavailable

A zero price means the dashboard could not find a safe current price source.
If the value is still empty, confirm the bot and dashboard are using the same state.db and config.yaml.

Safe operating checklist

Before running live:
1

Use a dedicated wallet

Do not run an automated bot from your main wallet.
2

Keep only a small amount of BNB in that wallet

Limit exposure while testing and operating the bot.
3

Start with dry_run enabled

Use dry_run: true before allowing live transactions.
4

Run the smoke test

Execute python -m bot.smoke_test_lfg before running the bot.
5

Confirm candles and signals look correct

Let the bot run and verify that market data and decisions make sense.
6

Test one tiny BUY in test mode

Use test_mode: true, test_action: "BUY", and a tiny test_amount_bnb.
7

Confirm the dashboard shows the lot

Make sure the local database and dashboard match the expected result.
8

Only then disable test_mode

Move to live operation only after the small test is confirmed.

Community note

This bot was built as a contribution to the LFG.RICH community and to support developers, builders, and traders exploring the LFG.RICH launchpad and protocol. You are free to use, modify, improve, and share this project. Before running live trades, review the configuration, test with small amounts, and adjust the strategy to your own needs. The goal of this project is to help increase adoption, experimentation, and community-driven development around LFG.RICH.