mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-10 04:22:05 +10:00
cleanup
This commit is contained in:
@ -5,4 +5,5 @@ QUOTE_MINT=WSOL
|
|||||||
QUOTE_AMOUNT=0.1
|
QUOTE_AMOUNT=0.1
|
||||||
COMMITMENT_LEVEL=finalized
|
COMMITMENT_LEVEL=finalized
|
||||||
USE_SNIPE_LIST=false
|
USE_SNIPE_LIST=false
|
||||||
SNIPE_LIST_REFRESH_INTERVAL=30000
|
SNIPE_LIST_REFRESH_INTERVAL=30000
|
||||||
|
CHECK_IF_MINT_IS_RENOUNCED=false
|
||||||
@ -20,6 +20,7 @@ In order to run the script you need to:
|
|||||||
- COMMITMENT_LEVEL
|
- COMMITMENT_LEVEL
|
||||||
- USE_SNIPE_LIST (buy only tokens listed in snipe-list.txt)
|
- USE_SNIPE_LIST (buy only tokens listed in snipe-list.txt)
|
||||||
- SNIPE_LIST_REFRESH_INTERVAL (how often snipe list should be refreshed in milliseconds)
|
- SNIPE_LIST_REFRESH_INTERVAL (how often snipe list should be refreshed in milliseconds)
|
||||||
|
- CHECK_IF_MINT_IS_RENOUNCED (script will buy only if mint is renounced)
|
||||||
- Install dependencies by typing: `npm install`
|
- Install dependencies by typing: `npm install`
|
||||||
- Run the script by typing: `npm run buy` in terminal
|
- Run the script by typing: `npm run buy` in terminal
|
||||||
|
|
||||||
|
|||||||
38
buy.ts
38
buy.ts
@ -31,7 +31,7 @@ import {
|
|||||||
} from './liquidity';
|
} from './liquidity';
|
||||||
import { retrieveEnvVariable } from './utils';
|
import { retrieveEnvVariable } from './utils';
|
||||||
import { getMinimalMarketV3, MinimalMarketLayoutV3 } from './market';
|
import { getMinimalMarketV3, MinimalMarketLayoutV3 } from './market';
|
||||||
import { MintLayout } from "./types";
|
import { MintLayout } from './types';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
import bs58 from 'bs58';
|
import bs58 from 'bs58';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
@ -101,6 +101,7 @@ let commitment: Commitment = retrieveEnvVariable(
|
|||||||
logger,
|
logger,
|
||||||
) as Commitment;
|
) as Commitment;
|
||||||
|
|
||||||
|
const CHECK_IF_MINT_IS_RENOUNCED = retrieveEnvVariable('CHECK_IF_MINT_IS_RENOUNCED', logger) === 'true';
|
||||||
const USE_SNIPE_LIST = retrieveEnvVariable('USE_SNIPE_LIST', logger) === 'true';
|
const USE_SNIPE_LIST = retrieveEnvVariable('USE_SNIPE_LIST', logger) === 'true';
|
||||||
const SNIPE_LIST_REFRESH_INTERVAL = Number(
|
const SNIPE_LIST_REFRESH_INTERVAL = Number(
|
||||||
retrieveEnvVariable('SNIPE_LIST_REFRESH_INTERVAL', logger),
|
retrieveEnvVariable('SNIPE_LIST_REFRESH_INTERVAL', logger),
|
||||||
@ -200,36 +201,31 @@ export async function processRaydiumPool(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mintable = await checkMintable(poolState.baseMint)
|
if (CHECK_IF_MINT_IS_RENOUNCED) {
|
||||||
if(mintable) {
|
const mintOption = await checkMintable(poolState.baseMint);
|
||||||
console.log('Mintable check passed, proceding with buy');
|
|
||||||
|
if (mintOption !== true) {
|
||||||
|
logger.warn({ ...poolState, }, 'Skipping, owner can mint tokens!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await buy(id, poolState);
|
await buy(id, poolState);
|
||||||
} else {
|
|
||||||
console.log('Skipping, owner can mint tokens!')
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error({ ...poolState, error: e }, `Failed to process pool`);
|
logger.error({ ...poolState, error: e }, `Failed to process pool`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkMintable(vault: PublicKey) {
|
export async function checkMintable(vault: PublicKey): Promise<boolean | undefined> {
|
||||||
try {
|
try {
|
||||||
let { data } = (await solanaConnection.getAccountInfo(vault)) || {};
|
let { data } = (await solanaConnection.getAccountInfo(vault)) || {};
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Deserialize Data.
|
const deserialize = MintLayout.decode(data), mintAuthorityOption = deserialize.mintAuthorityOption;
|
||||||
const deserialize = MintLayout.decode(data)
|
return mintAuthorityOption === 0;
|
||||||
const mintoption = deserialize.mintAuthorityOption
|
} catch (e) {
|
||||||
|
logger.error({ mint: vault, error: e }, `Failed to check if mint is renounced`);
|
||||||
if (mintoption === 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +315,7 @@ async function buy(
|
|||||||
{
|
{
|
||||||
mint: accountData.baseMint,
|
mint: accountData.baseMint,
|
||||||
url: `https://solscan.io/tx/${signature}?cluster=${network}`,
|
url: `https://solscan.io/tx/${signature}?cluster=${network}`,
|
||||||
dexURL: `https://dexscreener.com/solana/${accountData.baseMint}?maker=${wallet.publicKey}`
|
dexURL: `https://dexscreener.com/solana/${accountData.baseMint}?maker=${wallet.publicKey}`,
|
||||||
},
|
},
|
||||||
'Buy',
|
'Buy',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user