From a0e46ec83e1c4f4938dd80563ea183ee6c53fd53 Mon Sep 17 00:00:00 2001 From: bijianing97 <826015751@qq.com> Date: Tue, 3 Feb 2026 14:06:43 +0800 Subject: [PATCH] Add tradewiz parser --- cmd/txparse/main.go | 2 +- pkg/shreder/program_tradewiz.go | 50 +++++++++++++++++++++++++++++++++ pkg/shreder/txparser.go | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 pkg/shreder/program_tradewiz.go diff --git a/cmd/txparse/main.go b/cmd/txparse/main.go index 1b16f32..8ecd014 100644 --- a/cmd/txparse/main.go +++ b/cmd/txparse/main.go @@ -15,7 +15,7 @@ import ( const ( rpcURL = "https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d" - txSignature = "4tcpUCVUZtUFDKGwZVBexkQpYiPhFgW4wfnrTEQgPrkQxpfsDEVMWN2UBfYxpy1EsDzuatuP1wgsUowTqeh2fnie" + txSignature = "4xkfvs5HrABpZcmbHwvqS6SRY9gYatc9DfqEZ78RCp4bgrMnmfRw4Tv8RSyT7rfDwNzmNAysezAn5TDsVBrbYXy6" labelFilter = "" ) diff --git a/pkg/shreder/program_tradewiz.go b/pkg/shreder/program_tradewiz.go new file mode 100644 index 0000000..610388b --- /dev/null +++ b/pkg/shreder/program_tradewiz.go @@ -0,0 +1,50 @@ +package shreder + +import ( + "encoding/binary" + "fmt" + + "github.com/gagliardetto/solana-go" + "github.com/shopspring/decimal" +) + +var tradewizProgramID = solana.MustPublicKeyFromBase58("B3jytJa6Tzpn4Ly7GNnDm3dMGqUin5aMRm5aPsJGU5G7") + +func parseTradewizInstruction(tx VersionedTransaction, instructionIndex int) (TxSignalBatch, error) { + if instructionIndex >= len(tx.Instructions) { + return nil, fmt.Errorf("instruction index out of bounds") + } + ix := tx.Instructions[instructionIndex] + if len(ix.Data) < 9 { + return nil, fmt.Errorf("data too short for tradewiz buy args, len=%d", len(ix.Data)) + } + if len(ix.Accounts) < 3 { + return nil, fmt.Errorf("accounts too short") + } + + // data format: 0x00 + u64(wsol amount) + u64(...) + wsolAmount := binary.LittleEndian.Uint64(ix.Data[1:9]) + + mint, err := tx.GetAccount(int(ix.Accounts[2])) + if err != nil { + return nil, err + } + + return TxSignalBatch{&TxSignal{ + TxHash: tx.Signatures[0].String(), + Label: "tradewiz", + Maker: tx.StaticAccountKeys[0].String(), + Token0Address: mint.String(), + Token1Address: wsolMint, + Token0Amount: decimal.Zero, + Token1Amount: formatSolAmount(wsolAmount), + Program: "Pump", + Event: "buy", + IsToken2022: false, + IsMayhemMode: false, + ExactSOL: true, + Block: tx.Block, + Token0AmountUint64: 0, + Token1AmountUint64: wsolAmount, + }}, nil +} diff --git a/pkg/shreder/txparser.go b/pkg/shreder/txparser.go index 5ce97b3..f98440c 100644 --- a/pkg/shreder/txparser.go +++ b/pkg/shreder/txparser.go @@ -73,6 +73,7 @@ var ( bloomRouterProgramID: {parseBloomRouterInstruction, "bloomrouter"}, dlmmProgramID: {parseDlmmInstruction, "dlmm"}, dbotProgramID: {parseDbotInstruction, "dbot"}, + tradewizProgramID: {parseTradewizInstruction, "tradewiz"}, } )