Giter Club home page Giter Club logo

solana-spl-token-sniper's Introduction

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.

solana-spl-token-sniper's People

Contributors

danbayk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.