49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package pump_parser
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/gagliardetto/solana-go"
|
|
)
|
|
|
|
var (
|
|
WSOLString = "So11111111111111111111111111111111111111112"
|
|
WSOL = solana.MustPublicKeyFromBase58("So11111111111111111111111111111111111111112")
|
|
USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
)
|
|
|
|
const (
|
|
SOLDecimals = 9
|
|
)
|
|
|
|
var (
|
|
InstructionIgnoredError = errors.New("instruction ignored")
|
|
)
|
|
|
|
type swapParser func(tx *Tx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint) ([]Swap, [2]uint, error)
|
|
type actionParser func(tx *Tx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint) ([2]uint, error)
|
|
|
|
func getInnerInstructions(innerInstructions InnerInstructions, offset uint) ([]Instruction, error) {
|
|
var inners []Instruction
|
|
var prefixLen = offset
|
|
if prefixLen > uint(len(innerInstructions.Instructions)) {
|
|
return nil, fmt.Errorf("error inner instruction index out of range")
|
|
}
|
|
if prefixLen == 0 {
|
|
inners = innerInstructions.Instructions
|
|
} else {
|
|
inners = innerInstructions.Instructions[prefixLen:]
|
|
}
|
|
return inners, nil
|
|
}
|
|
|
|
func isMayhemPump(feeAccount solana.PublicKey) bool {
|
|
for _, mayhemFeeAccount := range mayhemFeeAccounts {
|
|
if feeAccount.Equals(mayhemFeeAccount) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|