Skip to content

0xfnzero/parser-proxy-unixsocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Parser Proxy UNIX Socket

Ultra-low latency Solana DEX event UNIX Socket proxy with protobuf streaming

High-performance UNIX Socket server for streaming Solana DEX events with microsecond-level latency

Version License

Rust Solana UNIX Socket gRPC

δΈ­ζ–‡ | English | Website | Telegram | Discord


A UNIX Socket proxy server for Solana DEX events based on sol-parser-sdk. Real-time monitoring of DEX trading events from PumpFun, Raydium, Orca, Meteora, and more, streamed to clients via UNIX Socket with protobuf serialization.

✨ Features

  • πŸ”₯ Ultra-low Latency - Built on sol-parser-sdk with 10-20ΞΌs parsing latency
  • 🌐 Real-time UNIX Socket Push - Support multiple concurrent client connections with protobuf
  • πŸ“Š Multi-protocol Support - PumpFun, PumpSwap, Raydium AMM V4/CLMM, Orca Whirlpool, Meteora, etc.
  • 🎯 Event Filtering - Only push events you care about
  • βš™οΈ TOML Configuration - All parameters flexibly configurable via config file
  • πŸ”„ Auto Reconnection - Automatic client cleanup on disconnect
  • πŸ“ Multi-language Clients - TypeScript client with real-time streaming
  • πŸ“š Library Support - Use as both standalone binary and Rust library
  • πŸ› οΈ Easy Integration - Simple API for custom implementations

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Yellowstone gRPCβ”‚
β”‚   (Solana RPC)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ sol-parser-sdk  β”‚
β”‚  (10-20ΞΌs parse)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  UNIX Socket    β”‚
β”‚  Server         β”‚
β”‚  (Broadcast)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Clients (TS/Python/...)             β”‚
β”‚  (Real-time DEX Events)             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation

Prerequisites

1. Clone Repository

git clone https://github.com/0xfnzero/parser-proxy-unixsocket.git
cd parser-proxy-unixsocket

2. Build Project

# Build the Rust server
cargo build --release

# Install client dependencies (optional)
cd examples
npm install
cd ..

3. Generate Protocol Buffers

# The build script automatically generates protobuf files
cargo build

4. Verify Installation

# Test the server
cargo run --release -- --help

# Test the client
cd examples
npm start

πŸš€ Quick Start

1. Configure Server

Edit config.toml:

[server]
unix_socket_path = "/tmp/parser_proxy.sock"

[grpc]
endpoint = "https://solana-yellowstone-grpc.publicnode.com:443"
token = ""  # Optional: your gRPC token
enable_metrics = true
enable_tls = true
connection_timeout_ms = 10000
request_timeout_ms = 30000

[protocols]
pumpfun = true
pumpswap = false
raydium_amm_v4 = false
raydium_clmm = false
orca_whirlpool = false
meteora_pools = false
meteora_damm_v2 = false

[events]
# PumpFun events
pumpfun_trade = true
pumpfun_create = true
pumpfun_migrate = true

# PumpSwap events
pumpswap_buy = false
pumpswap_sell = false
pumpswap_create_pool = false
pumpswap_liquidity_added = false
pumpswap_liquidity_removed = false

# Raydium AMM V4 events
raydium_amm_v4_swap = false

# Raydium CLMM events
raydium_clmm_swap = false

# Orca Whirlpool events
orca_whirlpool_swap = false

# Meteora Pools events
meteora_pools_swap = false

# Meteora DAMM V2 events
meteora_damm_v2_swap = false
meteora_damm_v2_add_liquidity = false
meteora_damm_v2_remove_liquidity = false
meteora_damm_v2_create_position = false
meteora_damm_v2_close_position = false

2. Start Server

cargo run --release

Server will start based on config file (default UNIX socket at /tmp/parser_proxy.sock)

3. Start Client

TypeScript Client

cd examples
npm install
npm start

✨ Features:

  • Auto-convert using protobufjs
  • Terminal real-time event display (with colors)
  • TypeScript type safety
  • Real-time event streaming
  • Automatic reconnection

πŸ“Š Supported Protocols and Events

Supported DEX Protocols

Protocol Config Field Description
PumpFun protocols.pumpfun PumpFun Meme token trading
PumpSwap protocols.pumpswap PumpSwap exchange protocol
Raydium AMM V4 protocols.raydium_amm_v4 Raydium Automated Market Maker V4
Raydium CLMM protocols.raydium_clmm Raydium Concentrated Liquidity MM
Orca Whirlpool protocols.orca_whirlpool Orca Whirlpool Concentrated Liquidity
Meteora Pools protocols.meteora_pools Meteora Dynamic AMM
Meteora DAMM V2 protocols.meteora_damm_v2 Meteora Dynamic AMM V2

