metaora dlmm init
This commit is contained in:
@@ -199,6 +199,8 @@ func metaoradlmmParser(tx *Tx, instruction Instruction, innerInstructions InnerI
|
||||
|
||||
discriminator := *(*[8]byte)(decode[:8])
|
||||
switch discriminator {
|
||||
case meteoraInitializeLbPairDiscriminator:
|
||||
return metaoradlmmInitializeParser(tx, instruction, innerInstructions, offset)
|
||||
case meteoraDlmmSwapDiscriminator, meteoraDlmmSwapExactOutDiscriminator, meteoraDlmmSwapWithPriceImpactDiscriminator:
|
||||
return metaoradlmmSwapParser(tx, instruction, innerInstructions, offset)
|
||||
case meteoraDlmmSwap2Discriminator, meteoraDlmmSwapExactOut2Discriminator, meteoraDlmmSwapWithPriceImpact2Discriminator:
|
||||
@@ -214,6 +216,57 @@ func metaoradlmmParser(tx *Tx, instruction Instruction, innerInstructions InnerI
|
||||
}
|
||||
}
|
||||
|
||||
func metaoradlmmInitializeParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
market := tx.rawTx.accountList[instruction.Accounts[0]]
|
||||
token0 := tx.rawTx.accountList[instruction.Accounts[2]]
|
||||
token1 := tx.rawTx.accountList[instruction.Accounts[3]]
|
||||
|
||||
entryContract := tx.rawTx.accountList[tx.rawTx.Transaction.Message.Instructions[offset[0]].ProgramIDIndex]
|
||||
|
||||
var baseDecimals uint8
|
||||
var quoteDecimals uint8
|
||||
for _, acc := range tx.rawTx.Meta.PostTokenBalances {
|
||||
if acc.MintAccount.Equals(token0) {
|
||||
baseDecimals = uint8(acc.UITokenAmount.Decimals)
|
||||
}
|
||||
if acc.MintAccount.Equals(token1) {
|
||||
quoteDecimals = uint8(acc.UITokenAmount.Decimals)
|
||||
}
|
||||
}
|
||||
swap := Swap{
|
||||
Program: SolProgramMeteoraDLMM,
|
||||
Event: "create",
|
||||
Pool: market,
|
||||
BaseMint: token0,
|
||||
QuoteMint: token1,
|
||||
BaseTokenProgram: tx.rawTx.accountList[instruction.Accounts[11]],
|
||||
QuoteTokenProgram: tx.rawTx.accountList[instruction.Accounts[12]],
|
||||
Creator: tx.rawTx.accountList[0],
|
||||
BaseMintDecimals: baseDecimals,
|
||||
QuoteMintDecimals: quoteDecimals,
|
||||
User: tx.rawTx.accountList[instruction.Accounts[8]],
|
||||
EntryContract: entryContract,
|
||||
}
|
||||
var prefixLen = offset[1]
|
||||
inners, err := getInnerInstructions(innerInstructions, prefixLen)
|
||||
if err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("pump create get inner instructions error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
var programIndex = instruction.ProgramIDIndex
|
||||
|
||||
for innerIndex, innerInstr := range inners {
|
||||
if innerInstr.ProgramIDIndex == programIndex && bytes.Equal(innerInstr.Data[:8], pumpEventDiscriminator[:]) && bytes.Equal(innerInstr.Data[8:16], meteoraInitializeLbPairEventDiscriminator[:]) {
|
||||
if offset[1] == 0 {
|
||||
offset[0] += 1
|
||||
} else {
|
||||
offset[1] += uint(innerIndex) + 1 + prefixLen
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return []Swap{swap}, offset, nil
|
||||
}
|
||||
|
||||
func metaoradlmmSwapParser(tx *Tx, instruction Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error) {
|
||||
result := tx.rawTx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user