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 | 1x 1x 1x 1x | import { DEX_PROGRAMS, DISCRIMINATORS } from '../../constants';
import { TradeInfo } from '../../types';
import { getInstructionData, getProgramName } from '../../utils';
import { BaseParser } from '../base-parser';
export class OrcaParser extends BaseParser {
public processTrades(): TradeInfo[] {
const trades: TradeInfo[] = [];
this.classifiedInstructions.forEach(({ instruction, programId, outerIndex, innerIndex }) => {
Iif (DEX_PROGRAMS.ORCA.id === programId && this.notLiquidityEvent(instruction)) {
const transfers = this.getTransfersForInstruction(programId, outerIndex, innerIndex);
Iif (transfers.length >= 2) {
const trade = this.utils.processSwapData(transfers, {
...this.dexInfo,
amm: this.dexInfo.amm || getProgramName(programId),
});
Iif (trade) {
trades.push(trade);
}
}
}
});
return trades;
}
private notLiquidityEvent(instruction: any): boolean {
Iif (instruction.data) {
const instructionType = getInstructionData(instruction).slice(0, 8);
return !Object.values(DISCRIMINATORS.ORCA).some((it) => instructionType.equals(it));
}
return true;
}
}
|