dexparser

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 22 Imported by: 0

README ΒΆ

Solana DEX Parser (Go)

Go Version License Docs

A high-performance Go library for parsing Solana DEX transactions.

Supports 23 full parsers + 55 routing detection (program IDs), including Jupiter, Raydium, Orca, Meteora, Pumpfun, Pumpswap, and 9 trading bots with fee detection + 6 bot programs.

Installation

go get github.com/DefaultPerson/solana-dex-parser-go

Quick Start

package main

import (
    "encoding/json"
    "fmt"

    dexparser "github.com/DefaultPerson/solana-dex-parser-go"
)

func main() {
    var tx dexparser.SolanaTransaction
    json.Unmarshal([]byte(txJSON), &tx)

    parser := dexparser.NewDexParser()
    result := parser.ParseAll(&tx, nil)

    fmt.Printf("Trades: %d\n", len(result.Trades))
    fmt.Printf("Liquidities: %d\n", len(result.Liquidities))
    fmt.Printf("MemeEvents: %d\n", len(result.MemeEvents))
}

Features

  • Multi-Protocol - Jupiter, Raydium, Orca, Meteora, Pumpfun, Moonit, etc.
  • Rich Data - Trades, liquidity events, transfers, meme events
  • High Performance - Optimized JSON parsing, memory pooling
  • gRPC Support - ShredParser for Helius/Triton streams

Documentation

Supported Protocols

Status Legend:

  • βœ… Parser β€” Full trade/liquidity parsing with instruction decoding
  • πŸ”— Constants β€” Program ID defined for routing detection only
DEX Aggregators & Routers
Protocol Trades Liquidity Transfers Status
Jupiter (V6, DCA, Limit, VA) βœ… ❌ βœ… βœ… Parser
OKX DEX βœ… ❌ βœ… πŸ”— Constants
DFlow βœ… ❌ βœ… βœ… Parser
Sanctum βœ… ❌ βœ… πŸ”— Constants
Photon βœ… ❌ βœ… βœ… Parser
Raydium Route βœ… ❌ βœ… βœ… Parser
Major AMMs
Protocol Trades Liquidity Transfers Status
Raydium V4 βœ… βœ… βœ… βœ… Parser
Raydium CPMM βœ… βœ… βœ… βœ… Parser
Raydium CL βœ… βœ… βœ… βœ… Parser
Orca Whirlpool βœ… βœ… βœ… βœ… Parser
Meteora DLMM βœ… βœ… βœ… βœ… Parser
Meteora Pools βœ… βœ… βœ… βœ… Parser
Meteora DAMM βœ… βœ… βœ… βœ… Parser
PumpSwap βœ… βœ… βœ… βœ… Parser
Phoenix βœ… ❌ βœ… πŸ”— Constants
Lifinity βœ… ❌ βœ… πŸ”— Constants
Lifinity V2 βœ… ❌ βœ… πŸ”— Constants
OpenBook βœ… ❌ βœ… πŸ”— Constants
Prop AMM / Dark Pools
Protocol Trades Liquidity Transfers Status
SolFi βœ… ❌ βœ… βœ… Parser
GoonFi βœ… ❌ βœ… βœ… Parser
Obric V2 βœ… ❌ βœ… βœ… Parser
HumidiFi βœ… ❌ βœ… βœ… Parser
Meme & Launch Platforms
Protocol Trades Create Migrate Status
Pumpfun βœ… βœ… βœ… βœ… Parser
Raydium Launchpad βœ… βœ… βœ… βœ… Parser
Meteora DBC βœ… βœ… βœ… βœ… Parser
Moonit βœ… βœ… βœ… βœ… Parser
Heaven.xyz βœ… βœ… βœ… βœ… Parser
Sugar.money βœ… βœ… βœ… βœ… Parser
Bonk βœ… βœ… βœ… πŸ”— Constants
BoopFun βœ… βœ… βœ… βœ… Parser
Trading Bots (Fee Account Detection)
Bot Detection Status
Trojan βœ… βœ… Parser
BONKbot βœ… βœ… Parser
Axiom βœ… βœ… Parser
GMGN βœ… βœ… Parser
BullX βœ… βœ… Parser
Maestro βœ… βœ… Parser
Bloom βœ… βœ… Parser
BananaGun βœ… βœ… Parser
Raybot βœ… βœ… Parser
Trading Bots (Program Detection)
Bot Detection Status
Mintech βœ… πŸ”— Constants
Nova βœ… πŸ”— Constants
Apepro βœ… πŸ”— Constants
BananaGun βœ… πŸ”— Constants
Bloom βœ… πŸ”— Constants
Maestro βœ… πŸ”— Constants
Additional AMMs
Protocol Trades Liquidity Transfers Status
GooseFX βœ… ❌ βœ… πŸ”— Constants
Mercurial βœ… ❌ βœ… πŸ”— Constants
Stabble βœ… ❌ βœ… πŸ”— Constants
1Dex βœ… ❌ βœ… πŸ”— Constants
ZeroFi βœ… ❌ βœ… πŸ”— Constants
Legacy Protocols
Protocol Trades Liquidity Status
Serum V3 βœ… ❌ πŸ”— Constants
Aldrin βœ… ❌ πŸ”— Constants
Aldrin V2 βœ… ❌ πŸ”— Constants
Crema βœ… ❌ πŸ”— Constants
Saber βœ… ❌ πŸ”— Constants
Saros βœ… ❌ πŸ”— Constants

