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 | 1x 1x 1x 1x | import { TransactionAdapter } from '../../transaction-adapter';
import { ClassifiedInstruction, DexInfo, PumpfunEvent, PumpfunTradeEvent, TradeInfo, TransferData } from '../../types';
import { BaseParser } from '../base-parser';
import { PumpfunEventParser } from './parser-pumpfun-event';
import { getPumpfunTradeInfo } from './util';
export class PumpfunParser extends BaseParser {
private eventParser: PumpfunEventParser;
constructor(
adapter: TransactionAdapter,
dexInfo: DexInfo,
transferActions: Record<string, TransferData[]>,
classifiedInstructions: ClassifiedInstruction[]
) {
super(adapter, dexInfo, transferActions, classifiedInstructions);
this.eventParser = new PumpfunEventParser(adapter);
}
public processTrades(): TradeInfo[] {
const events = this.eventParser
.parseInstructions(this.classifiedInstructions)
.filter((event) => event.type === 'TRADE');
return events.map((event) => this.createTradeInfo(event));
}
private createTradeInfo(data: PumpfunEvent): TradeInfo {
const event = data.data as PumpfunTradeEvent;
const trade = getPumpfunTradeInfo(event, {
slot: data.slot,
signature: data.signature,
timestamp: data.timestamp,
idx: data.idx,
dexInfo: this.dexInfo,
});
return this.utils.attachTokenTransferInfo(trade, this.transferActions);
}
}
|