diff --git a/solanaswap-go/checks.go b/solanaswap-go/checks.go index d277de6..3d72406 100644 --- a/solanaswap-go/checks.go +++ b/solanaswap-go/checks.go @@ -68,6 +68,17 @@ func (p *Parser) isPumpFunTradeEventInstruction(inst solana.CompiledInstruction) return bytes.Equal(decodedBytes[:16], PumpfunTradeEventDiscriminator[:]) } +func (p *Parser) isPumpFunCreateEventInstruction(inst solana.CompiledInstruction) bool { + if !p.allAccountKeys[inst.ProgramIDIndex].Equals(PUMP_FUN_PROGRAM_ID) || len(inst.Data) < 16 { + return false + } + decodedBytes, err := base58.Decode(inst.Data.String()) + if err != nil { + return false + } + return bytes.Equal(decodedBytes[:16], PumpfunCreateEventDiscriminator[:]) +} + func (p *Parser) isJupiterRouteEventInstruction(inst solana.CompiledInstruction) bool { if !p.allAccountKeys[inst.ProgramIDIndex].Equals(JUPITER_PROGRAM_ID) || len(inst.Data) < 16 { return false diff --git a/solanaswap-go/event_pumpfun.go b/solanaswap-go/event_pumpfun.go index a427d3d..5c51244 100644 --- a/solanaswap-go/event_pumpfun.go +++ b/solanaswap-go/event_pumpfun.go @@ -47,6 +47,15 @@ func (p *Parser) processPumpfunSwaps(instructionIndex int) []SwapData { swaps = append(swaps, SwapData{Type: PUMP_FUN, Data: eventData}) } } + if p.isPumpFunCreateEventInstruction(innerInstruction) { + eventData, err := p.parsePumpfunCreateEventInstruction(innerInstruction) + if err != nil { + p.Log.Errorf("error processing Pumpfun create event: %s", err) + } + if eventData != nil { + swaps = append(swaps, SwapData{Type: PUMP_FUN, Data: eventData}) + } + } } } } @@ -94,3 +103,22 @@ func handlePumpfunTradeEvent(decoder *ag_binary.Decoder) (*PumpfunTradeEvent, er return &trade, nil } + +func (p *Parser) parsePumpfunCreateEventInstruction(instruction solana.CompiledInstruction) (*PumpfunCreateEvent, error) { + decodedBytes, err := base58.Decode(instruction.Data.String()) + if err != nil { + return nil, fmt.Errorf("error decoding instruction data: %s", err) + } + decoder := ag_binary.NewBorshDecoder(decodedBytes[16:]) + + return handlePumpfunCreateEvent(decoder) +} + +func handlePumpfunCreateEvent(decoder *ag_binary.Decoder) (*PumpfunCreateEvent, error) { + var trade PumpfunCreateEvent + if err := decoder.Decode(&trade); err != nil { + return nil, fmt.Errorf("error unmarshaling TradeEvent: %s", err) + } + + return &trade, nil +}