Mayhem Strategy is a sophisticated trading system that exploits the Mayhem bot mechanics on PumpFun to create sustainable tokenomics with long-term viability through automated buyback mechanisms, liquidity management, and price stabilization strategies.
- Mayhem Bot Exploitation: Advanced detection and exploitation of pump-and-dump patterns on PumpFun
- Automated Buyback Engine: Sophisticated token buyback mechanism to stabilize prices and sustain tokenomics
- Liquidity Management: Automatic liquidity rebalancing and market-making
- Risk Management: Comprehensive position sizing, stop-loss, and take-profit management
- Real-time Monitoring: Dashboard monitoring, alerting, and performance analytics
- Production-Ready: Error handling, logging, retry mechanisms, and graceful shutdown
src/
├── bot.ts # Main trading bot orchestrator
├── index.ts # Entry point
├── monitor.ts # Monitoring dashboard
├── buyback.ts # Buyback daemon
├── config/
│ └── index.ts # Configuration management
├── services/
│ ├── solana.ts # Solana blockchain interactions
│ ├── pumpfun.ts # PumpFun API integration
│ ├── dex.ts # DEX/AMM interactions
│ └── buyback.ts # Buyback engine
├── strategies/
│ └── mayhem.ts # Mayhem exploitation strategy
├── types/
│ └── index.ts # Type definitions
├── utils/
│ └── logger.ts # Structured logging
└── monitor/
└── service.ts # Monitoring and alerting
- Node.js >= 18.0.0
- npm >= 9.0.0
- Solana wallet with SOL balance
- PumpFun API credentials (optional)
# Clone repository
git clone https://github.com/mayhem-strategy/bot.git
cd bot
# Install dependencies
npm install
# Build TypeScript
npm run build- Create
.envfile from template:
cp .env.example .env- Update
.envwith your settings:
# Solana Configuration
SOLANA_RPC_ENDPOINT=https://api.mainnet-beta.solana.com
PRIVATE_KEY=<your_base58_encoded_private_key>
WALLET_ADDRESS=<your_wallet_address>
# Trading Configuration
TRADING_ENABLED=true
MAX_SLIPPAGE=0.02
MIN_LIQUIDITY=1000
# Buyback Configuration
BUYBACK_ENABLED=true
BUYBACK_THRESHOLD=0.15
BUYBACK_AMOUNT=50
BUYBACK_INTERVAL=60000
# Monitoring
ALERT_WEBHOOK_URL=<discord_webhook_url>
LOG_LEVEL=infoStart the main trading bot:
npm start
# or
npm run dev # Development with auto-reloadStart the monitoring dashboard:
npm run monitorStart the buyback daemon (separate process):
npm run buybackThe bot analyzes PumpFun tokens for "Mayhem" opportunities - periods of intense buying pressure or sentiment manipulation.
- Hype Phase Analysis: Tracks token lifecycle (1-5 phases)
- Buy Pressure: Percentage of buy volume vs. total volume
- Volatility: Uses log returns to measure price volatility
- Trade Frequency: Number of trades in monitoring window
- Strong Buy: Hype ≥ 3, Buy pressure > 70%, Low volatility
- Buy: Hype ≥ 2, Buy pressure > 60%
- Sell: Buy pressure < 30%, Hype ≤ 2
- Hold: Mixed signals
The buyback engine stabilizes token price by automatically purchasing tokens when price falls below the configured threshold.
- Threshold Detection: Monitors price decline percentage
- Signal Generation: Evaluates buyback need based on market conditions
- Position Sizing: Calculates optimal buyback amount
- Execution: Executes buyback transaction on DEX
- Impact Tracking: Measures price impact of buyback
buybackParameters: {
enabled: true,
threshold: 0.15, // 15% price decline triggers buyback
amount: 50, // Buy 50 SOL worth each time
interval: 60000, // Check every 60 seconds
targetPriceFloor: 0.00005, // Don't buy below this price
maxBuybacksPerDay: 10 // Limit buybacks per day
}- Maximum position size: Configured in
riskParameters - Maximum open positions: 10 concurrent positions
- Stop-loss: Automatically close positions on 10% loss
- Take-profit: Automatically close positions on 25% gain
- Daily loss limit: $100 per day (configurable)
- Max position allocation: 30% of portfolio
- Slippage tolerance: 2% (configurable)
The system continuously assesses risk on four dimensions:
- Portfolio Risk: Current daily loss vs. daily limit
- Day Trading Risk: Leveraged exposure
- System Risk: Error rate and reliability
- Single Token Risk: Concentration risk
Risk levels:
- Safe: Overall score < 0.4
- Caution: Overall score 0.4-0.6
- Danger: Overall score 0.6-0.8
- Critical: Overall score > 0.8
Start the monitoring dashboard:
npm run monitorDisplays real-time:
- Portfolio value and P&L
- Open positions
- Performance metrics (24h)
- Active alerts
Alerts are published with severity levels:
- Info: General information
- Warning: Non-critical issues
- Error: Trading errors, connection issues
- Critical: Risk management triggers, system failures
Configure Discord or other webhook for alert notifications:
ALERT_WEBHOOK_URL=https://discordapp.com/api/webhooks/...- Win Rate: Percentage of profitable trades
- Profit Factor: Gross profit / gross loss
- Sharpe Ratio: Risk-adjusted returns
- Max Drawdown: Largest decline from peak
- Average Win/Loss: Mean profit/loss per trade
- RPC Latency: Blockchain connectivity
- Memory Usage: Process memory consumption
- CPU Usage: Processor utilization
- Error Rate: Percentage of failed operations
// Initialize bot
await tradingBot.initialize();
// Start trading
await tradingBot.start();
// Stop trading
await tradingBot.stop();
// Get portfolio
tradingBot.getPortfolio();
// Get positions
tradingBot.getPositions();
// Get status
tradingBot.getStatus();// Analyze Mayhem opportunity
const signal = await mayhemStrategy.analyzeMayhemOpportunity(mint);
// Monitor for entry
await mayhemStrategy.monitorForEntry(mint, durationMs);
// Check exit condition
mayhemStrategy.shouldExit(position);// Analyze buyback need
const signal = buybackEngine.analyzeBuybackNeed(
mint,
currentPrice,
previousPrice,
volume24h,
holders
);
// Execute buyback
const result = await buybackEngine.executeBuyback(mint, amount);
// Get statistics
buybackEngine.getBuybackStats();npm run dev# Build
npm run build
# Start
npm startCreate Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
CMD ["node", "dist/index.js"]Build and run:
docker build -t mayhem-strategy .
docker run -d --env-file .env mayhem-strategyInstall PM2:
npm install -g pm2Create ecosystem.config.js:
module.exports = {
apps: [
{
name: 'trading-bot',
script: './dist/index.js',
instances: 1,
exec_mode: 'fork',
watch: false,
env_file: '.env',
},
{
name: 'buyback-daemon',
script: './dist/buyback.js',
instances: 1,
exec_mode: 'fork',
watch: false,
env_file: '.env',
},
{
name: 'monitor',
script: './dist/monitor.js',
instances: 1,
exec_mode: 'fork',
watch: false,
env_file: '.env',
},
],
};Start with PM2:
pm2 start ecosystem.config.js
pm2 logs
pm2 stop all- Never commit
.envfile to version control - Use hardware wallet for large balances
- Rotate private keys periodically
- Restrict IP access to RPC endpoints
- Use environment variables for sensitive data
- Rate limiting for PumpFun API calls
- Timeout handling for network requests
- Retry with exponential backoff
- Circuit breakers for failing services
- Approval scoping: Only approve necessary amounts
- Reentrancy protection: Built into Solana programs
- Slippage protection: Configurable limits
- Amount validation: Check before execution
Bot won't start:
# Check configuration
npm run type-check
# Check connection
curl https://api.mainnet-beta.solana.comInsufficient balance:
# Check wallet balance
solana balance <wallet_address>
# Fund wallet from exchange or faucetRPC timeout errors:
# Try different RPC endpoint in .env
SOLANA_RPC_ENDPOINT=https://api.mainnet-beta.solana.com
# Alternative: https://solana-api.projectserum.comTransactions failing:
# Check transaction signature
solana confirm <signature>
# Check account info
solana account <account_address>Logs are organized by context (service):
[bot.ts] Trading loop error
[SolanaService] Transaction sent
[MayhemStrategy] Entry opportunity found
[BuybackEngine] Buyback executed
[MonitoringService] Alert published
Set log level:
LOG_LEVEL=debug # Most verbose
LOG_LEVEL=info # Standard
LOG_LEVEL=warn # Important warnings only
LOG_LEVEL=error # Only errors- Poll Interval: Adjust for responsiveness vs. RPC load
- Monitoring Interval: Balance between data freshness and network usage
- Position Limits: Higher limits = more trading but more risk
- Slippage Tolerance: Lower = better prices but higher failure rate
- Use RPC node close to your location
- Implement connection pooling
- Cache market data locally
- Batch RPC calls where possible
- Fork repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - see LICENSE file for details
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: [Join Discord Server]
- Documentation: Full Docs
- Raydium LP management
- Multi-wallet coordination
- Advanced risk models (VaR, Expected Shortfall)
- Machine learning price prediction
- Option strategies
- Cross-chain arbitrage
- Community signal sharing
- Web dashboard
Version: 1.0.0 Last Updated: 2026-04-08 Maintainer: Mayhem Strategy Team