Metadata-Version: 2.4
Name: on1builder
Version: 2.3.0
Summary: ON1Builder is a cross-chain arbitrage bot for Ethereum and EVM-compatible networks, designed to automate profitable trading opportunities.
Author-email: john0n1 <john@on1.no>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohappyeyeballs==2.6.1
Requires-Dist: aiohttp==3.13.3
Requires-Dist: aiosignal==1.4.0
Requires-Dist: annotated-types==0.7.0
Requires-Dist: attrs==25.4.0
Requires-Dist: bitarray==3.8.0
Requires-Dist: cachetools==6.2.4
Requires-Dist: certifi==2026.1.4
Requires-Dist: charset-normalizer==3.4.4
Requires-Dist: ckzg==2.1.5
Requires-Dist: click==8.3.1
Requires-Dist: colorlog==6.10.1
Requires-Dist: cytoolz==1.1.0
Requires-Dist: eth-account==0.13.7
Requires-Dist: eth-hash==0.7.1
Requires-Dist: eth-keyfile==0.8.1
Requires-Dist: eth-keys==0.7.0
Requires-Dist: eth-rlp==2.2.0
Requires-Dist: eth-typing==5.2.1
Requires-Dist: eth-utils==5.3.1
Requires-Dist: eth-abi==5.2.0
Requires-Dist: frozenlist==1.8.0
Requires-Dist: greenlet==3.3.0
Requires-Dist: hexbytes==1.3.1
Requires-Dist: idna==3.11
Requires-Dist: markdown-it-py==4.0.0
Requires-Dist: mdurl==0.1.2
Requires-Dist: multidict==6.7.0
Requires-Dist: parsimonious==0.10.0
Requires-Dist: prompt-toolkit==3.0.52
Requires-Dist: propcache==0.4.1
Requires-Dist: psutil==7.2.1
Requires-Dist: pycryptodome==3.23.0
Requires-Dist: pydantic==2.12.5
Requires-Dist: pydantic-settings==2.12.0
Requires-Dist: pydantic-core==2.41.5
Requires-Dist: pygments==2.19.2
Requires-Dist: python-dotenv==1.2.1
Requires-Dist: pyunormalize==17.0.0
Requires-Dist: questionary==2.1.1
Requires-Dist: regex==2025.11.3
Requires-Dist: requests==2.32.5
Requires-Dist: rich==14.2.0
Requires-Dist: rlp==4.1.0
Requires-Dist: shellingham==1.5.4
Requires-Dist: sqlalchemy==2.0.45
Requires-Dist: toolz==1.1.0
Requires-Dist: typer==0.21.1
Requires-Dist: types-requests==2.32.4.20260107
Requires-Dist: typing-inspection==0.4.2
Requires-Dist: typing-extensions==4.15.0
Requires-Dist: urllib3==2.6.3
Requires-Dist: wcwidth==0.2.14
Requires-Dist: web3==7.14.0
Requires-Dist: websockets==15.0.1
Requires-Dist: yarl==1.22.0
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# -

