From eb2bde98ac05e7574010c0d6878df47f863215f6 Mon Sep 17 00:00:00 2001 From: thloyi Date: Wed, 11 Mar 2026 14:41:56 +0800 Subject: [PATCH] update parsed tx: add swap at instr idx --- parser.go | 5 +++++ tx.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/parser.go b/parser.go index cceccfa..aea992c 100644 --- a/parser.go +++ b/parser.go @@ -127,6 +127,9 @@ func (tx *Tx) Parser() error { //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 { @@ -172,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) } @@ -219,6 +223,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) } // tx.Swaps = append(tx.Swaps, swaps...) diff --git a/tx.go b/tx.go index d06537d..cca598c 100644 --- a/tx.go +++ b/tx.go @@ -12,6 +12,8 @@ type Swap struct { TxIndex int + InstrIdx uint8 + Pool solana.PublicKey BaseMint solana.PublicKey QuoteMint solana.PublicKey