burn.filter.ts 894 B

123456789101112131415161718192021222324
  1. import { Filter, FilterResult } from './pool-filters';
  2. import { Connection } from '@solana/web3.js';
  3. import { LiquidityPoolKeysV4 } from '@raydium-io/raydium-sdk';
  4. import { logger } from '../helpers';
  5. export class BurnFilter implements Filter {
  6. constructor(private readonly connection: Connection) {}
  7. async execute(poolKeys: LiquidityPoolKeysV4): Promise<FilterResult> {
  8. try {
  9. const amount = await this.connection.getTokenSupply(poolKeys.lpMint, this.connection.commitment);
  10. const burned = amount.value.uiAmount === 0;
  11. return { ok: burned, message: burned ? undefined : "Burned -> Creator didn't burn LP" };
  12. } catch (e: any) {
  13. if (e.code == -32602) {
  14. return { ok: true };
  15. }
  16. logger.error({ mint: poolKeys.baseMint }, `Failed to check if LP is burned`);
  17. }
  18. return { ok: false, message: 'Failed to check if LP is burned' };
  19. }
  20. }