Skip to content

High-performance suite for Solana HFT and DeFi: CLI, gRPC bots, and low-latency integrations with Jito, bloXroute, Jupiter, and DEXes

License

Notifications You must be signed in to change notification settings

outsmartchad/solana-trading-cli

Repository files navigation

🔗doc

Main Features

  • Create your own Solana SPL tokens on mainnet | Pump.fun

  • Swap tokens on Jupiter, Raydium, Orca, Meteora, and pump.fun

    • how to use Jupiter cli & trading functions: here
    • how to use Raydium cli & trading functions: here
    • how to use Orca cli & trading functions: here
    • how to use Meteora cli & trading functions: here
  • land transactions faster using Jito/bloXroute

  • Fetch the real-time price, lp-burn percentage, pool reserve and market cap of any liquidity pool

  • fixed % tp/sl module

  • First Open-Source gRPC pump.fun sniper bot (0.4-2 seconds latency) here

  • First Open-Source gRPC copy bot here

  • Open-source gRPC Raydium sniper bot here

  • Got everything needed to create your own trading bot

Credits

Installation 🛠️

  1. git clone https://github.com/outsmartchad/solana-trading-cli.git
  2. cd solana-trading-cli
  3. nvm install
  4. nvm use
  5. npm install
  6. ts-node test.ts (Remember to run this to test all the cli script)

Prerequisites 🚨

  1. we have added a .env.copy file in src/helpers/.env.copy for you to follow and paste your keys to the code (specify the custom jito fee if you need).
  2. Add your mainnet wallet secret key(must), devnet wallet secret key (optional), RPC endpoint(must) and shyft api key(optional)
  3. rename the .env.copy file to .env

Usage ✅:

Developer CLI:

  • Check the balance of a token in your wallet
  • wrap/unwrap solana
  • Create a new SPL token or zk-compressed token (on SOL mainnet/devnet/zk-devnet) and it will automatically mint to your wallet
  • boost volume of a token by creating buy and sell orders in just one transaction
  • Add or Remove liquidity to a pool
  • Buy, Sell, and launch token in pump.fun
  • monitor real-time pump-fun's create, trade, and complete bonding curve events

Trader CLI:

  • integrates both jito tips, bloXroute fee that land transactions faster
  • swap tokens on Raydium, Meteora, and Orca
  • swap tokens using Jupiter API
  • ws copy bot with auto-buy&sell
  • geyser grpc Pump.fun sniper bot with 0.4-2 seconds latency
  • geyser grpc Copy bot to copy trades from a target wallet address
  • geyser grpc Raydium sniper bot
  • easy-to-use tp/sl module

Features in Development 🚧:

  • With user-defined Jito tips and priority Lamports supported for every command
  • sniping tools on raydium using yellowstone geyser grpc
  • More Strategies for Trading dev
  • more features to come...

Commands </> (Please see the command examples in examples/ to get start~)

payer options is by default use the private key in .env file, but you can also specify the path to the secret key if you want to use another wallet

  1. Specify the token symbol, name, mint keypair(optional, will help u to generate), supply, decimals, path to metadata json file, path to image file, the cluster you want to use, and the file type(png, jpg, jpeg).

    ts-node create --payer <PATH_TO_SECRET_KEY> --symbol <TOKEN_SYMBOL> --token_name <TOKEN_NAME> --mint <PATH_TO_MINT_KEYPAIR> --supply <SUPPLY_OF_TOKEN> --decimals <DECIMALS> --metadata <PATH_METADATA_JSON> --image <PATH_TO_IMAGE> --cluster <CLUSTER> --priority-fee <PRIORITY_FEE> --file_type <FILE_TYPE>
  2. Specify the token address, the percentage of the token you want to burn and the cluster you want to use.

    ts-node burn --payer <PATH_TO_SECRET_KEY> --token_address <ADDRESS_TOKEN> --percentage <BURN_PERCENTAGE> --cluster <CLUSTER>
  3. Specify the token address and the cluster you want to use.

    ts-node revoke_authority --payer <PATH_TO_SECRET_KEY> --mint_address <ADDRESS_TOKEN> --cluster <CLUSTER> --mint --freeze
  4. Specify the token address you want to query and the cluster for boosting the volume of the token.

    ts-node boost_volume --token_address <TOKEN_ADDRESS> --payer <PATH_TO_SECRET_KEY> --cluster <CLUSTER> --sol_per_order <SOL_PER_ORDER>
  5. Specify the token address, the amount of Sol you want to swap, and the cluster you want to use.

    ts-node buy --payer <PATH_TO_SECRET_KEY> --token_address <ADDRESS_TOKEN> --sol <NUMBER_OF_SOL> --cluster <CLUSTER>
  6. Specify the token address, the percentage of the token you want to sell, and the cluster you want to use.

    ts-node sell --payer <PATH_TO_SECRET_KEY> --token_address <ADDRESS_TOKEN> --percentage <SELL_PERCENTAGE> --cluster <CLUSTER>
  7. Specify the token address, the pool id(optional, will help to find the pool with the most liquidity using the given token address), the amount of Sol you want to add, and the cluster you want to use.

    ts-node add_pool --payer <PATH_WALLET> --token_address <ADDRESS_TOKEN> --pool_id <POOL_ID> --sol <NUMBER_OF_SOL> --cluster <CLUSTER> --priority_fee <PRIORITY_FEE>
  8. Specify the token address, the percentage of the LP token you want to remove(1=1%), and the cluster you want to use.

    ts-node remove_pool --payer <PATH_PAYER> --token_address <TOKEN_ADDRESS> --percentage <LP_TOKEN_PERCENTAGE> --cluster <CLUSTER>
  9. wrap your sol to wsol.

    ts-node wrap_sol.js --size <size>
  10. unwrap your wsol to sol.

    ts-node unwrap_sol.js

Pump.fun commands

  1. Specify the path to your mint keypair, the amount of Sol you want to buy, the name of the token, the symbol of the token, the description of the token, the telegram link, the twitter link, the website link, and the image file path.

    ts-node createAndBuy --pathToMintKeypair <PATH_TO_MINT_KEYPAIR> --sol <NUMBER_OF_SOL> --name <TOKEN_NAME> --symbol <TOKEN_SYMBOL> --description <TOKEN_DESCRIPTION> --telegram <TELEGRAM_LINK> --twitter <TWITTER_LINK> --website <WEBSITE_LINK> --file <IMAGE_FILE_PATH>
  2. Specify the token address, the sol you want to buy

    ts-node buy --token_address <ADDRESS_TOKEN> --sol <NUMBER_OF_SOL>
  3. Specify the token address, the percentage of the token you want to sell

    ts-node sell --token_address <ADDRESS_TOKEN> --percentage <SELL_PERCENTAGE>

Code Usage </>

Token:

  • src/Token/create.js: create a spl token on devnet or mainnet with a given name, symbol, token image(using irys decentralized storage), metadata json file, supply, decimals, the code by default revokes the mint authority and freeze authority after creating the token so that the token has a cap and no one can feeze the token of the token holder, it will then mint all the token to your wallet

  • src/Token/burn.js: burn spl token with a given percentage of the token from your wallet

  • src/Token/revoke_authority.js: revoke mint and freeze authority of a given token

Trading:

  • src/Trading/dex/raydium/sell.js: selling spl token for SOL in your wallet using raydium dex swap function

  • src/Trading/dex/raydium/buy.js: buying spl token using SOL in your wallet using raydium dex swap function

  • src/Trading/volume/boost_volume.js: boost the volume of a token by creating a buy and sell order in just one transaction in a way to avoid possible MEV

  • src/Trading/memecoin_trading_strategies/copy-trading/copy-trade.js: copy trading program to follow a user-defined wallet address to auto-buy&sell

Transactions:

  • src/Transactions/jito_tips_tx_executor.js: execute the transaction by sending the bundles to Jito validators, they help us to land the transaction to the Solana blockchain faster than just using priority fee.

  • src/Transactions/simple_tx_executor.js: execute the transaction by sending the request to the Solana blockchain with a given priority gas fee.

Pool:

  • src/Pool/add_pool.js: add liquidity to a pool in a given token address, the code find the most liquid pool (TOKEN_ADDRESS/SOL) in the raydium dex and add liquidity to it. You need to specify the amount of liquidity(sol) you want to add.

  • src/Pool/remove_pool.js: remove liquidity from a pool in a given token address, the code find the most liquid pool (TOKEN_ADDRESS/SOL) in the raydium dex and remove liquidity from it. You need to specify the amount of percentage of liquidity you want to remove.

  • src/Pool/swap.js: swap token for another token in the raydium dex, src/Trading/dex/raydium/buy.js and src/Trading/dex/raydium/sell.js are based on this code.

  • src/Pool/query_pool.js: query the pool information of a given pool address in the raydium dex, it use shyft api to get the pool information. Please make sure you have your shyft api key inside the code before running this code.

Helper methods:

  • src/helpers/config.js: configuration file for the code.

  • src/helpers/util.js: utility functions for the code, including: send transactions to Solana blockchain, dropped transactions handling, etc.

  • src/helpers/check_balance.js: check the balance of a given token in your wallet

Project Structure

.solana-memecoin-cli
├── data
|   ├── Image_file                     # store image file (jpeg, jpg,...)
|   ├── metadata_file                  # store .json file about the token metadata
|   ├── payer_keypair                  # store wallet keypair .json
|   └── token_keypair                  # store token keypair .json
├── examples (Screenshots of Commands) # all screenshot to show how we use the command line tool
|   ├── add_liquidity                  # see how to add liquidity to a pool on Raydium
|   ├── burn_token                     # see how to burn a token with WSOL using Raydium swap
|   ├── create_token                   # see how to create a SPL token on mainnet or devnet
|   ├── buy_token                      # buy a token using raydium with both jito bundles and priority fees
|   ├── create_token                   # create a token with 0% extra fees on solana (mainnet or devnet)
|   ├── remove_liquidity               # remove some liquidity from a pool on Raydium
|   ├── boost_volume                   # boost the volume of a token on raydium
|   ├── pump_createAndInitialBuy       # create and initial buy token on pump.fun
|   ├── pump_buy                       # buy token on pump.fun
|   ├── pump_sell                      # sell token on pump.fun
|   └── sell_token                     # sell the token with a percentage using Raydium swap
└── src
    ├── helpers
    │   ├── .env
    │   ├── .env.copy
    │   ├── check_balance.js
    │   ├── config.js
    │   ├── unwrap_sol.js
    │   ├── util.js
    │   └── wrap_sol.js
    ├── Trading_dev
    │   ├── dex
    │   │   ├── meteora
    │   │   │   ├── swap.js
    │   │   │   ├── buy.js
    │   │   │   ├── sell.js
    │   │   │   ├── constants.js
    │   │   │   ├── fetch-pool.js
    │   │   │   ├── fetch-price.js
    │   │   │   └── idl.js
    │   │   └── orca
    │   │       └── #same as meteora/raydium
    │   └── memecoin_trading_strategies/
    │       ├── copy-trading/
    │       │   ├── copy-buy.js
    │       │   ├── copy-sell.js
    │       │   ├── copy-trade.js
    │       │   └── grpc-copy-bot/
    │       └── tp_sl
    │           ├── stop-loss.js
    │           └── take-profit.js
    ├── Memecoin_dev
    │   ├── bundled_launcher
    │   ├── market-making_dev/
    │   │   └── boost_volume.js
    │   └── sniping_dev
    │       ├── grpc_pump_sniper/
    │       └── grpc_raydium_sniper/
    ├── Transactions
    │   ├── bloXroute_tips_tx_executor.js
    │   ├── jito_tips_tx_executor.js
    │   └── simple_tx_executor.js
    ├── Token
    │   ├── zk-compression/
    │   ├── burn.js
    │   ├── create.js
    │   └── revoke_authority.js
    ├── raydium
    │   ├── Pool/
    │   │   ├── add_pool.js
    │   │   ├── create_pool.js
    │   │   ├── fetch_pool.js
    │   │   ├── formatAmmKeysById.js
    │   │   ├── query_pool.js
    │   │   ├── remove_pool.js
    │   │   └── swap.js
    │   ├── token-filters
    │   │   ├── lp-burn.js
    │   │   ├── maker-count.js
    │   │   ├── marketcap.js
    │   │   ├── pool-sol.js
    │   │   ├── tx-count.js
    │   │   └── volume.js
    │   ├── buy.js
    │   ├── constants.js
    │   ├── fetch-price.js
    │   ├── raydium_config.js
    │   └── sell.js
    ├── jupiter
    │   ├── swap/
    │   │   ├── buy-helper.js
    │   │   ├── sell-helper.js
    │   │   └── swap-helper.js
    │   ├── dca.js
    │   └── limit-order.js
    └── pumpfunsdk
        ├── pump-keypair/
        └── pumpdotfun-sdk
            ├── images/
            └── src
                ├── IDL/
                ├── pump-events-listener/
                │   └── listeners.js
                ├── amm.js
                ├── buy.js
                ├── createAndBuy.js
                ├── pumpfun.js
                ├── sell.js
                ├── tools.js
                └── util.js

Contributing

  • Contributions is wellcome!!!
  • Fork it
  • git checkout -b feature/YourNewFeature
  • git commit -m 'bug Fixed/added new feature'
  • git push origin feature/YourNewFeature
  • And Please open a pull request

Apply Latest Changes from remote repo

  • git stash -u # Stash your changes
  • git pull --rebase # Pull the latest changes
  • git stash pop # Apply Your stashed changes

Disclaimer

This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

Use at your own risk. The authors take no responsibility for any harm or damage caused by the use of this software. Users are responsible for ensuring the suitability and safety of this software for their specific use cases.

By using this software, you acknowledge that you have read, understood, and agree to this disclaimer.

If you think this project is useful, please give us a star🌟, it will help us a lot.

It is a work in progress, if you have any suggestions or any problems, please let us know!

Stay tuned for the updates.🤖