punm parser

This commit is contained in:
thloyi
2025-11-21 12:01:44 +08:00
parent a945f3b45d
commit f86c5591c1
13 changed files with 228 additions and 148 deletions

View File

@@ -2,6 +2,7 @@ package pump_parser
import (
"errors"
"fmt"
"github.com/gagliardetto/solana-go"
)
@@ -20,42 +21,22 @@ var (
InstructionIgnoredError = errors.New("instruction ignored")
)
type swapParser func(result *RawTx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error)
type actionParser func(result *RawTx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint, tx *Tx) ([2]uint, error)
type swapParser func(tx *Tx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error)
type actionParser func(tx *Tx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint) ([2]uint, error)
//type PumpComplete struct {
// IsMayhem bool
// IsToken2022 bool
//}
//type PumpStatusCache map[solana.PublicKey]PumpComplete
//
//var (
// pumpCompleteCache PumpStatusCache = make(map[solana.PublicKey]PumpComplete)
// pumpCompleteCacheLock sync.Mutex
//)
//
//func getPumpCompleteStatus(pumpToken solana.PublicKey) (PumpComplete, bool) {
// pumpCompleteCacheLock.Lock()
// defer pumpCompleteCacheLock.Unlock()
// status, exists := pumpCompleteCache[pumpToken]
// return status, exists
//}
//
//func setPumpCompleteStatus(pumpToken solana.PublicKey, mayhem bool, token2022 bool) {
// pumpCompleteCacheLock.Lock()
// defer pumpCompleteCacheLock.Unlock()
// pumpCompleteCache[pumpToken] = PumpComplete{
// IsMayhem: mayhem,
// IsToken2022: token2022,
// }
//}
//
//func removePumpCompleteStatus(pumpToken solana.PublicKey) {
// pumpCompleteCacheLock.Lock()
// defer pumpCompleteCacheLock.Unlock()
// delete(pumpCompleteCache, pumpToken)
//}
func getInnerInstructions(innerInstructions InnerInstructions, offset uint) ([]Instruction, error) {
var inners []Instruction
var prefixLen = offset
if prefixLen > uint(len(innerInstructions.Instructions)) {
return nil, fmt.Errorf("error inner instruction index out of range")
}
if prefixLen == 0 {
inners = innerInstructions.Instructions
} else {
inners = innerInstructions.Instructions[prefixLen:]
}
return inners, nil
}
func isMayhemPump(feeAccount solana.PublicKey) bool {
for _, mayhemFeeAccount := range mayhemFeeAccounts {