A Solana trading bot that listens to transaction events, identifies buy transactions, evaluates profit/loss conditions, and performs automated trading using Raydium SDK, Jito block engine bundles, and gRPC stream subscription.
- Detects buy transactions across multiple wallet addresses via gRPC
- Automatically places buy orders on new mints if profit conditions are met
- Monitors token price via Raydium liquidity pool
- Evaluates take-profit, stop-loss, and expiry conditions
- Sends sell transactions via Jito bundles for MEV inclusion
- Uses
PriceListenerMintto reactively listen to token price changes - Built-in position manager for active trades
- Solana Web3.js
- Raydium SDK Client (custom)
- gRPC via Yellowstone for transaction streaming
- Jito Block Engine for bundle submission
- Anchor Wallet for signing
- Written in TypeScript
git clone https://github.com/Sandwich-Co/copy-trader.git cd copy-tradernpm installReplace the private key and RPC/grpc endpoints as needed in main.ts:
let botKp = Keypair.fromSecretKey(bs58.decode("<YOUR_PRIVATE_KEY>")); let rpcUrl = "https://mainnet.helius-rpc.com/?api-key=<YOUR-API-KEY>"; let grpcUrl = "https://your.grpc.endpoint";You can toggle isVps to switch between local and production endpoints.
npx ts-node src/main.ts-
Initialization:
- Initializes Raydium SDK and Jito client.
- Fetches LP info and sets up gRPC subscription.
-
Buy Logic:
- On detecting a buy transaction (from external wallets), it checks if the mint is new and not seen before.
- Builds a buy transaction using Raydium SDK.
- Signs and sends the transaction through Jito bundles.
-
Position Tracking:
- Each buy initializes a
Positionwith stop-loss, take-profit, and expiry conditions. - Uses
PriceListenerMintto track price updates.
- Each buy initializes a
-
Sell Logic:
- If position value exceeds thresholds or expires, the bot builds a sell transaction and submits it via Jito.
-
Cleanup:
- If a sell is detected from own wallet, it removes position and stops listener.
List of wallet addresses to monitor can be modified via the wallets array in main.ts. These addresses will be included in the gRPC transaction stream filter.
- Keep your bot private key secure.
- Do not commit or share your private key.
- Monitor Jito and gRPC endpoints for rate limits or access issues.
MIT License