|
| 1 | +# ElizaOS Arbitrage Plugin |
| 2 | + |
| 3 | +A powerful DEX arbitrage trading plugin for ElizaOS, designed to identify and automatically execute profitable cross-market trading opportunities on Ethereum-based decentralized exchanges. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The ElizaOS Arbitrage Plugin monitors multiple decentralized exchanges (DEXs) like Uniswap and Sushiswap for price discrepancies in token pairs. When it identifies a profitable arbitrage opportunity that exceeds the configured threshold, it automatically executes the trade using Flashbots bundles to maximize profits and minimize risk. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Real-time Market Monitoring**: Continuously watches market conditions across multiple DEXs via WebSocket connections |
| 12 | +- **Automated Opportunity Detection**: Analyzes price differences to identify profitable arbitrage paths |
| 13 | +- **Smart Trade Execution**: Uses Flashbots to execute trades privately and avoid front-running |
| 14 | +- **Configurable Trading Parameters**: Customizable profit thresholds, gas limits, and other trading parameters |
| 15 | +- **Risk Management**: Advanced volume optimization to minimize price impact and maximize profits |
| 16 | +- **Performance Optimization**: Efficient batch processing and concurrent operations for minimal latency |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- Node.js 18 or higher |
| 21 | +- An Ethereum wallet with private key |
| 22 | +- Access to an Ethereum WSS endpoint |
| 23 | +- Flashbots relay signing key |
| 24 | +- Bundle executor smart contract deployment |
| 25 | + |
| 26 | +## Installation |
| 27 | + |
| 28 | +```bash |
| 29 | +npm install @elizaos-plugins/plugin-arbitrage |
| 30 | +``` |
| 31 | + |
| 32 | +## Configuration |
| 33 | + |
| 34 | +To use the plugin, you need to configure your ElizaOS character with the necessary settings: |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "name": "Trader", |
| 39 | + "settings": { |
| 40 | + "secrets": { |
| 41 | + "EVM_PRIVATE_KEY": "YOUR_PRIVATE_KEY_HERE", |
| 42 | + "FLASHBOTS_RELAY_SIGNING_KEY": "YOUR_FLASHBOTS_KEY_HERE", |
| 43 | + "BUNDLE_EXECUTOR_ADDRESS": "YOUR_EXECUTOR_ADDRESS_HERE" |
| 44 | + }, |
| 45 | + "arbitrage": { |
| 46 | + "ethereumWsUrl": "YOUR_ETH_WSS_URL", |
| 47 | + "rpcUrl": "YOUR_ETH_RPC_URL" |
| 48 | + } |
| 49 | + }, |
| 50 | + "plugins": [ |
| 51 | + "@elizaos/plugin-arbitrage", |
| 52 | + "@elizaos/plugin-evm" |
| 53 | + ] |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +### Required Settings |
| 58 | + |
| 59 | +| Setting | Description | |
| 60 | +|---------|-------------| |
| 61 | +| `EVM_PRIVATE_KEY` | Private key for your Ethereum wallet (keep this secure!) | |
| 62 | +| `FLASHBOTS_RELAY_SIGNING_KEY` | Signing key for Flashbots bundles | |
| 63 | +| `BUNDLE_EXECUTOR_ADDRESS` | Address of your bundle executor contract | |
| 64 | +| `ethereumWsUrl` | WebSocket URL for your Ethereum node | |
| 65 | +| `rpcUrl` | RPC URL for your Ethereum node | |
| 66 | + |
| 67 | +## Usage |
| 68 | + |
| 69 | +The plugin integrates with ElizaOS and provides the following capabilities: |
| 70 | + |
| 71 | +### Actions |
| 72 | + |
| 73 | +- `EXECUTE_ARBITRAGE`: Scans for and executes profitable arbitrage opportunities |
| 74 | + |
| 75 | +### Providers |
| 76 | + |
| 77 | +- `marketProvider`: Provides real-time market data and arbitrage opportunities |
| 78 | + |
| 79 | +### Example Interactions |
| 80 | + |
| 81 | +``` |
| 82 | +User: "Find arbitrage opportunities" |
| 83 | +Trader: "Scanning for arbitrage trades..." |
| 84 | +``` |
| 85 | + |
| 86 | +## Advanced Configuration |
| 87 | + |
| 88 | +You can customize trading parameters by modifying the thresholds in `src/config/thresholds.ts`: |
| 89 | + |
| 90 | +```typescript |
| 91 | +export const DEFAULT_THRESHOLDS: MarketThresholds = { |
| 92 | + minProfitThreshold: BigNumber.from("100000000000000"), // 0.0001 ETH |
| 93 | + maxTradeSize: BigNumber.from("1000000000000000000"), // 1 ETH |
| 94 | + gasLimit: 500000, |
| 95 | + minerRewardPercentage: 90 |
| 96 | +}; |
| 97 | +``` |
| 98 | + |
| 99 | +## Architecture |
| 100 | + |
| 101 | +The plugin consists of several key components: |
| 102 | + |
| 103 | +- **Core Engine**: Implements the arbitrage detection and execution logic |
| 104 | +- **Market Adapters**: Interfaces with various DEXs like Uniswap and Sushiswap |
| 105 | +- **WebSocket Manager**: Handles real-time market data updates |
| 106 | +- **Service Layer**: Integrates with ElizaOS to provide plugin functionality |
| 107 | + |
| 108 | +## Security Considerations |
| 109 | + |
| 110 | +- Ensure your private keys are stored securely |
| 111 | +- Test with small amounts before deploying with significant capital |
| 112 | +- Monitor gas costs to ensure profitability |
| 113 | +- Implement circuit breakers for market volatility |
0 commit comments