Total: 23 full parsers + 55 routing detection (program IDs)

Shred Parser Support

Real-time shred-stream processing for live blockchain data analysis via gRPC streams (Helius, Triton, etc.):

parser := dexparser.NewShredParser()
result := parser.ParseAll(&tx, nil)

// Access parsed instructions by program
for program, instructions := range result.Instructions {
    fmt.Printf("%s: %d instructions\n", program, len(instructions))
}
Key Differences: ShredParser vs DexParser
Feature DexParser ShredParser
Input Data Complete transaction Raw message only
Execution State Post-execution Pre-execution
Transfer Data βœ… Actual results ❌ No execution
Use Case Historical analysis Real-time monitoring
Shred Parser Protocol Support
Protocol Status Notes
Pumpfun βœ… Buy, Sell, Create, Migrate
PumpSwap βœ… Buy, Sell, Add/Remove Liquidity
Jupiter V6 βœ… Route, SharedAccountsRoute
Raydium V4 βœ… Swap instructions
Raydium Launchpad βœ… Buy, Sell, Create
Meteora DBC βœ… Dynamic bonding curve
DFlow βœ… Swap routing
Photon βœ… Multi-hop aggregation
System Program βœ… SOL transfers
Token Program βœ… SPL transfers
Token 2022 βœ… Token extensions

License

MIT License - see LICENSE

Acknowledgments

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func ConvertYellowstoneTransaction ΒΆ added in v1.2.0

func ConvertYellowstoneTransaction(grpc *YellowstoneTransaction, slot uint64, blockTime int64) *adapter.SolanaTransaction

ConvertYellowstoneTransaction converts a Yellowstone gRPC transaction to SolanaTransaction format that can be used with DexParser.ParseAll() or ShredParser.ParseAll()

Types ΒΆ

type DexParser ΒΆ

type DexParser struct {
	// contains filtered or unexported fields
}

DexParser is the main parser class for Solana DEX transactions

func NewDexParser ΒΆ

func NewDexParser() *DexParser

NewDexParser creates a new DexParser instance

func (*DexParser) ParseAll ΒΆ

ParseAll parses all data from a transaction

func (*DexParser) ParseBatch ΒΆ added in v1.2.0

func (dp *DexParser) ParseBatch(txs []*adapter.SolanaTransaction, config *types.ParseConfig, maxWorkers int) []*types.ParseResult

