Production-ready Node.js CLI tool for Solana token projects to manually claim creator fees and execute buybacks with integrated trade feed monitoring.
- Auto Fee Claims: Transfer accumulated fees (SOL or SPL tokens) with safety checks
- Auto Buybacks: Execute token buybacks via Jupiter aggregator with best routing
- Trade Feed: Monitor recent buyers and sellers from on-chain transactions
- Multiple RPC Support: Switch between Helius, RPC Pool, and Phantom RPCs
- Beautiful CLI: Gradient banner, clean logs, and elegant output
- Production Ready: Retry logic, error handling, and comprehensive logging
- Safety First: Minimum SOL reserve protection, slippage warnings, and confirmation prompts
- Node.js 18 or higher
- npm or yarn
- A Solana wallet with base58 private key
- Jupiter API key (provided)
# Clone or download the project
cd turnbackbot
# Install dependencies
npm install
# Copy environment configuration
cp env.example .env
# Edit .env with your configuration
nano .env
# Build the project
npm run build
# Link for global use (optional)
npm linkEdit the .env file with your settings:
# RPC Configuration (optional - defaults to Helius)
RPC_URL=https://lauraine-qytyxk-fast-mainnet.helius-rpc.com/
# Fee Wallet (base58 encoded private key)
FEE_WALLET_PRIVATE_KEY=your_base58_private_key_here
# Token Configuration
TARGET_MINT=TokenMintAddressHere
# INPUT_MINT: Token to swap FROM (default: SOL - Wrapped SOL)
# So11111111111111111111111111111111111111112 = SOL (Wrapped SOL)
# EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v = USDC
INPUT_MINT=So11111111111111111111111111111111111111112
# Trading Parameters
SLIPPAGE_BPS=100
MIN_SOL_RESERVE=0.05
DEFAULT_BUYBACK_AMOUNT=100
# Jupiter API
JUPITER_API_BASE=https://quote-api.jup.ag
JUPITER_API_KEY=e5029ac2-5c57-43a4-bcfa-cfe4da70cbd4
# Explorer
EXPLORER_BASE_URL=https://solscan.io
# Logging
LOG_LEVEL=info
TRADE_FEED_DEFAULT_LIMIT=20- RPC_URL: Solana RPC endpoint (defaults to Helius if not set)
- FEE_WALLET_PRIVATE_KEY: Base58 encoded private key for the fee wallet
- TARGET_MINT: Token mint address to buy back
- INPUT_MINT: Token to spend for buybacks (usually USDC or WSOL)
- SLIPPAGE_BPS: Maximum slippage in basis points (100 = 1%)
- MIN_SOL_RESERVE: Minimum SOL to keep in wallet for transaction fees
- DEFAULT_BUYBACK_AMOUNT: Default amount for buyback operations
- JUPITER_API_KEY: API key for Jupiter aggregator
- EXPLORER_BASE_URL: Block explorer base URL for transaction links
- LOG_LEVEL: Logging verbosity (debug/info/warn/error)
- TRADE_FEED_DEFAULT_LIMIT: Default number of trades to fetch in feed
Check wallet balances and configuration:
turnbackbot statusOutput shows:
- Current RPC URL
- Wallet public key
- SOL balance and minimum reserve
- Input token balance (for buybacks)
- Target token balance
Manually claim accumulated fees:
# Claim SOL
turnbackbot claim --mint SOL --amount 0.5
# Claim SOL to another wallet
turnbackbot claim --mint SOL --amount 0.5 --to <recipient_pubkey>
# Claim SPL tokens
turnbackbot claim --mint <TOKEN_MINT> --amount 100
# Skip confirmation prompt
turnbackbot claim --mint SOL --amount 0.2 --yesOptions:
--mint <address>: Token mint address or "SOL" for native SOL--amount <number>: Amount to transfer--to <address>: Recipient address (optional, defaults to fee wallet)--yes: Skip confirmation prompt
Safety Features:
- Validates sufficient balance before transfer
- Ensures MIN_SOL_RESERVE is maintained
- Creates recipient token account if needed
- Confirmation prompt (unless --yes is used)
Execute manual buyback via Jupiter:
# Basic buyback using config defaults
turnbackbot buyback --amount 100
# Specify input/output tokens
turnbackbot buyback --amount 100 --in <USDC_MINT> --out <TARGET_MINT>
# Custom slippage
turnbackbot buyback --amount 100 --slippage 200
# Dry run (simulate without executing)
turnbackbot buyback --amount 100 --dry-run
# Skip confirmation
turnbackbot buyback --amount 100 --yesOptions:
--amount <number>: Amount of input token to swap--in <mint>: Input token mint (defaults to INPUT_MINT from config)--out <mint>: Output token mint (defaults to TARGET_MINT from config)--slippage <bps>: Slippage in basis points (defaults to config)--dry-run: Simulate without executing transaction--yes: Skip confirmation prompt
Safety Features:
- Validates sufficient balance
- Ensures MIN_SOL_RESERVE is maintained
- Displays quote with expected output and price impact
- Warns on high slippage (>200 bps) or price impact (>1%)
- Confirmation prompt (unless --yes or --dry-run)
Monitor recent buyers and sellers:
# Show recent trades
turnbackbot feed --mint <TARGET_MINT>
# Show 50 most recent trades
turnbackbot feed --mint <TARGET_MINT> --limit 50
# Show trades from last hour
turnbackbot feed --mint <TARGET_MINT> --since 60
# Filter by DEX
turnbackbot feed --mint <TARGET_MINT> --dex jupiterOptions:
--mint <address>: Token mint address to monitor--limit <number>: Number of trades to display (default: 20)--since <minutes>: Only show trades from last N minutes--dex <name>: Filter by DEX (auto|jupiter|raydium|orca|pump)
Output:
- Time ago (relative)
- Side (BUY ↑ / SELL ↓)
- Wallet address (shortened)
- Token amount delta
- DEX source (Jupiter, Raydium, Orca, Pump.fun, or Unknown)
- Transaction signature (shortened)
Use a different RPC for any command:
# Use alternate RPC for status check
turnbackbot status --rpc https://mercuria-fronten-1cd8.mainnet.rpcpool.com/...
# Use Phantom RPC for buyback
turnbackbot buyback --amount 100 --rpc https://solana-mainnet.phantom.app/...Available RPCs:
- Default Helius:
https://lauraine-qytyxk-fast-mainnet.helius-rpc.com/ - RPC Pool:
https://mercuria-fronten-1cd8.mainnet.rpcpool.com/dfacae7d-d474-4d76-abd1-ef8da42a6510 - Phantom:
https://solana-mainnet.phantom.app/YBPpkkN4g91xDiAnTE9r0RcMkjg0sKUIWvAfoFVJ?advancedTxSubmission=true
The trade feed analyzes on-chain transactions to identify buyers and sellers:
- Fetch Transactions: Retrieves recent signatures for the token mint
- Parse Transactions: Gets parsed transaction data with token balance changes
- Analyze Changes: Compares pre/post token balances to determine:
- Buyer: Wallet that increased token balance
- Seller: Wallet that decreased token balance
- Detect DEX: Identifies the DEX/router from program IDs and logs
- Filter & Format: Applies filters and displays in readable table
- Jupiter (v4 & v6)
- Raydium (v4 & CLMM)
- Orca (Whirlpool)
- Pump.fun
- Best-effort detection: Some complex transactions may be misattributed
- Pure transfers excluded: Only swap-like transactions are included
- Mint/burn events filtered: Focus is on trading activity
- Unknown routes: Transactions not matching known DEXs labeled "Unknown"
- Rate limits: Large limits may be slow due to RPC rate limiting
- Recent transactions only: Limited to recent blockchain history
Clean, elegant console output with:
- Color-coded messages (blue info, green success, yellow warning, red error)
- Transaction links with explorer URLs
- Boxed summaries for important operations
- Trade feed with formatted tables
Structured JSON logs written to logs/turnbackbot.log:
- Timestamps for all operations
- Full error details and stack traces
- Transaction signatures and metadata
- Rotation: 5 files × 10MB each
- Private Key: Never commit
.envfile or share private keys - Mainnet Warning: Banner displayed on every run
- Masked Secrets: Private keys and RPC URLs are masked in logs
- Confirmation Prompts: Required for all financial operations (unless --yes)
- Balance Checks: Validates sufficient funds before operations
- Reserve Protection: MIN_SOL_RESERVE ensures funds for future fees
- Use a dedicated wallet for fee operations
- Start with
--dry-runto test buybacks - Set conservative slippage limits
- Monitor logs for any anomalies
- Test on devnet/testnet before mainnet
- Keep Node.js and dependencies updated
npm run dev status
npm run dev -- buyback --amount 10 --dry-runnpm run buildnpm run clean
npm run buildsrc/
├── index.ts # Entry point, banner, initialization
├── cli.ts # Commander CLI commands
├── config.ts # Configuration loading & validation
├── solana/
│ ├── connection.ts # RPC connection with retry
│ ├── wallet.ts # Keypair loading (base58)
│ ├── token.ts # ATA, balances, token operations
│ └── tx.ts # Transaction sending & confirmation
├── fee/
│ └── claim.ts # Fee claim logic (SOL & SPL)
├── buyback/
│ └── buyback.ts # Buyback execution logic
├── swap/
│ └── jupiter.ts # Jupiter quote & swap integration
├── feed/
│ └── tradeFeed.ts # Trade feed detection & formatting
├── logs/
│ └── logger.ts # Winston file logs + pretty console
├── ui/
│ ├── banner.ts # ASCII banner with gradient
│ └── pretty.ts # Boxen tables & formatting
└── utils/
└── retry.ts # Retry logic with backoff
Ensure .env file exists and contains a valid base58 private key.
Wallet SOL balance is below MIN_SOL_RESERVE + transaction fees. Add more SOL.
- Check RPC connectivity
- Verify token mints are correct
- Ensure sufficient liquidity exists for the swap
- Try with a different RPC using
--rpc
- Token may have low trading activity
- Try increasing
--limit - Remove
--sincefilter to see all historical trades
- Switch to alternate RPC using
--rpcflag - Check RPC endpoint is accessible
- Retry logic will automatically handle temporary failures
MIT
For issues or questions:
- Check this README thoroughly
- Review logs in
logs/turnbackbot.log - Test with
--dry-runflag first - Verify configuration in
.env