Skip to content

xeaiow/solana-spl-token-sniper

 
 

Repository files navigation

Solana SPL-Token Sniper

Overview

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.

How the program works

  • 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.

Setup

Use the following instructions to install and run the program (assume node is installed):

  1. Create a Solana wallet and obtain public and private keys (Phantom wallet recommended).
  2. Obtain a Solana RPC/websocket connection, can use https://api.mainnet-beta.solana.com and wss://api.mainnet-beta.solana.com for testing purposes.
  3. Run npm install.
  4. Inside the ./swap/config.js file, enter public key, private key, and both RPC connections.

Running the scripts

This project contains two different strategies for sniping new liquidity pairs:\

Strategy #1:

  • 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.

Strategy #2:

  • 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.

Future improvements

  1. Automatic position exit strategy: Implementing an automatic exit strategy based on user-specified parameters. Currently have to manually swap the tokens back to SOL.
  2. Rugpull prevention: SPL-Token are often rugpulled after launch, prevent the purchase of tokens with low-liquidity and no social media pages.
  3. 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.

About

Solana SPL-Token sniper for new Raydium liquidity pools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%