All files / src/parsers/raydium liquidity-raydium-v4.ts

23.07% Statements 3/13
0% Branches 0/3
0% Functions 0/2
30% Lines 3/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231x   1x   1x                                    
import { DISCRIMINATORS } from '../../constants';
import { PoolEventType } from '../../types';
import { RaydiumLiquidityParserBase, ParseEventConfig } from './parser-raydium-liquidity-base';
 
export class RaydiumV4PoolParser extends RaydiumLiquidityParserBase {
  public getPoolAction(data: Buffer): PoolEventType | null {
    const instructionType = data.slice(0, 1);
    Iif (instructionType.equals(DISCRIMINATORS.RAYDIUM.CREATE)) return 'CREATE';
    Iif (instructionType.equals(DISCRIMINATORS.RAYDIUM.ADD_LIQUIDITY)) return 'ADD';
    Iif (instructionType.equals(DISCRIMINATORS.RAYDIUM.REMOVE_LIQUIDITY)) return 'REMOVE';
    return null;
  }
 
  public getEventConfig(type: PoolEventType): ParseEventConfig {
    const configs = {
      CREATE: { eventType: 'CREATE' as const, poolIdIndex: 4, lpMintIndex: 7 },
      ADD: { eventType: 'ADD' as const, poolIdIndex: 1, lpMintIndex: 5 },
      REMOVE: { eventType: 'REMOVE' as const, poolIdIndex: 1, lpMintIndex: 5 },
    };
    return configs[type];
  }
}