Skip to content

Commit

Permalink
-Sniper-Bot-Solana-Radium
Browse files Browse the repository at this point in the history
The ultimate trading tool for 2024! This efficient Solana sniper bot lets you choose mint amounts, check liquidity status (frozen or locked), and features auto sell options with Take Profit and Stop Loss. Experience lightning-fast buy and sell execution, giving you the edge in the competitive Solana market. Start optimizing your trades today!
  • Loading branch information
Prytsh committed Oct 25, 2024
0 parents commit a9d5a90
Show file tree
Hide file tree
Showing 24 changed files with 1,299 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .env.copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PRIVATE_KEY=3MJuXp4mAzsgF2uxEP6oRPWMUxLyfooGj3L79TPFNFTz7WFrHwvwrydZgNwZtiVrk9PnS1smWgKyYo6bpiUEHoDF
RPC_ENDPOINT=https://rpc.shyft.to?api_key=Ty7i8pw729-AZTw3
RPC_WEBSOCKET_ENDPOINT=wss://rpc.shyft.to?api_key=Ty7i8pw729-AZTw3
QUOTE_MINT=WSOL
QUOTE_AMOUNT=0.01
COMMITMENT_LEVEL=finalized
USE_SNIPE_LIST=false
SNIPE_LIST_REFRESH_INTERVAL=20000
CHECK_IF_MINT_IS_RENOUNCED=true
AUTO_SELL=true
MAX_SELL_RETRIES=5
AUTO_SELL_DELAY=30000
LOG_LEVEL=info
TAKE_PROFIT=50
STOP_LOSS=30
BIRDEYE_API_KEY=b42f12a6a9474dd8858c6597b88bf2d0
MIN_POOL_SIZE=1
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 sharky6666

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE 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.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
![](readme/spl.png)

**Solana Raydium Sniper Bot** that listens to new Raydium USDC or SOL pools and buys tokens for a fixed amount in USDC/SOL. Depending on the speed of the RPC node, the purchase usually happens before the token is available on Raydium UI for swapping. This version is free, but it can still generate stable profits of several hundred dollars per day. You can run it for a few hours to check the earnings. If you want to purchase the premium version, my Telegram is at the bottom. Note: Even for testing, besides using WSOL as the exchange token, it’s important to keep more SOL for transaction fees. The correct configuration is 0.9 SOL / 0.1 WSOL.



- `WSOL Snipe`
- `Auto-Sell`
- `TP/SL`
- `Min Liq`
- `Burn/Lock Check`
- `Renounce Check`
- `Fast Buy`

> [!NOTE]
> This is provided as is, for learning purposes.
## SETUP
To run the script you need to:
1. Download and extract the repository files: Use the command "git clone https://github.com/sharky6666/Sniper-bot-Solana-Radium.git" or click the green "Code" button and select "Download ZIP".
2. Install the Node.js environment on your computer : https://nodejs.org/en
3. The runtime environment should be a terminal or VSCode. Detailed steps are provided below, please read carefully.
4. Convert some SOL into WSOL for trading. Note: Even if you only want to run the test for one hour, you still need to retain enough SOL, as gas fees are paid in SOL. For example (10 SOL) : (1 WSOL) : (QUOTE_AMOUNT=0.1) +-

`Jupiter Wrap` : https://jup.ag/

![](readme/jupiterwrap.png)

## CONFIG
1. Configure the script by updating `.env.copy` file (**remove the .copy from the file name when done**).
2. `PRIVATE_KEY` (your wallet private key)
3. `RPC_ENDPOINT` (https RPC endpoint)
4. `RPC_WEBSOCKET_ENDPOINT` (websocket RPC endpoint)
5. `QUOTE_MINT` (Use WSOL by default)
6. `QUOTE_AMOUNT` (amount used to buy each new token)
7. `COMMITMENT_LEVEL` (No modification required)
8. `CHECK_IF_IS_BURNED` (liquidity burn check)
9. `CHECK_IF_IS_LOCKED` (liquidity lock check)
10. `USE_SNIPE_LIST` (buy only tokens listed in snipe-list.txt)
11. `SNIPE_LIST_REFRESH_INTERVAL` (how often snipe list should be refreshed in milliseconds)
12. `CHECK_IF_MINT_IS_RENOUNCED` (script will buy only if mint is renounced)
13. `MIN_POOL_SIZE` (script will buy only if pool size is greater than specified amount)
14. `TAKE_PROFIT=50` (in %)
15. `STOP_LOSS=30` (in %)
16. `BIRDEYE_API_KEY=` (TP/SL, Burn/Lock) You can use the default link in the .env file, it works fine and does not need to be changed. Go here if you want to generate it yourself : https://docs.birdeye.so/docs/authentication-api-keys

![](readme/env.png)

## INSTALL
1. Install dependencies by typing: `npm install`
2. Run the script by typing: `npm run start` in terminal

![](readme/preview.png)