Supported Event Types

Each protocol supports the following event types (enable in [events] config section):

  • πŸ“ˆ Trade/Swap - Trading/swapping events
  • πŸ’§ Deposit - Add liquidity
  • πŸ’Έ Withdraw - Remove liquidity
  • 🏊 Create/Initialize - Pool creation/initialization
  • πŸ”„ Migrate - Migration events

Complete Event List

Event Type Config Field Description
PumpFun Events
PumpFun Trade pumpfun_trade PumpFun trading events
PumpFun Create pumpfun_create PumpFun token creation events
PumpFun Migrate pumpfun_migrate PumpFun migration events
PumpSwap Events
PumpSwap Buy pumpswap_buy PumpSwap buy events
PumpSwap Sell pumpswap_sell PumpSwap sell events
PumpSwap Create Pool pumpswap_create_pool PumpSwap pool creation events
PumpSwap Liquidity Added pumpswap_liquidity_added PumpSwap liquidity added events
PumpSwap Liquidity Removed pumpswap_liquidity_removed PumpSwap liquidity removed events
Raydium AMM V4 Events
Raydium AMM V4 Swap raydium_amm_v4_swap Raydium AMM V4 swap events
Raydium CLMM Events
Raydium CLMM Swap raydium_clmm_swap Raydium CLMM swap events
Orca Whirlpool Events
Orca Whirlpool Swap orca_whirlpool_swap Orca Whirlpool swap events
Meteora Events
Meteora Pools Swap meteora_pools_swap Meteora Pools swap events
Meteora DAMM V2 Events
Meteora DAMM V2 Swap meteora_damm_v2_swap Meteora DAMM V2 swap events
Meteora DAMM V2 Add Liquidity meteora_damm_v2_add_liquidity Meteora DAMM V2 add liquidity events
Meteora DAMM V2 Remove Liquidity meteora_damm_v2_remove_liquidity Meteora DAMM V2 remove liquidity events
Meteora DAMM V2 Create Position meteora_damm_v2_create_position Meteora DAMM V2 create position events
Meteora DAMM V2 Close Position meteora_damm_v2_close_position Meteora DAMM V2 close position events

πŸ”§ Configuration

Server Configuration

[server]
unix_socket_path = "/tmp/parser_proxy.sock"  # UNIX socket path

gRPC Configuration

[grpc]
endpoint = "https://solana-yellowstone-grpc.publicnode.com:443"
token = ""                    # gRPC auth token (optional)
enable_metrics = true         # Enable performance metrics
enable_tls = true             # Enable TLS
connection_timeout_ms = 10000 # Connection timeout (ms)
request_timeout_ms = 30000    # Request timeout (ms)

Protocol and Event Filtering

Enable/disable specific protocols and events via config:

[protocols]
pumpfun = true           # Enable PumpFun protocol
raydium_amm_v4 = false   # Disable Raydium AMM V4

[events]
pumpfun_trade = true     # Enable PumpFun trade events
pumpfun_create = false   # Disable PumpFun create events

Note: At least one protocol and one event type must be enabled, otherwise server will fail to start

πŸ“‘ UNIX Socket Message Format

Message Structure

The server uses protobuf serialization for messages with the following format:

message ServerMessage {
  oneof message {
    ServerAck ack = 1;        // Server acknowledgment
    DexEvent event = 2;       // DEX event
    ServerError error = 3;    // Error response
    ServerHeartbeat heartbeat = 4; // Server heartbeat
  }
}

Event Format