[![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
![Status](https://img.shields.io/badge/Status-Active-success)
![Tests](https://img.shields.io/badge/Tests-Manual%20%2F%20Local-inactive)
![Coverage](https://img.shields.io/badge/Coverage-TBD-lightgrey)

Async, multi-chain MEV/arbitrage engine with safety rails, flashloan support, and live telemetry. Highly customizable via config.

## Overview
ON1Builder is a modular MEV searcher framework designed for building and deploying arbitrage, front-running, and back-running strategies across multiple EVM-compatible blockchains. It emphasizes safety, configurability, and observability, making it suitable for both development and production environments.

---

## Key Features
- **Multi-Chain Support**: Easily connect to any EVM-compatible chain with configurable RPC and WebSocket endpoints (prefers Nethermind, Geth nodes).
- **MEV Strategies**: Built-in support for common MEV strategies including arbitrage, front-running, back-running, and flashloan-based trades.
- **Safety Mechanisms**: Configurable slippage caps, gas price ceilings, and balance tiers to minimize risk.
- **Flashloan Integration**: Seamless integration with popular flashloan providers for capital-efficient trading.
- **Simulation Backends**: Supports multiple simulation backends (eth_call, Anvil, Tenderly) for pre-execution validation.
- **Telemetry & Monitoring**: Heartbeats, performance summaries, structured logging, and notification channels (Slack, Telegram, Discord, Email) for real-time monitoring.
- **Extensible Architecture**: Modular design allows for easy addition of new strategies, chains, and features.

## Quick Snapshot

| Track | Summary |
| ----- | ------- |
| Core Focus | MEV searcher: arbitrage, back/front-run, flashloans |
| Chains | Ethereum ready (public RPC OK); multi-chain capable |
| Safety | Slippage caps, gas ceilings, balance tiers, emergency stop |
| Telemetry | Heartbeats, perf summaries, structured logs, notifications |

## Feature Highlights

<img width="9867" height="2500" alt="Dia" src="https://github.com/user-attachments/assets/9acc0ac1-c5f3-45f1-a8c9-bf6bf1f3b232" />

## Quick Start

### 1. Clone & env
```bash
git clone https://github.com/John0n1/ON1Builder.git
cd ON1Builder
```
- Windows
```bash
python -m venv .venv
. .venv/Scripts/activate
pip install -r requirements.txt
pip install -e .
```
- Linux/MacOS
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
```

### 2. Configure (minimum)
```bash
copy .env.example .env
# edit:
#   WALLET_KEY, WALLET_ADDRESS
#   RPC_URL_1="https://ethereum-rpc.publicnode.com"
#   WEBSOCKET_URL_1="wss://ethereum-rpc.publicnode.com"   # public WS is auto-skipped for txpool
#   ETHERSCAN_API_KEY=...
```

### 3. Run
```bash
python -m on1builder status check
python -m on1builder run start
```


> With public RPC/WS, txpool scanning is disabled on purpose (unreliable pending tx support). Provide a private WS endpoint if you want pending tx monitoring.

## Architecture Map

<img width="6265" height="4722" alt="Arch" src="https://github.com/user-attachments/assets/934d3aaa-fae0-49c2-b28d-e740bedf0e2f" />

## Configuration Cheat Sheet

| Setting | Description |
| ------- | ----------- |
| `WALLET_KEY`, `WALLET_ADDRESS` | Required for signing/monitoring |
| `RPC_URL_1` | HTTP RPC endpoint (public OK) |
| `WEBSOCKET_URL_1` | WS endpoint; use private if you want txpool scanning |
| `ETHERSCAN_API_KEY` | Optional but recommended for ABI/tx metadata |
| `MIN_PROFIT_ETH` | Profit floor per trade (ETH) |
| `MAX_GAS_PRICE_GWEI` | Hard gas ceiling |
| `SUBMISSION_MODE` | `public`, `private`, or `bundle` (relay submission) |
| `PRIVATE_RPC_URL` | Private RPC endpoint (Flashbots Protect, etc.) |
| `BUNDLE_RELAY_URL` | Bundle relay endpoint (MEV-Boost/Flashbots) |
| `SIMULATION_BACKEND` | `eth_call`, `anvil`, or `tenderly` |
| `SIMULATION_CONCURRENCY` | Max concurrent simulations |
| `NOTIFICATION_CHANNELS` | `slack,telegram,discord,email` (blank = off) |
| `ORACLE_FEEDS` | JSON map of chain_id → symbol → Chainlink feed address |
| `ORACLE_STALE_SECONDS` | Max age (seconds) before oracle price is treated as stale |
| `MARKET_PRICE_PERSIST_INTERVAL` | Persist price snapshots to DB every N seconds (0 disables) |
| `STARTUP_TEST_TRANSACTION` | Run a diagnostic self-tx on startup (requires `ALLOW_INSUFFICIENT_FUNDS_TESTS`) |
| `ALLOW_INSUFFICIENT_FUNDS_TESTS` | Bypass local balance checks for test sends (debug only) |

Full list lives in `.env.example`.

PublicNode endpoints can be used for EVM chains listed in `.env.example`. Non-EVM endpoints
(Sui, Aptos, Osmosis, Avalanche P/X, Polygon Heimdall) are not supported by ON1Builder.

## Running & Monitoring

```bash
# Validate config
python -m on1builder status check

# Start bot
python -m on1builder run start

# View logs
tail -f logs/on1builder.log          # *nix
Get-Content logs\\on1builder.log -Wait  # Windows
```

Heartbeats report balance tier, pending tx count (0 if txpool scanner is disabled), and memory usage.

## Development

<img width="15082" height="7425" alt="flow" src="https://github.com/user-attachments/assets/c7838b3d-65f1-4856-ae90-34bb55d82e3e" />

```bash
python -m pytest            # fast/local tests
RUN_LIVE_API_TESTS=1 python -m pytest tests/test_external_api_logic.py
black src tests && flake8 src tests && mypy src
```

Pre-commit hooks are configured in `.pre-commit-config.yaml`.

## Optional Utilities

ON1Builder ships a few utilities that are not required for core execution but can be
integrated in advanced deployments:

- `src/on1builder/utils/error_recovery.py`: Retry/circuit-breaker helpers and a recovery
  manager. The TransactionManager now reports failures to this manager for tracking and
  optional recovery strategies, but most strategies are placeholders by default.
- `src/on1builder/utils/container.py`: A lightweight DI container for advanced lifecycle
  management. The core runtime does not use it yet; opt in if you want centralized wiring.

## Flashloan setup
You need to deploy your own flashloan provider contract or use an existing one. Make sure to configure the flashloan provider address in your strategy settings.

To learn about deploying a flashloan contract, refer to the documentation of the flashloan provider you intend to use (e.g., Aave, dYdX) we recommend  [Aave](https://docs.aave.com/developers/guides/flash-loans)

Here's a basic outline of the steps involved:

1. Choose a Flashloan Provider: Decide which flashloan provider you want to use (e.g., Aave, dYdX).
2. We recommend using Remix IDE for deploying smart contracts. Open Remix IDE in your web browser.
3. Create a New File: In Remix, create a new Solidity file (e.g., FlashloanProvider.sol) and write or paste the flashloan contract code.
4. Compile the Contract: Use the Solidity compiler in Remix to compile your flashloan contract.
5. Deploy the Contract:
   - Select the appropriate environment (e.g., Injected Web3 for MetaMask).
   - Choose the contract you want to deploy.
   - Click the "Deploy" button and confirm the transaction in your wallet.
6. Note the Contract Address: After deployment, copy the contract address. You'll need to configure this address in .env

## API Keys

The bot is able to function without API keys, but some features are limited. It's recommended to set up the following free API keys for best experience:

- **Etherscan API Key**: For fetching contract ABIs and transaction metadata. Sign up at [Etherscan](https://etherscan.io/apis).
- **Tenderly Account**: For advanced simulation backend. Sign up at [Tenderly](https://tenderly.co/).
- **Binance API Key**: For fetching token prices. Sign up at [Binance](https://www.binance.com/en/support/faq/360002502072).
- CoinGecko API Key: Optional, for additional price data. Sign up at [CoinGecko](https://www.coingecko.com/en/api).
- Cryptocompare API Key: Optional, for additional price data. Sign up at [Cryptocompare](https://min-api.cryptocompare.com/).
- CoinMarketCap API Key: Optional, for additional price data. Sign up at [CoinMarketCap](https://coinmarketcap.com/api/).


## Safety Notes

- Public WS endpoints are auto-skipped for txpool scanning to avoid noisy failures.
- Price lookups are limited to a small, well-known token set; repeated failures are silenced after blacklisting.
- Emergency balance tiers keep the bot idle when funds are low.

## License

MIT - see [LICENSE](LICENSE).

## Disclaimer

Use at your own risk. No warranty. MEV strategies can be volatile and may incur losses. Keep keys safe; never use production keys on public demos.