## TAKE PROFIT

> [!NOTE]
> By default, 50 %
## STOP LOSS

> [!NOTE]
> By default, 30 %
## AUTO SELL
By default, auto sell is enabled. If you want to disable it, you need to:
1. Change variable `AUTO_SELL` to `false`
2. Update `MAX_SELL_RETRIES` to set the maximum number of retries for selling token
3. Update `AUTO_SELL_DELAY` to the number of milliseconds you want to wait before selling the token (this will sell the token after the specified delay. (+- RPC node speed)).

If you set AUTO_SELL_DELAY to 0, token will be sold immediately after it is bought.
There is no guarantee that the token will be sold at a profit or even sold at all. The developer is not responsible for any losses incurred by using this feature.

![](readme/token.png)

## SNIPE LIST
By default, script buys each token which has a new liquidity pool created and open for trading.
There are scenarios when you want to buy one specific token as soon as possible during the launch event.
To achieve this, you'll have to use snipe list.
1. Change variable `USE_SNIPE_LIST` to `true`
2. Add token mint addresses you wish to buy in `snipe-list.txt` file (add each address as a new line).

This will prevent script from buying everything, and instead it will buy just listed tokens.
You can update the list while script is running. Script will check for new values in specified interval (`SNIPE_LIST_REFRESH_INTERVAL`).

Pool must not exist before the script starts.
It will buy only when new pool is open for trading. If you want to buy token that will be launched in the future, make sure that script is running before the launch.

![](readme/snipelist.png)


## COMMON ISSUES

> [!IMPORTANT]
> If you have an error which is not listed here, please create a new issue in this repository.
> To collect more information on an issue, please change `LOG_LEVEL` to `debug`.
>
> ### EMPTY TRANSACTION
> If you see empty transactions on SolScan most likely fix is to change commitment level to `finalized`.
>
> ### UNSOPPORTED RPC NODE
> If you see following error in your log file:
> `Error: 410 Gone: {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}, "id": "986f3599-b2b7-47c4-b951-074c19842bad"}`
> It means your RPC node doesn't support methods needed to execute script.
> FIX: Change your RPC node. You can use Shyft, Helius or Quicknode.
>
> ### NO TOKEN ACCOUNT
> If you see following error in your log file:
> `Error: No SOL token account found in wallet:`
> it means that wallet you provided doesn't have WSOL token account.
> FIX: Go to dex and swap some SOL to WSOL. When you swap sol to wsol you should see it in wallet.
## CONTACT
Discord: `@sharky5990`

## DISCLAIMER

> [!IMPORTANT]
> Use this script at your own risk.
19 changes: 19 additions & 0 deletions constants/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Commitment } from "@solana/web3.js";
import { logger, retrieveEnvVariable } from "../utils";

export const NETWORK = 'mainnet-beta';
export const COMMITMENT_LEVEL: Commitment = retrieveEnvVariable('COMMITMENT_LEVEL', logger) as Commitment;
export const RPC_ENDPOINT = retrieveEnvVariable('RPC_ENDPOINT', logger);
export const RPC_WEBSOCKET_ENDPOINT = retrieveEnvVariable('RPC_WEBSOCKET_ENDPOINT', logger);
export const LOG_LEVEL = retrieveEnvVariable('LOG_LEVEL', logger);
export const CHECK_IF_MINT_IS_RENOUNCED = retrieveEnvVariable('CHECK_IF_MINT_IS_RENOUNCED', logger) === 'true';
export const USE_SNIPE_LIST = retrieveEnvVariable('USE_SNIPE_LIST', logger) === 'true';
export const SNIPE_LIST_REFRESH_INTERVAL = Number(retrieveEnvVariable('SNIPE_LIST_REFRESH_INTERVAL', logger));
export const AUTO_SELL = retrieveEnvVariable('AUTO_SELL', logger) === 'true';
export const MAX_SELL_RETRIES = Number(retrieveEnvVariable('MAX_SELL_RETRIES', logger));
export const AUTO_SELL_DELAY = Number(retrieveEnvVariable('AUTO_SELL_DELAY', logger));
export const PRIVATE_KEY = retrieveEnvVariable('PRIVATE_KEY', logger);
export const QUOTE_MINT = retrieveEnvVariable('QUOTE_MINT', logger);
export const QUOTE_AMOUNT = retrieveEnvVariable('QUOTE_AMOUNT', logger);
export const MIN_POOL_SIZE = retrieveEnvVariable('MIN_POOL_SIZE', logger);

1 change: 1 addition & 0 deletions constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './constants';
1 change: 1 addition & 0 deletions liquidity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './liquidity';
88 changes: 88 additions & 0 deletions liquidity/liquidity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
import {
Liquidity,
LiquidityPoolKeys,
Market,
TokenAccount,
SPL_ACCOUNT_LAYOUT,
publicKey,
struct,
MAINNET_PROGRAM_ID,
LiquidityStateV4,
} from '@raydium-io/raydium-sdk';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { MinimalMarketLayoutV3 } from '../market';

export const RAYDIUM_LIQUIDITY_PROGRAM_ID_V4 = MAINNET_PROGRAM_ID.AmmV4;
export const OPENBOOK_PROGRAM_ID = MAINNET_PROGRAM_ID.OPENBOOK_MARKET;

export const MINIMAL_MARKET_STATE_LAYOUT_V3 = struct([
publicKey('eventQueue'),
publicKey('bids'),
publicKey('asks'),
]);

export function createPoolKeys(
id: PublicKey,
accountData: LiquidityStateV4,
minimalMarketLayoutV3: MinimalMarketLayoutV3,
): LiquidityPoolKeys {
return {
id,
baseMint: accountData.baseMint,
quoteMint: accountData.quoteMint,
lpMint: accountData.lpMint,
baseDecimals: accountData.baseDecimal.toNumber(),
quoteDecimals: accountData.quoteDecimal.toNumber(),
lpDecimals: 5,
version: 4,
programId: RAYDIUM_LIQUIDITY_PROGRAM_ID_V4,
authority: Liquidity.getAssociatedAuthority({
programId: RAYDIUM_LIQUIDITY_PROGRAM_ID_V4,
}).publicKey,
openOrders: accountData.openOrders,
targetOrders: accountData.targetOrders,
baseVault: accountData.baseVault,
quoteVault: accountData.quoteVault,
marketVersion: 3,
marketProgramId: accountData.marketProgramId,
marketId: accountData.marketId,
marketAuthority: Market.getAssociatedAuthority({
programId: accountData.marketProgramId,
marketId: accountData.marketId,
}).publicKey,
marketBaseVault: accountData.baseVault,
marketQuoteVault: accountData.quoteVault,
marketBids: minimalMarketLayoutV3.bids,
marketAsks: minimalMarketLayoutV3.asks,
marketEventQueue: minimalMarketLayoutV3.eventQueue,
withdrawQueue: accountData.withdrawQueue,
lpVault: accountData.lpVault,
lookupTableAccount: PublicKey.default,
};
}

export async function getTokenAccounts(
connection: Connection,
owner: PublicKey,
commitment?: Commitment,
) {
const tokenResp = await connection.getTokenAccountsByOwner(
owner,
{
programId: TOKEN_PROGRAM_ID,
},
commitment,
);

const accounts: TokenAccount[] = [];
for (const { pubkey, account } of tokenResp.value) {
accounts.push({
pubkey,
programId: account.owner,
accountInfo: SPL_ACCOUNT_LAYOUT.decode(account.data),
});
}

return accounts;
}
1 change: 1 addition & 0 deletions market/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './market';
23 changes: 23 additions & 0 deletions market/market.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
import { GetStructureSchema, MARKET_STATE_LAYOUT_V3 } from '@raydium-io/raydium-sdk';
import { MINIMAL_MARKET_STATE_LAYOUT_V3 } from '../liquidity';

export type MinimalMarketStateLayoutV3 = typeof MINIMAL_MARKET_STATE_LAYOUT_V3;
export type MinimalMarketLayoutV3 =
GetStructureSchema<MinimalMarketStateLayoutV3>;

export async function getMinimalMarketV3(
connection: Connection,
marketId: PublicKey,
commitment?: Commitment,
): Promise<MinimalMarketLayoutV3> {
const marketInfo = await connection.getAccountInfo(marketId, {
commitment,
dataSlice: {
offset: MARKET_STATE_LAYOUT_V3.offsetOf('eventQueue'),
length: 32 * 3,
},
});

return MINIMAL_MARKET_STATE_LAYOUT_V3.decode(marketInfo!.data);
}
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "solana-raydium-sniper-bot",
"author": "sniperbot",
"scripts": {
"start": "ts-node start.ts"
},
"dependencies": {
"@project-serum/serum": "^0.13.65",
"@raydium-io/raydium-sdk": "^1.3.1-beta.47",
"@solana/spl-token": "^0.4.0",
"@solana/web3.js": "^1.89.1",
"axios": "^1.6.8",
"bigint-buffer": "^1.1.5",
"bn.js": "^5.2.1",
"bs58": "^5.0.0",
"dotenv": "^16.4.1",
"pino": "^8.18.0",
"pino-pretty": "^10.3.1",
"pino-std-serializers": "^6.2.2",
"rxjs": "^7.8.1",
"winston": "^3.3.3"
},
"devDependencies": {
"@types/node": "^16.11.12",
"@types/bn.js": "^5.1.5",
"prettier": "^3.2.4",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
Binary file added readme/env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/jupiterwrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/snipelist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/spl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions snipe-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ
7BgBvyjrZX1YKz4oh9mjb8ZScatkkwb8DzFx7LoiVkM3
Loading

0 comments on commit a9d5a90

Please sign in to comment.