fix okx user

This commit is contained in:
thloyi
2025-12-22 17:56:40 +08:00
parent b44c7372d5
commit 9898554bf8
19 changed files with 635 additions and 5712 deletions

35
pump.go
View File

@@ -218,6 +218,13 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
if err != nil {
return nil, increaseOffset(offset), fmt.Errorf("pump create get inner instructions error: %v,offset, %d, %d", err, offset[0], offset[1])
}
if instruction.StackHeight != nil && *instruction.StackHeight > 2 {
for _, innerInstr := range inners {
if innerInstr.StackHeight != nil && *innerInstr.StackHeight == *instruction.StackHeight-1 {
entryContract = result.accountList[innerInstr.ProgramIDIndex]
}
}
}
for innerIndex, innerInstr := range inners {
if innerInstr.ProgramIDIndex == feeEventProgramIndex && bytes.Equal(innerInstr.Data[:8], pumpGetFeesDiscriminator[:]) {
@@ -262,11 +269,6 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
}
offset = [2]uint{newoffset[0], newoffset[1]}
ataUserIdx := instruction.Accounts[5]
userIndex := instruction.Accounts[6]
userBase := getAccountBalanceAfterTx(result, ataUserIdx)
userQuote, _ := GetSolAfterTx(result, userIndex)
event := ""
baseTokenProgram := solana.TokenProgramID
@@ -284,6 +286,24 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
Decimals: 6,
}
}
var user = tradeEvent.User
ataUserIdx := instruction.Accounts[5]
userIndex := instruction.Accounts[6]
if !tradeEvent.User.IsOnCurve() && (entryContract.Equals(okxDexRoutersV2) || entryContract.Equals(okxAggregatorV2)) {
userBaseAmount, ataIndex := tokenBalanceChange(result, 0, baseTokenProgram, tradeEvent.Mint)
//&& userBaseAmount.BigInt().Uint64() == tradeEvent.TokenAmount
if !userBaseAmount.IsZero() {
user = result.accountList[0]
userIndex = 0
ataUserIdx = ataIndex
}
}
userBase := getAccountBalanceAfterTx(result, ataUserIdx)
userQuote, _ := GetSolAfterTx(result, userIndex)
solAmount := tradeEvent.SolAmount
if tradeEvent.IsBuy && bytes.Equal(instruction.Data[:8], pumpBuyV2Discriminator[:]) {
fee := tradeEvent.Fee + tradeEvent.CreatorFee
@@ -304,7 +324,7 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
Creator: tradeEvent.Creator,
BaseMintDecimals: 6,
QuoteMintDecimals: 9,
User: tradeEvent.User,
User: user,
BaseAmount: decimal.NewFromUint64(tradeEvent.TokenAmount),
QuoteAmount: decimal.NewFromUint64(solAmount),
BaseReserve: decimal.NewFromUint64(tradeEvent.RealTokenReserves),
@@ -327,13 +347,14 @@ func BuyOrSellParser(tx *Tx, instruction Instruction, innerInstructions InnerIns
Creator: tradeEvent.Creator,
BaseMintDecimals: 6,
QuoteMintDecimals: 9,
User: tradeEvent.User,
User: user,
Mayhem: isMayhemPump(result.accountList[instruction.Accounts[1]]),
UserBaseBalance: userBase,
UserQuoteBalance: decimal.NewFromUint64(userQuote),
EntryContract: entryContract,
})
}
return swaps, offset, nil
}