Educational Base sniper bot demonstrating RugGuard pre-trade safety integration. Not production-grade.
Project description
rugguard-sniper-bot-example
⚠ Educational, not production-grade. Read Safety before going live on mainnet.
An example Base sniper bot that demonstrates the canonical pre-trade safety integration with RugGuard. For each candidate token, the bot calls /v1/pretrade/check, then routes to a mock buy (sized by RugGuard's max_suggested_exposure_usd) or a skip log line based on policy_recommendation.
The bot does not actually execute on-chain. It logs what it would buy. Swap execute_buy_mock for your own DEX router call to make it real.
Why
Sniper bots that buy fresh token launches are textbook rug-pull bait. A pre-trade safety gate cuts a measurable chunk of losses before they happen. This kit shows the smallest-viable integration: ~120 LOC of bot logic on top of RugGuard's /v1/pretrade/check endpoint.
Install + offline demo
pip install rugguard-sniper-bot-example
rugguard-sniper --demo
The demo runs the bot through 3 representative candidates (safe USDC, fresh memecoin, drained pool) without paying or touching the network.
Expected output:
Sniper bot: 3 candidates on base, policy=balanced, intended_size=$100.0, session cap=$1.0
[BUY ] base:0x83358... score= 12 verdict=safe size=$ 100.00/$100 reasons=[-] sig=a0c71156
[BUY*] base:0x4ed4E... score= 62 verdict=medium_risk size=$ 20.00/$100 reasons=[OWNER_NOT_RENOUNCED, TOP10_CONCENTRATION_HIGH] sig=a0c71156
[SKIP ] base:0xfc048... score= 95 verdict=critical size=$ 0.00/$100 reasons=[TOP10_CONCENTRATION_HIGH, LP_INSUFFICIENT_LIQUIDITY] sig=a0c71156
Session summary:
candidates evaluated: 3
executed (mock): 2
skipped: 1
RugGuard spend: $0.03 USDC
Would-be buy total: $300.00
Actual exposure: $120.00
Capital protected: $180.00
The [BUY*] asterisk means "RugGuard clamped this from $100 to $20 due to medium risk". The Capital protected line shows the difference between naive-buy size and RugGuard-clamped size.
Run with real candidates (live x402 payment)
# 1. Get a funded x402 wallet (Base mainnet, ≥ $0.05 USDC)
export RUGGUARD_X402_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HEX
# 2. Inline list
rugguard-sniper --addresses 0xABC...,0xDEF... --chain base --size 100 --policy balanced
# 3. Or from a file (one address per line, '#' comments OK)
rugguard-sniper --addresses-file tokens.txt --chain base --size 100
Each candidate costs $0.01 USDC. The bot enforces a hard --session-cap (default $1) and aborts before exceeding it.
CLI flags
| Flag | Default | Description |
|---|---|---|
--demo |
False |
Offline 3-scenario walk-through. No payment. |
--addresses |
— | Comma-separated token addresses to evaluate. |
--addresses-file |
— | File path, one address per line, # comments OK. |
--chain |
base |
base or solana. |
--size |
100.0 |
Intended trade size in USD per candidate. |
--policy |
balanced |
conservative / balanced / aggressive. |
--session-cap |
1.0 |
Hard USD cap on total RugGuard spend per run. |
Policy modes (recap)
| Policy | Blocks at | Cautions at | Allows below |
|---|---|---|---|
conservative |
score ≥ 51 (medium_risk) | 26-50 | ≤ 25 |
balanced (default) |
score ≥ 71 (high_risk) | 51-70 | ≤ 50 |
aggressive |
score ≥ 91 (critical) | 71-90 | ≤ 70 |
uncertain verdict → caution in all modes.
Library API
bot.py exports a few primitives you can call directly without using the CLI:
from rugguard_sniper_bot import (
evaluate_candidate, run_sniper, SniperDecision, SniperStats, DecisionCache,
)
decision = await evaluate_candidate(
chain="base",
contract="0xABC...",
intended_trade_usd=100.0,
policy="balanced",
private_key_hex=YOUR_KEY,
api_url="https://rugguard.redfleet.fr",
cache=DecisionCache(),
)
# decision.recommendation in {"allow", "caution", "block", "error"}
# decision.executed_size_usd ← clamped by RugGuard
Safety
This is the most important section. Read before going live on mainnet.
What this kit does NOT do (and what you must add)
- No actual on-chain execution.
execute_buy_mockis a log line. Swap it for your Uniswap V2 / Aerodrome router integration before going live. - No mempool subscription. A real sniper listens for
PoolCreated/PairCreatedevents. Add a websockets-based listener (Alchemy / QuickNode / Helius). - No position management. No stop-loss, take-profit, time-based exit. Build a separate
position_managermodule. - No retry / circuit breaker. Network errors route to
recommendation="error"and skip. Production should retry transient failures with backoff, alert on sustained failures. - No alerts / structured logging.
printis the only output. Wirestructlog+ a Telegram/Discord webhook before production.
Recommended hardening
- Use
rugguard-mcpfor production x402. The bundledx402_pay.pyhere is pedagogical — it has an asset whitelist but no spend caps. The fullrugguard-mcpships session caps, 24h caps, file-locked TOCTOU-safe charge reservation, and replay-window protection. - Dedicated wallet. Generate a fresh EOA, fund only with the USDC you can afford to lose. Treat the wallet balance itself as a hard cap.
- Verify signed reports. Production: install
rugguard-verifyand validate everySniperDecision'ssignature_fingerprintagainst/v1/pubkeybefore trusting it. The fingerprint is already surfaced inSniperDecision.signature_fingerprint. - Independent sanity check. Don't trust RugGuard alone. Cross-check with at least one other signal (your own liquidity threshold, a different rug-scanner) for the trades that actually move money.
Wallet hygiene
# DO NOT commit the private key
echo "RUGGUARD_X402_PRIVATE_KEY=0x..." >> .env
echo ".env" >> .gitignore
The bot reads the key from the env var only. Never accept it as a CLI flag (would leak into shell history + ps output).
Companion packages
rugguard-mcp— MCP server for Claude Desktop / Cursor / LangGraphrugguard-pydantic-ai-agent— Pydantic AI typed toolrugguard-langgraph-agent— LangGraph noderugguard-verify— Ed25519 signed-report verifier CLI
License
MIT. See LICENSE. Use at your own risk — this is example code, not investment advice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rugguard_sniper_bot_example-0.1.3.tar.gz.
File metadata
- Download URL: rugguard_sniper_bot_example-0.1.3.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a063de4deba48f49530153565f69b4ad245244fff269658c80dccb7716aba3b
|
|
| MD5 |
e95e18430b31aa86513a79c6a383bd4f
|
|
| BLAKE2b-256 |
2ad181dacba9d863ff6242f0ab74cf6cdc3c4529e5e70fa964aa5a18b0acd717
|
Provenance
The following attestation bundles were made for rugguard_sniper_bot_example-0.1.3.tar.gz:
Publisher:
publish.yml on dbe006/rugguard-sniper-bot-example
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rugguard_sniper_bot_example-0.1.3.tar.gz -
Subject digest:
2a063de4deba48f49530153565f69b4ad245244fff269658c80dccb7716aba3b - Sigstore transparency entry: 1563261964
- Sigstore integration time:
-
Permalink:
dbe006/rugguard-sniper-bot-example@7fc4dcdaa9b4eba33c213407bb6660c10a37289b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dbe006
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fc4dcdaa9b4eba33c213407bb6660c10a37289b -
Trigger Event:
release
-
Statement type:
File details
Details for the file rugguard_sniper_bot_example-0.1.3-py3-none-any.whl.
File metadata
- Download URL: rugguard_sniper_bot_example-0.1.3-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abc446038d3b92f7ab55bb856c65b97ae82b34cefdc28efcd915f33f14e5a968
|
|
| MD5 |
b38b40cfe048bb841e855bb690d15cd5
|
|
| BLAKE2b-256 |
90a8116bb6949fdfc7bb28c801fba0cec9f06d1128fc387b0f6f1efcf8ab701a
|
Provenance
The following attestation bundles were made for rugguard_sniper_bot_example-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on dbe006/rugguard-sniper-bot-example
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rugguard_sniper_bot_example-0.1.3-py3-none-any.whl -
Subject digest:
abc446038d3b92f7ab55bb856c65b97ae82b34cefdc28efcd915f33f14e5a968 - Sigstore transparency entry: 1563262298
- Sigstore integration time:
-
Permalink:
dbe006/rugguard-sniper-bot-example@7fc4dcdaa9b4eba33c213407bb6660c10a37289b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dbe006
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7fc4dcdaa9b4eba33c213407bb6660c10a37289b -
Trigger Event:
release
-
Statement type: