Skip to content

ARBProtocol/solana-jupiter-bot

Repository files navigation

⚠️ This bot can lead to loss of your funds, use at your own risk. Start with small amounts and protect your keys.

This README is not complete. Try asking the community on the ARB Discord if you have any questions.


Arb Jupiter Bot - JUPV4

JupiterSDK Twitter Discord

This bot is an open-source CLI tool that allows you to automate your crypto trading strategies on the Solana blockchain. The bot is currently written in JS and uses the Jupiter V4 SDK to find routes and execute trades.

nav


features

  • mainnet network support

  • all Jupiter Aggregator coins

  • easy to use Config Wizard

  • CLI UI

  • Trading strategies

    • Arbitrage strategy
    • PingPong strategy
  • Slippage management

    • BPS slippage
  • Profit management

    • min profit % (target)
  • Charts

    • latency chart
    • simulated profit chart
  • History & Statistics

    • history of trades (CLI table)
    • statistics of all trades
  • Advanced

    • custom UI colors
    • min. interval beetween iterations (to avoid 429)
  • hotkeys

  • lots of fun

CLI UI

⚠️ EPILEPSY WARNING - CLI UI is constantly refreshed and may be disruptive for sensitive people

🔥 CLI UI helps you monitor your trading strategy with little impact on performance.

CLI UI currently displays a simulated profit chart and latency chart. The latency chart shows you the time taken to compute routes with Jupiter SDK.

All trades are stored in trades history and will be shown in the table. Table is limited to 5 entries, but history stores all trades.

💡 UI elements can be hidden or shown using hotkeys.

· back to top ·

install

Please don't use npm, use yarn instead.

$ git clone https://github.com/arbprotocol/solana-jupiter-bot && cd solana-jupiter-bot
$ yarn

Set your wallet private key in the .env file

SOLANA_WALLET_PRIVATE_KEY=hgq847chjjjJUPITERiiiISaaaAWESOMEaaANDiiiIwwWANNAbbbBErrrRICHh

Set the default RPC ARB Protocol RPC is used by default

DEFAULT_RPC=https://my-super-lazy-rpc.gov
ALT_RPC_LIST=https://change-this-url-in-env.gov,https://change-alt-urls-in-env.com

· back to top ·

quickstart

  1. Clone this repo
  2. Install dependencies
  3. Set your wallet private key in the .env file
  4. Run yarn start to start the Config Wizard
  5. Follow the steps in the Config Wizard
  Usage:
    $ yarn start
      This will open Config Wizard and start the bot

    $ yarn trade
      Start Bot and Trade with latest config

    $ yarn wizard
      Start Config Wizard only

some tips 👀

🔨 The bot is a Tool, not a holy grail that will make you rich just by running it. If you don't know what you are doing, you WILL lose money.

👉 RPC / Network speed & good trading strategy is the key to success. You can speed up the bor but disabling AMMS not being used or too slow.

🙉 Not everything is so obvious. eg. a larger trade size can lead to smaller profits than a lower trade size.

🛑 If you frequently get 429 errors, you should increase the minInterval in the config (Advanced step).

🥵 You want to arbitrage USDC or USDT? YES! Guess what? E V E R Y O N E wants to arbitrage USDC or USDT. If you don't have access to a super fancy RPC, there is a good chance you will end up with lots of 'Slippage errors'.

🥶 SLIPPAGE ERRORS are not bot errors. They are part of the Solana blockchain. If you want to avoid them you have to go with the super fancy RPC or pick the less popular pairs/coins - just try to find out which ones hold profit opportunities.

🏓 PingPong strategy is really poweful on sideways markets. Search through charts the coins that are constantly moving up and down.

📡 If you can't run the bot, it's likely something wrong with the network, RPC, or config file.

😬 Don't like the intro? You can disable it in the .env file with SKIP_INTRO=true

· back to top ·

hotkeys

While the bot is running, you can use some hotkeys that will change the behaviour of the bot or UI

[H] - show/hide Help

[CTRL] + [C] - obviously it will kill the bot

[I] - incognito RPC Hide RPC address - helpful when streaming / screenshotting

[E] - force execution with current setup & profit (may result in loss - you bypass all rules)

[R] - force execution, stop the bot (may result in loss - you bypass all rules)

[L] - show/hide latency chart (of Jupiter computeRoutes())

[P] - show/hide profit chart

[T] - show/hide trade history table *table isn't working yet

[S] - simulation mode switch (enable/disable trading)

· back to top ·

Balance management and error handling

