Skip to content

SaltyTaro/1.7

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Cross-Chain LSD Arbitrage Bot

A sophisticated arbitrage bot that monitors price differences of Liquid Staking Derivative (LSD) tokens across multiple blockchain networks and automatically executes profitable arbitrage trades. The bot can leverage flash loans for capital efficiency when appropriate and uses Socket Protocol and Across Protocol for cross-chain transfers.

Features

  • Multi-Chain Support: Monitors Ethereum, Arbitrum, Optimism, Polygon, and Base
  • LSD Token Support: Tracks stETH, rETH, cbETH, frxETH
  • Flash Loan Integration: Uses AAVE flash loans for capital-efficient arbitrage
  • Bridge Selection: Dynamically routes between Socket Protocol and Across Protocol
  • Gas Optimization: Smart gas price strategies for each chain
  • MEV Protection: Optional private mempool usage
  • Inventory Management: Cross-chain balance optimization
  • Paper Trading: Simulation mode for testing without risking real funds
  • PnL Tracking: Records and analyzes profits and losses over time

Architecture

The bot consists of several key components:

  1. Main Bot Logic: Orchestrates the monitoring and execution workflow
  2. Arbitrage Finder: Scans for price differences and calculates profitability
  3. Arbitrage Executor: Executes the trades using optimal strategies
  4. Exchange Connectors: Interfaces with DEXs on different chains
  5. Bridge Utilities: Handles cross-chain transfers
  6. Web3 Utilities: Manages blockchain connections and transactions
  7. Simulation Mode: Tests strategies without risking real funds

Prerequisites

  • Node.js v16+
  • Yarn
  • Private keys for executing transactions
  • RPC URLs for all supported networks
  • Socket Protocol API key
  • Across Protocol API key (if using Across)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/lsd-arbitrage-bot.git
    cd lsd-arbitrage-bot
  2. Install dependencies:

    yarn install
  3. Create a .env file with your configuration (see .env.example):

    cp .env.example .env
  4. Edit the .env file with your private keys, RPC URLs, and API keys.

Configuration

The bot has a flexible configuration system in the config directory. The main configuration file is config/default.js, and you can override settings in config/custom.js.

Key configuration options:

  • Networks: RPC URLs, gas settings, and confirmation times
  • Tokens: Addresses on each network
  • Exchanges: DEX configurations for Uniswap, Curve, and Balancer
  • Bridges: Socket and Across configurations
  • Flash Loans: AAVE V3 pool addresses and parameters
  • Bot Settings: Minimum profit thresholds, max slippage, etc.

Usage

Basic Usage

Run the bot in simulation mode (no real trades):

yarn start --simulate

Run with real trading:

yarn start

Command Line Options

  • --simulate or -s: Run in simulation mode without executing trades
  • --monitor-only or -m: Monitor opportunities without executing trades
  • --once or -o: Run once and exit (useful for cron jobs)
  • --token <symbol> or -t <symbol>: Only monitor specific token (e.g., stETH)
  • --chains <chains> or -c <chains>: Comma-separated list of chains to monitor (e.g., ethereum,arbitrum)
  • --no-flashloan or -n: Disable flash loan opportunities
  • --profit <amount> or -p <amount>: Minimum profit threshold in USD

Examples

Monitor only stETH on Ethereum and Arbitrum:

yarn start --token stETH --chains ethereum,arbitrum --simulate

Run once to check for opportunities:

yarn start --once

Set a higher profit threshold:

yarn start --profit 100 --simulate

Flash Loan Implementation

Flash loans are implemented using AAVE V3 pools. The bot:

  1. Identifies profitable arbitrage opportunities on the same chain
  2. Calculates optimal loan amounts
  3. Executes loans, arbitrage, and repayment in a single transaction

To use flash loans, ensure the FLASH_LOAN_ENABLED setting is set to true in your .env file.

Bridge Selection

The bot dynamically selects between Socket Protocol and Across Protocol based on:

  1. Fee comparison
  2. Estimated transfer time
  3. Return on investment calculation

You can set PREFERRED_BRIDGE in your .env file to prefer a specific bridge or set it to auto for dynamic selection.

Monitoring and Logs

Logs are stored in the logs directory:

  • logs/arbitrage.log: Main application logs
  • logs/profits.json: Profit/loss records for each trade

Security Considerations

  • Private keys are stored locally and used to sign transactions
  • The bot validates token addresses before interacting with them
  • Emergency shutdown can be triggered if suspicious activity is detected
  • Optional MEV protection via private mempool

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your improvements.

License

MIT

Disclaimer

Trading cryptocurrencies involves significant risk. This software is provided for educational and informational purposes only. Use at your own risk. The authors assume no responsibility for financial losses incurred using this software.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors