fix pump wrapper buy and sell

This commit is contained in:
thloyi
2026-05-13 16:53:22 +08:00
parent 8d4aad1932
commit 8b608889cb
4 changed files with 30 additions and 1 deletions

View File

@@ -14,7 +14,7 @@ func main() {
const rpcURL = "https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d" const rpcURL = "https://staked.helius-rpc.com?api-key=5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d"
txHash := os.Getenv("TX_HASH") txHash := os.Getenv("TX_HASH")
if txHash == "" { if txHash == "" {
txHash = "29v7u2ewLr3Se6cWYC2xwN8jszqMWwvVgPz7MqkctTveMo1csWWYDBcUsjuJwb5ciugc5so1jc9QcmR7syJTjEns" txHash = "24wP3rk2ZfSVDB5YGyEQbhuy1jRXKZYkzXDRrDwwoKgzD6G4Kyyh4vmnir9ye98uLVKA5bBMj5Fq4cwgbDxp2Gie"
} }
if txHash == "" { if txHash == "" {

View File

@@ -777,6 +777,9 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
for innerIndex, innerInstr := range inners { for innerIndex, innerInstr := range inners {
if innerInstr.ProgramIDIndex == feeEventProgramIndex && bytes.Equal(innerInstr.Data[:8], pumpGetFeesDiscriminator[:]) { if innerInstr.ProgramIDIndex == feeEventProgramIndex && bytes.Equal(innerInstr.Data[:8], pumpGetFeesDiscriminator[:]) {
if tradeFound {
continue
}
err = agbinary.NewBorshDecoder(innerInstr.Data[8:]).Decode(&tradeFeeArg) err = agbinary.NewBorshDecoder(innerInstr.Data[8:]).Decode(&tradeFeeArg)
if err != nil { if err != nil {
return nil, increaseOffset(offset), fmt.Errorf("pump get fees event decode error: %v, offset, %d, %d", err, offset[0], offset[1]) return nil, increaseOffset(offset), fmt.Errorf("pump get fees event decode error: %v, offset, %d, %d", err, offset[0], offset[1])

View File

@@ -102,6 +102,31 @@ func TestPumpCompleteMatchesTradeEvent(t *testing.T) {
} }
} }
func TestPumpExactQuoteInKeepsFeeArgBeforeMatchedTrade(t *testing.T) {
EnableAllParsers()
tx := mustParseRPCFixtureTx(t, "3jugr2KthX3cUHzPrMpaFKM7RtxXM6Gcxi8eFjDL7aZGLXpc6f1RaVdnAoB4ye5bRVYsP2fFs3aLaP19Utz91ewv")
if len(tx.Swaps) != 4 {
t.Fatalf("swaps len = %d, want 4", len(tx.Swaps))
}
for i := 0; i < 3; i++ {
swap := tx.Swaps[i]
if swap.Program != SolProgramPump || swap.Event != "buy" {
t.Fatalf("swap[%d] = %s/%s, want Pump/buy", i, swap.Program, swap.Event)
}
assertDecimalString(t, fmt.Sprintf("swap[%d].quote_amount", i), swap.QuoteAmount, "329217")
assertDecimalString(t, fmt.Sprintf("swap[%d].fixed_amount", i), swap.FixedAmount, "333333")
}
sell := tx.Swaps[3]
if sell.Program != SolProgramPump || sell.Event != "sell" {
t.Fatalf("swap[3] = %s/%s, want Pump/sell", sell.Program, sell.Event)
}
assertDecimalString(t, "swap[3].base_amount", sell.BaseAmount, "12282189230")
assertDecimalString(t, "swap[3].quote_amount", sell.QuoteAmount, "987647")
}
func TestPumpV2Discriminators(t *testing.T) { func TestPumpV2Discriminators(t *testing.T) {
tests := []struct { tests := []struct {
name string name string

File diff suppressed because one or more lines are too long