Balances are checked when the bot loads and also as it is running to avoid it running when there is insufficient balance (to help prevent spamming NSF transactions). There is also a setting in the bot that will end the process when too many errors have stacked up. This acts as a fail-safe. It is set to 100 errors at the moment. If you want to adjust this setting it is located currently in the /src/bot/swap.js file line 78.

if (cache.tradeCounter.errorcount>100){
	console.log('Error Count is too high for swaps: '+cache.tradeCounter.errorcount);
	console.log('Ending to stop endless transactions failing');
	process.exit();
}

Slippage management

Advanced slippage handling has been added to the code. USE AT YOUR OWN RISK! To enable it you need to set adaptiveSlippage: 1 in the config.json to enable this feature. This will adjust the slippage for the route to be a percentage of the total less the required profit. It takes the simulated profit and removes the percentage required profit to create an adaptive slippage with some handling for the size of the profit detected. Related code area is shown below anv can be edited as needed.

var slippagerevised = (100*(simulatedProfit-cache.config.minPercProfit+(slippage/100))).toFixed(3)

if (slippagerevised>500) {
	// Make sure on really big numbers it is only 30% of the total
	slippagerevised = (0.3*slippagerevised).toFixed(3);
} else {
	slippagerevised = (0.8*slippagerevised).toFixed(3);
}

BPS slippage

Simple BPS slippage. The slippage is set in the Jupiter SDK. Make sure your percentage profit is a few points above the slippage. For instance 0.1% profit would need to have a slippage BPS below 10 to break even. Best to leave a little wiggle rooom for safety as low liquidity can cause your result to be a new netagive. Always test and check to make sure you are trading in a pair that can support the size you are swapping.

Speed of Lookups

One way you can speed up the lookup of the bot is to disable unused routes or ones that are too slow to be meaningful. Be careful here as you do not want to turn off the wrong ones. You can check with Birdeye and Jupiter front end to see the main pools and then do an analysis of the key ones for the pair you are swapping. Others can be turned off to gain some speed. Always test with a small amount and expect you will LOSE to begin with if you turn off so many you access only low liquidity pools. Edit at your own RISK.

Edit the /src/bot/setup.js file to alter these settings:

To turn one off, set the value to true

		ammsToExclude: {
                    'Aldrin': false,
                    'Crema': false,
                    'Cropper': true,
                    'Cykura': true,
                    'DeltaFi': false,
                    'GooseFX': true,
                    'Invariant': false,
                    'Lifinity': false,
                    'Lifinity V2': false,
                    'Marinade': false,
                    'Mercurial': false,
                    'Meteora': false,
                    'Raydium': false,
                    'Raydium CLMM': false,
                    'Saber': false,
                    'Serum': true,
                    'Orca': false,
                    'Step': false, 
                    'Penguin': false,
                    'Saros': false,
                    'Stepn': true,
                    'Orca (Whirlpools)': false,   
                    'Sencha': false,
                    'Saber (Decimals)': false,
                    'Dradex': true,
                    'Balansol': true,
                    'Openbook': false,
                    'Marco Polo': false,
                    'Oasis': false,
                    'BonkSwap': false,
                    'Phoenix': false,
                    'Symmetry': true,
                    'Unknown': true			
		}

Pro ARB trading configurations

In some circumstances -- when speed is a key element to the success of ARB trading, enabling the setting onlyDirectRoutes: true may be an option to explore. This feature limits the available routes supplied via the JUP4 SDK to a subset of what is available by only returning direct routes.

It is possible this can help make things route faster and convert more trades. It definitely does not guarantee the best route. You need to ensure the routes and pools are sufficient for the amount you are trading. So always test with a very small amount and use at your own risk. Setting it on the wrong pair can cause you to lose tokens.

This setting can be found in the ./src/bot/index.js file as shown below:

const routes = await jupiter.computeRoutes({
	inputMint: new PublicKey(inputToken.address),
	outputMint: new PublicKey(outputToken.address),
	amount: amountInJSBI,
	slippageBps: slippage,
	feeBps: 0,
	forceFetch: true,
	**onlyDirectRoutes: false,**
        	filterTopNResult: 2,
	enforceSingleTx: false,
	swapMode: 'ExactIn',
});

· back to top ·

contributing

Arb Jupiter Bot is an open source project and contributions are welcome.

· back to top ·

license

MIT yay! 🎉

· back to top ·

risk disclaimer

This software is provided as is, without any warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the authors be liable for any claim, damages, or other liability.

· back to top ·