mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-10 04:22:05 +10:00
Merge pull request #90 from TheoBrigitte/freezable
Add freezable filter
This commit is contained in:
@ -43,6 +43,7 @@ FILTER_CHECK_DURATION=60000
|
||||
FILTER_CHECK_INTERVAL=2000
|
||||
CONSECUTIVE_FILTER_MATCHES=3
|
||||
CHECK_IF_MINT_IS_RENOUNCED=true
|
||||
CHECK_IF_FREEZABLE=true
|
||||
CHECK_IF_BURNED=true
|
||||
MIN_POOL_SIZE=5
|
||||
MAX_POOL_SIZE=50
|
||||
|
||||
@ -79,6 +79,7 @@ You should see the following output:
|
||||
- Pool must not exist before the script starts.
|
||||
- `SNIPE_LIST_REFRESH_INTERVAL` - Interval in milliseconds to refresh the snipe list.
|
||||
- `CHECK_IF_MINT_IS_RENOUNCED` - Set to `true` to buy tokens only if their mint is renounced.
|
||||
- `CHECK_IF_FREEZABLE` - Set to `true` to buy tokens only if they are not freezable.
|
||||
- `CHECK_IF_BURNED` - Set to `true` to buy tokens only if their liquidity pool is burned.
|
||||
- `MIN_POOL_SIZE` - Bot will buy only if the pool size is greater than or equal the specified amount.
|
||||
- Set `0` to disable.
|
||||
|
||||
1
bot.ts
1
bot.ts
@ -26,6 +26,7 @@ import { WarpTransactionExecutor } from './transactions/warp-transaction-executo
|
||||
export interface BotConfig {
|
||||
wallet: Keypair;
|
||||
checkRenounced: boolean;
|
||||
checkFreezable: boolean;
|
||||
checkBurned: boolean;
|
||||
minPoolSize: TokenAmount;
|
||||
maxPoolSize: TokenAmount;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { Connection } from '@solana/web3.js';
|
||||
import { LiquidityPoolKeysV4, Token, TokenAmount } from '@raydium-io/raydium-sdk';
|
||||
import { BurnFilter } from './burn.filter';
|
||||
import { RenouncedFilter } from './renounced.filter';
|
||||
import { RenouncedFreezeFilter } from './renounced.filter';
|
||||
import { PoolSizeFilter } from './pool-size.filter';
|
||||
import { CHECK_IF_BURNED, CHECK_IF_MINT_IS_RENOUNCED, logger } from '../helpers';
|
||||
import { CHECK_IF_BURNED, CHECK_IF_FREEZABLE, CHECK_IF_MINT_IS_RENOUNCED, logger } from '../helpers';
|
||||
|
||||
export interface Filter {
|
||||
execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>;
|
||||
@ -31,8 +31,8 @@ export class PoolFilters {
|
||||
this.filters.push(new BurnFilter(connection));
|
||||
}
|
||||
|
||||
if (CHECK_IF_MINT_IS_RENOUNCED) {
|
||||
this.filters.push(new RenouncedFilter(connection));
|
||||
if (CHECK_IF_MINT_IS_RENOUNCED || CHECK_IF_FREEZABLE) {
|
||||
this.filters.push(new RenouncedFreezeFilter(connection, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_FREEZABLE));
|
||||
}
|
||||
|
||||
if (!args.minPoolSize.isZero() || !args.maxPoolSize.isZero()) {
|
||||
|
||||
@ -4,23 +4,29 @@ import { Connection } from '@solana/web3.js';
|
||||
import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
|
||||
import { logger } from '../helpers';
|
||||
|
||||
export class RenouncedFilter implements Filter {
|
||||
constructor(private readonly connection: Connection) {}
|
||||
export class RenouncedFreezeFilter implements Filter {
|
||||
constructor(private readonly connection: Connection, private readonly checkRenounced: boolean, private readonly checkFreezable: boolean) {}
|
||||
|
||||
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
|
||||
const errorMessage = [ this.checkRenounced ? 'mint' : undefined, this.checkFreezable ? 'freeze' : undefined ].filter((e) => e !== undefined);
|
||||
try {
|
||||
const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment);
|
||||
if (!accountInfo?.data) {
|
||||
return { ok: false, message: 'Renounced -> Failed to fetch account data' };
|
||||
return { ok: false, message: 'RenouncedFreeze -> Failed to fetch account data' };
|
||||
}
|
||||
|
||||
const deserialize = MintLayout.decode(accountInfo.data);
|
||||
const renounced = deserialize.mintAuthorityOption === 0;
|
||||
return { ok: renounced, message: renounced ? undefined : 'Renounced -> Creator can mint more tokens' };
|
||||
const renounced = !this.checkRenounced || deserialize.mintAuthorityOption === 0;
|
||||
const freezable = !this.checkFreezable || deserialize.freezeAuthorityOption !== 0;
|
||||
|
||||
const message = [ renounced ? undefined : 'mint', !freezable ? undefined : 'freeze' ].filter((e) => e !== undefined);
|
||||
const ok = renounced && !freezable;
|
||||
|
||||
return { ok: ok, message: ok ? undefined : `RenouncedFreeze -> Creator can ${message.join(' and ')} tokens` };
|
||||
} catch (e) {
|
||||
logger.error({ mint: poolKeys.baseMint }, `Failed to check if mint is renounced`);
|
||||
logger.error({ mint: poolKeys.baseMint }, `RenouncedFreeze -> Failed to check if creator can ${errorMessage.join(' and ')} tokens`);
|
||||
}
|
||||
|
||||
return { ok: false, message: 'Renounced -> Failed to check if mint is renounced' };
|
||||
return { ok: false, message: `RenouncedFreeze -> Failed to check if creator can ${errorMessage.join(' and ')} tokens` };
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ export const FILTER_CHECK_INTERVAL = Number(retrieveEnvVariable('FILTER_CHECK_IN
|
||||
export const FILTER_CHECK_DURATION = Number(retrieveEnvVariable('FILTER_CHECK_DURATION', logger));
|
||||
export const CONSECUTIVE_FILTER_MATCHES = Number(retrieveEnvVariable('CONSECUTIVE_FILTER_MATCHES', logger));
|
||||
export const CHECK_IF_MINT_IS_RENOUNCED = retrieveEnvVariable('CHECK_IF_MINT_IS_RENOUNCED', logger) === 'true';
|
||||
export const CHECK_IF_FREEZABLE = retrieveEnvVariable('CHECK_IF_FREEZABLE', logger) === 'true';
|
||||
export const CHECK_IF_BURNED = retrieveEnvVariable('CHECK_IF_BURNED', logger) === 'true';
|
||||
export const MIN_POOL_SIZE = retrieveEnvVariable('MIN_POOL_SIZE', logger);
|
||||
export const MAX_POOL_SIZE = retrieveEnvVariable('MAX_POOL_SIZE', logger);
|
||||
|
||||
3
index.ts
3
index.ts
@ -15,6 +15,7 @@ import {
|
||||
PRE_LOAD_EXISTING_MARKETS,
|
||||
LOG_LEVEL,
|
||||
CHECK_IF_MINT_IS_RENOUNCED,
|
||||
CHECK_IF_FREEZABLE,
|
||||
CHECK_IF_BURNED,
|
||||
QUOTE_MINT,
|
||||
MAX_POOL_SIZE,
|
||||
@ -115,6 +116,7 @@ function printDetails(wallet: Keypair, quoteToken: Token, bot: Bot) {
|
||||
logger.info(`Filter check duration: ${botConfig.filterCheckDuration} ms`);
|
||||
logger.info(`Consecutive filter matches: ${botConfig.consecutiveMatchCount} ms`);
|
||||
logger.info(`Check renounced: ${botConfig.checkRenounced}`);
|
||||
logger.info(`Check freezable: ${botConfig.checkFreezable}`);
|
||||
logger.info(`Check burned: ${botConfig.checkBurned}`);
|
||||
logger.info(`Min pool size: ${botConfig.minPoolSize.toFixed()}`);
|
||||
logger.info(`Max pool size: ${botConfig.maxPoolSize.toFixed()}`);
|
||||
@ -149,6 +151,7 @@ const runListener = async () => {
|
||||
wallet,
|
||||
quoteAta: getAssociatedTokenAddressSync(quoteToken.mint, wallet.publicKey),
|
||||
checkRenounced: CHECK_IF_MINT_IS_RENOUNCED,
|
||||
checkFreezable: CHECK_IF_FREEZABLE,
|
||||
checkBurned: CHECK_IF_BURNED,
|
||||
minPoolSize: new TokenAmount(quoteToken, MIN_POOL_SIZE, false),
|
||||
maxPoolSize: new TokenAmount(quoteToken, MAX_POOL_SIZE, false),
|
||||
|
||||
Reference in New Issue
Block a user