pump buy_exact_sol_in parsered

This commit is contained in:
thloyi
2025-11-24 17:47:56 +08:00
parent f86c5591c1
commit 1f63a3a18f
6 changed files with 72 additions and 10 deletions

34
pump.go
View File

@@ -174,6 +174,15 @@ type PumpTradeEvent struct {
Fee uint64
Creator solana.PublicKey
CreatorFeeBasisPoints uint64
CreatorFee uint64
}
type PumpTradeFeeArg struct {
IsPump bool
MarketCap [16]byte
TradeSize uint64
}
type CompleteEvent struct {
@@ -189,8 +198,16 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
var err error
var programIndex = instruction.ProgramIDIndex
feeEventProgramIndex := 0
for i, b := range result.accountList {
if b.Equals(pumpFeesProgram) {
feeEventProgramIndex = i
break
}
}
var (
tradeEvent PumpTradeEvent
tradeFeeArg PumpTradeFeeArg
completeEvent CompleteEvent
completed bool
newoffset [2]uint
@@ -203,6 +220,13 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
}
for innerIndex, innerInstr := range inners {
if innerInstr.ProgramIDIndex == feeEventProgramIndex && bytes.Equal(innerInstr.Data[:8], pumpGetFeesDiscriminator[:]) {
err = agbinary.NewBorshDecoder(innerInstr.Data[8:]).Decode(&tradeFeeArg)
if err != nil {
return nil, increaseOffset(offset), fmt.Errorf("pump get fees event decode error: %v, offset, %d, %d", err, offset[0], offset[1])
}
continue
}
if innerInstr.ProgramIDIndex == programIndex && bytes.Equal(innerInstr.Data[:8], pumpEventDiscriminator[:]) {
if bytes.Equal(innerInstr.Data[8:16], pumpTradeEventDiscriminator[8:16]) {
err = agbinary.NewBorshDecoder(innerInstr.Data[16:]).Decode(&tradeEvent)
@@ -260,6 +284,14 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
Decimals: 6,
}
}
solAmount := tradeEvent.SolAmount
if tradeEvent.IsBuy && bytes.Equal(instruction.Data[:8], pumpBuyV2Discriminator[:]) {
fee := tradeEvent.Fee + tradeEvent.CreatorFee
solAmount = tradeFeeArg.TradeSize
if solAmount > fee {
solAmount = solAmount - fee
}
}
swaps := []Swap{
{
Program: SolProgramPump,
@@ -274,7 +306,7 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
QuoteMintDecimals: 9,
User: tradeEvent.User,
BaseAmount: decimal.NewFromUint64(tradeEvent.TokenAmount),
QuoteAmount: decimal.NewFromUint64(tradeEvent.SolAmount),
QuoteAmount: decimal.NewFromUint64(solAmount),
BaseReserve: decimal.NewFromUint64(tradeEvent.RealTokenReserves),
QuoteReserve: decimal.NewFromUint64(tradeEvent.RealSolReserves),
Mayhem: isMayhemPump(result.accountList[instruction.Accounts[1]]),