ParseBatch parses multiple transactions concurrently maxWorkers: maximum number of concurrent workers, if <= 1, will use sequential processing

func (*DexParser) ParseBatchWithCallback ΒΆ added in v1.2.0

func (dp *DexParser) ParseBatchWithCallback(
	txs []*adapter.SolanaTransaction,
	config *types.ParseConfig,
	maxWorkers int,
	callback ParseCallback,
) []*types.ParseResult

ParseBatchWithCallback parses multiple transactions with callback support maxWorkers: maximum number of concurrent workers, if <= 1, will use sequential processing callback: optional callback function called for each completed transaction

func (*DexParser) ParseLiquidity ΒΆ

func (dp *DexParser) ParseLiquidity(tx *adapter.SolanaTransaction, config *types.ParseConfig) []types.PoolEvent

ParseLiquidity parses liquidity events from a transaction

func (*DexParser) ParseTrades ΒΆ

func (dp *DexParser) ParseTrades(tx *adapter.SolanaTransaction, config *types.ParseConfig) []types.TradeInfo

ParseTrades parses trades from a transaction

func (*DexParser) ParseTransfers ΒΆ

func (dp *DexParser) ParseTransfers(tx *adapter.SolanaTransaction, config *types.ParseConfig) []types.TransferData

ParseTransfers parses transfers from a transaction

func (*DexParser) RegisterLiquidityParser ΒΆ

func (dp *DexParser) RegisterLiquidityParser(programId string, factory LiquidityParserFactory)

RegisterLiquidityParser registers a liquidity parser for a program ID

func (*DexParser) RegisterMemeEventParser ΒΆ

func (dp *DexParser) RegisterMemeEventParser(programId string, factory MemeEventParserFactory)

RegisterMemeEventParser registers a meme event parser for a program ID

func (*DexParser) RegisterTradeParser ΒΆ

func (dp *DexParser) RegisterTradeParser(programId string, factory TradeParserFactory)

RegisterTradeParser registers a trade parser for a program ID

func (*DexParser) RegisterTransferParser ΒΆ

func (dp *DexParser) RegisterTransferParser(programId string, factory TransferParserFactory)

RegisterTransferParser registers a transfer parser for a program ID

type LiquidityParserFactory ΒΆ

type LiquidityParserFactory func(
	adapter *adapter.TransactionAdapter,
	transferActions map[string][]types.TransferData,
	classifiedInstructions []types.ClassifiedInstruction,
) parsers.LiquidityParser

LiquidityParserFactory creates a liquidity parser

type MemeEventParserFactory ΒΆ

type MemeEventParserFactory func(
	adapter *adapter.TransactionAdapter,
	transferActions map[string][]types.TransferData,
) parsers.EventParser

MemeEventParserFactory creates a meme event parser

type ParseCallback ΒΆ added in v1.2.0

type ParseCallback func(index int, tx *adapter.SolanaTransaction, result *types.ParseResult, err error) bool

ParseCallback defines the callback function type for batch parsing index: the index of the transaction in the batch tx: the transaction being parsed (may be nil) result: the parse result err: any error that occurred during parsing returns: true to continue processing, false to stop early

type PumpfunBuyData ΒΆ

type PumpfunBuyData struct {
	Mint         string `json:"mint"`
	BondingCurve string `json:"bondingCurve"`
	TokenAmount  uint64 `json:"tokenAmount"`
	SolAmount    uint64 `json:"solAmount"`
	User         string `json:"user"`
}

PumpfunBuyData contains buy instruction data

type PumpfunCreateData ΒΆ

type PumpfunCreateData struct {
	Name         string `json:"name"`
	Symbol       string `json:"symbol"`
	URI          string `json:"uri"`
	Mint         string `json:"mint"`
	BondingCurve string `json:"bondingCurve"`
	User         string `json:"user"`
}

PumpfunCreateData contains create instruction data

type PumpfunInstruction ΒΆ

