|
| 1 | +# Rabbi Trader Plugin |
| 2 | + |
| 3 | +An automated cryptocurrency trading plugin for Solana tokens with integrated trust scoring, market analysis, and Twitter notifications. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Automated trading on Solana blockchain |
| 8 | +- Real-time market data analysis using DexScreener |
| 9 | +- Trust score evaluation for tokens |
| 10 | +- Twitter integration for trade notifications |
| 11 | +- Safety limits and risk management |
| 12 | +- Simulation capabilities before executing trades |
| 13 | +- Performance tracking and trade history |
| 14 | +- Rate limiting and cache management |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +```bash |
| 19 | +npm install @elizaos/plugin-rabbi-trader |
| 20 | +``` |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +The following environment variables need to be configured: |
| 25 | + |
| 26 | +- `WALLET_PRIVATE_KEY`: Your Solana wallet private key |
| 27 | +- `WALLET_PUBLIC_KEY`: Your Solana wallet public address |
| 28 | +- `RPC_URL`: Solana RPC endpoint (defaults to mainnet) |
| 29 | +- `BIRDEYE_API_KEY`: API key for Birdeye data provider |
| 30 | +- `TWITTER_ENABLED`: Enable/disable Twitter notifications |
| 31 | +- `TWITTER_USERNAME`: Twitter username for notifications |
| 32 | +- `DEXSCREENER_WATCHLIST_ID`: DexScreener watchlist identifier |
| 33 | +- `COINGECKO_API_KEY`: CoinGecko API key for additional market data |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +```typescript |
| 38 | +import createRabbiTraderPlugin from '@elizaos/plugin-rabbi-trader'; |
| 39 | +import { IAgentRuntime } from '@elizaos/core'; |
| 40 | + |
| 41 | +const plugin = await createRabbiTraderPlugin( |
| 42 | + (key: string) => process.env[key], |
| 43 | + runtime |
| 44 | +); |
| 45 | + |
| 46 | +// Plugin will automatically start monitoring and trading if enabled |
| 47 | +``` |
| 48 | + |
| 49 | +## Configuration |
| 50 | + |
| 51 | +### Safety Limits |
| 52 | + |
| 53 | +The plugin includes built-in safety limits that can be configured: |
| 54 | + |
| 55 | +```typescript |
| 56 | +export const SAFETY_LIMITS = { |
| 57 | + MINIMUM_TRADE: 0.01, // Minimum SOL per trade |
| 58 | + MAX_POSITION_SIZE: 0.1, // Maximum 10% of token liquidity |
| 59 | + MAX_SLIPPAGE: 0.05, // Maximum 5% slippage allowed |
| 60 | + MIN_LIQUIDITY: 1000, // Minimum $1000 liquidity required |
| 61 | + MIN_VOLUME: 2000, // Minimum $2000 24h volume required |
| 62 | + MIN_TRUST_SCORE: 0.4, // Minimum trust score to trade |
| 63 | + STOP_LOSS: 0.2, // 20% stop loss trigger |
| 64 | + TAKE_PROFIT: 0.12, // Take profit at 12% gain |
| 65 | + TRAILING_STOP: 0.2 // 20% trailing stop from highest |
| 66 | +}; |
| 67 | +``` |
| 68 | + |
| 69 | +### Trading Parameters |
| 70 | + |
| 71 | +Default trading parameters can be adjusted in the configuration: |
| 72 | + |
| 73 | +```typescript |
| 74 | +{ |
| 75 | + CHECK_INTERVAL: 5 * 60 * 1000, // Check every 5 minutes |
| 76 | + REENTRY_DELAY: 60 * 60 * 1000, // Wait 1 hour before re-entering |
| 77 | + MAX_ACTIVE_POSITIONS: 5, // Maximum concurrent positions |
| 78 | + MIN_WALLET_BALANCE: 0.05 // Keep minimum 0.05 SOL in wallet |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## API Integration |
| 83 | + |
| 84 | +The plugin integrates with multiple APIs: |
| 85 | + |
| 86 | +- **Birdeye API**: Market data and token security information |
| 87 | +- **DexScreener**: Real-time trading data and market analysis |
| 88 | +- **Twitter**: Trade notifications and updates |
| 89 | +- **Jupiter**: Token swaps and liquidity aggregation |
| 90 | + |
| 91 | +## Error Handling |
| 92 | + |
| 93 | +The plugin includes comprehensive error handling for common scenarios: |
| 94 | + |
| 95 | +```typescript |
| 96 | +export const ERROR_SIGNATURES = [ |
| 97 | + { |
| 98 | + sig: "0x13be252b", |
| 99 | + name: "InsufficientAllowance", |
| 100 | + description: "Token allowance too low" |
| 101 | + }, |
| 102 | + { |
| 103 | + sig: "0xf4d678b8", |
| 104 | + name: "InsufficientBalance", |
| 105 | + description: "Insufficient token balance" |
| 106 | + }, |
| 107 | + // ... additional error signatures |
| 108 | +]; |
| 109 | +``` |
| 110 | + |
| 111 | +## Trade Analysis |
| 112 | + |
| 113 | +The plugin performs detailed analysis before executing trades: |
| 114 | + |
| 115 | +1. Token security evaluation |
| 116 | +2. Market data analysis |
| 117 | +3. Trust score calculation |
| 118 | +4. Liquidity assessment |
| 119 | +5. Volume verification |
| 120 | +6. Price movement analysis |
| 121 | +7. Holder distribution review |
| 122 | + |
| 123 | +## Twitter Integration |
| 124 | + |
| 125 | +When enabled, the plugin can post trade notifications with: |
| 126 | + |
| 127 | +- Token information |
| 128 | +- Trade details (buy/sell price, amount) |
| 129 | +- Trust score and risk level |
| 130 | +- Market metrics |
| 131 | +- Transaction signature |
| 132 | +- Profit/loss for sells |
| 133 | + |
| 134 | +## Caching |
| 135 | + |
| 136 | +The plugin implements multiple caching mechanisms: |
| 137 | + |
| 138 | +- Token analysis cache (20 minutes) |
| 139 | +- Twitter rate limiting cache (hourly limits) |
| 140 | +- Skip/wait cache (2 hours) |
| 141 | +- Analysis history (24 hours) |
| 142 | + |
| 143 | +## Development |
| 144 | + |
| 145 | +### Building |
| 146 | + |
| 147 | +```bash |
| 148 | +npm run build |
| 149 | +``` |
| 150 | + |
| 151 | +### Development Mode |
| 152 | + |
| 153 | +```bash |
| 154 | +npm run dev |
| 155 | +``` |
| 156 | + |
| 157 | +## Dependencies |
| 158 | + |
| 159 | +Key dependencies include: |
| 160 | + |
| 161 | +- `@solana/web3.js`: Solana blockchain interaction |
| 162 | +- `@elizaos/core`: Core agent runtime |
| 163 | +- `@elizaos/plugin-solana`: Solana integration |
| 164 | +- `@elizaos/plugin-trustdb`: Trust score database |
| 165 | +- `node-cache`: Caching functionality |
| 166 | +- `bignumber.js`: Precise number handling |
| 167 | + |
| 168 | +## Contributing |
| 169 | + |
| 170 | +1. Fork the repository |
| 171 | +2. Create your feature branch |
| 172 | +3. Commit your changes |
| 173 | +4. Push to the branch |
| 174 | +5. Create a new Pull Request |
| 175 | + |
| 176 | +## License |
| 177 | + |
| 178 | +This project is licensed under the MIT License - see the LICENSE file for details. |
| 179 | + |
0 commit comments