- β¨ Introduction
- β‘οΈ Key Features
- ποΈ Project Structure
- π οΈ Prerequisites
- π Installation - Get Started in Minutes
- βοΈ Configuration - Tailor 0xBuilder to Your Strategy
- Deploy Your Flashloan Contract
- π Register for API Keys
- πΉοΈ Run the Bot - Engage the Engines
- π― Strategies
- π Logging
- π οΈ Troubleshooting
- π€ Contributing
- π License
β οΈ Disclaimer - Proceed with Caution- π Acknowledgements
0xBuilder Built for traders, developers, and researchers, 0xBuilder is your gateway to mastering MEV opportunities on the Ethereum network. engineered for high-frequency trading and maximum profit extraction. including:
- β‘οΈ Lightning-Fast Front-Running
- π Strategic Back-Running
- π₯ͺ Devastating Sandwich Attacks
- π° Capital-Efficient Flashloan Arbitrage
β οΈ Heads Up! 0xBuilder is under active development. Expect bugs β use with extreme caution and at your own risk.
- Mempool Mastery: Relentlessly scans the Ethereum mempool, pinpointing lucrative arbitrage and MEV opportunities.
- Strategic Arsenal: Deploy cutting-edge strategies like Front-Running, Back-Running, Sandwich Attacks, and Flashloan Arbitrage with surgical precision.
- Flashloan Fury: Leverage flashloans from Aave V3 for maximum capital efficiency and zero upfront capital requirements.
- Market Intelligence: Integrated market analysis, powered by real-time data from top-tier cryptocurrency APIs, ensuring data-driven decisions.
- Gas Optimization: Dynamic gas price adjustments to conquer network congestion and maximize profitability.
- Unbreakable Nonce Management: Advanced nonce handling to guarantee transaction success and prevent costly failures.
- Ironclad Safety Net: Multi-layered safety checks and risk assessment protocols to safeguard your assets.
- Transaction Bundling: Bundle transactions for atomic execution and front-running dominance.
- DeFi Protocol Prowess: Seamlessly interacts with leading DeFi platforms like Uniswap, Sushiswap, Aave, and more.
- Limitless Customization: Highly configurable architecture supporting multiple wallets, tokens, trading pairs, and adaptable strategies.
- Crystal-Clear Logging: Comprehensive, detailed logs for in-depth performance analysis, debugging, and strategy refinement.
/0xBuilder/
βββ abi/ # Smart Contract ABIs (JSON)
β βββ uniswap_abi.json
β βββ erc20_abi.json
β βββ aave_pool_abi.json
βββ contracts/ # Solidity Smart Contracts
β βββ SimpleFlashloan.sol
β βββ IERC20.sol
βββ linear_regression/ # Machine Learning Models & Data
β βββ training_data.csv
β βββ price_model.joblib
βββ python/ # Core Python Scripts & Logic
β βββ safety_net.py # Risk Management & Safety Checks
β βββ strategy_net.py # MEV Strategy Implementation & Execution
β βββ mempool_monitor.py # Ethereum Mempool Monitoring Engine
β βββ market_monitor.py # Market Data Analysis & Prediction
β βββ main.py # Main Bot Entry Point & Orchestration
β βββ transaction_core.py # Transaction Building & Execution Engine
β βββ main_core.py # Core Application Logic & Component Management
β βββ nonce_core.py # Ethereum Nonce Management System
β βββ api_config.py # Cryptocurrency API Integration & Data Handling
β βββ configuration.py # Configuration Loading & Validation
| βββ abi_registry.py # Centralized ABI Registry
β βββ 0xBuilder.log # Log File (Default)
| βββ __init__.py # Python Package Initialization
β βββ pyutils/ # Python Utility Modules
β βββ strategyexecutionerror.py # Custom Strategy Execution Exception
β βββ strategyconfiguration.py # Strategy Configuration Classes
βββ utils/ # Utility JSON Configuration Files
β βββ token_addresses.json # Monitored Token Addresses
β βββ erc20_signatures.json # ERC20 Function Signatures
β βββ token_symbols.json # Token Symbol Mappings
βββ .env # Environment Variable Configuration File
βββ requirements.txt # Python Dependencies List
Prepare your system and environment to harness the full potential of 0xBuilder.
- Operating System: Linux (Ubuntu 20.04+ Recommended), Windows 10/11, macOS 12+
- Blazing Network:
- Internet: Minimum 50Mbps, 100Mbps recommended for optimal performance
- Robust Hardware:
- CPU: 4+ Cores, 3.0GHz+ (Intel i7/Ryzen 7 or better for peak efficiency)
- RAM: Minimum 16GB, 32GB recommended for heavy-duty operations
- Storage: 1.3TB NVMe SSD minimum, 2TB for optimal data handling
- Ethereum Execution Client: Choose your weapon:
- Geth (Go, Recommended for stability and speed)
- Nethermind (C#/.NET)
- Besu (Java)
- Erigon (Go)
- Reth (Rust)
- EthereumJS (TypeScript, Sepolia/Holesky only)
- Python Dependencies: Arm your environment with packages from
requirements.txt
Set up your Ethereum Execution and Beacon clients for seamless blockchain interaction.
Choose Your Execution Client:
Client | Language | OS Support | Networks | Sync Methods |
---|---|---|---|---|
Geth | Go | Linux, Windows, macOS | Mainnet, Sepolia, Holesky | Snap, Full |
Nethermind | C#/.NET | Linux, Windows, macOS | Mainnet, Sepolia, Holesky | Snap, Fast, Full |
Besu | Java | Linux, Windows, macOS | Mainnet, Sepolia, Holesky | Snap, Fast, Full |
Erigon | Go | Linux, Windows, macOS | Mainnet, Sepolia, Holesky | Full |
Reth | Rust | Linux, Windows, macOS | Mainnet, Sepolia, Holesky | Full |
EthereumJS | TypeScript | Linux, Windows, macOS | Sepolia, Holesky | Full |
Example: Geth Configuration
-
Install Geth: Follow the official guide.
-
Launch Geth Node:
./geth --mainnet --syncmode snap --http --http.api eth,net,admin,web3,txpool --ws --ws.api eth,net,admin,web3,txpool --maxpeers 100 --cache 16000 --ipcpath ~/0xBuilder/geth.ipc --allow-insecure-unlock --http.corsdomain "*"
-
Monitor Sync:
geth attach ipc:/path/to/geth.ipc > eth.syncing
Set up a Beacon Node (Optional, but recommended for advanced monitoring and future features):
-
Install Prysm: Follow the Prysm guide.
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh chmod +x prysm.sh
-
Launch Prysm Beacon Chain:
./prysm.sh beacon-chain --accept-terms-of-use --execution-endpoint ~/0xBuilder/geth.ipc --mainnet --checkpoint-sync-url https://beaconstate.info --genesis-beacon-api-url https://beaconstate.info
Alternative Beacon Clients:
git clone https://github.com/John0n1/0xBuilder.git
cd 0xBuilder
Isolate your bot's dependencies:
# Linux/MacOS
python3 -m venv venv
source venv/bin/activate
Install required Python packages:
python -m pip install --upgrade pip
pip install -r requirements.txt
-
Create
.env
File:# Linux/MacOS cp .env.example .env # Windows copy .env.example .env
-
Edit
.env
: Configure API keys, node endpoints, wallet details, and more. -
Secure Your Secrets:
ls -la .env chmod 600 .env
Example .env
: (Refer to .env.example
for a full list of variables)
# API Configuration
ETHERSCAN_API_KEY=YOUR_ETHERSCAN_API_KEY
INFURA_PROJECT_ID=YOUR_INFURA_PROJECT_ID
COINGECKO_API_KEY=YOUR_COINGECKO_API_KEY
COINMARKETCAP_API_KEY=YOUR_COINMARKETCAP_API_KEY
CRYPTOCOMPARE_API_KEY=YOUR_CRYPTOCOMPARE_API_KEY
# Ethereum Node Configuration
HTTP_ENDPOINT=http://127.0.0.1:8545
WS_ENDPOINT=wss://127.0.0.1:8546
IPC_ENDPOINT=/path/to/geth.ipc
# Wallet Configuration
WALLET_ADDRESS=0xYourWalletAddress
WALLET_KEY=YOUR_PRIVATE_KEY
# Token Configuration (Paths to JSON files)
TOKEN_ADDRESSES=utils/token_addresses.json
TOKEN_SYMBOLS=utils/token_symbols.json
ERC20_SIGNATURES=utils/erc20_signatures.json
# DEX Router Addresses
UNISWAP_ADDRESS=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D # Uniswap V2 Router
SUSHISWAP_ADDRESS=0xd9e1cE17F2641f24aE83637ab66a2cca9C378B9F # Sushiswap Router
# ABI Paths (Paths to ABI JSON files)
UNISWAP_ABI=abi/uniswap_abi.json
SUSHISWAP_ABI=abi/sushiswap_abi.json
ERC20_ABI=abi/erc20_abi.json
# Flashloan Configuration
AAVE_FLASHLOAN_ADDRESS=0xYourFlashloanContractAddress # Your deployed Flashloan contract
AAVE_POOL_ADDRESS=0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 # Aave V3 Pool Address
Validate and customize JSON configuration files in the utils/
directory:
File | Description | Format |
---|---|---|
token_addresses.json |
Monitored token contract addresses | {"SYMBOL": "ADDRESS", ...} |
token_symbols.json |
Token symbol to address mappings | {"SYMBOL": "API_ID", ...} |
erc20_signatures.json |
ERC20 function signatures | {"function_name": "selector"} |
Maximize capital with a flashloan contract.
Deployment via Remix IDE (Recommended)
-
Open Remix: Go to Remix IDE.
-
Create Contract: Create a new file
SimpleFlashloan.sol
. -
Paste Code: Copy and paste the provided Solidity code into Remix.
-
Compile: Compile using Solidity v0.8.19 or later.
-
Deploy: Deploy to Ethereum using MetaMask or your preferred wallet.
-
Update
.env
: Add your deployed contract address to.env
:AAVE_FLASHLOAN_ADDRESS=0xYourDeployedContractAddress
Example Flashloan Contract (AAVE V3):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "https://github.com/aave/aave-v3-core/blob/master/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol";
import "https://github.com/aave/aave-v3-core/blob/master/contracts/interfaces/IPoolAddressesProvider.sol";
import "https://github.com/aave/aave-v3-core/blob/master/contracts/dependencies/openzeppelin/contracts/IERC20.sol";
contract SimpleFlashLoan is FlashLoanSimpleReceiverBase {
address payable public owner;
event FlashLoanRequested(address token, uint256 amount);
event FlashLoanExecuted(address token, uint256 amount, uint256 premium, bool success);
constructor(address _addressProvider) FlashLoanSimpleReceiverBase(IPoolAddressesProvider(_addressProvider)) {
owner = payable(msg.sender);
}
modifier onlyOwner() {
require(msg.sender == owner, "Not contract owner");
_;
}
function fn_RequestFlashLoan(address _token, uint256 _amount) public onlyOwner {
emit FlashLoanRequested(_token, _amount);
POOL.flashLoanSimple(address(this), _token, _amount, "", 0);
}
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address initiator,
bytes calldata params
) external override returns (bool) {
require(IERC20(asset).approve(address(POOL), amount + premium), "Approval failed");
emit FlashLoanExecuted(asset, amount, premium, true);
return true;
}
function withdrawToken(address _tokenAddress) public onlyOwner {
IERC20 token = IERC20(_tokenAddress);
uint256 balance = token.balanceOf(address(this));
require(balance > 0, "No tokens to withdraw");
token.transfer(owner, balance);
}
function withdrawETH() public onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No ETH to withdraw");
owner.transfer(balance);
}
receive() external payable {}
}
Register for API keys from these essential services and add them to your .env
file:
- Infura: Your gateway to Ethereum node infrastructure.
- Etherscan: For on-chain data and transaction insights.
- CoinGecko: Real-time and historical crypto market data.
- CoinMarketCap: Comprehensive cryptocurrency market data.
- CryptoCompare: Another robust source for crypto market data.
- Binance (Optional): For Binance-specific market data and volume analysis.
Prepare for liftoff and execute 0xBuilder!
Pre-Flight Checklist:
- π Ethereum Node: Ensure your node is fully synchronized and running.
- π°οΈ Beacon Node: (Optional) Verify your beacon node is active.
- π Configuration: Double-check
.env
variables and JSON config files. - β½ ETH Balance: Fund your wallet with enough ETH to cover gas costs.
Launch Sequence:
-
Activate Virtual Environment:
source venv/bin/activate
-
Start 0xBuilder:
python python/main.py
Monitor & Control:
- Logs: Track bot activity and performance in
python/0xBuilder.log
. - Console: Monitor real-time status updates in your terminal.
- Shutdown: Press
Ctrl+C
in the console to initiate a graceful shutdown.
Performance Tuning:
- Node Sync: Maintain a fully synchronized Ethereum node for optimal performance.
- API Limits: Monitor API usage and respect rate limits; consider upgrading API tiers for higher limits.
- ETH Balance: Ensure your wallet has sufficient ETH to cover transaction fees.
- Log Analysis: Regularly review logs to identify and resolve issues, and optimize strategies.
- Dependency Updates: Keep Python dependencies updated to benefit from performance improvements and security patches.
0xBuilder is armed with a suite of powerful MEV strategies:
- Aggressive Front-Running: Seize immediate profit opportunities by front-running pending transactions with speed and precision.
- Predictive Front-Running: Leverage advanced price prediction models to anticipate market movements and front-run strategically.
- Volatility Front-Running: Capitalize on high market volatility with front-running techniques optimized for volatile tokens.
- Advanced Front-Running: A multi-faceted strategy combining risk assessment, market analysis, and intelligent decision-making for sophisticated front-running executions.
- Price Dip Back-Running: Back-run transactions that trigger price dips, profiting from post-dip rebounds.
- Flashloan Back-Running: Execute back-running strategies with zero upfront capital using flashloans for maximum efficiency.
- High Volume Back-Running: Target high-volume tokens for back-running, leveraging volume for increased profit potential.
- Advanced Back-Running: Employ comprehensive market analysis and condition assessment for optimized back-running executions.
- Flash Profit Sandwich Attack: Maximize profit extraction with sandwich attacks powered by flashloans, minimizing risk and maximizing capital utilization.
- Price Boost Sandwich Attack: Exploit price momentum with sandwich attacks, capitalizing on tokens exhibiting strong upward price action.
- Arbitrage Sandwich Attack: Combine sandwich attacks with arbitrage detection to profit from both MEV and arbitrage opportunities in a single, powerful strategy.
- Advanced Sandwich Attack: Deploy risk-managed sandwich attacks using advanced market condition analysis and dynamic parameter adjustments for optimal execution and profit.
- High-Value ETH Transfer: Intercept and capitalize on high-value ETH transfers, leveraging strategic positioning for MEV extraction.
0xBuilder provides detailed logs in python/0xBuilder.log
to keep you informed:
- Transaction Insights: Real-time detection of profitable transactions in the mempool.
- Strategy Performance: Track the execution and success of each strategy, with detailed profit metrics.
- Error & Exception Tracking: Immediate alerts for any errors or exceptions, enabling rapid troubleshooting.
- Detailed Activity Logs: Comprehensive logs of bot activities, transactions, and market analysis for in-depth performance review.
Customize logging verbosity and formatting in python/main_core.py
using the setup_logging()
function.
Common Pitfalls & Solutions:
Issue | Solution |
---|---|
Node Connection Failures | Verify Ethereum node is running and endpoints are correct |
API Rate Limit Reached | Implement request throttling; consider upgrading API tiers |
Insufficient Gas Balance | Fund your wallet with adequate ETH for transaction fees |
Nonce Synchronization Errors | Reset Nonce Core or manually synchronize nonce with node |
Node Synchronization Status | Ensure your Ethereum node is fully synchronized with network |
Debugging:
- Verbose Logging: Increase logging level to
DEBUG
for detailed output. - Dependency Sanity Check: Ensure all dependencies in
requirements.txt
are up-to-date and correctly installed. - Contract Explorer: Verify your flashloan contract is deployed and functioning correctly using a block explorer (e.g., Etherscan).
- Testnet Trials: Thoroughly test strategies and configurations on testnets like Sepolia or Holesky before deploying to mainnet.
Become a part of the 0xBuilder community! Contributions are welcome and highly encouraged! β€οΈβ€οΈ
Contribution Guidelines:
- Fork & Branch: Fork the repository and create a dedicated feature branch for your contributions.
- Code Style: Adhere to PEP 8 guidelines for Python code style.
- Unit Tests: Include comprehensive unit tests to ensure the quality and reliability of your contributions.
- Pull Requests: Submit well-documented pull requests with clear descriptions of your changes and their benefits.
For detailed contribution guidelines, please review CONTRIBUTING.md.
0xBuilder is released under the MIT License.