message DexEvent {
  string event_type = 1;      // Event type identifier
  
  oneof event_detail {
    // PumpFun events
    PumpFunTradeEvent pumpfun_trade = 2;
    PumpFunCreateEvent pumpfun_create = 3;
    PumpFunMigrateEvent pumpfun_migrate = 4;
    
    // PumpSwap events
    PumpSwapBuyEvent pumpswap_buy = 5;
    PumpSwapSellEvent pumpswap_sell = 6;
    PumpSwapCreatePoolEvent pumpswap_create_pool = 7;
    PumpSwapLiquidityAddedEvent pumpswap_liquidity_added = 8;
    PumpSwapLiquidityRemovedEvent pumpswap_liquidity_removed = 9;
    
    // Raydium events
    RaydiumClmmSwapEvent raydium_clmm_swap = 10;
    RaydiumAmmV4SwapEvent raydium_amm_v4_swap = 11;
    
    // Orca events
    OrcaWhirlpoolSwapEvent orca_whirlpool_swap = 12;
    
    // Meteora events
    MeteoraPoolsSwapEvent meteora_pools_swap = 13;
    
    // Meteora DAMM V2 events
    MeteoraDammV2SwapEvent meteora_damm_v2_swap = 14;
    MeteoraDammV2AddLiquidityEvent meteora_damm_v2_add_liquidity = 15;
    MeteoraDammV2RemoveLiquidityEvent meteora_damm_v2_remove_liquidity = 16;
    MeteoraDammV2CreatePositionEvent meteora_damm_v2_create_position = 17;
    MeteoraDammV2ClosePositionEvent meteora_damm_v2_close_position = 18;
  }
}

Event Metadata

All events include base metadata:

message EventMetadata {
  string signature = 1;        // Transaction signature
  uint64 slot = 2;            // Slot number
  uint64 tx_index = 3;        // Transaction index in slot
  int64 block_time_us = 4;    // Block timestamp (microseconds)
  int64 grpc_recv_us = 5;     // gRPC receive timestamp (microseconds)
}

πŸ“š Library Usage

This project can be used as both a standalone binary and as a Rust library. Here's how to use it in your Rust project:

Add to Cargo.toml

[dependencies]
parser-proxy-unixsocket = "0.1.1"
tokio = { version = "1.42.0", features = ["full"] }

Basic Usage

use parser_proxy_unixsocket::run_server;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Start server with config file
    run_server("config.toml").await?;
    
    Ok(())
}

Advanced Usage with Custom Configuration

use parser_proxy_unixsocket::ParserProxyServer;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Create server
    let server = ParserProxyServer::new("config.toml")?;
    
    // Start server (this will run indefinitely)
    server.run().await?;
    
    Ok(())
}

Features

  • Binary: Enable the binary feature for standalone usage
  • Default: Core library functionality
[dependencies]
parser-proxy-unixsocket = { version = "0.1.1", features = ["binary"] }

πŸ”¬ Development

Project Structure

parser-proxy-unixsocket/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs                    # Main entry point
β”‚   β”œβ”€β”€ lib.rs                     # Library entry point
β”‚   β”œβ”€β”€ config.rs                  # Config file loading and parsing
β”‚   β”œβ”€β”€ unix_socket_server.rs      # UNIX socket server implementation
β”‚   └── event_converter.rs         # Event converter
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ client.ts                  # TypeScript client example
β”‚   β”œβ”€β”€ parser_messages.js         # Generated protobuf JavaScript
β”‚   β”œβ”€β”€ parser_messages.d.ts       # TypeScript definitions
β”‚   β”œβ”€β”€ package.json               # Node.js dependencies
β”‚   └── tsconfig.json              # TypeScript configuration
β”œβ”€β”€ proto/
β”‚   └── messages.proto             # Protocol buffer definitions
β”œβ”€β”€ config.toml                    # Configuration file
β”œβ”€β”€ config.toml.example            # Example configuration
β”œβ”€β”€ Cargo.toml                     # Rust project config
β”œβ”€β”€ build.rs                       # Build script for protobuf
β”œβ”€β”€ README.md                      # English documentation
β”œβ”€β”€ README_CN.md                   # Chinese documentation
└── LICENSE                        # MIT License

Adding New Protocols

When adding new protocols, you only need to:

  1. Add new message definitions in proto/messages.proto
  2. Add new fields in the DexEvent oneof
  3. Add corresponding match branches in Rust conversion functions
  4. Add parsing logic in TypeScript client

Run Tests

cargo test

Performance Monitoring

Performance metrics are displayed when server starts:

πŸ“Š gRPC receive time: 1234567890 ΞΌs
⚑ Event parsing took: 15 μs

🎯 Use Cases

  1. Trading Bots - Real-time DEX monitoring for arbitrage strategies
  2. Price Monitoring - Track trading prices of specific tokens
  3. New Token Alerts - Monitor new token creation events
  4. Liquidity Analysis - Analyze DEX liquidity changes
  5. Data Analytics - Collect on-chain trading data for analysis

πŸ“„ License

MIT License

πŸ”— Related Projects

πŸ“ž Contact

For issues or suggestions, please submit an Issue.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors