mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2026-06-22 04:11:27 +10:00
Add freezable filter
Check if owner can freeze tokens
This commit is contained in:
@@ -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,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' };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user