all parser

This commit is contained in:
thloyi
2026-02-09 14:46:19 +08:00
parent 5da088ce13
commit 9ece4aebb9
22 changed files with 6720 additions and 174 deletions

View File

@@ -1,6 +1,7 @@
package pump_parser
import (
"encoding/binary"
"errors"
"fmt"
@@ -38,6 +39,36 @@ func getInnerInstructions(innerInstructions InnerInstructions, offset uint) ([]I
return inners, nil
}
func parseTokenTransfer(tx *RawTx, instr Instruction) (from solana.PublicKey, to solana.PublicKey, amount uint64, err error) {
if len(instr.Accounts) < 3 {
return solana.PublicKey{}, solana.PublicKey{}, 0, fmt.Errorf("not enough accounts for token transfer instruction")
}
programAccount := tx.accountList[instr.ProgramIDIndex]
if !programAccount.Equals(solana.TokenProgramID) && !programAccount.Equals(solana.Token2022ProgramID) {
return solana.PublicKey{}, solana.PublicKey{}, 0, fmt.Errorf("not a token program instruction")
}
if len(instr.Data) < 9 {
return solana.PublicKey{}, solana.PublicKey{}, 0, fmt.Errorf("invalid data length for token transfer instruction")
}
method := instr.Data[0]
if method != 3 && method != 12 { // Transfer instruction
return solana.PublicKey{}, solana.PublicKey{}, 0, fmt.Errorf("not a token transfer instruction")
}
if method == 3 {
// Transfer
amount = binary.LittleEndian.Uint64(instr.Data[1:9])
from = tx.accountList[instr.Accounts[0]]
to = tx.accountList[instr.Accounts[1]]
} else {
// TransferChecked
amount = binary.LittleEndian.Uint64(instr.Data[1:9])
from = tx.accountList[instr.Accounts[0]]
to = tx.accountList[instr.Accounts[2]]
}
return from, to, amount, nil
}
func isMayhemPump(feeAccount solana.PublicKey) bool {
for _, mayhemFeeAccount := range mayhemFeeAccounts {
if feeAccount.Equals(mayhemFeeAccount) {