type PumpfunInstruction struct {
	Type      string      `json:"type"`
	Data      interface{} `json:"data"`
	Slot      uint64      `json:"slot"`
	Timestamp int64       `json:"timestamp"`
	Signature string      `json:"signature"`
	Idx       string      `json:"idx"`
	Signer    []string    `json:"signer"`
}

PumpfunInstruction represents a parsed Pumpfun instruction

type PumpfunInstructionParser ΒΆ

type PumpfunInstructionParser struct {
	// contains filtered or unexported fields
}

PumpfunInstructionParser parses Pumpfun instructions

func NewPumpfunInstructionParser ΒΆ

func NewPumpfunInstructionParser(adapter *adapter.TransactionAdapter, classifier *classifier.InstructionClassifier) *PumpfunInstructionParser

NewPumpfunInstructionParser creates a new Pumpfun instruction parser

func (*PumpfunInstructionParser) ProcessInstructions ΒΆ

func (p *PumpfunInstructionParser) ProcessInstructions() []interface{}

ProcessInstructions processes all Pumpfun instructions

type PumpfunMigrateData ΒΆ

type PumpfunMigrateData struct {
	Mint                  string `json:"mint"`
	BondingCurve          string `json:"bondingCurve"`
	User                  string `json:"user"`
	PoolMint              string `json:"poolMint"`
	QuoteMint             string `json:"quoteMint"`
	LpMint                string `json:"lpMint"`
	UserPoolTokenAccount  string `json:"userPoolTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
}

PumpfunMigrateData contains migrate instruction data

type PumpfunSellData ΒΆ

type PumpfunSellData struct {
	Mint         string `json:"mint"`
	BondingCurve string `json:"bondingCurve"`
	TokenAmount  uint64 `json:"tokenAmount"`
	SolAmount    uint64 `json:"solAmount"`
	User         string `json:"user"`
}

PumpfunSellData contains sell instruction data

type PumpswapAddLiquidityData ΒΆ

type PumpswapAddLiquidityData struct {
	PoolMint              string `json:"poolMint"`
	User                  string `json:"user"`
	BaseMint              string `json:"baseMint"`
	QuoteMint             string `json:"quoteMint"`
	LpMint                string `json:"lpMint"`
	UserBaseTokenAccount  string `json:"userBaseTokenAccount"`
	UserQuoteTokenAccount string `json:"userQuoteTokenAccount"`
	UserPoolTokenAccount  string `json:"userPoolTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
	LpTokenAmountOut      uint64 `json:"lpTokenAmountOut"`
	MaxBaseAmountIn       uint64 `json:"maxBaseAmountIn"`
	MaxQuoteAmountIn      uint64 `json:"maxQuoteAmountIn"`
}

PumpswapAddLiquidityData contains add liquidity instruction data

type PumpswapBuyInstructionData ΒΆ

type PumpswapBuyInstructionData struct {
	PoolMint              string `json:"poolMint"`
	User                  string `json:"user"`
	BaseMint              string `json:"baseMint"`
	QuoteMint             string `json:"quoteMint"`
	UserBaseTokenAccount  string `json:"userBaseTokenAccount"`
	UserQuoteTokenAccount string `json:"userQuoteTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
	BaseAmountOut         uint64 `json:"baseAmountOut"`
	MaxQuoteAmountIn      uint64 `json:"maxQuoteAmountIn"`
}

PumpswapBuyInstructionData contains buy instruction data

type PumpswapCreatePoolInstructionData ΒΆ

type PumpswapCreatePoolInstructionData struct {
	PoolMint              string `json:"poolMint"`
	User                  string `json:"user"`
	BaseMint              string `json:"baseMint"`
	QuoteMint             string `json:"quoteMint"`
	LpMint                string `json:"lpMint"`
	UserBaseTokenAccount  string `json:"userBaseTokenAccount"`
	UserQuoteTokenAccount string `json:"userQuoteTokenAccount"`
	UserPoolTokenAccount  string `json:"userPoolTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
	BaseAmountIn          uint64 `json:"baseAmountIn"`
	QuoteAmountOut        uint64 `json:"quoteAmountOut"`
}

