From 6bab10866b2352500e556aadaafd1f6b1275153e Mon Sep 17 00:00:00 2001 From: samlior Date: Thu, 8 Jan 2026 16:25:34 +0800 Subject: [PATCH] fix: photon buy --- pkg/shreder/txparser.go | 1 + pkg/shreder/txparser_test.go | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pkg/shreder/txparser.go b/pkg/shreder/txparser.go index 8d39243..3b1d54b 100644 --- a/pkg/shreder/txparser.go +++ b/pkg/shreder/txparser.go @@ -1126,6 +1126,7 @@ func parsePhotonBuy(tx *versionedTransaction, instruction *compiledInstruction) Event: "buy", IsToken2022: false, IsMayhemMode: false, + ExactSOL: true, Block: tx.Block, Token0AmountUint64: args.TokenAmount, Token1AmountUint64: solAmount, diff --git a/pkg/shreder/txparser_test.go b/pkg/shreder/txparser_test.go index 2a7ce63..a19589a 100644 --- a/pkg/shreder/txparser_test.go +++ b/pkg/shreder/txparser_test.go @@ -252,3 +252,40 @@ func TestParseBonkSell(t *testing.T) { t.Fatalf("expected token1 amount 1379707703, got %d", signal.Token1AmountUint64) } } + +func TestParsePhotonBuy(t *testing.T) { + rpcUrl := os.Getenv("SOL_RPC_URL") + if rpcUrl == "" { + t.Fatalf("SOL_RPC_URL is not set") + } + + client := rpc.New(rpcUrl) + signals := ParseTransaction( + getTransaction(t, client, "4DCEcXAWBxagXoUNGhWsJ7qfxq5SuE5BG2cBDBqAY7sCHkBopaMJu33ZnXnFHqzPMmWxVxq6666KRF4hMHVB33Ux"), + nil, + false, + ) + if len(signals) != 1 { + t.Fatalf("expected 1 signal, got %d", len(signals)) + } + + signal := signals[0] + if signal.Label != "photon" { + t.Fatalf("expected terminal signal, got %s", signal.Label) + } + if signal.Event != "buy" { + t.Fatalf("expected buy event, got %s", signal.Event) + } + if signal.Maker != "8sUm7sLf3Steu6oVyVQqoA9GpFcMRz6YhrAidd4x7g7a" { + t.Fatalf("expected maker 8sUm7sLf3Steu6oVyVQqoA9GpFcMRz6YhrAidd4x7g7a, got %s", signal.Maker) + } + if signal.Token0Address != "jx4PF2MwC7AK9S8dTeYm29hM3vAN8Rtfs2VX4Vz5UVj" { + t.Fatalf("expected token0 address jx4PF2MwC7AK9S8dTeYm29hM3vAN8Rtfs2VX4Vz5UVj, got %s", signal.Token0Address) + } + if signal.Token0AmountUint64 != 1796593710706 { + t.Fatalf("expected token0 amount 1796593710706, got %d", signal.Token0AmountUint64) + } + if signal.Token1AmountUint64 != 1955555553 { + t.Fatalf("expected token1 amount 1955555553, got %d", signal.Token1AmountUint64) + } +}