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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1x 1x 1x | import { DISCRIMINATORS } from '../../constants';
import { PoolEventType } from '../../types';
import { RaydiumLiquidityParserBase, ParseEventConfig } from './parser-raydium-liquidity-base';
export class RaydiumCLPoolParser extends RaydiumLiquidityParserBase {
public getPoolAction(data: Buffer): { name: string; type: PoolEventType } | null {
const instructionType = data.slice(0, 8);
for (const [name, discriminator] of Object.entries(DISCRIMINATORS.RAYDIUM_CL.CREATE)) {
Iif (instructionType.equals(discriminator)) return { name, type: 'CREATE' };
}
for (const [name, discriminator] of Object.entries(DISCRIMINATORS.RAYDIUM_CL.ADD_LIQUIDITY)) {
Iif (instructionType.equals(discriminator)) return { name, type: 'ADD' };
}
for (const [name, discriminator] of Object.entries(DISCRIMINATORS.RAYDIUM_CL.REMOVE_LIQUIDITY)) {
Iif (instructionType.equals(discriminator)) return { name, type: 'REMOVE' };
}
return null;
}
public getEventConfig(type: PoolEventType, instructionType: { name: string; type: PoolEventType }): ParseEventConfig {
const configs = {
CREATE: {
eventType: 'CREATE' as const,
poolIdIndex: ['openPosition', 'openPositionV2'].includes(instructionType.name) ? 5 : 4,
lpMintIndex: ['openPosition', 'openPositionV2'].includes(instructionType.name) ? 5 : 4,
},
ADD: {
eventType: 'ADD' as const,
poolIdIndex: 2,
lpMintIndex: 2,
tokenAmountOffsets: { token0: 32, token1: 24, lp: 8 },
},
REMOVE: {
eventType: 'REMOVE' as const,
poolIdIndex: 3,
lpMintIndex: 3,
tokenAmountOffsets: { token0: 32, token1: 24, lp: 8 },
},
};
return configs[type];
}
}
|