swap amount input
This commit is contained in:
@@ -666,22 +666,33 @@ func metaoradlmmSwapParser(tx *Tx, instruction Instruction, innerInstructions In
|
||||
}
|
||||
|
||||
discriminator := *(*[8]byte)(decode[:8])
|
||||
var swapMode SwapMode
|
||||
var fixedAmount decimal.Decimal
|
||||
var limitAmount decimal.Decimal
|
||||
switch discriminator {
|
||||
case meteoraDlmmSwapDiscriminator, meteoraDlmmSwap2Discriminator:
|
||||
var args meteoraDlmmSwapArgs
|
||||
if err := agbinary.NewBorshDecoder(decode[8:]).Decode(&args); err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("meteora dlmm swap decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
swapMode = SwapModeExactIn
|
||||
fixedAmount = decimal.NewFromUint64(args.AmountIn)
|
||||
limitAmount = decimal.NewFromUint64(args.MinAmountOut)
|
||||
case meteoraDlmmSwapExactOutDiscriminator, meteoraDlmmSwapExactOut2Discriminator:
|
||||
var args meteoraDlmmSwapExactOutArgs
|
||||
if err := agbinary.NewBorshDecoder(decode[8:]).Decode(&args); err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("meteora dlmm swap_exact_out decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
swapMode = SwapModeExactOut
|
||||
fixedAmount = decimal.NewFromUint64(args.OutAmount)
|
||||
limitAmount = decimal.NewFromUint64(args.MaxInAmount)
|
||||
case meteoraDlmmSwapWithPriceImpactDiscriminator, meteoraDlmmSwapWithPriceImpact2Discriminator:
|
||||
var args meteoraDlmmSwapWithPriceImpactArgs
|
||||
if err := agbinary.NewBorshDecoder(decode[8:]).Decode(&args); err != nil {
|
||||
return nil, increaseOffset(offset), fmt.Errorf("meteora dlmm swap_with_price_impact decode error: %v, offset, %d, %d", err, offset[0], offset[1])
|
||||
}
|
||||
swapMode = SwapModeExactIn
|
||||
fixedAmount = decimal.NewFromUint64(args.AmountIn)
|
||||
default:
|
||||
return nil, increaseOffset(offset), InstructionIgnoredError
|
||||
}
|
||||
@@ -861,6 +872,7 @@ func metaoradlmmSwapParser(tx *Tx, instruction Instruction, innerInstructions In
|
||||
StartBinId: swapEvent.StartBinId,
|
||||
EndBinId: swapEvent.EndBinId,
|
||||
}
|
||||
swap.SetSwapAmountInfo(swapMode, fixedAmount, limitAmount)
|
||||
|
||||
return []Swap{swap}, offset, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user