From 3fdd4c4490a2a7a0297db954514a64bb0d1237bd Mon Sep 17 00:00:00 2001 From: thloyi Date: Wed, 11 Feb 2026 14:58:12 +0800 Subject: [PATCH] fix parse error --- internal/test2/test.go | 2 +- meta.go | 1 + meteoradamm.go | 9 ++++++++- orcawhirpool.go | 18 +++++++++--------- raydiumcpmm.go | 4 ++-- raydiumlaunchlab.go | 2 +- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/internal/test2/test.go b/internal/test2/test.go index bbafadd..bba9a8b 100644 --- a/internal/test2/test.go +++ b/internal/test2/test.go @@ -23,7 +23,7 @@ var () func main() { - var slot uint64 = 399230674 + var slot uint64 = 399477968 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 diff --git a/meta.go b/meta.go index 3e8f99a..09cb4b9 100644 --- a/meta.go +++ b/meta.go @@ -234,5 +234,6 @@ var transferDiscriminator = uint32(2) var createAccountWithSeedDiscriminator = uint32(3) var systemProgram = solana.MustPublicKeyFromBase58("11111111111111111111111111111111") +var momoProgram = solana.MustPublicKeyFromBase58("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr") var eventDiscriminator = [8]byte{228, 69, 165, 46, 81, 203, 154, 29} diff --git a/meteoradamm.go b/meteoradamm.go index 92af5ac..b3ad244 100644 --- a/meteoradamm.go +++ b/meteoradamm.go @@ -90,7 +90,7 @@ func meteoraDammV2InitializePoolParser(tx *Tx, instruction Instruction, innerIns var prefixLen = offset[1] inners, err := getInnerInstructions(innerInstructions, prefixLen) if err != nil { - return nil, increaseOffset(offset), fmt.Errorf("meta Bonding Curve initial get inner instructions error: %v, offset, %d, %d", err, offset[0], offset[1]) + return nil, increaseOffset(offset), fmt.Errorf("meta damm initial get inner instructions error: %v, offset, %d, %d", err, offset[0], offset[1]) } var loadedEvent bool var initializePoolEvent MetaoraDammInitializePoolEvent @@ -119,6 +119,13 @@ func meteoraDammV2InitializePoolParser(tx *Tx, instruction Instruction, innerIns } baseVaultAccountIndex := instruction.Accounts[10] quoteVaultAccountIndex := instruction.Accounts[11] + if bytes.Equal(instruction.Data[:8], meteoraDammV2InitializePoolWithDynamicConfig[:]) { + baseVaultAccountIndex = instruction.Accounts[11] + quoteVaultAccountIndex = instruction.Accounts[12] + } else if bytes.Equal(instruction.Data[:8], meteoraDammV2InitializeCustomizablePoolDiscriminator[:]) { + baseVaultAccountIndex = instruction.Accounts[9] + quoteVaultAccountIndex = instruction.Accounts[10] + } baseVaultTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, baseVaultAccountIndex) if err != nil { diff --git a/orcawhirpool.go b/orcawhirpool.go index c15b785..9d1f2ff 100644 --- a/orcawhirpool.go +++ b/orcawhirpool.go @@ -848,11 +848,11 @@ func orcaWhirPoolSwapV2Parser(tx *Tx, instruction Instruction, innerInstructions var baseFound, quoteFound bool var skipOffset = 0 for i, inner := range inners { + if !tx.rawTx.accountList[inner.ProgramIDIndex].Equals(solana.Token2022ProgramID) && !tx.rawTx.accountList[inner.ProgramIDIndex].Equals(solana.TokenProgramID) { + continue + } from, to, amount, err := parseTokenTransfer(tx.rawTx, inner) if err != nil { - if i <= 1 { //maybe momo?? - continue - } return nil, increaseOffset(offset), fmt.Errorf("orca whirpool swapv2 parse token transfer error: %v, offset, %d, %d", err, offset[0], offset[1]) } if !baseFound && (from.Equals(vault0Account) || to.Equals(vault0Account)) { @@ -1010,11 +1010,11 @@ func orcaWhirPoolTwoHopSwapParser(tx *Tx, instruction Instruction, innerInstruct { baseTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, pool2VaultBase) if err != nil { - return nil, increaseOffset(offset), fmt.Errorf("failed to get pool1 token0 vault balance after tx: %v", err) + return nil, increaseOffset(offset), fmt.Errorf("failed to get pool2 token0 vault balance after tx: %v", err) } quoteTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, pool2VaultQuote) if err != nil { - return nil, increaseOffset(offset), fmt.Errorf("failed to get pool1 token1 vault balance after tx: %v", err) + return nil, increaseOffset(offset), fmt.Errorf("failed to get pool2 token1 vault balance after tx: %v", err) } userBase := getAccountBalanceAfterTx(tx.rawTx, pool2UserBase) @@ -1105,8 +1105,8 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru //pool2UserBase := instruction.Accounts[8] pool2VaultBase := instruction.Accounts[11] - pool2UserQuote := instruction.Accounts[12] - pool2VaultQuote := instruction.Accounts[13] + pool2VaultQuote := instruction.Accounts[12] + pool2UserQuote := instruction.Accounts[13] swaps := make([]Swap, 2) { @@ -1186,11 +1186,11 @@ func orcaWhirPoolTwoHopSwapV2Parser(tx *Tx, instruction Instruction, innerInstru { baseTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, pool2VaultBase) if err != nil { - return nil, increaseOffset(offset), fmt.Errorf("failed to get pool1 token0 vault balance after tx: %v", err) + return nil, increaseOffset(offset), fmt.Errorf("failed to get pool2 token0 vault balance after tx: %v", err) } quoteTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, pool2VaultQuote) if err != nil { - return nil, increaseOffset(offset), fmt.Errorf("failed to get pool1 token1 vault balance after tx: %v", err) + return nil, increaseOffset(offset), fmt.Errorf("failed to get pool2 token1 vault balance after tx: %v", err) } userBase := decimal.Zero diff --git a/raydiumcpmm.go b/raydiumcpmm.go index d12af05..1eabce9 100644 --- a/raydiumcpmm.go +++ b/raydiumcpmm.go @@ -54,12 +54,12 @@ func raydiumCPmmCreatePoolParser(tx *Tx, instruction Instruction, innerInstructi vault1 = instruction.Accounts[12] } - baseTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, instruction.Accounts[vault0]) + baseTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, vault0) if err != nil { return nil, increaseOffset(offset), fmt.Errorf("failed to get token0 vault balance after tx: %v", err) } - quoteTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, instruction.Accounts[vault1]) + quoteTokenBalance, err := getTokenBalanceAfterTx(tx.rawTx, vault1) if err != nil { return nil, increaseOffset(offset), fmt.Errorf("failed to get token1 vault balance after tx: %v", err) } diff --git a/raydiumlaunchlab.go b/raydiumlaunchlab.go index e521379..c071ca1 100644 --- a/raydiumlaunchlab.go +++ b/raydiumlaunchlab.go @@ -143,7 +143,7 @@ type RaydiumLaunchLabCreateEvent struct { } func raydiumLaunchLabInitializeParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) { - if len(instruction.Accounts) < 16 { + if len(instruction.Accounts) < 15 { return nil, increaseOffset(offset), fmt.Errorf("not enough accounts for initialize instruction") } user := tx.rawTx.accountList[instruction.Accounts[0]]