mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-09 20:12:06 +10:00
Add social filter
This commit is contained in:
@ -43,6 +43,7 @@ FILTER_CHECK_DURATION=60000
|
||||
FILTER_CHECK_INTERVAL=2000
|
||||
CONSECUTIVE_FILTER_MATCHES=3
|
||||
CHECK_IF_MUTABLE=false
|
||||
CHECK_IF_SOCIALS=true
|
||||
CHECK_IF_MINT_IS_RENOUNCED=true
|
||||
CHECK_IF_FREEZABLE=false
|
||||
CHECK_IF_BURNED=true
|
||||
|
||||
@ -94,6 +94,7 @@ Note: When using snipe list filters below will be disabled.
|
||||
- `CONSECUTIVE_FILTER_MATCHES` - How many times in a row pool needs to match the filters.
|
||||
- This is useful because when pool is burned (and rugged), other filters may not report the same behavior. eg. pool size may still have old value
|
||||
- `CHECK_IF_MUTABLE` - Set to `true` to buy tokens only if their metadata are not mutable.
|
||||
- `CHECK_IF_SOCIALS` - Set to `true` to buy tokens only if they have at least 1 social.
|
||||
- `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.
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
import { Filter, FilterResult } from './pool-filters';
|
||||
import { Connection, PublicKey } from '@solana/web3.js';
|
||||
import { Connection } from '@solana/web3.js';
|
||||
import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
|
||||
import { getPdaMetadataKey } from '@raydium-io/raydium-sdk';
|
||||
import { getMetadataAccountDataSerializer, MetadataAccountData, MetadataAccountDataArgs } from '@metaplex-foundation/mpl-token-metadata';
|
||||
import { MetadataAccountData, MetadataAccountDataArgs } from '@metaplex-foundation/mpl-token-metadata';
|
||||
import { Serializer } from '@metaplex-foundation/umi/serializers';
|
||||
import { logger } from '../helpers';
|
||||
|
||||
export class MutableFilter implements Filter {
|
||||
constructor(private readonly connection: Connection, private readonly metadataSerializer: Serializer<MetadataAccountDataArgs, MetadataAccountData>) {}
|
||||
constructor(private readonly connection: Connection, private readonly metadataSerializer: Serializer<MetadataAccountDataArgs, MetadataAccountData>, private readonly checkMutable: boolean, private readonly checkSocials: boolean) {}
|
||||
|
||||
async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
|
||||
const errorMessage = [ this.checkMutable ? 'mutable' : undefined, this.checkSocials ? 'socials' : undefined ].filter((e) => e !== undefined);
|
||||
try {
|
||||
const metadataPDA = getPdaMetadataKey(poolKeys.baseMint);
|
||||
const metadataAccount = await this.connection.getAccountInfo(metadataPDA.publicKey);
|
||||
@ -17,13 +18,26 @@ export class MutableFilter implements Filter {
|
||||
return { ok: false, message: 'Mutable -> Failed to fetch account data' };
|
||||
}
|
||||
const deserialize = this.metadataSerializer.deserialize(metadataAccount.data);
|
||||
const mutable = deserialize[0].isMutable;
|
||||
const mutable = this.checkMutable ? deserialize[0].isMutable: false;
|
||||
|
||||
return { ok: !mutable, message: !mutable ? undefined : "Mutable -> Creator can change metadata" };
|
||||
} catch (e: any) {
|
||||
logger.error({ mint: poolKeys.baseMint }, `Mutable -> Failed to check if metadata are mutable`);
|
||||
const hasSocials = this.checkSocials ? (Object.values(await this.getSocials(deserialize[0])).some((value: any) => value !== null && value.length > 0)) === true: true;
|
||||
|
||||
const message = [ !mutable ? undefined : 'metadata can be changed', hasSocials ? undefined : 'has no socials' ].filter((e) => e !== undefined);
|
||||
const ok = !mutable && hasSocials;
|
||||
|
||||
return { ok: ok, message: ok ? undefined : `MutableSocials -> Token ${message.join(' and ')}` };
|
||||
} catch (e) {
|
||||
logger.error({ mint: poolKeys.baseMint, error: e }, `MutableSocials -> Failed to check ${errorMessage.join(' and ')}`);
|
||||
return { ok: false, message: `MutableSocials -> Failed to check ${errorMessage.join(' and ')}` };
|
||||
}
|
||||
|
||||
return { ok: false, message: 'Mutable -> Failed to check if metadata are mutable' };
|
||||
logger.error({ mint: poolKeys.baseMint }, `MutableSocials -> Failed to check ${errorMessage.join(' and ')}`);
|
||||
return { ok: false, message: `MutableSocials -> Failed to check ${errorMessage.join(' and ')}` };
|
||||
}
|
||||
|
||||
async getSocials(metadata: MetadataAccountData): Promise<Object> {
|
||||
const response = await fetch(metadata.uri);
|
||||
const data = await response.json();
|
||||
return data?.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { BurnFilter } from './burn.filter';
|
||||
import { MutableFilter } from './mutable.filter';
|
||||
import { RenouncedFreezeFilter } from './renounced.filter';
|
||||
import { PoolSizeFilter } from './pool-size.filter';
|
||||
import { CHECK_IF_BURNED, CHECK_IF_FREEZABLE, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_MUTABLE, logger } from '../helpers';
|
||||
import { CHECK_IF_BURNED, CHECK_IF_FREEZABLE, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_MUTABLE, CHECK_IF_SOCIALS, logger } from '../helpers';
|
||||
|
||||
export interface Filter {
|
||||
execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>;
|
||||
@ -37,8 +37,8 @@ export class PoolFilters {
|
||||
this.filters.push(new RenouncedFreezeFilter(connection, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_FREEZABLE));
|
||||
}
|
||||
|
||||
if (CHECK_IF_MUTABLE) {
|
||||
this.filters.push(new MutableFilter(connection, getMetadataAccountDataSerializer()));
|
||||
if (CHECK_IF_MUTABLE || CHECK_IF_SOCIALS) {
|
||||
this.filters.push(new MutableFilter(connection, getMetadataAccountDataSerializer(), CHECK_IF_MUTABLE, CHECK_IF_SOCIALS));
|
||||
}
|
||||
|
||||
if (!args.minPoolSize.isZero() || !args.maxPoolSize.isZero()) {
|
||||
|
||||
@ -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_MUTABLE = retrieveEnvVariable('CHECK_IF_MUTABLE', logger) === 'true';
|
||||
export const CHECK_IF_SOCIALS = retrieveEnvVariable('CHECK_IF_SOCIALS', 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';
|
||||
|
||||
Reference in New Issue
Block a user