Add freezable filter

Check if owner can freeze tokens
This commit is contained in:
Theo Brigitte
2024-04-19 23:00:32 +02:00
parent df38d332a0
commit 508e521433
6 changed files with 22 additions and 11 deletions

View File

@ -43,6 +43,7 @@ FILTER_CHECK_DURATION=60000
FILTER_CHECK_INTERVAL=2000 FILTER_CHECK_INTERVAL=2000
CONSECUTIVE_FILTER_MATCHES=3 CONSECUTIVE_FILTER_MATCHES=3
CHECK_IF_MINT_IS_RENOUNCED=true CHECK_IF_MINT_IS_RENOUNCED=true
CHECK_IF_FREEZABLE=true
CHECK_IF_BURNED=true CHECK_IF_BURNED=true
MIN_POOL_SIZE=5 MIN_POOL_SIZE=5
MAX_POOL_SIZE=50 MAX_POOL_SIZE=50

1
bot.ts
View File

@ -26,6 +26,7 @@ import { WarpTransactionExecutor } from './transactions/warp-transaction-executo
export interface BotConfig { export interface BotConfig {
wallet: Keypair; wallet: Keypair;
checkRenounced: boolean; checkRenounced: boolean;
checkFreezable: boolean;
checkBurned: boolean; checkBurned: boolean;
minPoolSize: TokenAmount; minPoolSize: TokenAmount;
maxPoolSize: TokenAmount; maxPoolSize: TokenAmount;

View File

@ -1,9 +1,9 @@
import { Connection } from '@solana/web3.js'; import { Connection } from '@solana/web3.js';
import { LiquidityPoolKeysV4, Token, TokenAmount } from '@raydium-io/raydium-sdk'; import { LiquidityPoolKeysV4, Token, TokenAmount } from '@raydium-io/raydium-sdk';
import { BurnFilter } from './burn.filter'; import { BurnFilter } from './burn.filter';
import { RenouncedFilter } from './renounced.filter'; import { RenouncedFreezeFilter } from './renounced.filter';
import { PoolSizeFilter } from './pool-size.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 { export interface Filter {
execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>; execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>;
@ -31,8 +31,8 @@ export class PoolFilters {
this.filters.push(new BurnFilter(connection)); this.filters.push(new BurnFilter(connection));
} }
if (CHECK_IF_MINT_IS_RENOUNCED) { if (CHECK_IF_MINT_IS_RENOUNCED || CHECK_IF_FREEZABLE) {
this.filters.push(new RenouncedFilter(connection)); this.filters.push(new RenouncedFreezeFilter(connection, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_FREEZABLE));
} }
if (!args.minPoolSize.isZero() || !args.maxPoolSize.isZero()) { if (!args.minPoolSize.isZero() || !args.maxPoolSize.isZero()) {

View File

@ -4,23 +4,28 @@ import { Connection } from '@solana/web3.js';
import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk'; import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
import { logger } from '../helpers'; import { logger } from '../helpers';
export class RenouncedFilter implements Filter { export class RenouncedFreezeFilter implements Filter {
constructor(private readonly connection: Connection) {} constructor(private readonly connection: Connection, private readonly checkRenounced: boolean, private readonly checkFreezable: boolean) {}
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> { async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
try { try {
const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment); const accountInfo = await this.connection.getAccountInfo(poolKeys.baseMint, this.connection.commitment);
if (!accountInfo?.data) { if (!accountInfo?.data) {
return { ok: false, message: 'Renounced -> Failed to fetch account data' }; return { ok: false, message: 'Failed to fetch account data' };
} }
const deserialize = MintLayout.decode(accountInfo.data); const deserialize = MintLayout.decode(accountInfo.data);
const renounced = deserialize.mintAuthorityOption === 0; const renounced = !this.checkRenounced || deserialize.mintAuthorityOption === 0;
return { ok: renounced, message: renounced ? undefined : 'Renounced -> Creator can mint more tokens' }; 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) { } catch (e) {
logger.error({ mint: poolKeys.baseMint }, `Failed to check if mint is renounced`); logger.error({ mint: poolKeys.baseMint }, `Failed to check if mint is renounced and freezable`);
} }
return { ok: false, message: 'Renounced -> Failed to check if mint is renounced' }; return { ok: false, message: 'Renounced -> Failed to check if mint is renounced and freezable' };
} }
} }

View File

@ -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 FILTER_CHECK_DURATION = Number(retrieveEnvVariable('FILTER_CHECK_DURATION', logger));
export const CONSECUTIVE_FILTER_MATCHES = Number(retrieveEnvVariable('CONSECUTIVE_FILTER_MATCHES', 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_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 CHECK_IF_BURNED = retrieveEnvVariable('CHECK_IF_BURNED', logger) === 'true';
export const MIN_POOL_SIZE = retrieveEnvVariable('MIN_POOL_SIZE', logger); export const MIN_POOL_SIZE = retrieveEnvVariable('MIN_POOL_SIZE', logger);
export const MAX_POOL_SIZE = retrieveEnvVariable('MAX_POOL_SIZE', logger); export const MAX_POOL_SIZE = retrieveEnvVariable('MAX_POOL_SIZE', logger);

View File

@ -15,6 +15,7 @@ import {
PRE_LOAD_EXISTING_MARKETS, PRE_LOAD_EXISTING_MARKETS,
LOG_LEVEL, LOG_LEVEL,
CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_MINT_IS_RENOUNCED,
CHECK_IF_FREEZABLE,
CHECK_IF_BURNED, CHECK_IF_BURNED,
QUOTE_MINT, QUOTE_MINT,
MAX_POOL_SIZE, 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(`Filter check duration: ${botConfig.filterCheckDuration} ms`);
logger.info(`Consecutive filter matches: ${botConfig.consecutiveMatchCount} ms`); logger.info(`Consecutive filter matches: ${botConfig.consecutiveMatchCount} ms`);
logger.info(`Check renounced: ${botConfig.checkRenounced}`); logger.info(`Check renounced: ${botConfig.checkRenounced}`);
logger.info(`Check freezable: ${botConfig.checkFreezable}`);
logger.info(`Check burned: ${botConfig.checkBurned}`); logger.info(`Check burned: ${botConfig.checkBurned}`);
logger.info(`Min pool size: ${botConfig.minPoolSize.toFixed()}`); logger.info(`Min pool size: ${botConfig.minPoolSize.toFixed()}`);
logger.info(`Max pool size: ${botConfig.maxPoolSize.toFixed()}`); logger.info(`Max pool size: ${botConfig.maxPoolSize.toFixed()}`);
@ -149,6 +151,7 @@ const runListener = async () => {
wallet, wallet,
quoteAta: getAssociatedTokenAddressSync(quoteToken.mint, wallet.publicKey), quoteAta: getAssociatedTokenAddressSync(quoteToken.mint, wallet.publicKey),
checkRenounced: CHECK_IF_MINT_IS_RENOUNCED, checkRenounced: CHECK_IF_MINT_IS_RENOUNCED,
checkFreezable: CHECK_IF_FREEZABLE,
checkBurned: CHECK_IF_BURNED, checkBurned: CHECK_IF_BURNED,
minPoolSize: new TokenAmount(quoteToken, MIN_POOL_SIZE, false), minPoolSize: new TokenAmount(quoteToken, MIN_POOL_SIZE, false),
maxPoolSize: new TokenAmount(quoteToken, MAX_POOL_SIZE, false), maxPoolSize: new TokenAmount(quoteToken, MAX_POOL_SIZE, false),