all parser
This commit is contained in:
31
globals.go
31
globals.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user