소스 검색

Add freezable filter

Check if owner can freeze tokens
Theo Brigitte 1 년 전
부모
커밋
508e521433
6개의 변경된 파일22개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 0
      .env.copy
  2. 1 0
      bot.ts
  3. 4 4
      filters/pool-filters.ts
  4. 12 7
      filters/renounced.filter.ts
  5. 1 0
      helpers/constants.ts
  6. 3 0
      index.ts

+ 1 - 0
.env.copy

@@ -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

+ 1 - 0
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;

+ 4 - 4
filters/pool-filters.ts

@@ -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()) {

+ 12 - 7
filters/renounced.filter.ts

@@ -4,23 +4,28 @@ 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> {
     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: '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 }, `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' };
   }
 }

+ 1 - 0
helpers/constants.ts

@@ -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 - 0
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),