This project is Solana SPL-Token sniper which aims to swap (purchase) new Raydium liquidity pairs within the first price candle by scanning Solana blockchain transactions.
- Scans the Solana blockchain for an "initialize market" transaction which is decoded for all necessary liquidity pool keys and related information.
- Begins sending/retrying the "swap" transaction until the liquidity pool is live, minimizing the time between the transaction and the creation of the LP.
- Upon sending a valid transaction, begins to track the users position with current price/percent gain by scanning and decoding on-chain liquidity pool information in order to get the most accurate data.
Use the following instructions to install and run the program (assume node is installed):
- Create a Solana wallet and obtain public and private keys (Phantom wallet recommended).
- Obtain a Solana RPC/websocket connection, can use
https://api.mainnet-beta.solana.com
andwss://api.mainnet-beta.solana.com
for testing purposes. - Run
npm install
. - Inside the
./swap/config.js
file, enter public key, private key, and both RPC connections.
This project contains two different strategies for sniping new liquidity pairs:\
- The first strategy obtains necessary liquidity pool keys from the transaction which creates the LP. To run this script with
node websocket.js
. The transaction may fail multiple times before succeeding as Solana transactions can be dropped with certain RPC nodes. - NOTE: this script is slower as it must wait for the "add liquidity" transaction to reach "confirmed" status before obtaining pool data. This results in ~30 seconds between the pool creation and swap transaction.
- The second strategy obtains necessary liquidity pool keys from the "initialize market" transaction which typically occurs ~2 minutes before the LP is live on Raydium. This allows for all pool keys to be precomputed. This script also retries the swap transaction multiple times per second which allows for the swap to be sent during the "processed" state of the "add liquidity" transaction instead of "confirmed", greatly reducing the time between the creation of the LP and the swap transaction. This script can be run with
node findInitMarketTx.js
.
Both scripts utilize the same swapping/position management system found in./swap/swap.js
and/swap/swap3.js
.
- Automatic position exit strategy: Implementing an automatic exit strategy based on user-specified parameters. Currently have to manually swap the tokens back to SOL.
- Rugpull prevention: SPL-Token are often rugpulled after launch, prevent the purchase of tokens with low-liquidity and no social media pages.
- Reducing tx time: Reduce time between LP creation and swap tx by utilizing a faster RPC connection and minimizing RPC calls before sending swap tx.