pipo tx parse
This commit is contained in:
@@ -245,17 +245,13 @@ type OkxV2SwapScorch struct {
|
||||
Id [16]byte
|
||||
}
|
||||
|
||||
func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex int) (*TxSignal, error) {
|
||||
msg := tx.Message
|
||||
if instructionIndex >= len(msg.Instructions) {
|
||||
return nil, fmt.Errorf("instruction index out of bounds")
|
||||
}
|
||||
ix := msg.Instructions[instructionIndex]
|
||||
if len(ix.Data) < 8 {
|
||||
func parseOkxDexRouteV2Instruction(tx TransactionGetter, accounts []uint8, data []byte) (*TxSignal, error) {
|
||||
|
||||
if len(data) < 8 {
|
||||
return nil, nil
|
||||
}
|
||||
disc := ix.Data[:8]
|
||||
data := ix.Data[8:]
|
||||
disc := data[:8]
|
||||
data = data[8:]
|
||||
|
||||
var (
|
||||
args *OkxV2SwapArgs
|
||||
@@ -288,8 +284,8 @@ func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex in
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
if len(ix.Accounts) < 15 {
|
||||
return nil, fmt.Errorf("invalid account count: %d", len(ix.Accounts))
|
||||
if len(accounts) < 15 {
|
||||
return nil, fmt.Errorf("invalid account count: %d", len(accounts))
|
||||
}
|
||||
var (
|
||||
inputAmount uint64
|
||||
@@ -303,24 +299,24 @@ func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex in
|
||||
}
|
||||
}
|
||||
if routeCount > 1 {
|
||||
logger.Warn("pumpSwapSell at inputIdx=0: multiple instances found", "tx", tx.Signatures[0].String(), "routeCount", routeCount)
|
||||
logger.Warn("pumpSwapSell at inputIdx=0: multiple instances found", "tx", tx.Signatures(), "routeCount", routeCount)
|
||||
return nil, nil
|
||||
}
|
||||
if inputAmount == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
srcMint, err := getStaticKey(tx.Message.StaticAccountKeys, int(ix.Accounts[3]))
|
||||
srcMint, err := tx.GetAccount(accounts[3]) //getStaticKey(tx.Message.StaticAccountKeys, int(ix.Accounts[3]))
|
||||
|
||||
var (
|
||||
srcIdx uint8
|
||||
)
|
||||
if len(ix.Accounts) <= 15 {
|
||||
if len(accounts) <= 15 {
|
||||
return nil, nil
|
||||
}
|
||||
accounts := ix.Accounts[14:]
|
||||
accounts = accounts[14:]
|
||||
for i, acctIdx := range accounts {
|
||||
key, err := getStaticKey(tx.Message.StaticAccountKeys, int(acctIdx))
|
||||
key, err := tx.GetAccount(acctIdx) // getStaticKey(tx.Message.StaticAccountKeys, int(acctIdx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -333,7 +329,7 @@ func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex in
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
baseMint, err := getStaticKey(tx.Message.StaticAccountKeys, int(accounts[srcIdx]))
|
||||
baseMint, err := tx.GetAccount(accounts[srcIdx]) // getStaticKey(tx.Message.StaticAccountKeys, int(accounts[srcIdx]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -341,17 +337,18 @@ func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex in
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
quoteMint, err := getStaticKey(tx.Message.StaticAccountKeys, int(accounts[srcIdx+1]))
|
||||
quoteMint, err := tx.GetAccount(accounts[srcIdx+1]) // getStaticKey(tx.Message.StaticAccountKeys, int(accounts[srcIdx+1]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !quoteMint.Equals(solana.WrappedSol) {
|
||||
return nil, nil
|
||||
}
|
||||
maker, _ := tx.GetAccount(0)
|
||||
|
||||
return &TxSignal{
|
||||
TxHash: tx.Signatures[0].String(),
|
||||
Maker: tx.Message.StaticAccountKeys[0].String(),
|
||||
TxHash: tx.Signatures(),
|
||||
Maker: maker.String(),
|
||||
Token0Address: baseMint.String(),
|
||||
Token1Address: wsolMint,
|
||||
Token0Amount: formatTokenAmount(inputAmount),
|
||||
@@ -363,6 +360,7 @@ func parseOkxDexRouteV2Instruction(tx *versionedTransaction, instructionIndex in
|
||||
IsMayhemMode: false,
|
||||
ExactSOL: false,
|
||||
Token0AmountUint64: inputAmount,
|
||||
Block: tx.Block(),
|
||||
Token1AmountUint64: 0,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user