Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9327eab010 | ||
|
|
0ef57cf79a | ||
|
|
03030d817d | ||
|
|
401dca225a | ||
|
|
db8c8727f4 | ||
|
|
09de6ba649 | ||
|
|
7a82990770 | ||
|
|
e82bcb3c07 | ||
|
|
a74f769064 | ||
|
|
1e276e8bd2 | ||
|
|
eb2bde98ac | ||
| 66f0d247f5 | |||
| 879b7fefad | |||
| 149dfae378 | |||
| 8c4b43747c | |||
|
|
e9ba16766f | ||
|
|
cd1d681621 | ||
|
|
920c5ba25b | ||
|
|
3d447ef2e8 | ||
|
|
b0d4342fa2 |
120
chainlink.go
Normal file
120
chainlink.go
Normal file
@@ -0,0 +1,120 @@
|
||||
package pump_parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
var (
|
||||
chainlinkSOLUSDFeedAccount = solana.MustPublicKeyFromBase58("CH31Xns5z3M1cTAbKW34jcxPPciazARpijcHj9rxtemt")
|
||||
chainlinkSubmitDiscriminator = calculateDiscriminator("global:submit")
|
||||
)
|
||||
|
||||
func chainLinkParser(tx *Tx, instruction Instruction, inners InnerInstructions, offset [2]uint) ([2]uint, error) {
|
||||
if !tx.rawTx.accountList[instruction.ProgramIDIndex].Equals(chainLinkProgram) {
|
||||
return increaseOffset(offset), fmt.Errorf("system program instruction not found, block: %d, tx: %s, outerIndex: %d, innerIndex: %d", tx.rawTx.Slot, tx.rawTx.TxHash(), offset[0], offset[1])
|
||||
}
|
||||
if tx.rawTx.Meta.Err != nil {
|
||||
return increaseOffset(offset), nil
|
||||
}
|
||||
|
||||
decode := instruction.Data
|
||||
discriminator := binary.LittleEndian.Uint32(decode[0:4])
|
||||
|
||||
switch discriminator {
|
||||
case transferDiscriminator:
|
||||
return chainLinkSubmitParser(instruction, inners, offset, tx, decode[4:])
|
||||
default:
|
||||
return increaseOffset(offset), nil
|
||||
}
|
||||
}
|
||||
|
||||
func chainLinkSubmitParser(instruction Instruction, inners InnerInstructions, offset [2]uint, tx *Tx, decodeData []byte) ([2]uint, error) {
|
||||
if len(instruction.Accounts) < 6 {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
|
||||
inner, err := getInnerInstructions(inners, offset[1])
|
||||
if err != nil {
|
||||
return increaseOffset(offset), err
|
||||
}
|
||||
|
||||
if len(inner) < 1 {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
storeInstruction := inner[0]
|
||||
if len(storeInstruction.Accounts) < 2 {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
if storeInstruction.Accounts[0] >= len(tx.rawTx.accountList) || tx.rawTx.accountList[storeInstruction.Accounts[0]] != chainlinkSOLUSDFeedAccount {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
if !bytes.Equal(storeInstruction.Data[0:8], chainlinkSubmitDiscriminator[:]) {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
data, err := parseChainLinkSubmitData(storeInstruction.Data)
|
||||
if err != nil {
|
||||
return increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
tx.ChainLink.Timestamp = int64(data.Timestamp)
|
||||
tx.ChainLink.Price = decimal.NewFromBigInt(data.Price(), -8)
|
||||
return increaseOffset(offset), nil
|
||||
}
|
||||
|
||||
type SubmitData struct {
|
||||
Discriminator [8]byte
|
||||
Timestamp uint64
|
||||
Answer [16]byte
|
||||
}
|
||||
|
||||
func parseChainLinkSubmitData(data []byte) (*SubmitData, error) {
|
||||
if len(data) != 32 {
|
||||
return nil, errors.New("invalid submit data length")
|
||||
}
|
||||
var submitData SubmitData
|
||||
copy(submitData.Discriminator[:], data[:8])
|
||||
submitData.Timestamp = binary.LittleEndian.Uint64(data[8:16])
|
||||
copy(submitData.Answer[:], data[16:32])
|
||||
return &submitData, nil
|
||||
}
|
||||
|
||||
func (s *SubmitData) Price() *big.Int {
|
||||
return int128LEBytesToBigInt(s.Answer)
|
||||
}
|
||||
|
||||
func int128LEBytesToBigInt(bytes [16]byte) *big.Int {
|
||||
// Create new big.Int
|
||||
bigInt := new(big.Int)
|
||||
|
||||
// Reverse bytes for little-endian to big-endian conversion
|
||||
reversed := make([]byte, 16)
|
||||
for i := 0; i < 16; i++ {
|
||||
reversed[15-i] = bytes[i]
|
||||
}
|
||||
|
||||
// Check if negative (first byte in little-endian is highest byte)
|
||||
isNegative := bytes[15]&0x80 != 0
|
||||
|
||||
if isNegative {
|
||||
// If negative, flip all bits
|
||||
for i := range reversed {
|
||||
reversed[i] = ^reversed[i]
|
||||
}
|
||||
// Convert to big.Int
|
||||
bigInt.SetBytes(reversed)
|
||||
// Add 1 and negate
|
||||
bigInt.Add(bigInt, big.NewInt(1))
|
||||
bigInt.Neg(bigInt)
|
||||
} else {
|
||||
// If positive, convert directly
|
||||
bigInt.SetBytes(reversed)
|
||||
}
|
||||
|
||||
return bigInt
|
||||
}
|
||||
576
checking.go
576
checking.go
@@ -1,576 +0,0 @@
|
||||
package pump_parser
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
)
|
||||
|
||||
func checkBonkGmgnBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
var version, _ = rawTx.Version.(solana.MessageVersion)
|
||||
if version != solana.MessageVersionLegacy {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 10 && len(rawTx.Transaction.Message.Instructions) != 9 {
|
||||
return false
|
||||
}
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront1111111111151111111111111655") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
return false
|
||||
}
|
||||
|
||||
// gmgn 会先创建 wsol 账户, 而不是 token 账户
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId != solana.WrappedSol {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 token.syncNative
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.TokenProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "J" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
offset := 5
|
||||
if len(rawTx.Transaction.Message.Instructions) == 10 {
|
||||
// 检查 ata.create
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[offset]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "1" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
offset++
|
||||
}
|
||||
|
||||
// 检查 bonk.buy
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[offset]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != raydiumLaunchLabProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
offset++
|
||||
|
||||
// 检查 token.closeAccount
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[offset]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.TokenProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "A" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
offset++
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[offset]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
offset++
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[offset]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
var (
|
||||
axiomTxLoopupTable = solana.MustPublicKeyFromBase58("7RKtfATWCe98ChuwecNq8XCzAzfoK3DtZTprFsPMGtio")
|
||||
axiomProgramID = solana.MustPublicKeyFromBase58("AxiomfHaWDemCFBLBayqnEnNwE6b7B2Qz3UmzMpgbMG6")
|
||||
gmgnProgramID = solana.MustPublicKeyFromBase58("GMgnVFR8Jb39LoXsEVzb3DvBy3ywCmdmJquHUy1Lrkqb")
|
||||
)
|
||||
|
||||
func checkBonkAxiomBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
var version, _ = rawTx.Version.(solana.MessageVersion)
|
||||
if version == solana.MessageVersionLegacy || len(rawTx.Transaction.Message.AddressTableLookups) != 1 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid transaction version or address table lookups: %v %v %v", rawTx.Transaction.Signatures[0].String(), version, len(rawTx.Transaction.Message.AddressTableLookups))
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查 addressLookupTable 是否是 Axiom 的
|
||||
if rawTx.Transaction.Message.AddressTableLookups[0].AccountKey != axiomTxLoopupTable {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid address lookup table: %v", rawTx.Transaction.Signatures[0].String())
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 10 {
|
||||
return false
|
||||
}
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for ComputeBudget: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid number of accounts for ComputeBudget: %v", len(instruction.Accounts))
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront") || !strings.HasSuffix(accountId, "TradeWithAxiomDotTrade") {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid account ID for ComputeBudget: %v", accountId)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for ComputeBudget: %v", programId)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for SPLAssociatedTokenAccount: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for SPLAssociatedTokenAccount: %v", instruction.Data.String())
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid number of accounts for SPLAssociatedTokenAccount: %v", len(instruction.Accounts))
|
||||
return false
|
||||
}
|
||||
|
||||
// axiom 会先创建 token 账户, 而不是 wsol 账户
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId == solana.WrappedSol {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid account ID for SPLAssociatedTokenAccount, expected token account but got wsol: %v", accountId)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for SPLAssociatedTokenAccount2: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for SPLAssociatedTokenAccount2: %v", instruction.Data.String())
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid number of accounts for SPLAssociatedTokenAccount2: %v", len(instruction.Accounts))
|
||||
return false
|
||||
}
|
||||
|
||||
// axiom 会先创建 token 账户, 而不是 wsol 账户
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId != solana.WrappedSol {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid account ID for SPLAssociatedTokenAccount2, expected wsol but got: %v", accountId)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for SystemProgram3: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for SystemProgram transfer3: %v", instruction.Data)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 token.syncNative
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[5]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.TokenProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for TokenProgram3: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "J" {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for TokenProgram syncNative3: %v", instruction.Data.String())
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 bonk.buy
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[6]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != raydiumLaunchLabProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 token.closeAccount
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[7]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.TokenProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for TokenProgram closeAccount: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "A" {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for TokenProgram closeAccount: %v", instruction.Data.String())
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[8]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for SystemProgram transfer4: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for SystemProgram transfer4: %v", instruction.Data)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[9]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid program ID for SystemProgram transfer5: %v", programId)
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
log.Printf("CheckBonkAxiomBuy: Invalid data for SystemProgram transfer5: %v", instruction.Data)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func checkPumpFunAxiomBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
if rawTx.Version == "legacy" || len(rawTx.Transaction.Message.AddressTableLookups) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查 addressLookupTable 是否是 Axiom 的
|
||||
if rawTx.Transaction.Message.AddressTableLookups[0].AccountKey != axiomTxLoopupTable {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 6 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront") || !strings.HasSuffix(accountId, "TradeWithAxiomDotTrade") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
return false
|
||||
}
|
||||
|
||||
// axiom 会先创建 token 账户, 而不是 wsol 账户
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId == solana.WrappedSol {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查调用axiom合约
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != axiomProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[5]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func checkPumpFunGmgnBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
if rawTx.Version != "legacy" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 6 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront1111111111151111111111111655") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId == solana.WrappedSol {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查调用 gmgn 合约
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != gmgnProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[5]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
65
consts.go
65
consts.go
@@ -41,6 +41,12 @@ var platformFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("9yMwSPk9mrXSN7yDHUuZurAh1sjbJsfpUqjZ7SvVtdco"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("92Med3qeK7duC5iiYsHX38H2f2twJfRsSx93oNrza2VH"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("65gDv7pZQCZELsNpNYSFEBtNFpWZAbxmRFB6BGMqFkHH"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("8jgg7moFJkHyTtAv9M6RBSPMp2oXeXhuiUMKW8YbYCWn"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("BJgbYMZgqm79gNrmm31tV3L8GQorw91XFm4m7evyfPjr"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("BWgb8wR1FEGiu1jCDSKuHKf752W27b4iN6SvoNCiK4qp"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("GV4Bt6ehW5x5dqtaWAJBSnz8uum5Z2Rp9P2Tr5iVuQn5"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("2jwHNxavSoMZMEDbT1eV9PcPt5dDcayCqM6MkgaPpmWQ"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("66N1M2aaDSdJFZ1d7YoVN4EU45ju6XiscapLVHn5FLms"): PlatformTrojan,
|
||||
solana.MustPublicKeyFromBase58("4mih95RmBqfHYvEfqq6uGGLp1Fr3gVS3VNSEa3JVRfQK"): PlatformRaybot,
|
||||
solana.MustPublicKeyFromBase58("3udvfL24waJcLhskRAsStNMoNUvtyXdxrWQz4hgi953N"): PlatformMoonshot,
|
||||
solana.MustPublicKeyFromBase58("3kxSQybWEeQZsMuNWMRJH4TxrhwoDwfv41TNMLRzFP5A"): PlatformMEVX,
|
||||
@@ -61,6 +67,7 @@ var platformFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("HkJYryz2BNeMQfuuSWDYktWt5fZLV26eK6nqu7EJycoG"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("BfFX9rUm8qTZiZjmeq9BktWVTNuG3YWMc5AvkrCKJike"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("2ApLdwLrGayEmxgpLX9BTR47Q2QprfMg5SpjrLeaK8s7"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("AVahywMVNRYzdgWrufSWrtdGXAeNEvfpJFxhVFK516mT"): PlatformDexScreener,
|
||||
}
|
||||
|
||||
var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
@@ -178,6 +185,7 @@ var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("soyascXFW5wEEYiwfEmHy2pNwomqzvggJosGVD6TJdY"): MevAgentSoyas,
|
||||
solana.MustPublicKeyFromBase58("soyasDBdKjADwPz3xk82U3TNPRDKEWJj7wWLajNHZ1L"): MevAgentSoyas,
|
||||
solana.MustPublicKeyFromBase58("soyasE2abjBAynmHbGWgEwk4ctBy7JMTUCNrMbjcnyH"): MevAgentSoyas,
|
||||
solana.MustPublicKeyFromBase58("soyasF3QPWPAKKmgA3GjfWax1kmTT1aoqSGxPzVLNUQ"): MevAgentSoyas,
|
||||
solana.MustPublicKeyFromBase58("ste11JV3MLMM7x7EJUM2sXcJC1H7F4jBLnP9a9PG8PH"): MevAgentStellium,
|
||||
solana.MustPublicKeyFromBase58("ste11MWPjXCRfQryCshzi86SGhuXjF4Lv6xMXD2AoSt"): MevAgentStellium,
|
||||
solana.MustPublicKeyFromBase58("ste11p5x8tJ53H1NbNQsRBg1YNRd4GcVpxtDw8PBpmb"): MevAgentStellium,
|
||||
@@ -190,6 +198,7 @@ var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("ASde6y8pBCU1aityWHRpqT7pEAcEonjCgFUMeh5egRes"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("ASUv6G8Cj6zt71UAqD1aVtDC3CRn6FFddqF17ZiegrES"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("ASY4mvCtrACKFK8Jiuvqcu8fad9gGTzvfm5zp4megRes"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("astraubkDw81n4LuutzSQ8uzHCv4BhPVhfvTcYv8SKC"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("astraEJ2fEj8Xmy6KLG7B3VfbKfsHXhHrNdCQx7iGJK"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("B1ooMsWjc4SUVVuLyCu1ig2RdomQnHKgMzBMfmSo3DK"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("B1ooMZfUJmAvppzc5cr7eYG8Cenig4FbQGBytr4DGCh"): MevAgentAstralane,
|
||||
@@ -201,6 +210,14 @@ var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("B1ooMauwuJPhHsXqt3uj7B92CAFG8kaD1Q2iGEmGYnx"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("B1ooMdjcY7zemxDWiH8jVZPxEMdHnE5AraWPHdHQoPj"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("B1ooMKzu6siJzQutP6a6oLiY3fpzgQnBZsAjxuAm9qo"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AstrA1ejL4UeXC2SBP4cpeEmtcFPZVLxx3XGKXyCW6to"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AsTra79FET4aCKWspPqeSFvjJNyp96SvAnrmyAxqg5b7"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AsTRADtvb6tTmrsqULQ9Wji9PigDMjhfEMza6zkynEvV"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AsTRAEoyMofR3vUPpf9k68Gsfb6ymTZttEtsAbv8Bk4d"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AStrAJv2RN2hKCHxwUMtqmSxgdcNZbihCwc1mCSnG83W"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("Astran35aiQUF57XZsmkWMtNCtXGLzs8upfiqXxth2bz"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("AStRAnpi6kFrKypragExgeRoJ1QnKH7pbSjLAKQVWUum"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("ASTRaoF93eYt73TYvwtsv6fMWHWbGmMUZfVZPo3CRU9C"): MevAgentAstralane,
|
||||
solana.MustPublicKeyFromBase58("Gu2UGEfze3Gg5cHuEC4jGbyCufgpev75RkVvBdKKtf12"): MevAgentNozomi,
|
||||
solana.MustPublicKeyFromBase58("E8wD3SMD1trozPrvSN9F6SyuUXD7rrFDuR3WexGziKG5"): MevAgent0slot,
|
||||
solana.MustPublicKeyFromBase58("18hCV7f9CPmZRAH3QCNZaGHhHeNSfisQKeKuFkQsPLY"): MevAgent0slot,
|
||||
@@ -319,6 +336,51 @@ var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("bgH7YhymSykyvMa3nAZpzvrn73owJHU5iB75S1aiLT9"): MevAgentNozomi,
|
||||
solana.MustPublicKeyFromBase58("pfngGVVQLiVRFbLWw3Ektiv17ef9NiRZbcgdAhh4ZEW"): MevAgentNozomi,
|
||||
solana.MustPublicKeyFromBase58("nEFs3jph8HJt7honu3k7XtGUufMnwAvSXmXcKSPxryP"): MevAgentNozomi,
|
||||
solana.MustPublicKeyFromBase58("Fa1con11xLjPddfzRwRUB16sbFZggp2JeJkCeWREyR8X"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con11TM1RuAQzbQzYjTy4Ekfap9Lnc9fnEbQYEd6Q"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con113Bvi76nS5AzUiRDC2fqjfzkNMUNRLgQybMYt"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con1QGHJK232s8yZpzZZwqPexnAKcoyKj626LNsMv"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con1zUzb6qJVFz5tNkPq1Ahm8H1qKW7Q48252QbkQ"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con16d3MSwd3SAiwvr2LwgkpE7ot8zntbpuec8HAx"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con1i7mpa7Qc6epYJ6r4P9AbU77DFFz173r59Df1x"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con18nWn8TdAGL7JX8PertfMUGVSc899NawokJ4Bq"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con1GKusK2EqsfzrDzGPaYZSxQtFGzJiRMMU9Zm2g"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Fa1con1RDwVwM9VrJ53CwVefD3VU9c58EMpDawV7fLMi"): MevagentFa1con,
|
||||
solana.MustPublicKeyFromBase58("Sp1x2AqpQckPLaWnWCJUNg8k6qQexfaEWcSRKf5JcDV"): MevagentBlocksprint,
|
||||
solana.MustPublicKeyFromBase58("Sp4JHSh9cksfzXbgK7Pq2ovtn8LirLQydaJKTsiNT77"): MevagentBlocksprint,
|
||||
solana.MustPublicKeyFromBase58("Sp1xMS2cbw83SZDNr4AGqkBYYLjb3LvVnmDSrTMaHkr"): MevagentBlocksprint,
|
||||
solana.MustPublicKeyFromBase58("SpagSJmnh8E9cGT5Y431xPPaS2c1xLREGGCWN9yDeUf"): MevagentBlocksprint,
|
||||
solana.MustPublicKeyFromBase58("SpWrza9E63MQuHeGnnfzmtLVCs3pBdjyKPXUABPo9nq"): MevagentBlocksprint,
|
||||
solana.MustPublicKeyFromBase58("moon17L6BgxXRX5uHKudAmqVF96xia9h8ygcmG2sL3F"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moon26Sek222Md7ZydcAGxoKG832DK36CkLrS3PQY4c"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moon7fwyajcVstMoBnVy7UBcTx87SBtNoGGAaH2Cb8V"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonBtH9HvLHjLqi9ivyrMVKgFUsSfrz9BwQ9khhn1u"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonCJg8476LNFLptX1qrK8PdRsA1HD1R6XWyu9MB93"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonF2sz7qwAtdETnrgxNbjonnhGGjd6r4W4UC9284s"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonKfftMiGSak3cezvhEqvkPSzwrmQxQHXuspC96yj"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonQBUKBpkifLcTd78bfxxt4PYLwmJ5admLW6cBBs8"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonXwpKwoVkMegt5Bc776cSW793X1irL5hHV1vJ3JA"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("moonZ6u9E2fgk6eWd82621eLPHt9zuJuYECXAYjMY1C"): MevAgentMoon,
|
||||
solana.MustPublicKeyFromBase58("SpEEdz8S1KorkMZqjMUxfxrmWwofmp6ReNP2Nx6CUmq"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("SpeeDy3GJM4wcrQmk1itRFWgidvxX4rwjTLMv78wwjE"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("SPeEdva37vW8vRtqgYjprQs1g3965icfVN5Rt7SMAyh"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("speEdrSEpox5GUfHWcBc7tQjRuSfUin2yvB7qoYvvJh"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("SPeEDmkHkN3A2roSZf6aZyEMsmrGqTHKqwP51y2Y4rV"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("SpeedLdTJXh2RKpXEaP8JCxkWoUVXhtdPQ1EnxBJMxc"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("SpEediGKLbbXndSYTzwmz6Z3NDgHQLDcTDEvGFkSMH9"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("speede8xCcUq2Tiv1efXeTuE3k9TDNq8TnGKaKSc6J4"): MevAgentSpeedlanding,
|
||||
solana.MustPublicKeyFromBase58("harkEpXoJv5qVzHaN7HSuUAd6PHjyMcFMcDYBMDJCEQ"): MevAgentAllenhark,
|
||||
solana.MustPublicKeyFromBase58("harkm2BTWxZuszoNpZnfe84jRbQTg6KGHaQBmWzDGQQ"): MevAgentAllenhark,
|
||||
solana.MustPublicKeyFromBase58("harkR2YJ4Dpt4UDJTcBirjnSPBhNpQFcoFkNpCkVqNk"): MevAgentAllenhark,
|
||||
solana.MustPublicKeyFromBase58("t3QLYyXH4vZYbEifLqjD581t5dPVhq9LABxWceySzL2"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t46SqGmwStEffUMp1fr2xmv5uyR85TB9annJuLKLf83"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t1TcSg9biJsz4NjKjhopK8QZzPS4KzBgFSszu5QTGgF"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t2XFAFBaUkCzxJwEbLWFX9PKFjfBCp2tSyFtx5z4RZM"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t55hdzzftxWkYy3J8t32C9RRcZDuMZ4LDuBmbTzJFkU"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t6UtTQLUGHJJrzxAb8PBBZdZKra8SWUqvTv9zPnxKNz"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t7qUQU35sLpPydh42BcPmtEfTWW8gBe4Ry3gjwVnokJ"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t8pPgarSK3TnuLbbHmoE1RCQdLxfxuPqNTyFjBKahok"): MevAgentRaiden,
|
||||
solana.MustPublicKeyFromBase58("t96GGdw3MiaGR993XN8PSsRpKGXx56t5Wf6zcF1hBpY"): MevAgentRaiden,
|
||||
}
|
||||
|
||||
var entryContractAddresses = map[solana.PublicKey]string{
|
||||
@@ -360,6 +422,7 @@ var entryContractAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("B3111yJCeHBcA1bizdJjUFPALfhAfSRnAbJzGUtnt56A"): EntryContractBinanceWallet,
|
||||
solana.MustPublicKeyFromBase58("FLASHX8DrLbgeR8FcfNV1F5krxYcYMUdBkrP1EPBtxB9"): EntryContractAxiom,
|
||||
solana.MustPublicKeyFromBase58("F5tfvbLog9VdGUPqBDTT8rgXvTTcq7e5UiGnupL1zvBq"): EntryContractAxiom,
|
||||
solana.MustPublicKeyFromBase58("Gz9VPiSLQYbvKyb3jZPjNfyA6n4T4qVFUuAukgL964nL"): EntryContractAxiom,
|
||||
solana.MustPublicKeyFromBase58("B3jytJa6Tzpn4Ly7GNnDm3dMGqUin5aMRm5aPsJGU5G7"): EntryContractTradewiz,
|
||||
solana.MustPublicKeyFromBase58("DBotWvSso9oD1ZB3aHx2LiD2ZoFpF8PbKjaT4uHKLLVs"): EntryContractDbot,
|
||||
solana.MustPublicKeyFromBase58("term9YPb9mzAsABaqN71A4xdbxHmpBNZavpBiQKZzN3"): EntryContractPadre,
|
||||
@@ -367,3 +430,5 @@ var entryContractAddresses = map[solana.PublicKey]string{
|
||||
|
||||
var okxDexRoutersV2 = solana.MustPublicKeyFromBase58("proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u")
|
||||
var okxAggregatorV2 = solana.MustPublicKeyFromBase58("6m2CDdhRgxpH4WjvdzxAYbGxwdGUz5MziiL5jek2kBma")
|
||||
|
||||
var axiomOuterContract = solana.MustPublicKeyFromBase58("FLASHX8DrLbgeR8FcfNV1F5krxYcYMUdBkrP1EPBtxB9")
|
||||
|
||||
35
enum.go
35
enum.go
@@ -1,20 +1,26 @@
|
||||
package pump_parser
|
||||
|
||||
const (
|
||||
MevAgentJito = "jito"
|
||||
MevAgent0slot = "0slot"
|
||||
MevAgentBlocxRoute = "blocxroute"
|
||||
MevAgentNozomi = "nozomi"
|
||||
MevAgentNextBlock = "nextblock"
|
||||
MevAgentHelius = "helius"
|
||||
MevAgentNode1 = "node1"
|
||||
MevAgentFlashBlock = "flashBlock"
|
||||
MevAgentUnknown = "unknown"
|
||||
MevAgentBlockRazor = "blockrazor"
|
||||
MevAgentFast = "fast"
|
||||
MevAgentSoyas = "soyas"
|
||||
MevAgentStellium = "stellium"
|
||||
MevAgentAstralane = "astralane"
|
||||
MevAgentJito = "jito"
|
||||
MevAgent0slot = "0slot"
|
||||
MevAgentBlocxRoute = "blocxroute"
|
||||
MevAgentNozomi = "nozomi"
|
||||
MevAgentNextBlock = "nextblock"
|
||||
MevAgentHelius = "helius"
|
||||
MevAgentNode1 = "node1"
|
||||
MevAgentFlashBlock = "flashBlock"
|
||||
MevAgentUnknown = "unknown"
|
||||
MevAgentBlockRazor = "blockrazor"
|
||||
MevAgentFast = "fast"
|
||||
MevAgentSoyas = "soyas"
|
||||
MevAgentStellium = "stellium"
|
||||
MevAgentAstralane = "astralane"
|
||||
MevagentFa1con = "fa1con"
|
||||
MevagentBlocksprint = "blocksprint"
|
||||
MevAgentMoon = "moon"
|
||||
MevAgentSpeedlanding = "speedlanding"
|
||||
MevAgentAllenhark = "allenhark"
|
||||
MevAgentRaiden = "raiden"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -75,6 +81,7 @@ const (
|
||||
PlatformMaestro = "maestro"
|
||||
PlatformBonkBot = "bonkbot"
|
||||
PlatformPadre = "padre"
|
||||
PlatformDexScreener = "dexscreener"
|
||||
|
||||
// used to flag transactions impersonating platform users
|
||||
PlatformFake = "fake"
|
||||
|
||||
154
error.go
154
error.go
@@ -79,54 +79,54 @@ const (
|
||||
|
||||
const (
|
||||
GenericError InstructionErrorVariant = iota
|
||||
/// The arguments provided to a program were invalid
|
||||
// InvalidArgument / The arguments provided to a program were invalid
|
||||
InvalidArgument
|
||||
/// An instruction's data contents were invalid
|
||||
// InvalidInstructionData / An instruction's data contents were invalid
|
||||
InvalidInstructionData
|
||||
/// An account's data contents was invalid
|
||||
// InvalidAccountData / An account's data contents was invalid
|
||||
InvalidAccountData
|
||||
/// An account's data was too small
|
||||
// AccountDataTooSmall / An account's data was too small
|
||||
AccountDataTooSmall
|
||||
/// An account's balance was too small to complete the instruction
|
||||
// InsufficientFunds / An account's balance was too small to complete the instruction
|
||||
InsufficientFunds
|
||||
/// The account did not have the expected program id
|
||||
// IncorrectProgramId / The account did not have the expected program id
|
||||
IncorrectProgramId
|
||||
/// A signature was required but not found
|
||||
// MissingRequiredSignature / A signature was required but not found
|
||||
MissingRequiredSignature
|
||||
/// An initialize instruction was sent to an account that has already been initialized.
|
||||
// AccountAlreadyInitialized / An initialize instruction was sent to an account that has already been initialized.
|
||||
AccountAlreadyInitialized
|
||||
/// An attempt to operate on an account that hasn't been initialized.
|
||||
// UninitializedAccount / An attempt to operate on an account that hasn't been initialized.
|
||||
UninitializedAccount
|
||||
/// Program's instruction lamport balance does not equal the balance after the instruction
|
||||
// UnbalancedInstruction / Program's instruction lamport balance does not equal the balance after the instruction
|
||||
UnbalancedInstruction
|
||||
/// Program illegally modified an account's program id
|
||||
// ModifiedProgramId / Program illegally modified an account's program id
|
||||
ModifiedProgramId
|
||||
/// Program spent the lamports of an account that doesn't belong to it
|
||||
// ExternalAccountLamportSpend / Program spent the lamports of an account that doesn't belong to it
|
||||
ExternalAccountLamportSpend
|
||||
/// Program modified the data of an account that doesn't belong to it
|
||||
// ExternalAccountDataModified / Program modified the data of an account that doesn't belong to it
|
||||
ExternalAccountDataModified
|
||||
/// Read-only account's lamports modified
|
||||
// ReadonlyLamportChange / Read-only account's lamports modified
|
||||
ReadonlyLamportChange
|
||||
/// Read-only account's data was modified
|
||||
// ReadonlyDataModified / Read-only account's data was modified
|
||||
ReadonlyDataModified
|
||||
/// An account was referenced more than once in a single instruction
|
||||
// DuplicateAccountIndex / An account was referenced more than once in a single instruction
|
||||
// Deprecated, instructions can now contain duplicate accounts
|
||||
DuplicateAccountIndex
|
||||
/// Executable bit on account changed, but shouldn't have
|
||||
// ExecutableModified / Executable bit on account changed, but shouldn't have
|
||||
ExecutableModified
|
||||
/// Rent_epoch account changed, but shouldn't have
|
||||
// RentEpochModified / Rent_epoch account changed, but shouldn't have
|
||||
RentEpochModified
|
||||
/// The instruction expected additional account keys
|
||||
// NotEnoughAccountKeys / The instruction expected additional account keys
|
||||
NotEnoughAccountKeys
|
||||
/// Program other than the account's owner changed the size of the account data
|
||||
// AccountDataSizeChanged / Program other than the account's owner changed the size of the account data
|
||||
AccountDataSizeChanged
|
||||
/// The instruction expected an executable account
|
||||
// AccountNotExecutable / The instruction expected an executable account
|
||||
AccountNotExecutable
|
||||
/// Failed to borrow a reference to account data, already borrowed
|
||||
// AccountBorrowFailed / Failed to borrow a reference to account data, already borrowed
|
||||
AccountBorrowFailed
|
||||
/// Account data has an outstanding reference after a program's execution
|
||||
// InstructionAccountBorrowOutstanding / Account data has an outstanding reference after a program's execution
|
||||
InstructionAccountBorrowOutstanding
|
||||
/// The same account was multiply passed to an on-chain program's entrypoint, but the program
|
||||
// DuplicateAccountOutOfSync / The same account was multiply passed to an on-chain program's entrypoint, but the program
|
||||
/// modified them differently. A program can only modify one instance of the account because
|
||||
/// the runtime cannot determine which changes to pick or how to merge them if both are modified
|
||||
DuplicateAccountOutOfSync
|
||||
@@ -136,42 +136,42 @@ const (
|
||||
|
||||
Custom // Custom(u32),
|
||||
|
||||
/// The return value from the program was invalid. Valid errors are either a defined builtin
|
||||
// InvalidError / The return value from the program was invalid. Valid errors are either a defined builtin
|
||||
/// error value or a user-defined error in the lower 32 bits.
|
||||
InvalidError
|
||||
/// Executable account's data was modified
|
||||
// ExecutableDataModified / Executable account's data was modified
|
||||
ExecutableDataModified
|
||||
/// Executable account's lamports modified
|
||||
// ExecutableLamportChange / Executable account's lamports modified
|
||||
ExecutableLamportChange
|
||||
/// Executable accounts must be rent exempt
|
||||
// ExecutableAccountNotRentExempt / Executable accounts must be rent exempt
|
||||
ExecutableAccountNotRentExempt
|
||||
/// Unsupported program id
|
||||
// UnsupportedProgramId / Unsupported program id
|
||||
UnsupportedProgramId
|
||||
/// Cross-program invocation call depth too deep
|
||||
// CallDepth / Cross-program invocation call depth too deep
|
||||
CallDepth
|
||||
/// An account required by the instruction is missing
|
||||
// MissingAccount / An account required by the instruction is missing
|
||||
MissingAccount
|
||||
/// Cross-program invocation reentrancy not allowed for this instruction
|
||||
// ReentrancyNotAllowed / Cross-program invocation reentrancy not allowed for this instruction
|
||||
ReentrancyNotAllowed
|
||||
/// Length of the seed is too long for address generation
|
||||
// MaxSeedLengthExceeded / Length of the seed is too long for address generation
|
||||
MaxSeedLengthExceeded
|
||||
/// Provided seeds do not result in a valid address
|
||||
// InvalidSeeds / Provided seeds do not result in a valid address
|
||||
InvalidSeeds
|
||||
/// Failed to reallocate account data of this length
|
||||
// InvalidRealloc / Failed to reallocate account data of this length
|
||||
InvalidRealloc
|
||||
/// Computational budget exceeded
|
||||
// ComputationalBudgetExceeded / Computational budget exceeded
|
||||
ComputationalBudgetExceeded
|
||||
/// Cross-program invocation with unauthorized signer or writable account
|
||||
// PrivilegeEscalation / Cross-program invocation with unauthorized signer or writable account
|
||||
PrivilegeEscalation
|
||||
/// Failed to create program execution environment
|
||||
// ProgramEnvironmentSetupFailure / Failed to create program execution environment
|
||||
ProgramEnvironmentSetupFailure
|
||||
/// Program failed to complete
|
||||
// ProgramFailedToComplete / Program failed to complete
|
||||
ProgramFailedToComplete
|
||||
/// Program failed to compile
|
||||
// ProgramFailedToCompile / Program failed to compile
|
||||
ProgramFailedToCompile
|
||||
/// Account is immutable
|
||||
// Immutable / Account is immutable
|
||||
Immutable
|
||||
/// Incorrect authority provided
|
||||
// IncorrectAuthority / Incorrect authority provided
|
||||
IncorrectAuthority
|
||||
/// Failed to serialize or deserialize account data
|
||||
///
|
||||
@@ -185,23 +185,23 @@ const (
|
||||
|
||||
BorshIoError // BorshIoError(String)
|
||||
|
||||
// An account does not have enough lamports to be rent-exempt
|
||||
// AccountNotRentExempt An account does not have enough lamports to be rent-exempt
|
||||
AccountNotRentExempt
|
||||
/// Invalid account owner
|
||||
// InvalidAccountOwner Invalid account owner
|
||||
InvalidAccountOwner
|
||||
/// Program arithmetic overflowed
|
||||
// ArithmeticOverflow Program arithmetic overflowed
|
||||
ArithmeticOverflow
|
||||
/// Unsupported sysvar
|
||||
// UnsupportedSysvar Unsupported sysvar
|
||||
UnsupportedSysvar
|
||||
/// Illegal account owner
|
||||
// IllegalOwner Illegal account owner
|
||||
IllegalOwner
|
||||
/// Accounts data allocations exceeded the maximum allowed per transaction
|
||||
// MaxAccountsDataAllocationsExceeded / Accounts data allocations exceeded the maximum allowed per transaction
|
||||
MaxAccountsDataAllocationsExceeded
|
||||
/// Max accounts exceeded
|
||||
// MaxAccountsExceeded Max accounts exceeded
|
||||
MaxAccountsExceeded
|
||||
/// Max instruction trace length exceeded
|
||||
// MaxInstructionTraceLengthExceeded Max instruction trace length exceeded
|
||||
MaxInstructionTraceLengthExceeded
|
||||
/// Builtin programs must consume compute units
|
||||
// BuiltinProgramsMustConsumeComputeUnits Builtin programs must consume compute units
|
||||
BuiltinProgramsMustConsumeComputeUnits
|
||||
)
|
||||
|
||||
@@ -210,6 +210,15 @@ type TransactionError struct {
|
||||
rest []byte
|
||||
}
|
||||
|
||||
type TransactionParsedError struct {
|
||||
Index uint8
|
||||
Variant TransactionErrorVariant
|
||||
Enum InstructionErrorVariant
|
||||
CustomCode uint32
|
||||
|
||||
UnKnown string
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidTransactionError = errors.New("invalid transaction error")
|
||||
NotAnInstructionError = errors.New("not an instruction error")
|
||||
@@ -233,6 +242,49 @@ func DecodeTransactionError(data []byte) (*TransactionError, error) {
|
||||
return &err, nil
|
||||
}
|
||||
|
||||
func ParseTransactionErrorFromGeyser(data []byte) *TransactionParsedError {
|
||||
if len(data) == 0 {
|
||||
return nil
|
||||
}
|
||||
transactionError, err := DecodeTransactionError(data)
|
||||
if err != nil {
|
||||
return &TransactionParsedError{
|
||||
UnKnown: string(data),
|
||||
}
|
||||
}
|
||||
|
||||
enumErr, err := transactionError.GetInstructionError()
|
||||
if err != nil {
|
||||
return &TransactionParsedError{
|
||||
Variant: transactionError.Variant,
|
||||
UnKnown: string(data),
|
||||
}
|
||||
}
|
||||
if enumErr.Variant != Custom {
|
||||
return &TransactionParsedError{
|
||||
Index: enumErr.Index,
|
||||
Variant: transactionError.Variant,
|
||||
Enum: enumErr.Variant,
|
||||
}
|
||||
}
|
||||
customCode, err := enumErr.Custom()
|
||||
if err != nil {
|
||||
return &TransactionParsedError{
|
||||
Index: enumErr.Index,
|
||||
Variant: transactionError.Variant,
|
||||
Enum: enumErr.Variant,
|
||||
UnKnown: string(data),
|
||||
}
|
||||
}
|
||||
|
||||
return &TransactionParsedError{
|
||||
Index: enumErr.Index,
|
||||
Variant: transactionError.Variant,
|
||||
Enum: enumErr.Variant,
|
||||
CustomCode: customCode.Code,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *TransactionError) GetCustomErrorCode() (uint8, uint32, error) {
|
||||
instr, err := e.GetInstructionError()
|
||||
if err != nil {
|
||||
|
||||
47
error_test.go
Normal file
47
error_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package pump_parser
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDecodeTransactionError(t *testing.T) {
|
||||
var testCases = []struct {
|
||||
name string
|
||||
data string
|
||||
}{
|
||||
{
|
||||
name: "ComputationalBudgetExceeded",
|
||||
data: "CAAAAAMlAAAA",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
bytesData, err := base64.StdEncoding.DecodeString(tc.data)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to decode base64 data for %s: %v", tc.name, err)
|
||||
return
|
||||
}
|
||||
te, err := DecodeTransactionError(bytesData)
|
||||
if err != nil {
|
||||
t.Errorf("Decoded error for %s: %v", tc.name, err)
|
||||
return
|
||||
}
|
||||
|
||||
if te.Variant != InstructionError {
|
||||
t.Errorf("Expected Variant to be InstructionError for %s, got %d", tc.name, te.Variant)
|
||||
return
|
||||
}
|
||||
errName, err := te.GetInstructionError()
|
||||
if err != nil {
|
||||
t.Errorf("Failed to get instruction error for %s: %v", tc.name, err)
|
||||
return
|
||||
}
|
||||
if errName.Variant != ComputationalBudgetExceeded {
|
||||
t.Errorf("Expected instruction error variant to be Custom for %s, got %d", tc.name, errName.Variant)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,17 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
"github.com/shopspring/decimal"
|
||||
parser "github.com/thloyi/pump-parser"
|
||||
example "github.com/thloyi/pump-parser/internal/example"
|
||||
)
|
||||
|
||||
var (
|
||||
pumpProgram = solana.MustPublicKeyFromBase58("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P")
|
||||
pumpAmmProgram = solana.MustPublicKeyFromBase58("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA")
|
||||
)
|
||||
|
||||
func main() {
|
||||
//pool, err := ants.NewPool(100, ants.WithPreAlloc(true), ants.WithNonblocking(true))
|
||||
//if err != nil {
|
||||
@@ -31,7 +38,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
ptx := msg.Tx
|
||||
fmt.Println("consume", ptx.ComputeUnitsConsumed, "limit", ptx.CuLimit, "hash", ptx.GetTxHash())
|
||||
// fmt.Println("consume", ptx.ComputeUnitsConsumed, "limit", ptx.CuLimit, "hash", ptx.GetTxHash())
|
||||
//data, _ := json.Marshal(tx)
|
||||
//fmt.Println(string(data))
|
||||
//continue
|
||||
@@ -44,40 +51,9 @@ func main() {
|
||||
//}
|
||||
|
||||
// 处理交易
|
||||
txErr, ok := ptx.Err.(*parser.TransactionError)
|
||||
var customerErrCode uint32
|
||||
var instructorErrIndex uint8
|
||||
if ok {
|
||||
instructorErrIndex, customerErrCode, _ = txErr.GetCustomErrorCode()
|
||||
fmt.Printf("now: %s, block: %d, tx: %s, errInstr Code: %d, errInstrIndex: %d, err: %v\n", time.Now().Format("2006-01-02 15:04:05"), ptx.Block, ptx.GetTxHash(), customerErrCode, instructorErrIndex, ptx.Err)
|
||||
} else {
|
||||
txs := example.FromTx(ptx)
|
||||
if len(txs) == 0 {
|
||||
fmt.Printf("tx is empty, block: %d, tx %s \n", ptx.Block, ptx.GetTxHash())
|
||||
continue
|
||||
}
|
||||
// printed := false
|
||||
for _, tx := range txs {
|
||||
if tx.Program != parser.SolProgramPumpAMM {
|
||||
continue
|
||||
}
|
||||
//if tx.Token1Amount.GreaterThanOrEqual(decimal.NewFromFloat(0.1)) || tx.Event != "buy" {
|
||||
// continue
|
||||
//}
|
||||
// printed = true
|
||||
fmt.Printf("t: %s, block: %d, is cash:%v hash: %s, maker: %s, program: %s, event: %s, token0: %s, entryContract: %s, token balance: %s, EntryContract: %s\n",
|
||||
time.Now().Format(time.RFC3339Nano),
|
||||
tx.Block, tx.Cashback, tx.GetTxHash(), tx.Maker, tx.Program, tx.Event, tx.Token0Amount, tx.EntryContract, tx.AfterSignerToken0Balance, tx.EntryContract)
|
||||
//break
|
||||
}
|
||||
//if !printed {
|
||||
// continue
|
||||
//}
|
||||
//fmt.Printf("t: %s, block: %d, hash: %s, signer: %s, program: %s, event: %s, token0: %s, token1: %s, signer before sol :%s, after sol: %s, after token: %s, tokencreator: %s, tokenprogram: %s, mayhem: %t\n",
|
||||
// time.Now().Format(time.RFC3339Nano),
|
||||
// tx.Block, tx.GetTxHash(), tx.Maker, tx.Program, tx.Event, tx.Token0Amount.String(), tx.Token1Amount.String(),
|
||||
// tx.BeforeSolBalance, tx.AfterSOLBalance, tx.AfterSignerToken0Balance, tx.TokenCreator, tx.Token0Program, tx.Mayhem)
|
||||
|
||||
if len(ptx.Swaps) > 0 && (ptx.Swaps[0].Program == parser.SolProgramPump || ptx.Swaps[0].Program == parser.SolProgramPumpAMM) {
|
||||
fmt.Printf("success tx : %s, program: %s, event: %s, block: %d, tx: %s, base: %s, quote: %s \n", time.Now().Format("2006-01-02 15:04:05"), ptx.Swaps[0].Program, ptx.Swaps[0].Event, ptx.Block, ptx.GetTxHash(),
|
||||
ptx.Swaps[0].BaseAmount.Div(decimal.NewFromInt(1e6)), ptx.Swaps[0].QuoteAmount.Div(decimal.NewFromInt(1e9)))
|
||||
}
|
||||
// currentBlock = ptx.Block
|
||||
//
|
||||
|
||||
@@ -3,7 +3,6 @@ package parser
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
types "github.com/thloyi/pump-parser"
|
||||
)
|
||||
|
||||
@@ -23,24 +22,14 @@ func NewPumpHandler(cb func(*types.Tx)) *PumpHandler {
|
||||
func (h *PumpHandler) HandleMessage(rawTx *types.RawTx) {
|
||||
if rawTx.Meta.Err != nil {
|
||||
// Notify the channel about the failed transaction
|
||||
beforeSolBalance := decimal.Zero
|
||||
afterSolBalance := decimal.Zero
|
||||
if rawTx.Meta.PreBalances != nil && len(rawTx.Meta.PreBalances) > 0 {
|
||||
beforeSolBalance = decimal.NewFromUint64(rawTx.Meta.PreBalances[0]).Div(decimal.NewFromInt(1e9))
|
||||
var parsedTx = &types.Tx{}
|
||||
parsedTx.SetRawTx(rawTx)
|
||||
err := parsedTx.Parser()
|
||||
if err != nil {
|
||||
fmt.Printf("parser failed tx error: %s, block: %d tx: %s\n", err, rawTx.Slot, rawTx.TxHash())
|
||||
return
|
||||
}
|
||||
if rawTx.Meta.PostBalances != nil && len(rawTx.Meta.PostBalances) > 0 {
|
||||
afterSolBalance = decimal.NewFromUint64(rawTx.Meta.PostBalances[0]).Div(decimal.NewFromInt(1e9))
|
||||
}
|
||||
h.callback(&types.Tx{
|
||||
TxHash: (*[64]byte)((rawTx.Transaction.Signatures[0][:])),
|
||||
Err: rawTx.Meta.Err,
|
||||
Signer: rawTx.GetSigner(),
|
||||
Block: rawTx.Slot,
|
||||
BlockIndex: uint64(rawTx.IndexWithinBlock),
|
||||
|
||||
BeforeSolBalance: beforeSolBalance,
|
||||
AfterSOLBalance: afterSolBalance,
|
||||
})
|
||||
h.callback(parsedTx)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -50,19 +50,18 @@ type Client struct {
|
||||
func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client {
|
||||
var subscription pb.SubscribeRequest
|
||||
|
||||
var failed = false
|
||||
//var failed = true
|
||||
var vote = false
|
||||
subscription.Transactions = make(map[string]*pb.SubscribeRequestFilterTransactions)
|
||||
subscription.Transactions["transactions_sub"] = &pb.SubscribeRequestFilterTransactions{
|
||||
Failed: &failed,
|
||||
Vote: &vote,
|
||||
//Failed: &failed,
|
||||
Vote: &vote,
|
||||
}
|
||||
|
||||
subscription.Transactions["transactions_sub"].AccountInclude = []string{
|
||||
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", //Pump AMM
|
||||
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", //Pump
|
||||
}
|
||||
|
||||
subscription.BlocksMeta = make(map[string]*pb.SubscribeRequestFilterBlocksMeta)
|
||||
subscription.BlocksMeta["block_meta"] = &pb.SubscribeRequestFilterBlocksMeta{}
|
||||
|
||||
@@ -83,12 +82,12 @@ func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client
|
||||
func NewClientWithLaunchLab(endpoint string, ch chan SubscriptionMessage) *Client {
|
||||
var subscription pb.SubscribeRequest
|
||||
|
||||
var failed = false
|
||||
//var failed = false
|
||||
var vote = false
|
||||
subscription.Transactions = make(map[string]*pb.SubscribeRequestFilterTransactions)
|
||||
subscription.Transactions["transactions_sub"] = &pb.SubscribeRequestFilterTransactions{
|
||||
Failed: &failed,
|
||||
Vote: &vote,
|
||||
//Failed: &failed,
|
||||
Vote: &vote,
|
||||
}
|
||||
|
||||
subscription.Transactions["transactions_sub"].AccountInclude = []string{
|
||||
|
||||
@@ -23,7 +23,7 @@ var ()
|
||||
|
||||
func main() {
|
||||
|
||||
var slot uint64 = 399477968
|
||||
var slot uint64 = 403021435
|
||||
var data = NewBlockData(decimal.NewFromFloat(100.0))
|
||||
client := rpc.New("https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d")
|
||||
var rewards = false
|
||||
@@ -53,9 +53,9 @@ func main() {
|
||||
fmt.Println("from rpc tx error:", i, err)
|
||||
break
|
||||
}
|
||||
if rawTx.Meta.Err != nil {
|
||||
continue
|
||||
}
|
||||
//if rawTx.Meta.Err != nil {
|
||||
// continue
|
||||
//}
|
||||
parsedTx, err := solana_parser.ParseRawTx(rawTx)
|
||||
if err != nil {
|
||||
fmt.Println("parse tx error:", i, rawTx.TxHash(), err)
|
||||
@@ -91,9 +91,7 @@ func main() {
|
||||
fmt.Println("parse action error:", "tx", result.GetTxHash(), "i", i, "err", err)
|
||||
}
|
||||
}
|
||||
if result.GetTxHash() == "3vMp5Lqm7PxS9MXfXgmptKA9xLkyfKfJpuFs2mUfhRuqTWjGj7DcvSb65NsHQH5RF9JXVLbxrpUHV4LXrgmjXmft" {
|
||||
fmt.Println("xxx")
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Println("slot", slot, "tx count: ", len(data.Txs))
|
||||
|
||||
|
||||
62
meta.go
62
meta.go
@@ -68,25 +68,41 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
meteoraInitializeLbPairDiscriminator = calculateDiscriminator("global:initialize_lb_pair2")
|
||||
meteoraInitializeLbPairEventDiscriminator = calculateDiscriminator("event:LbPairCreate")
|
||||
meteoraDlmmSwapDiscriminator = calculateDiscriminator("global:swap")
|
||||
meteoraDlmmSwap2Discriminator = calculateDiscriminator("global:swap2")
|
||||
meteoraDlmmSwapExactOutDiscriminator = calculateDiscriminator("global:swap_exact_out")
|
||||
meteoraDlmmSwapExactOut2Discriminator = calculateDiscriminator("global:swap_exact_out2")
|
||||
meteoraDlmmSwapWithPriceImpactDiscriminator = calculateDiscriminator("global:swap_with_price_impact")
|
||||
meteoraDlmmSwapWithPriceImpact2Discriminator = calculateDiscriminator("global:swap_with_price_impact2")
|
||||
meteoraDlmmSwapEventDiscriminator = calculateDiscriminator("event:Swap")
|
||||
meteoraDlmmAddLiquidityDiscriminator = calculateDiscriminator("global:add_liquidity")
|
||||
meteoraDlmmAddLiquidity2Discriminator = calculateDiscriminator("global:add_liquidity2")
|
||||
meteoraDlmmAddLiquidityByStrategyDiscriminator = calculateDiscriminator("global:add_liquidity_by_strategy")
|
||||
meteoraDlmmAddLiquidityByStrategy2Discriminator = calculateDiscriminator("global:add_liquidity_by_strategy2")
|
||||
meteoraDlmmRemoveLiquidityDiscriminator = calculateDiscriminator("global:remove_liquidity")
|
||||
meteoraDlmmRemoveLiquidity2Discriminator = calculateDiscriminator("global:remove_liquidity2")
|
||||
meteoraDlmmRemoveLiquidityByRangeDiscriminator = calculateDiscriminator("global:remove_liquidity_by_range")
|
||||
meteoraDlmmRemoveLiquidityByRange2Discriminator = calculateDiscriminator("global:remove_liquidity_by_range2")
|
||||
meteoraDlmmAddLiquidityEventDiscriminator = calculateDiscriminator("event:AddLiquidity")
|
||||
meteoraDlmmRemoveLiquidityEventDiscriminator = calculateDiscriminator("event:RemoveLiquidity")
|
||||
meteoraInitializeLbPairDiscriminator = calculateDiscriminator("global:initialize_lb_pair2")
|
||||
meteoraInitializeLbPairEventDiscriminator = calculateDiscriminator("event:LbPairCreate")
|
||||
meteoraDlmmSwapDiscriminator = calculateDiscriminator("global:swap")
|
||||
meteoraDlmmSwap2Discriminator = calculateDiscriminator("global:swap2")
|
||||
meteoraDlmmSwapExactOutDiscriminator = calculateDiscriminator("global:swap_exact_out")
|
||||
meteoraDlmmSwapExactOut2Discriminator = calculateDiscriminator("global:swap_exact_out2")
|
||||
meteoraDlmmSwapWithPriceImpactDiscriminator = calculateDiscriminator("global:swap_with_price_impact")
|
||||
meteoraDlmmSwapWithPriceImpact2Discriminator = calculateDiscriminator("global:swap_with_price_impact2")
|
||||
meteoraDlmmInitializePositionDiscriminator = calculateDiscriminator("global:initialize_position")
|
||||
meteoraDlmmInitializePosition2Discriminator = calculateDiscriminator("global:initialize_position2")
|
||||
meteoraDlmmInitializePositionByOperatorDiscriminator = calculateDiscriminator("global:initialize_position_by_operator")
|
||||
meteoraDlmmInitializePositionPdaDiscriminator = calculateDiscriminator("global:initialize_position_pda")
|
||||
meteoraDlmmClosePositionDiscriminator = calculateDiscriminator("global:close_position")
|
||||
meteoraDlmmClosePosition2Discriminator = calculateDiscriminator("global:close_position2")
|
||||
meteoraDlmmClosePositionIfEmptyDiscriminator = calculateDiscriminator("global:close_position_if_empty")
|
||||
meteoraDlmmSwapEventDiscriminator = calculateDiscriminator("event:Swap")
|
||||
meteoraDlmmAddLiquidityDiscriminator = calculateDiscriminator("global:add_liquidity")
|
||||
meteoraDlmmAddLiquidity2Discriminator = calculateDiscriminator("global:add_liquidity2")
|
||||
meteoraDlmmAddLiquidityByStrategyDiscriminator = calculateDiscriminator("global:add_liquidity_by_strategy")
|
||||
meteoraDlmmAddLiquidityByStrategy2Discriminator = calculateDiscriminator("global:add_liquidity_by_strategy2")
|
||||
meteoraDlmmAddLiquidityByWeightDiscriminator = calculateDiscriminator("global:add_liquidity_by_weight")
|
||||
meteoraDlmmClaimFeeDiscriminator = calculateDiscriminator("global:claim_fee")
|
||||
meteoraDlmmClaimFee2Discriminator = calculateDiscriminator("global:claim_fee2")
|
||||
meteoraDlmmRebalanceLiquidityDiscriminator = calculateDiscriminator("global:rebalance_liquidity")
|
||||
meteoraDlmmRemoveLiquidityDiscriminator = calculateDiscriminator("global:remove_liquidity")
|
||||
meteoraDlmmRemoveLiquidity2Discriminator = calculateDiscriminator("global:remove_liquidity2")
|
||||
meteoraDlmmRemoveLiquidityByRangeDiscriminator = calculateDiscriminator("global:remove_liquidity_by_range")
|
||||
meteoraDlmmRemoveLiquidityByRange2Discriminator = calculateDiscriminator("global:remove_liquidity_by_range2")
|
||||
meteoraDlmmAddLiquidityEventDiscriminator = calculateDiscriminator("event:AddLiquidity")
|
||||
meteoraDlmmClaimFeeEventDiscriminator = calculateDiscriminator("event:ClaimFee")
|
||||
meteoraDlmmClaimFee2EventDiscriminator = calculateDiscriminator("event:ClaimFee2")
|
||||
meteoraDlmmPositionCloseEventDiscriminator = calculateDiscriminator("event:PositionClose")
|
||||
meteoraDlmmPositionCreateEventDiscriminator = calculateDiscriminator("event:PositionCreate")
|
||||
meteoraDlmmRebalancingEventDiscriminator = calculateDiscriminator("event:Rebalancing")
|
||||
meteoraDlmmRemoveLiquidityEventDiscriminator = calculateDiscriminator("event:RemoveLiquidity")
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -200,8 +216,10 @@ var (
|
||||
const (
|
||||
raydiumV4InitializePoolDiscriminator = uint8(1)
|
||||
|
||||
raydiumV4SwapBaseInDiscriminator = uint8(9)
|
||||
raydiumV4SwapBaseOutDiscriminator = uint8(11)
|
||||
raydiumV4SwapBaseInDiscriminator = uint8(9)
|
||||
raydiumV4SwapBaseOutDiscriminator = uint8(11)
|
||||
raydiumV4SwapBaseInV2Discriminator = uint8(16)
|
||||
raydiumV4SwapBaseOutV2Discriminator = uint8(17)
|
||||
|
||||
raydiumV4AddLiquidityDiscriminator = uint8(3)
|
||||
raydiumV4RemoveLiquidityDiscriminator = uint8(4)
|
||||
@@ -236,4 +254,6 @@ var createAccountWithSeedDiscriminator = uint32(3)
|
||||
var systemProgram = solana.MustPublicKeyFromBase58("11111111111111111111111111111111")
|
||||
var momoProgram = solana.MustPublicKeyFromBase58("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr")
|
||||
|
||||
var chainLinkProgram = solana.MustPublicKeyFromBase58("cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ")
|
||||
|
||||
var eventDiscriminator = [8]byte{228, 69, 165, 46, 81, 203, 154, 29}
|
||||
|
||||
906
metaoradlmm.go
906
metaoradlmm.go
File diff suppressed because it is too large
Load Diff
59
parser.go
59
parser.go
@@ -2,7 +2,6 @@ package pump_parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"slices"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
@@ -14,6 +13,11 @@ var defaultSwapPrograms = map[solana.PublicKey]swapParser{
|
||||
pumpProgram: pumpParser,
|
||||
}
|
||||
|
||||
var errTxParserPrograms = map[solana.PublicKey]swapParser{
|
||||
pumpAmmProgram: pumpAmmParser,
|
||||
pumpProgram: pumpParser,
|
||||
}
|
||||
|
||||
var swapPrograms = cloneSwapPrograms(defaultSwapPrograms)
|
||||
|
||||
type ParserOption func(*parserConfig)
|
||||
@@ -56,8 +60,9 @@ func WithMeteoraDlmm() ParserOption {
|
||||
}
|
||||
|
||||
var actionPrograms = map[solana.PublicKey]actionParser{
|
||||
systemProgram: systemParser,
|
||||
budgGetProgram: budgetParser,
|
||||
systemProgram: systemParser,
|
||||
budgGetProgram: budgetParser,
|
||||
chainLinkProgram: chainLinkParser,
|
||||
}
|
||||
|
||||
func ParseRawTx(rawTx *RawTx) (*Tx, error) {
|
||||
@@ -97,6 +102,49 @@ func (tx *Tx) Parser() error {
|
||||
|
||||
tx.Token = make(map[solana.PublicKey]TokenMeta)
|
||||
|
||||
if tx.rawTx.Meta.Err != nil {
|
||||
tx.Err = tx.rawTx.Meta.Err
|
||||
if tx.Err.UnKnown != "" {
|
||||
return nil
|
||||
}
|
||||
if len(tx.rawTx.Transaction.Message.Instructions) <= int(tx.Err.Index) {
|
||||
return nil
|
||||
}
|
||||
programIdx := tx.rawTx.Transaction.Message.Instructions[tx.Err.Index].ProgramIDIndex
|
||||
if len(accountList) <= programIdx {
|
||||
return nil
|
||||
}
|
||||
programAccount := accountList[programIdx]
|
||||
parserFunc, exists := errTxParserPrograms[programAccount]
|
||||
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
// parse failed tx
|
||||
swaps, _, err := parserFunc(tx, tx.rawTx.Transaction.Message.Instructions[tx.Err.Index], InnerInstructions{}, [2]uint{uint(tx.Err.Index), uint(0)})
|
||||
if err != nil {
|
||||
return nil
|
||||
//fmt.Printf("parser failed tx error: %s, block: %d tx: %s\n", err, tx.Block, tx.GetTxHash())
|
||||
}
|
||||
if len(swaps) > 0 {
|
||||
for i := range swaps {
|
||||
swaps[i].InstrIdx = tx.Err.Index
|
||||
}
|
||||
tx.Swaps = swaps
|
||||
}
|
||||
for i, instr := range tx.rawTx.Transaction.Message.Instructions {
|
||||
if p, exists := actionPrograms[accountList[instr.ProgramIDIndex]]; exists {
|
||||
_, err := p(tx, instr, InnerInstructions{}, [2]uint{uint(i), uint(0)})
|
||||
if err != nil {
|
||||
if errors.Is(err, InstructionIgnoredError) {
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
var innersMap = make(map[int]InnerInstructions)
|
||||
for _, inner := range tx.rawTx.Meta.InnerInstructions {
|
||||
innersMap[inner.Index] = inner
|
||||
@@ -127,6 +175,7 @@ func (tx *Tx) Parser() error {
|
||||
swap.AfterSOLBalance = decimal.NewFromUint64(tx.rawTx.Meta.PostBalances[userIdx]).Div(decimal.NewFromInt(1e9))
|
||||
}
|
||||
}
|
||||
swap.InstrIdx = uint8(i)
|
||||
tx.Swaps = append(tx.Swaps, swap)
|
||||
}
|
||||
|
||||
@@ -144,7 +193,7 @@ func (tx *Tx) Parser() error {
|
||||
innerLength := len(innersMap[i].Instructions)
|
||||
for j := 1; j <= innerLength; {
|
||||
if j <= 0 || j > innerLength {
|
||||
log.Printf("inner instruction index is out if range, block: %d, tx: %s, outerIndex: %d, innerIndex: %d", tx.Block, tx.GetTxHash(), ii, j)
|
||||
//log.Printf("inner instruction index is out if range, block: %d, tx: %s, outerIndex: %d, innerIndex: %d", tx.Block, tx.GetTxHash(), ii, j)
|
||||
break
|
||||
}
|
||||
innerInstr := innersMap[i].Instructions[j-1]
|
||||
@@ -174,6 +223,8 @@ func (tx *Tx) Parser() error {
|
||||
swap.AfterSOLBalance = decimal.NewFromUint64(tx.rawTx.Meta.PostBalances[userIdx]).Div(decimal.NewFromInt(1e9))
|
||||
}
|
||||
}
|
||||
swap.InstrIdx = uint8(i)
|
||||
swap.InnerIdx = uint8(j)
|
||||
tx.Swaps = append(tx.Swaps, swap)
|
||||
}
|
||||
// tx.Swaps = append(tx.Swaps, swaps...)
|
||||
|
||||
139
pump.go
139
pump.go
@@ -34,10 +34,19 @@ func pumpParser(tx *Tx, instruction Instruction, innerInstructions InnerInstruct
|
||||
|
||||
switch discriminator {
|
||||
case pumpBuyV2Discriminator, pumpBuyDiscriminator, pumpSellDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return failedTxBuyOrSellParser(tx, instruction, innerInstructions, offset)
|
||||
}
|
||||
return BuyOrSellParser(tx, instruction, innerInstructions, offset)
|
||||
case pumpCreateDiscriminator, pumpCreateV2Discriminator:
|
||||
if tx.Err != nil {
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
return CreateParser(tx, instruction, innerInstructions, offset)
|
||||
case pumpMigrateDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
return MigrateParser(tx, instruction, innerInstructions, offset)
|
||||
default:
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
@@ -178,6 +187,16 @@ type PumpTradeEvent struct {
|
||||
|
||||
CreatorFeeBasisPoints uint64
|
||||
CreatorFee uint64
|
||||
|
||||
TrackVolume bool
|
||||
TotalUnclaimedTokens uint64
|
||||
TotalClaimedTokens uint64
|
||||
CurrentSolVolume uint64
|
||||
LastUpdateTimestamp int64
|
||||
IxName string
|
||||
MayhemMode bool
|
||||
CashbackFeeBasisPoints uint64
|
||||
Cashback uint64
|
||||
}
|
||||
|
||||
type PumpTradeFeeArg struct {
|
||||
@@ -193,6 +212,112 @@ type CompleteEvent struct {
|
||||
Timestamp int64
|
||||
}
|
||||
|
||||
type PumpTradeArgs struct {
|
||||
Discriminator [8]byte
|
||||
Amount1 uint64
|
||||
Amount2 uint64
|
||||
}
|
||||
|
||||
func failedTxBuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
if tx.Err == nil || tx.Err.UnKnown != "" {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("tx pump failed but error is nil, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Variant != InstructionError {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump failed but error variant is not instruction error, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum != Custom && tx.Err.Enum != ComputationalBudgetExceeded && tx.Err.Enum != ProgramFailedToComplete {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump failed but error is not custom or computational budget exceeded, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum == Custom {
|
||||
if !(tx.Err.CustomCode == 1 ||
|
||||
tx.Err.CustomCode == 6042 ||
|
||||
tx.Err.CustomCode == 6041 ||
|
||||
tx.Err.CustomCode == 6040 ||
|
||||
tx.Err.CustomCode == 6023 || tx.Err.CustomCode == 6021 || tx.Err.CustomCode == 6003 || tx.Err.CustomCode == 6002) {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump failed but custom error code is unexpected, offset, %d, %d, code: %d", offset[0], offset[1], tx.Err.CustomCode)
|
||||
}
|
||||
}
|
||||
|
||||
result := tx.rawTx
|
||||
var entryContract = result.accountList[result.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
|
||||
user := result.accountList[instruction.Accounts[6]]
|
||||
ataUserIdx := instruction.Accounts[5]
|
||||
userIndex := instruction.Accounts[6]
|
||||
mint := result.accountList[instruction.Accounts[2]]
|
||||
var args PumpTradeArgs
|
||||
err := agbinary.NewBorshDecoder(instruction.Data[:]).Decode(&args)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump buy/sell decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
var event string
|
||||
var (
|
||||
solAmount, tokenAmount uint64
|
||||
)
|
||||
if bytes.Equal(args.Discriminator[:], pumpBuyV2Discriminator[:]) {
|
||||
event = "buy_failed"
|
||||
solAmount = args.Amount1
|
||||
tokenAmount = args.Amount2
|
||||
} else if bytes.Equal(args.Discriminator[:], pumpBuyDiscriminator[:]) {
|
||||
event = "buy_failed"
|
||||
solAmount = args.Amount2
|
||||
tokenAmount = args.Amount1
|
||||
} else if bytes.Equal(args.Discriminator[:], pumpSellDiscriminator[:]) {
|
||||
event = "sell_failed"
|
||||
solAmount = args.Amount2
|
||||
tokenAmount = args.Amount1
|
||||
} else {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("unknown pump trade instruction discriminator, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
var baseTokenProgram solana.PublicKey
|
||||
|
||||
if event == "buy_failed" {
|
||||
baseTokenProgram = result.accountList[instruction.Accounts[8]]
|
||||
} else {
|
||||
baseTokenProgram = result.accountList[instruction.Accounts[9]]
|
||||
}
|
||||
if !user.IsOnCurve() && (entryContract.Equals(okxDexRoutersV2) || entryContract.Equals(okxAggregatorV2)) {
|
||||
userBaseAmount, ataIndex := tokenBalanceChange(result, 0, baseTokenProgram, mint)
|
||||
//&& userBaseAmount.BigInt().Uint64() == tradeEvent.TokenAmount
|
||||
if !userBaseAmount.IsZero() {
|
||||
user = result.accountList[0]
|
||||
userIndex = 0
|
||||
ataUserIdx = ataIndex
|
||||
}
|
||||
}
|
||||
|
||||
userBase := getAccountBalanceAfterTx(result, ataUserIdx)
|
||||
userQuote, _ := GetSolAfterTx(result, userIndex)
|
||||
|
||||
bcIdx := instruction.Accounts[3]
|
||||
bcAtaIndex := instruction.Accounts[4]
|
||||
solReserves, _ := GetSolAfterTx(result, bcIdx)
|
||||
tokenReserves := getAccountBalanceAfterTx(result, bcAtaIndex)
|
||||
swaps := []Swap{
|
||||
{
|
||||
Program: SolProgramPump,
|
||||
Event: event,
|
||||
Pool: result.accountList[instruction.Accounts[3]],
|
||||
BaseMint: mint,
|
||||
QuoteMint: solana.PublicKey{},
|
||||
BaseTokenProgram: baseTokenProgram,
|
||||
QuoteTokenProgram: solana.PublicKey{},
|
||||
BaseMintDecimals: 6,
|
||||
QuoteMintDecimals: 9,
|
||||
User: user,
|
||||
BaseAmount: decimal.NewFromUint64(tokenAmount),
|
||||
QuoteAmount: decimal.NewFromUint64(solAmount),
|
||||
BaseReserve: tokenReserves,
|
||||
QuoteReserve: decimal.NewFromUint64(solReserves),
|
||||
Mayhem: isMayhemPump(result.accountList[instruction.Accounts[1]]),
|
||||
UserBaseBalance: userBase,
|
||||
UserQuoteBalance: decimal.NewFromUint64(userQuote),
|
||||
EntryContract: entryContract,
|
||||
},
|
||||
}
|
||||
return swaps, offset, nil
|
||||
}
|
||||
|
||||
func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
result := tx.rawTx
|
||||
var entryContract = result.accountList[result.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
@@ -219,11 +344,13 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("pump create get inner instructions error: %v,offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
if !entryContract.Equals(axiomOuterContract) {
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,6 +441,7 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
|
||||
solAmount = solAmount - fee
|
||||
}
|
||||
}
|
||||
isCashbackCoin := tradeEvent.CashbackFeeBasisPoints > 0 || tradeEvent.Cashback > 0
|
||||
swaps := []Swap{
|
||||
{
|
||||
Program: SolProgramPump,
|
||||
@@ -335,6 +463,7 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
|
||||
UserBaseBalance: userBase,
|
||||
UserQuoteBalance: decimal.NewFromUint64(userQuote),
|
||||
EntryContract: entryContract,
|
||||
Cashback: isCashbackCoin,
|
||||
},
|
||||
}
|
||||
if completed {
|
||||
|
||||
287
pumpamm.go
287
pumpamm.go
@@ -152,14 +152,29 @@ func pumpAmmParser(tx *Tx, instruction Instruction, innerInstructions InnerInstr
|
||||
discriminator := *(*[8]byte)(decode[:8])
|
||||
switch discriminator {
|
||||
case pumpAmmCreateDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
return ammCreatePoolParser(tx, instruction, innerInstructions, offset)
|
||||
case pumpAmmBuyDiscriminator, pumpAmmBuyV2Discriminator:
|
||||
if tx.Err != nil {
|
||||
return failedTxAmmBuyParser(tx, instruction, innerInstructions, offset)
|
||||
}
|
||||
return ammBuyParser(tx, instruction, innerInstructions, offset)
|
||||
case pumpAmmSellDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return failedTxAmmSellParser(tx, instruction, innerInstructions, offset)
|
||||
}
|
||||
return ammSellParser(tx, instruction, innerInstructions, offset)
|
||||
case pumpAmmDepositDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
return depositParse(tx, instruction, innerInstructions, offset)
|
||||
case pumpAmmWithdrawDiscriminator:
|
||||
if tx.Err != nil {
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
return withdrawParse(tx, instruction, innerInstructions, offset)
|
||||
default:
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
@@ -240,6 +255,254 @@ func ammCreatePoolParser(tx *Tx, instruction Instruction, innerInstructions Inne
|
||||
|
||||
}
|
||||
|
||||
type PumpSwapArgs struct {
|
||||
Discriminator [8]byte
|
||||
Amount1 uint64
|
||||
Amount2 uint64
|
||||
}
|
||||
|
||||
func failedTxAmmBuyParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
if tx.Err == nil || tx.Err.UnKnown != "" {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("tx pump amm sell failed but error is nil, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Variant != InstructionError {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but error variant is not instruction error, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum != Custom && tx.Err.Enum != ComputationalBudgetExceeded && tx.Err.Enum != ProgramFailedToComplete {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but error is not custom or computational budget exceeded, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum == Custom {
|
||||
if !(tx.Err.CustomCode == 1 || tx.Err.CustomCode == 6004 ||
|
||||
tx.Err.CustomCode == 6040 ||
|
||||
tx.Err.CustomCode == 6039 ||
|
||||
tx.Err.CustomCode == 6016 ||
|
||||
tx.Err.CustomCode == 6014) {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but custom error code is unexpected, offset, %d, %d, code: %d", offset[0], offset[1], tx.Err.CustomCode)
|
||||
}
|
||||
}
|
||||
|
||||
result := tx.rawTx
|
||||
var entryContract = result.accountList[result.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
var args PumpSwapArgs
|
||||
err := agbinary.NewBorshDecoder(instruction.Data[:]).Decode(&args)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm buy failed decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
var event string
|
||||
var (
|
||||
quoteAmount, tokenAmount uint64
|
||||
)
|
||||
if bytes.Equal(args.Discriminator[:], pumpAmmBuyV2Discriminator[:]) {
|
||||
event = "buy_failed"
|
||||
quoteAmount = args.Amount1
|
||||
tokenAmount = args.Amount2
|
||||
} else if bytes.Equal(args.Discriminator[:], pumpAmmBuyDiscriminator[:]) {
|
||||
event = "buy_failed"
|
||||
quoteAmount = args.Amount2
|
||||
tokenAmount = args.Amount1
|
||||
} else {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("unknown pump amm trade instruction discriminator, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
|
||||
baseMint := result.accountList[instruction.Accounts[3]]
|
||||
quoteMint := result.accountList[instruction.Accounts[4]]
|
||||
baseTokenProgram := result.accountList[instruction.Accounts[11]]
|
||||
quoteTokenProgram := result.accountList[instruction.Accounts[12]]
|
||||
|
||||
poolBaseAccountIdx := instruction.Accounts[7]
|
||||
poolQuoteAccountIdx := instruction.Accounts[8]
|
||||
var (
|
||||
baseMintDecimals uint8
|
||||
quoteMintDecimals uint8
|
||||
)
|
||||
for _, meta := range result.Meta.PostTokenBalances {
|
||||
if meta.AccountIndex == poolBaseAccountIdx {
|
||||
baseMintDecimals = uint8(meta.UITokenAmount.Decimals)
|
||||
} else if meta.AccountIndex == poolQuoteAccountIdx {
|
||||
quoteMintDecimals = uint8(meta.UITokenAmount.Decimals)
|
||||
}
|
||||
}
|
||||
if _, exists := tx.Token[baseMint]; !exists && !baseMint.Equals(wSolMint) {
|
||||
tx.Token[baseMint] = TokenMeta{
|
||||
Mint: baseMint,
|
||||
Decimals: baseMintDecimals,
|
||||
TokenProgram: baseTokenProgram,
|
||||
}
|
||||
}
|
||||
|
||||
if _, exists := tx.Token[quoteMint]; !exists && !quoteMint.Equals(wSolMint) {
|
||||
tx.Token[quoteMint] = TokenMeta{
|
||||
Mint: quoteMint,
|
||||
Decimals: quoteMintDecimals,
|
||||
TokenProgram: quoteTokenProgram,
|
||||
}
|
||||
}
|
||||
|
||||
var eventUser = tx.rawTx.accountList[instruction.Accounts[1]]
|
||||
|
||||
baseMintAtaUserIdx := instruction.Accounts[5]
|
||||
userIndex := instruction.Accounts[1]
|
||||
if !eventUser.IsOnCurve() && (entryContract.Equals(okxDexRoutersV2) || entryContract.Equals(okxAggregatorV2)) {
|
||||
userBaseAmount, ataIndex := tokenBalanceChange(result, 0, baseTokenProgram, baseMint)
|
||||
// && userBaseAmount.BigInt().Uint64() == event.BaseAmountOut
|
||||
if !userBaseAmount.IsZero() {
|
||||
eventUser = result.accountList[0]
|
||||
userIndex = 0
|
||||
baseMintAtaUserIdx = ataIndex
|
||||
}
|
||||
}
|
||||
|
||||
userBase := getAccountBalanceAfterTx(result, baseMintAtaUserIdx)
|
||||
userQuote := GetTokenBalanceAfterTx(result, userIndex, quoteTokenProgram, quoteMint)
|
||||
|
||||
if quoteMint.Equals(wSolMint) {
|
||||
userBalance, _ := GetSolAfterTx(result, userIndex)
|
||||
userQuote = userQuote.Add(decimal.NewFromUint64(userBalance))
|
||||
}
|
||||
baseReserve := getAccountBalanceAfterTx(result, instruction.Accounts[7])
|
||||
quoteReserve := getAccountBalanceAfterTx(result, instruction.Accounts[8])
|
||||
return []Swap{
|
||||
{
|
||||
Program: SolProgramPumpAMM,
|
||||
Event: event,
|
||||
Pool: tx.rawTx.accountList[instruction.Accounts[0]],
|
||||
BaseMint: baseMint,
|
||||
QuoteMint: quoteMint,
|
||||
BaseTokenProgram: baseTokenProgram,
|
||||
QuoteTokenProgram: quoteTokenProgram,
|
||||
BaseMintDecimals: baseMintDecimals,
|
||||
QuoteMintDecimals: quoteMintDecimals,
|
||||
User: eventUser,
|
||||
BaseAmount: decimal.NewFromUint64(tokenAmount),
|
||||
QuoteAmount: decimal.NewFromUint64(quoteAmount),
|
||||
BaseReserve: baseReserve,
|
||||
QuoteReserve: quoteReserve,
|
||||
Mayhem: isMayhemPump(result.accountList[instruction.Accounts[9]]),
|
||||
UserBaseBalance: userBase,
|
||||
UserQuoteBalance: userQuote,
|
||||
EntryContract: entryContract,
|
||||
},
|
||||
}, offset, nil
|
||||
}
|
||||
|
||||
func failedTxAmmSellParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
if tx.Err == nil || tx.Err.UnKnown != "" {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("tx pump amm sell failed but error is nil, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Variant != InstructionError {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but error variant is not instruction error, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum != Custom && tx.Err.Enum != ComputationalBudgetExceeded && tx.Err.Enum != ProgramFailedToComplete {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but error is not custom or computational budget exceeded, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
if tx.Err.Enum == Custom {
|
||||
if !(tx.Err.CustomCode == 1 || tx.Err.CustomCode == 6004 ||
|
||||
tx.Err.CustomCode == 6040 ||
|
||||
tx.Err.CustomCode == 6039 ||
|
||||
tx.Err.CustomCode == 6016 ||
|
||||
tx.Err.CustomCode == 6014) {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm sell failed but custom error code is unexpected, offset, %d, %d, code: %d", offset[0], offset[1], tx.Err.CustomCode)
|
||||
}
|
||||
}
|
||||
result := tx.rawTx
|
||||
var entryContract = result.accountList[result.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
var args PumpSwapArgs
|
||||
err := agbinary.NewBorshDecoder(instruction.Data[:]).Decode(&args)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed tx pump amm buy failed decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
var event string
|
||||
var (
|
||||
quoteAmount, tokenAmount uint64
|
||||
)
|
||||
if bytes.Equal(args.Discriminator[:], pumpAmmSellDiscriminator[:]) {
|
||||
event = "sell_failed"
|
||||
tokenAmount = args.Amount1
|
||||
quoteAmount = args.Amount2
|
||||
} else {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("unknown pump amm trade instruction discriminator, offset, %d, %d", offset[0], offset[1])
|
||||
}
|
||||
baseMint := result.accountList[instruction.Accounts[3]]
|
||||
quoteMint := result.accountList[instruction.Accounts[4]]
|
||||
baseTokenProgram := result.accountList[instruction.Accounts[11]]
|
||||
quoteTokenProgram := result.accountList[instruction.Accounts[12]]
|
||||
|
||||
poolBaseAccountIdx := instruction.Accounts[7]
|
||||
poolQuoteAccountIdx := instruction.Accounts[8]
|
||||
var (
|
||||
baseMintDecimals uint8
|
||||
quoteMintDecimals uint8
|
||||
)
|
||||
for _, meta := range result.Meta.PostTokenBalances {
|
||||
if meta.AccountIndex == poolBaseAccountIdx {
|
||||
baseMintDecimals = uint8(meta.UITokenAmount.Decimals)
|
||||
} else if meta.AccountIndex == poolQuoteAccountIdx {
|
||||
quoteMintDecimals = uint8(meta.UITokenAmount.Decimals)
|
||||
}
|
||||
}
|
||||
if _, exists := tx.Token[baseMint]; !exists && !baseMint.Equals(wSolMint) {
|
||||
tx.Token[baseMint] = TokenMeta{
|
||||
Mint: baseMint,
|
||||
Decimals: baseMintDecimals,
|
||||
TokenProgram: baseTokenProgram,
|
||||
}
|
||||
}
|
||||
|
||||
if _, exists := tx.Token[quoteMint]; !exists && !quoteMint.Equals(wSolMint) {
|
||||
tx.Token[quoteMint] = TokenMeta{
|
||||
Mint: quoteMint,
|
||||
Decimals: quoteMintDecimals,
|
||||
TokenProgram: quoteTokenProgram,
|
||||
}
|
||||
}
|
||||
|
||||
var eventUser = tx.rawTx.accountList[instruction.Accounts[1]]
|
||||
|
||||
baseMintAtaUserIdx := instruction.Accounts[5]
|
||||
userIndex := instruction.Accounts[1]
|
||||
if !eventUser.IsOnCurve() && (entryContract.Equals(okxDexRoutersV2) || entryContract.Equals(okxAggregatorV2)) {
|
||||
userBaseAmount, ataIndex := tokenBalanceChange(result, 0, baseTokenProgram, baseMint)
|
||||
// && userBaseAmount.BigInt().Uint64() == event.BaseAmountIn
|
||||
if !userBaseAmount.IsZero() {
|
||||
eventUser = result.accountList[0]
|
||||
userIndex = 0
|
||||
baseMintAtaUserIdx = ataIndex
|
||||
}
|
||||
}
|
||||
|
||||
userBase := getAccountBalanceAfterTx(result, baseMintAtaUserIdx)
|
||||
userQuote := GetTokenBalanceAfterTx(result, userIndex, quoteTokenProgram, quoteMint)
|
||||
|
||||
if quoteMint.Equals(wSolMint) {
|
||||
userBalance, _ := GetSolAfterTx(result, userIndex)
|
||||
userQuote = userQuote.Add(decimal.NewFromUint64(userBalance))
|
||||
}
|
||||
baseReserve := getAccountBalanceAfterTx(result, instruction.Accounts[7])
|
||||
quoteReserve := getAccountBalanceAfterTx(result, instruction.Accounts[8])
|
||||
return []Swap{
|
||||
{
|
||||
Program: SolProgramPumpAMM,
|
||||
Event: event,
|
||||
Pool: tx.rawTx.accountList[instruction.Accounts[0]],
|
||||
BaseMint: baseMint,
|
||||
QuoteMint: quoteMint,
|
||||
BaseTokenProgram: baseTokenProgram,
|
||||
QuoteTokenProgram: quoteTokenProgram,
|
||||
BaseMintDecimals: baseMintDecimals,
|
||||
QuoteMintDecimals: quoteMintDecimals,
|
||||
User: eventUser,
|
||||
BaseAmount: decimal.NewFromUint64(tokenAmount),
|
||||
QuoteAmount: decimal.NewFromUint64(quoteAmount),
|
||||
BaseReserve: baseReserve,
|
||||
QuoteReserve: quoteReserve,
|
||||
Mayhem: isMayhemPump(result.accountList[instruction.Accounts[9]]),
|
||||
UserBaseBalance: userBase,
|
||||
UserQuoteBalance: userQuote,
|
||||
EntryContract: entryContract,
|
||||
},
|
||||
}, offset, nil
|
||||
}
|
||||
|
||||
func ammBuyParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
result := tx.rawTx
|
||||
var entryContract = result.accountList[result.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
@@ -249,11 +512,13 @@ func ammBuyParser(tx *Tx, instruction Instruction, innerInstructions InnerInstru
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("pumpamm create get inner instructions error: %v, offset: %d, %d", err, offset[0], prefixLen)
|
||||
}
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
if !entryContract.Equals(axiomOuterContract) {
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,11 +635,13 @@ func ammSellParser(tx *Tx, instruction Instruction, innerInstructions InnerInstr
|
||||
return nil, increaseOffset(offset), fmt.Errorf("pumpamm sell get inner instructions error: %v, offset: %d, %d", err, offset[0], prefixLen)
|
||||
}
|
||||
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
if !entryContract.Equals(axiomOuterContract) {
|
||||
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
|
||||
for _, innerInstr := range innerInstructions.Instructions {
|
||||
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
|
||||
entryContract = result.accountList[innerInstr.ProgramIDIndex]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
101
rawtx.go
101
rawtx.go
@@ -73,6 +73,10 @@ func (tx *RawTx) GetAccountLust() []solana.PublicKey {
|
||||
return tx.getAccountList()
|
||||
}
|
||||
|
||||
func (tx *RawTx) GetAccountList() []solana.PublicKey {
|
||||
return tx.getAccountList()
|
||||
}
|
||||
|
||||
func (tx *RawTx) TxHash() string {
|
||||
if len(tx.Transaction.Signatures) > 0 {
|
||||
return tx.Transaction.Signatures[0].String()
|
||||
@@ -146,17 +150,17 @@ func (tb *TokenBalance) ParseAccount() {
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
Err interface{} `json:"err"`
|
||||
Fee uint64 `json:"fee"`
|
||||
InnerInstructions []InnerInstructions `json:"innerInstructions"`
|
||||
LoadedAddresses LoadedAddresses `json:"loadedAddresses"`
|
||||
LogMessages []string `json:"logMessages"`
|
||||
PostBalances []uint64 `json:"postBalances"`
|
||||
PostTokenBalances []TokenBalance `json:"postTokenBalances"`
|
||||
PreBalances []uint64 `json:"preBalances"`
|
||||
PreTokenBalances []TokenBalance `json:"preTokenBalances"`
|
||||
Rewards []interface{} `json:"rewards"`
|
||||
ComputeUnitsConsumed uint64 `json:"computeUnitsConsumed"`
|
||||
Err *TransactionParsedError `json:"err"`
|
||||
Fee uint64 `json:"fee"`
|
||||
InnerInstructions []InnerInstructions `json:"innerInstructions"`
|
||||
LoadedAddresses LoadedAddresses `json:"loadedAddresses"`
|
||||
LogMessages []string `json:"logMessages"`
|
||||
PostBalances []uint64 `json:"postBalances"`
|
||||
PostTokenBalances []TokenBalance `json:"postTokenBalances"`
|
||||
PreBalances []uint64 `json:"preBalances"`
|
||||
PreTokenBalances []TokenBalance `json:"preTokenBalances"`
|
||||
Rewards []interface{} `json:"rewards"`
|
||||
ComputeUnitsConsumed uint64 `json:"computeUnitsConsumed"`
|
||||
}
|
||||
type Header struct {
|
||||
NumReadonlySignedAccounts int `json:"numReadonlySignedAccounts"`
|
||||
@@ -294,6 +298,16 @@ func InstructionsFromRpc(instructions []solana.CompiledInstruction) []Instructio
|
||||
return instrs
|
||||
}
|
||||
|
||||
type RpcTransactionErr []interface{}
|
||||
|
||||
func marshalRpcTransactionErr(err any) string {
|
||||
e, _ := json.Marshal(err)
|
||||
if len(e) == 0 {
|
||||
return "UnKnown"
|
||||
}
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func FromRpcTransactionWithMeta(tx rpc.TransactionWithMeta, blockTime *uint64, slot uint64, index int64) (*RawTx, error) {
|
||||
created := int64(0)
|
||||
if blockTime != nil {
|
||||
@@ -321,8 +335,62 @@ func FromRpcTransactionWithMeta(tx rpc.TransactionWithMeta, blockTime *uint64, s
|
||||
yTx, _ := tx.GetTransaction()
|
||||
|
||||
if meta.Err != nil {
|
||||
e, _ := json.Marshal(meta.Err)
|
||||
sTx.Meta.Err = string(e)
|
||||
if iErr, ok := meta.Err.(map[string]any); ok {
|
||||
instructionError := iErr["InstructionError"]
|
||||
if instructionError == nil {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
UnKnown: marshalRpcTransactionErr(meta.Err),
|
||||
}
|
||||
} else {
|
||||
if oErr, ok := instructionError.([]any); ok {
|
||||
if len(oErr) <= 1 {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
UnKnown: marshalRpcTransactionErr(meta.Err),
|
||||
}
|
||||
} else if instrIdx, ok := oErr[0].(float64); ok {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
Index: uint8(instrIdx),
|
||||
Variant: InstructionError,
|
||||
}
|
||||
errDetail, ok := oErr[1].(string)
|
||||
if ok {
|
||||
if errDetail == "ComputationalBudgetExceeded" || errDetail == "ProgramFailedToComplete" {
|
||||
sTx.Meta.Err.Enum = ComputationalBudgetExceeded
|
||||
} else {
|
||||
sTx.Meta.Err.UnKnown = errDetail
|
||||
}
|
||||
} else {
|
||||
errDetail2, ok := oErr[1].(map[string]any)
|
||||
if ok && len(errDetail2) > 0 && errDetail2["Custom"] != nil {
|
||||
custom, ok := errDetail2["Custom"].(float64)
|
||||
if ok {
|
||||
sTx.Meta.Err.Enum = Custom
|
||||
sTx.Meta.Err.CustomCode = uint32(custom)
|
||||
} else {
|
||||
sTx.Meta.Err.UnKnown = marshalRpcTransactionErr(meta.Err)
|
||||
}
|
||||
|
||||
} else {
|
||||
sTx.Meta.Err.UnKnown = marshalRpcTransactionErr(meta.Err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
UnKnown: marshalRpcTransactionErr(meta.Err),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
UnKnown: marshalRpcTransactionErr(meta.Err),
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sTx.Meta.Err = &TransactionParsedError{
|
||||
UnKnown: marshalRpcTransactionErr(meta.Err),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
sTx.Meta.Fee = meta.Fee
|
||||
//sTx.Meta.InnerInstructions = meta.InnerInstructions
|
||||
@@ -799,12 +867,7 @@ func ConvertYellowstoneGrpcTransactionToSolanaTransaction(y *pb.SubscribeUpdateT
|
||||
|
||||
if meta.Err != nil && len(meta.Err.GetErr()) > 0 {
|
||||
// If the transaction has an error, we set the error in the Meta
|
||||
transError, err := DecodeTransactionError(meta.Err.GetErr())
|
||||
if err != nil {
|
||||
sTx.Meta.Err = err
|
||||
} else {
|
||||
sTx.Meta.Err = transError
|
||||
}
|
||||
sTx.Meta.Err = ParseTransactionErrorFromGeyser(meta.Err.GetErr())
|
||||
// sTx.Meta.Err = meta.Err.GetErr()
|
||||
}
|
||||
sTx.Meta.Fee = meta.Fee
|
||||
|
||||
98
raydiumv4.go
98
raydiumv4.go
@@ -29,6 +29,8 @@ func raydiumV4Parser(tx *Tx, instruction Instruction, innerInstructions InnerIns
|
||||
return raydiumv4WithdrawPNLParser(tx, instruction, innerInstructions, offset)
|
||||
case raydiumV4SwapBaseInDiscriminator, raydiumV4SwapBaseOutDiscriminator:
|
||||
return raydiumv4SwapParser(tx, instruction, innerInstructions, offset)
|
||||
case raydiumV4SwapBaseInV2Discriminator, raydiumV4SwapBaseOutV2Discriminator:
|
||||
return raydiumv4SwapV2Parser(tx, instruction, innerInstructions, offset)
|
||||
|
||||
default:
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
@@ -397,3 +399,99 @@ func raydiumv4SwapParser(tx *Tx, instruction Instruction, innerInstructions Inne
|
||||
},
|
||||
}, offset, nil
|
||||
}
|
||||
|
||||
func raydiumv4SwapV2Parser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
accountsLen := len(instruction.Accounts)
|
||||
if accountsLen != 8 {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("invalid number of accounts for raydiumv4 swapv2 instruction, offset %d, %d", offset[0], offset[1])
|
||||
}
|
||||
var entryContract = tx.rawTx.accountList[tx.rawTx.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
|
||||
ammAccount := tx.rawTx.accountList[instruction.Accounts[1]]
|
||||
user := tx.rawTx.accountList[instruction.Accounts[7]]
|
||||
userSourceTokenAccount := tx.rawTx.accountList[instruction.Accounts[5]]
|
||||
userDestinationTokenAccount := tx.rawTx.accountList[instruction.Accounts[6]]
|
||||
baseVaultIdx := instruction.Accounts[3]
|
||||
quoteVaultIdx := instruction.Accounts[4]
|
||||
|
||||
baseTokenbalance, err := getTokenBalanceAfterTx(tx.rawTx, baseVaultIdx)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed to get base vault balance after tx: %v", err)
|
||||
}
|
||||
quoteTokenbalance, err := getTokenBalanceAfterTx(tx.rawTx, quoteVaultIdx)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("failed to get quote vault balance after tx: %v", err)
|
||||
}
|
||||
inners, err := getInnerInstructions(innerInstructions, offset[1])
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), err
|
||||
}
|
||||
|
||||
var nextIndex int
|
||||
var srcFound, destFound bool
|
||||
var baseAmount, quoteAmount decimal.Decimal
|
||||
var event string
|
||||
for i, inner := range inners {
|
||||
from, to, amount, err := parseTokenTransfer(tx.rawTx, inner)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if from.Equals(userSourceTokenAccount) && !srcFound {
|
||||
if to.Equals(tx.rawTx.accountList[baseVaultIdx]) {
|
||||
event = "sell"
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
srcFound = true
|
||||
} else if to.Equals(tx.rawTx.accountList[quoteVaultIdx]) {
|
||||
event = "buy"
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
srcFound = true
|
||||
}
|
||||
} else if to.Equals(userDestinationTokenAccount) && !destFound {
|
||||
if from.Equals(tx.rawTx.accountList[quoteVaultIdx]) {
|
||||
event = "sell"
|
||||
quoteAmount = decimal.NewFromUint64(amount)
|
||||
destFound = true
|
||||
} else if from.Equals(tx.rawTx.accountList[baseVaultIdx]) {
|
||||
event = "buy"
|
||||
baseAmount = decimal.NewFromUint64(amount)
|
||||
destFound = true
|
||||
}
|
||||
}
|
||||
if srcFound && destFound {
|
||||
nextIndex = i + 1
|
||||
break
|
||||
}
|
||||
}
|
||||
if !srcFound || !destFound {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("raydiumv4 failed to find token transfer inner instruction for swapv2, offset %d, %d", offset[0], offset[1])
|
||||
}
|
||||
offset[1] += uint(nextIndex + 1)
|
||||
|
||||
userBase := getAccountBalanceAfterTx(tx.rawTx, instruction.Accounts[5])
|
||||
userQuote := getAccountBalanceAfterTx(tx.rawTx, instruction.Accounts[6])
|
||||
baseReserve, _ := decimal.NewFromString(baseTokenbalance.UITokenAmount.Amount)
|
||||
quoteReserve, _ := decimal.NewFromString(quoteTokenbalance.UITokenAmount.Amount)
|
||||
|
||||
return []Swap{
|
||||
{
|
||||
Program: SolProgramRaydiumV4,
|
||||
Event: event,
|
||||
Pool: ammAccount,
|
||||
BaseMint: baseTokenbalance.MintAccount,
|
||||
QuoteMint: quoteTokenbalance.MintAccount,
|
||||
BaseTokenProgram: baseTokenbalance.ProgramIDAccount,
|
||||
QuoteTokenProgram: quoteTokenbalance.ProgramIDAccount,
|
||||
BaseMintDecimals: uint8(baseTokenbalance.UITokenAmount.Decimals),
|
||||
QuoteMintDecimals: uint8(quoteTokenbalance.UITokenAmount.Decimals),
|
||||
User: user,
|
||||
BaseAmount: baseAmount,
|
||||
QuoteAmount: quoteAmount,
|
||||
BaseReserve: baseReserve,
|
||||
QuoteReserve: quoteReserve,
|
||||
Mayhem: false,
|
||||
UserBaseBalance: userBase,
|
||||
UserQuoteBalance: userQuote,
|
||||
EntryContract: entryContract,
|
||||
},
|
||||
}, offset, nil
|
||||
}
|
||||
|
||||
14
system.go
14
system.go
@@ -34,12 +34,14 @@ func TransferParser(result *RawTx, instruction Instruction, offset [2]uint, tx *
|
||||
from := result.accountList[result.Transaction.Message.Instructions[offset[0]].Accounts[0]]
|
||||
to := result.accountList[instruction.Accounts[1]]
|
||||
|
||||
if offset[1] == 0 {
|
||||
tx.SolTransfer = append(tx.SolTransfer, SolTransfer{
|
||||
From: from,
|
||||
To: to,
|
||||
Amount: decimal.NewFromInt(int64(lamports)), // solana decimals
|
||||
})
|
||||
if result.Meta.Err == nil {
|
||||
if offset[1] == 0 {
|
||||
tx.SolTransfer = append(tx.SolTransfer, SolTransfer{
|
||||
From: from,
|
||||
To: to,
|
||||
Amount: decimal.NewFromInt(int64(lamports)), // solana decimals
|
||||
})
|
||||
}
|
||||
}
|
||||
// load platform by to address
|
||||
platform, ok := platformFeeAddresses[to]
|
||||
|
||||
31
tx.go
31
tx.go
@@ -12,6 +12,9 @@ type Swap struct {
|
||||
|
||||
TxIndex int
|
||||
|
||||
InstrIdx uint8
|
||||
InnerIdx uint8
|
||||
|
||||
Pool solana.PublicKey
|
||||
BaseMint solana.PublicKey
|
||||
QuoteMint solana.PublicKey
|
||||
@@ -45,9 +48,12 @@ type Swap struct {
|
||||
AfterSOLBalance decimal.Decimal
|
||||
|
||||
//For meteora dlmm
|
||||
StartBinId int32
|
||||
EndBinId int32
|
||||
BinChanges []DlmmBinLiquidityChange
|
||||
ActiveBinId int32
|
||||
StartBinId int32
|
||||
EndBinId int32
|
||||
RemoveBp int32
|
||||
BinChanges []DlmmBinLiquidityChange
|
||||
PositionAccount solana.PublicKey
|
||||
|
||||
ConsumeUnit uint64
|
||||
}
|
||||
@@ -74,18 +80,23 @@ type SolTransfer struct {
|
||||
To solana.PublicKey
|
||||
Amount decimal.Decimal
|
||||
}
|
||||
type ChainLink struct {
|
||||
Timestamp int64
|
||||
Price decimal.Decimal
|
||||
}
|
||||
|
||||
type Tx struct {
|
||||
rawTx *RawTx
|
||||
Vote bool
|
||||
Signer solana.PublicKey
|
||||
Err interface{} `json:"err,omitempty"`
|
||||
Swaps []Swap `json:"swaps,omitempty"`
|
||||
SolTransfer []SolTransfer `json:"sol_transfer,omitempty"`
|
||||
Block uint64 `json:"block"`
|
||||
BlockIndex uint64 `json:"index"`
|
||||
TxHash *[64]byte `json:"-"`
|
||||
BlockAt int64 `json:"block_at"`
|
||||
Err *TransactionParsedError `json:"err,omitempty"`
|
||||
Swaps []Swap `json:"swaps,omitempty"`
|
||||
SolTransfer []SolTransfer `json:"sol_transfer,omitempty"`
|
||||
Block uint64 `json:"block"`
|
||||
ChainLink ChainLink `json:"chain_link"`
|
||||
BlockIndex uint64 `json:"index"`
|
||||
TxHash *[64]byte `json:"-"`
|
||||
BlockAt int64 `json:"block_at"`
|
||||
|
||||
CuFee decimal.Decimal `json:"cu_fee"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user