mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-18 02:31:18 +10:00
tsc & prettier
This commit is contained in:
@ -1,67 +1,76 @@
|
||||
import { Connection } from '@solana/web3.js';
|
||||
import { LiquidityPoolKeysV4, Token, TokenAmount } from '@raydium-io/raydium-sdk';
|
||||
import { getMetadataAccountDataSerializer } from '@metaplex-foundation/mpl-token-metadata';
|
||||
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, CHECK_IF_SOCIALS, logger } from '../helpers';
|
||||
import { Connection } from "@solana/web3.js";
|
||||
import { LiquidityPoolKeysV4, Token, TokenAmount } from "@raydium-io/raydium-sdk";
|
||||
import { getMetadataAccountDataSerializer } from "@metaplex-foundation/mpl-token-metadata";
|
||||
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,
|
||||
CHECK_IF_SOCIALS,
|
||||
logger,
|
||||
} from "../helpers";
|
||||
|
||||
export interface Filter {
|
||||
execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>;
|
||||
execute(poolKeysV4: LiquidityPoolKeysV4): Promise<FilterResult>;
|
||||
}
|
||||
|
||||
export interface FilterResult {
|
||||
ok: boolean;
|
||||
message?: string;
|
||||
ok: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface PoolFilterArgs {
|
||||
minPoolSize: TokenAmount;
|
||||
maxPoolSize: TokenAmount;
|
||||
quoteToken: Token;
|
||||
minPoolSize: TokenAmount;
|
||||
maxPoolSize: TokenAmount;
|
||||
quoteToken: Token;
|
||||
}
|
||||
|
||||
export class PoolFilters {
|
||||
private readonly filters: Filter[] = [];
|
||||
private readonly filters: Filter[] = [];
|
||||
|
||||
constructor(
|
||||
readonly connection: Connection,
|
||||
readonly args: PoolFilterArgs,
|
||||
) {
|
||||
if (CHECK_IF_BURNED) {
|
||||
this.filters.push(new BurnFilter(connection));
|
||||
}
|
||||
constructor(
|
||||
readonly connection: Connection,
|
||||
readonly args: PoolFilterArgs,
|
||||
) {
|
||||
if (CHECK_IF_BURNED) {
|
||||
this.filters.push(new BurnFilter(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 (CHECK_IF_MINT_IS_RENOUNCED || CHECK_IF_FREEZABLE) {
|
||||
this.filters.push(new RenouncedFreezeFilter(connection, CHECK_IF_MINT_IS_RENOUNCED, CHECK_IF_FREEZABLE));
|
||||
}
|
||||
|
||||
if (CHECK_IF_MUTABLE || CHECK_IF_SOCIALS) {
|
||||
this.filters.push(new MutableFilter(connection, getMetadataAccountDataSerializer(), CHECK_IF_MUTABLE, CHECK_IF_SOCIALS));
|
||||
}
|
||||
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()) {
|
||||
this.filters.push(new PoolSizeFilter(connection, args.quoteToken, args.minPoolSize, args.maxPoolSize));
|
||||
}
|
||||
}
|
||||
if (!args.minPoolSize.isZero() || !args.maxPoolSize.isZero()) {
|
||||
this.filters.push(new PoolSizeFilter(connection, args.quoteToken, args.minPoolSize, args.maxPoolSize));
|
||||
}
|
||||
}
|
||||
|
||||
public async execute(poolKeys: LiquidityPoolKeysV4): Promise<boolean> {
|
||||
if (this.filters.length === 0) {
|
||||
return true;
|
||||
}
|
||||
public async execute(poolKeys: LiquidityPoolKeysV4): Promise<boolean> {
|
||||
if (this.filters.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const result = await Promise.all(this.filters.map((f) => f.execute(poolKeys)));
|
||||
const pass = result.every((r) => r.ok);
|
||||
const result = await Promise.all(this.filters.map((f) => f.execute(poolKeys)));
|
||||
const pass = result.every((r) => r.ok);
|
||||
|
||||
if (pass) {
|
||||
return true;
|
||||
}
|
||||
if (pass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const filterResult of result.filter((r) => !r.ok)) {
|
||||
logger.trace(filterResult.message);
|
||||
}
|
||||
for (const filterResult of result.filter((r) => !r.ok)) {
|
||||
logger.trace(filterResult.message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user