PumpswapCreatePoolInstructionData contains create pool instruction data

type PumpswapInstruction ΒΆ

type PumpswapInstruction struct {
	Type      string      `json:"type"`
	Data      interface{} `json:"data"`
	Slot      uint64      `json:"slot"`
	Timestamp int64       `json:"timestamp"`
	Signature string      `json:"signature"`
	Idx       string      `json:"idx"`
	Signer    []string    `json:"signer"`
}

PumpswapInstruction represents a parsed Pumpswap instruction

type PumpswapInstructionParser ΒΆ

type PumpswapInstructionParser struct {
	// contains filtered or unexported fields
}

PumpswapInstructionParser parses Pumpswap instructions

func NewPumpswapInstructionParser ΒΆ

func NewPumpswapInstructionParser(adapter *adapter.TransactionAdapter, classifier *classifier.InstructionClassifier) *PumpswapInstructionParser

NewPumpswapInstructionParser creates a new Pumpswap instruction parser

func (*PumpswapInstructionParser) ProcessInstructions ΒΆ

func (p *PumpswapInstructionParser) ProcessInstructions() []interface{}

ProcessInstructions processes all Pumpswap instructions

type PumpswapRemoveLiquidityData ΒΆ

type PumpswapRemoveLiquidityData struct {
	PoolMint              string `json:"poolMint"`
	User                  string `json:"user"`
	BaseMint              string `json:"baseMint"`
	QuoteMint             string `json:"quoteMint"`
	LpMint                string `json:"lpMint"`
	UserBaseTokenAccount  string `json:"userBaseTokenAccount"`
	UserQuoteTokenAccount string `json:"userQuoteTokenAccount"`
	UserPoolTokenAccount  string `json:"userPoolTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
	LpTokenAmountIn       uint64 `json:"lpTokenAmountIn"`
	MinBaseAmountOut      uint64 `json:"minBaseAmountOut"`
	MinQuoteAmountOut     uint64 `json:"minQuoteAmountOut"`
}

PumpswapRemoveLiquidityData contains remove liquidity instruction data

type PumpswapSellInstructionData ΒΆ

type PumpswapSellInstructionData struct {
	PoolMint              string `json:"poolMint"`
	User                  string `json:"user"`
	BaseMint              string `json:"baseMint"`
	QuoteMint             string `json:"quoteMint"`
	UserBaseTokenAccount  string `json:"userBaseTokenAccount"`
	UserQuoteTokenAccount string `json:"userQuoteTokenAccount"`
	PoolBaseTokenAccount  string `json:"poolBaseTokenAccount"`
	PoolQuoteTokenAccount string `json:"poolQuoteTokenAccount"`
	BaseAmountIn          uint64 `json:"baseAmountIn"`
	MinQuoteAmountOut     uint64 `json:"minQuoteAmountOut"`
}

PumpswapSellInstructionData contains sell instruction data

type ShredInstructionParser ΒΆ

type ShredInstructionParser interface {
	ProcessInstructions() []interface{}
}

ShredInstructionParser interface for instruction parsers

type ShredParser ΒΆ

type ShredParser struct {
}

ShredParser parses Solana Shred transactions (pre-execution instruction analysis)

func NewShredParser ΒΆ

func NewShredParser() *ShredParser

NewShredParser creates a new ShredParser

func (*ShredParser) ParseAll ΒΆ

ParseAll parses both trades and liquidity events from transaction

type TradeParserFactory ΒΆ

type TradeParserFactory func(
	adapter *adapter.TransactionAdapter,
	dexInfo types.DexInfo,
	transferActions map[string][]types.TransferData,
	classifiedInstructions []types.ClassifiedInstruction,
) parsers.TradeParser

TradeParserFactory creates a trade parser

type TransferParserFactory ΒΆ

type TransferParserFactory func(
	adapter *adapter.TransactionAdapter,
	dexInfo types.DexInfo,
	transferActions map[string][]types.TransferData,
	classifiedInstructions []types.ClassifiedInstruction,
) parsers.TransferParser

TransferParserFactory creates a transfer parser

type YellowstoneAddressTableLookup ΒΆ added in v1.2.0

type YellowstoneAddressTableLookup struct {
	AccountKey      []byte
	WritableIndexes []byte
	ReadonlyIndexes []byte
}

YellowstoneAddressTableLookup represents address table lookup from gRPC

type YellowstoneHeader ΒΆ added in v1.2.0

type YellowstoneHeader struct {
	NumRequiredSignatures       int
	NumReadonlySignedAccounts   int
	NumReadonlyUnsignedAccounts int
}

YellowstoneHeader represents the message header from gRPC

type YellowstoneInnerInstructionSet ΒΆ added in v1.2.0

type YellowstoneInnerInstructionSet struct {
	Index        int
	Instructions []YellowstoneInstruction
}

YellowstoneInnerInstructionSet represents inner instructions from gRPC

type YellowstoneInstruction ΒΆ added in v1.2.0

type YellowstoneInstruction struct {
	ProgramIdIndex int
	Accounts       []byte
	Data           []byte
}

YellowstoneInstruction represents an instruction from gRPC

type YellowstoneLoadedAddresses ΒΆ added in v1.2.0

type YellowstoneLoadedAddresses struct {
	Writable [][]byte
	Readonly [][]byte
}

YellowstoneLoadedAddresses represents loaded addresses from gRPC

type YellowstoneMessageData ΒΆ added in v1.2.0

type YellowstoneMessageData struct {
	Header              YellowstoneHeader
	AccountKeys         [][]byte
	RecentBlockhash     []byte
	Instructions        []YellowstoneInstruction
	Versioned           bool
	AddressTableLookups []YellowstoneAddressTableLookup
}

YellowstoneMessageData represents the message data from gRPC

type YellowstoneReturnData ΒΆ added in v1.2.0

type YellowstoneReturnData struct {
	ProgramId []byte
	Data      []byte
}

YellowstoneReturnData represents return data from gRPC

type YellowstoneTokenAmount ΒΆ added in v1.2.0

type YellowstoneTokenAmount struct {
	Amount         string
	Decimals       int
	UiAmount       *float64
	UiAmountString string
}

YellowstoneTokenAmount represents token amount from gRPC

type YellowstoneTokenBalance ΒΆ added in v1.2.0

type YellowstoneTokenBalance struct {
	AccountIndex  int
	Mint          string
	Owner         string
	UiTokenAmount YellowstoneTokenAmount
}

YellowstoneTokenBalance represents token balance from gRPC

type YellowstoneTransaction ΒΆ added in v1.2.0

type YellowstoneTransaction struct {
	Signature   []byte
	IsVote      bool
	Transaction YellowstoneTransactionData
	Meta        YellowstoneTransactionMeta
}

YellowstoneTransaction represents a transaction from Yellowstone gRPC (Helius Laserstream/Triton)

type YellowstoneTransactionData ΒΆ added in v1.2.0

type YellowstoneTransactionData struct {
	Signatures [][]byte
	Message    YellowstoneMessageData
}

YellowstoneTransactionData represents the transaction data from gRPC

type YellowstoneTransactionMeta ΒΆ added in v1.2.0

type YellowstoneTransactionMeta struct {
	Err                  interface{}
	Fee                  uint64
	PreBalances          []uint64
	PostBalances         []uint64
	PreTokenBalances     []YellowstoneTokenBalance
	PostTokenBalances    []YellowstoneTokenBalance
	InnerInstructions    []YellowstoneInnerInstructionSet
	LogMessages          []string
	LoadedAddresses      YellowstoneLoadedAddresses
	ReturnData           *YellowstoneReturnData
	ComputeUnitsConsumed uint64
}

YellowstoneTransactionMeta represents the transaction metadata from gRPC

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL