When this program was developed, ** did not leave any backdoors** and tip programs, just so that users can try better. If you have a better money-making plan, you can contact me to eat meat together ✈️ @lever
An automated follow-trading bot for PancakeSwap Prediction V2 (contract 0x18B2A687610328590Bc8F2e5fEdDe3b582A49cdA). It listens to on-chain events, derives EMA-based signals from external markets, applies martingale progression with loss-follow rules, and can automatically claim winnings while persisting full history. The codebase is TypeScript-first and supports both dry-run and full simulation modes.
- Live on-chain monitoring – Subscribes to
StartRound,LockRound, andCloseRoundvia WebSocket/HTTP providers and schedules trades with a configurable lead time before round lock. - EMA strategy with optional reversal filter – Pulls EMA12/EMA144/EMA169 from Binance or OKX candles. The 12 EMA must be clearly above/below the long EMAs to open a position. An optional “break & pullback” reversal check (
EMA_REVERSAL_ENABLED) flips the signal when price sharply reverts after a breakout. - Martingale & forced follow-up – Adjustable multiplier and maximum steps. After three consecutive losses on the same side, the next round will be forced to follow that side once.
- Persistent history – Every bet (epoch, side, amount, EMA snapshot, forced flag, result, claim status, tx hashes) is stored in
bet-history.json. On restart the bot rebuilds martingale level, unresolved rounds, and pending claims. - Automatic claiming – Scans historic epochs after each new round, cross-checks
ledger,claimable, andrefundable, batches eligible epochs, and marks them as claimed (with tx hash) when the transaction succeeds. - Rate-limit aware retries – All RPC calls used for claiming are wrapped in exponential backoff to tolerate QuickNode’s 15 req/s limit.
- Simulation / dry-run –
SIMULATION_MODE=trueruns the full pipeline without private key or network IO.DRY_RUN=trueconstructs real transactions but skips broadcasting. - Manual claim script –
npm run claimreuses the same detection logic to list or claim epochs on demand.
- Node.js 18+
- npm 9+
- BSC endpoints (both WebSocket and HTTP). A free QuickNode plan works if you respect rate limits.
-
Install dependencies
npm install
-
Create configuration
cp .env.example .env
Fill at least:
BSC_WSS/BSC_HTTPPRIVATE_KEY(only when sending real bets/claims)TG_BOT_TOKEN+TG_USER_IDif you need Telegram alerts
-
Run the bot
npm run start
SIMULATION_MODE=true: full simulation (default) – no private key requiredDRY_RUN=true: build transactions but do not broadcast
-
Manual claim (optional)
npm run claim -- --dry-run # show pending epochs npm run claim # send claim transactions npm run claim -- 419820 419821 # claim selected epochs only
Key log prefixes:
[EMA]– current EMA readings[策略](strategy) – decision results (bull/bear/neutral, forced follow, reversal triggers)[下单]/[模拟]/[交易]– order scheduling, simulation notice, and transaction lifecycle[领取]– claim workflow, including rate-limit retries[历史]– history persistence and reconciliation notices
Telegram messages mirror these details, including last ten results, win-rate, forced flags, and simulation markers.
| Category | Variable | Description |
|---|---|---|
| RPC | BSC_WSS / BSC_HTTP |
Required BSC endpoints |
PRIVATE_KEY |
Wallet private key (omit for simulation) | |
| Betting | BET_AMOUNT |
Initial stake (BNB) |
DECISION_OFFSET |
Seconds before lock to submit the bet | |
| Gas | GAS_LIMIT |
Safety cap (default 300000) |
GAS_PRICE |
Fixed gas price in Gwei (lower values reduce cost but increase pending risk) | |
GAS_PRICE_FACTOR |
Alternative dynamic pricing based on bet size | |
| Strategy | MARTINGALE_FACTOR |
Progression multiplier |
MARTINGALE_MAX_STEPS |
Maximum martingale levels | |
FORCE_LOSS_STREAK |
Consecutive losses before forced follow (default 3) | |
EMA_REVERSAL_THRESHOLD |
Pullback distance used by reversal filter | |
EMA_REVERSAL_ENABLED |
Enable/disable reversal logic | |
| Market | MARKET_PROVIDER |
binance (default) or okx |
BINANCE_*, OKX_* |
Candle symbol/interval/limit per provider | |
| Claiming | AUTO_CLAIM |
Enable auto-claim outside simulation |
CLAIM_DELAY_SECONDS |
Delay after new round before scanning | |
CLAIM_LOOKBACK |
Extra epochs to scan as fallback | |
RATE_LIMIT_DELAY_MS |
Initial retry delay when throttled | |
RATE_LIMIT_MAX_RETRIES |
Retry attempts for throttled calls | |
| Storage | BET_HISTORY_FILE |
Path to history JSON |
| Runtime | SIMULATION_MODE, DRY_RUN, NO_WAIT |
Execution modes |
| Alerts | TG_BOT_TOKEN / TG_USER_ID |
Telegram notifications |
bet-history.json entry example:
{
"epoch": "419820",
"side": "betBear",
"amount": "1000000000000000",
"level": 0,
"result": "win",
"forcedFollow": false,
"claimed": true,
"claimTxHash": "0x…"
}The bot reloads this file on startup, rebuilds open positions, martingale level, and pending claims, and updates the claimed flag whenever an on-chain claim succeeds.
- Prediction bets/claims consume roughly 110k–130k gas. At 25 Gwei this is about 0.003 BNB. Dropping to 5 Gwei cuts cost to ~0.0006 BNB but increases the chance of pending transactions.
- Reducing
GAS_LIMITdoes not lower fees; it only risks “out of gas”. Keep it generous (~300k) and tuneGAS_PRICEinstead.
With MARTINGALE_FACTOR=3 and starting stake 0.005 BNB, the first six levels require:
| Level | Stake (BNB) |
|---|---|
| 1 | 0.005 |
| 2 | 0.015 |
| 3 | 0.045 |
| 4 | 0.135 |
| 5 | 0.405 |
| 6 | 1.215 |
| Total | ≈ 1.82 BNB |
Plan bankroll accordingly and consider gas fees on top of the stake.
-32007rate-limit errors – IncreaseRATE_LIMIT_DELAY_MS, reduceCLAIM_LOOKBACK, or upgrade the RPC plan. Retries are already built in and logged with the[限流]prefix.- EMA keeps logging “in the middle” – The conservative mode avoids trading when EMA12 sits between EMA144 and EMA169. Adjust thresholds or modify the strategy block in
scheduleBetto follow prior direction instead. - Gas feels expensive – Lower
GAS_PRICE(with caution), combine claim batches, or raise base stake to improve fee-to-profit ratio. - Want to re-test claim logic – Run
npm run claim -- --dry-runwith a history entry that hasclaimed=falsefor a known winning epoch.
- Type check:
npx tsc --noEmit - Example unit test:
npx ts-node tests/collect-claimable.test.ts - Manual claim dry-run:
npm run claim -- --dry-run
Core files:
src/index.ts– event loop, strategy, martingale, claim handlingsrc/binance.ts– market data fetch & EMA calculations (covers both Binance & OKX)
- Keep
.envout of version control and secure private keys in production. - Automated betting carries financial risk; this project is provided as-is without investment advice.
- Ensure compliance with local regulations, node provider ToS, and exchange API policies.
Good luck and happy trading! 🚀