mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-25 14:58:05 +00:00
Release solana-streamer-sdk v1.4.4
Update English and Chinese README installation versions. Document current SDK-backed gRPC and ShredStream usage. Depend on sol-parser-sdk v0.4.9 from crates.io.
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solana-streamer-sdk"
|
name = "solana-streamer-sdk"
|
||||||
version = "1.4.3"
|
version = "1.4.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||||
repository = "https://github.com/0xfnzero/solana-streamer"
|
repository = "https://github.com/0xfnzero/solana-streamer"
|
||||||
@@ -15,14 +15,14 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
[features]
|
[features]
|
||||||
default = ["sdk-parse-borsh"]
|
default = ["sdk-parse-borsh"]
|
||||||
sdk-parse-borsh = ["sol-parser-sdk/parse-borsh"]
|
sdk-parse-borsh = ["sol-parser-sdk/parse-borsh"]
|
||||||
# If both parser backend features are enabled, sol-parser-sdk 0.4.8+ uses zero-copy.
|
# If both parser backend features are enabled, sol-parser-sdk 0.4.9+ uses zero-copy.
|
||||||
sdk-parse-zero-copy = ["sol-parser-sdk/parse-zero-copy"]
|
sdk-parse-zero-copy = ["sol-parser-sdk/parse-zero-copy"]
|
||||||
sdk-perf-stats = ["sol-parser-sdk/perf-stats"]
|
sdk-perf-stats = ["sol-parser-sdk/perf-stats"]
|
||||||
sdk-ultra-perf = ["sol-parser-sdk/ultra-perf"]
|
sdk-ultra-perf = ["sol-parser-sdk/ultra-perf"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Keep the streamer facade in lockstep with the sibling SDK while both crates evolve together.
|
# Keep the streamer facade in lockstep with the sibling SDK while both crates evolve together.
|
||||||
sol-parser-sdk = { version = "0.4.8", default-features = false }
|
sol-parser-sdk = { version = "0.4.9", default-features = false }
|
||||||
solana-sdk = "3.0.0"
|
solana-sdk = "3.0.0"
|
||||||
solana-client = "3.1.12"
|
solana-client = "3.1.12"
|
||||||
solana-transaction-status = "3.1.12"
|
solana-transaction-status = "3.1.12"
|
||||||
|
|||||||
@@ -75,8 +75,9 @@
|
|||||||
|
|
||||||
### Multi-Protocol Support
|
### Multi-Protocol Support
|
||||||
- **PumpFun**: Meme coin trading platform events
|
- **PumpFun**: Meme coin trading platform events
|
||||||
|
- **Pump Fees**: Pump fee-sharing configuration events
|
||||||
- **PumpSwap**: PumpFun's swap protocol events
|
- **PumpSwap**: PumpFun's swap protocol events
|
||||||
- **Bonk**: Token launch platform events (letsbonk.fun)
|
- **Raydium Launchpad / Bonk**: Token launch platform events (letsbonk.fun / LaunchLab)
|
||||||
- **Raydium CPMM**: Raydium's Concentrated Pool Market Maker events
|
- **Raydium CPMM**: Raydium's Concentrated Pool Market Maker events
|
||||||
- **Raydium CLMM**: Raydium's Concentrated Liquidity Market Maker events
|
- **Raydium CLMM**: Raydium's Concentrated Liquidity Market Maker events
|
||||||
- **Raydium AMM V4**: Raydium's Automated Market Maker V4 events
|
- **Raydium AMM V4**: Raydium's Automated Market Maker V4 events
|
||||||
@@ -122,33 +123,33 @@ Add the dependency to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = { path = "./solana-streamer", version = "1.4.0" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "1.4.4" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
solana-streamer-sdk = "1.4.0"
|
solana-streamer-sdk = "1.4.4"
|
||||||
```
|
```
|
||||||
|
|
||||||
Parser backend features:
|
Parser backend features:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Default: sol-parser-sdk parse-borsh backend
|
# Default: sol-parser-sdk parse-borsh backend
|
||||||
solana-streamer-sdk = "1.4.0"
|
solana-streamer-sdk = "1.4.4"
|
||||||
|
|
||||||
# Zero-copy parser backend for latency-sensitive bots
|
# Zero-copy parser backend for latency-sensitive bots
|
||||||
solana-streamer-sdk = { version = "1.4.0", default-features = false, features = ["sdk-parse-zero-copy"] }
|
solana-streamer-sdk = { version = "1.4.4", default-features = false, features = ["sdk-parse-zero-copy"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
If both `sdk-parse-borsh` and `sdk-parse-zero-copy` are enabled, `sol-parser-sdk 0.4.4+` uses the zero-copy backend.
|
If both `sdk-parse-borsh` and `sdk-parse-zero-copy` are enabled, `sol-parser-sdk 0.4.9+` uses the zero-copy backend.
|
||||||
|
|
||||||
## 🔄 Migration Guide
|
## 🔄 Migration Guide
|
||||||
|
|
||||||
### Upgrading to v1.4.0
|
### Upgrading to v1.4.4
|
||||||
|
|
||||||
Version 1.4.0 moves the streamer parsing hot path onto `sol-parser-sdk 0.4.4` while preserving the existing subscription and callback API. Existing bots can usually upgrade by changing only the crate version.
|
Version 1.4.4 uses `sol-parser-sdk 0.4.9` from crates.io for all supported protocol parsing across Yellowstone gRPC, ShredStream, RPC transaction parsing, and account parsing while preserving the existing subscription and callback API. Existing bots can usually upgrade by changing only the crate version.
|
||||||
|
|
||||||
New optional capabilities:
|
New optional capabilities:
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ let callback = |event: DexEvent| {
|
|||||||
You can customize client configuration:
|
You can customize client configuration:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use solana_streamer_sdk::streaming::grpc::ClientConfig;
|
use solana_streamer_sdk::streaming::{grpc::ClientConfig, YellowstoneGrpc};
|
||||||
|
|
||||||
// Use default configuration
|
// Use default configuration
|
||||||
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
||||||
@@ -209,6 +210,69 @@ let grpc = YellowstoneGrpc::new_with_config(endpoint, token, config)?;
|
|||||||
- `connection.request_timeout`: Request timeout in seconds (default: 60)
|
- `connection.request_timeout`: Request timeout in seconds (default: 60)
|
||||||
- `connection.max_decoding_message_size`: Maximum message size in bytes (default: 10MB)
|
- `connection.max_decoding_message_size`: Maximum message size in bytes (default: 10MB)
|
||||||
|
|
||||||
|
### Minimal gRPC Subscription
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use solana_streamer_sdk::streaming::{
|
||||||
|
event_parser::{
|
||||||
|
common::{filter::EventTypeFilter, EventType},
|
||||||
|
core::EventDispatcher,
|
||||||
|
DexEvent, Protocol,
|
||||||
|
},
|
||||||
|
yellowstone_grpc::{AccountFilter, TransactionFilter},
|
||||||
|
YellowstoneGrpc,
|
||||||
|
};
|
||||||
|
|
||||||
|
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
||||||
|
|
||||||
|
let protocols = vec![
|
||||||
|
Protocol::PumpFun,
|
||||||
|
Protocol::PumpFees,
|
||||||
|
Protocol::PumpSwap,
|
||||||
|
Protocol::RaydiumLaunchpad,
|
||||||
|
Protocol::RaydiumCpmm,
|
||||||
|
Protocol::RaydiumClmm,
|
||||||
|
Protocol::RaydiumAmmV4,
|
||||||
|
Protocol::OrcaWhirlpool,
|
||||||
|
Protocol::MeteoraPools,
|
||||||
|
Protocol::MeteoraDammV2,
|
||||||
|
Protocol::MeteoraDlmm,
|
||||||
|
];
|
||||||
|
|
||||||
|
let program_ids = EventDispatcher::get_program_ids(&protocols)
|
||||||
|
.into_iter()
|
||||||
|
.map(|pubkey| pubkey.to_string())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let transaction_filter = TransactionFilter {
|
||||||
|
account_include: program_ids.clone(),
|
||||||
|
account_exclude: vec![],
|
||||||
|
account_required: vec![],
|
||||||
|
};
|
||||||
|
let account_filter = AccountFilter { account: vec![], owner: program_ids, filters: vec![] };
|
||||||
|
|
||||||
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFunBuy,
|
||||||
|
EventType::PumpSwapBuy,
|
||||||
|
EventType::BonkBuyExactIn,
|
||||||
|
EventType::RaydiumCpmmSwapBaseInput,
|
||||||
|
EventType::MeteoraDlmmSwap,
|
||||||
|
]));
|
||||||
|
|
||||||
|
grpc.subscribe_events_immediate(
|
||||||
|
protocols,
|
||||||
|
None,
|
||||||
|
vec![transaction_filter],
|
||||||
|
vec![account_filter],
|
||||||
|
event_type_filter,
|
||||||
|
None,
|
||||||
|
|event: DexEvent| {
|
||||||
|
println!("{:?}", event.metadata().event_type);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
```
|
||||||
|
|
||||||
## 📚 Usage Examples
|
## 📚 Usage Examples
|
||||||
|
|
||||||
### Usage Examples Summary Table
|
### Usage Examples Summary Table
|
||||||
@@ -270,14 +334,21 @@ Event filtering can provide significant performance improvements:
|
|||||||
**Trading Bot (Focus on Trade Events)**
|
**Trading Bot (Focus on Trade Events)**
|
||||||
```rust
|
```rust
|
||||||
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFunBuy,
|
||||||
|
EventType::PumpFunBuyExactSolIn,
|
||||||
|
EventType::PumpFunSell,
|
||||||
EventType::PumpSwapBuy,
|
EventType::PumpSwapBuy,
|
||||||
EventType::PumpSwapSell,
|
EventType::PumpSwapSell,
|
||||||
EventType::PumpFunBuy,
|
EventType::BonkBuyExactIn,
|
||||||
EventType::PumpFunSell,
|
EventType::BonkSellExactIn,
|
||||||
EventType::RaydiumCpmmSwapBaseInput,
|
EventType::RaydiumCpmmSwapBaseInput,
|
||||||
|
EventType::RaydiumCpmmSwapBaseOutput,
|
||||||
EventType::RaydiumClmmSwap,
|
EventType::RaydiumClmmSwap,
|
||||||
EventType::RaydiumAmmV4SwapBaseIn,
|
EventType::RaydiumAmmV4SwapBaseIn,
|
||||||
|
EventType::RaydiumAmmV4SwapBaseOut,
|
||||||
EventType::OrcaWhirlpoolSwap,
|
EventType::OrcaWhirlpoolSwap,
|
||||||
|
EventType::MeteoraPoolsSwap,
|
||||||
|
EventType::MeteoraDammV2Swap,
|
||||||
EventType::MeteoraDlmmSwap,
|
EventType::MeteoraDlmmSwap,
|
||||||
]));
|
]));
|
||||||
```
|
```
|
||||||
@@ -285,6 +356,7 @@ let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
|||||||
**Pool Monitoring (Focus on Liquidity Events)**
|
**Pool Monitoring (Focus on Liquidity Events)**
|
||||||
```rust
|
```rust
|
||||||
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFeesUpdateFeeShares,
|
||||||
EventType::PumpSwapCreatePool,
|
EventType::PumpSwapCreatePool,
|
||||||
EventType::PumpSwapDeposit,
|
EventType::PumpSwapDeposit,
|
||||||
EventType::PumpSwapWithdraw,
|
EventType::PumpSwapWithdraw,
|
||||||
@@ -292,6 +364,8 @@ let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
|||||||
EventType::RaydiumCpmmDeposit,
|
EventType::RaydiumCpmmDeposit,
|
||||||
EventType::RaydiumCpmmWithdraw,
|
EventType::RaydiumCpmmWithdraw,
|
||||||
EventType::RaydiumClmmCreatePool,
|
EventType::RaydiumClmmCreatePool,
|
||||||
|
EventType::OrcaWhirlpoolPoolInitialized,
|
||||||
|
EventType::MeteoraPoolsPoolCreated,
|
||||||
EventType::MeteoraDammV2AddLiquidity,
|
EventType::MeteoraDammV2AddLiquidity,
|
||||||
EventType::MeteoraPoolsAddLiquidity,
|
EventType::MeteoraPoolsAddLiquidity,
|
||||||
EventType::MeteoraDlmmAddLiquidity,
|
EventType::MeteoraDlmmAddLiquidity,
|
||||||
@@ -328,8 +402,9 @@ Note: Multiple subscription attempts on the same client return an error.
|
|||||||
## 🔧 Supported Protocols
|
## 🔧 Supported Protocols
|
||||||
|
|
||||||
- **PumpFun**: Primary meme coin trading platform
|
- **PumpFun**: Primary meme coin trading platform
|
||||||
|
- **Pump Fees**: Pump fee-sharing configuration events
|
||||||
- **PumpSwap**: PumpFun's swap protocol
|
- **PumpSwap**: PumpFun's swap protocol
|
||||||
- **Bonk**: Token launch platform (letsbonk.fun)
|
- **Raydium Launchpad / Bonk**: Token launch platform (letsbonk.fun / LaunchLab)
|
||||||
- **Raydium CPMM**: Raydium's Concentrated Pool Market Maker protocol
|
- **Raydium CPMM**: Raydium's Concentrated Pool Market Maker protocol
|
||||||
- **Raydium CLMM**: Raydium's Concentrated Liquidity Market Maker protocol
|
- **Raydium CLMM**: Raydium's Concentrated Liquidity Market Maker protocol
|
||||||
- **Raydium AMM V4**: Raydium's Automated Market Maker V4 protocol
|
- **Raydium AMM V4**: Raydium's Automated Market Maker V4 protocol
|
||||||
@@ -354,8 +429,8 @@ Note: Multiple subscription attempts on the same client return an error.
|
|||||||
|
|
||||||
### Event Parsing System
|
### Event Parsing System
|
||||||
|
|
||||||
- **sol-parser-sdk First**: Yellowstone gRPC, RPC transaction parsing, account parsing, and SDK ShredStream integration use the SDK implementation first
|
- **sol-parser-sdk Facade**: Yellowstone gRPC, ShredStream, RPC transaction parsing, and account parsing delegate protocol parsing to `sol-parser-sdk`
|
||||||
- **ComputeBudget Local Pass**: The local instruction pass is retained for ComputeBudget events and no-meta fallback cases
|
- **Local Non-DEX Pass**: Local handling is limited to streamer infrastructure and non-DEX compatibility cases such as ComputeBudget metadata
|
||||||
- **Extensible Bridge**: `streaming::sdk_bridge` exposes raw SDK access without forcing existing bots to change callbacks
|
- **Extensible Bridge**: `streaming::sdk_bridge` exposes raw SDK access without forcing existing bots to change callbacks
|
||||||
|
|
||||||
### Streaming Infrastructure
|
### Streaming Infrastructure
|
||||||
@@ -371,17 +446,10 @@ src/
|
|||||||
├── common/ # Common functionality and types
|
├── common/ # Common functionality and types
|
||||||
├── protos/ # Protocol buffer definitions
|
├── protos/ # Protocol buffer definitions
|
||||||
├── streaming/ # Event streaming system
|
├── streaming/ # Event streaming system
|
||||||
│ ├── event_parser/ # Event parsing system
|
│ ├── event_parser/ # Streamer-compatible event facade over sol-parser-sdk
|
||||||
│ │ ├── common/ # Common event parsing tools
|
│ │ ├── common/ # Public event metadata and filter types
|
||||||
│ │ ├── core/ # gRPC and compiled transaction parser entry points
|
│ │ ├── core/ # SDK dispatch entry points and compatibility wrappers
|
||||||
│ │ ├── protocols/# Protocol-specific parsers
|
│ │ ├── protocols/# Streamer event types and legacy module paths
|
||||||
│ │ │ ├── bonk/ # Bonk event parsing
|
|
||||||
│ │ │ ├── meteora_damm_v2/ # Meteora DAMM v2 event parsing
|
|
||||||
│ │ │ ├── pumpfun/ # PumpFun event parsing
|
|
||||||
│ │ │ ├── pumpswap/ # PumpSwap event parsing
|
|
||||||
│ │ │ ├── raydium_amm_v4/ # Raydium AMM V4 event parsing
|
|
||||||
│ │ │ ├── raydium_clmm/ # Raydium CLMM event parsing
|
|
||||||
│ │ │ ├── raydium_cpmm/ # Raydium CPMM event parsing
|
|
||||||
│ │ │ └── sol_parser_forward/ # SDK-forwarded protocol event wrappers
|
│ │ │ └── sol_parser_forward/ # SDK-forwarded protocol event wrappers
|
||||||
│ ├── parser_sdk_bridge/ # sol-parser-sdk event adapter
|
│ ├── parser_sdk_bridge/ # sol-parser-sdk event adapter
|
||||||
│ ├── rpc_parse.rs # RPC transaction parsing helpers
|
│ ├── rpc_parse.rs # RPC transaction parsing helpers
|
||||||
|
|||||||
+93
-25
@@ -74,8 +74,9 @@
|
|||||||
|
|
||||||
### 多协议支持
|
### 多协议支持
|
||||||
- **PumpFun**: 迷因币交易平台事件
|
- **PumpFun**: 迷因币交易平台事件
|
||||||
|
- **Pump Fees**: Pump 费用分成配置事件
|
||||||
- **PumpSwap**: PumpFun 的交换协议事件
|
- **PumpSwap**: PumpFun 的交换协议事件
|
||||||
- **Bonk**: 代币发布平台事件 (letsbonk.fun)
|
- **Raydium Launchpad / Bonk**: 代币发射平台事件 (letsbonk.fun / LaunchLab)
|
||||||
- **Raydium CPMM**: Raydium 集中池做市商事件
|
- **Raydium CPMM**: Raydium 集中池做市商事件
|
||||||
- **Raydium CLMM**: Raydium 集中流动性做市商事件
|
- **Raydium CLMM**: Raydium 集中流动性做市商事件
|
||||||
- **Raydium AMM V4**: Raydium 自动做市商 V4 事件
|
- **Raydium AMM V4**: Raydium 自动做市商 V4 事件
|
||||||
@@ -121,33 +122,33 @@ git clone https://github.com/0xfnzero/solana-streamer
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = { path = "./solana-streamer", version = "1.4.0" }
|
solana-streamer-sdk = { path = "./solana-streamer", version = "1.4.4" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
solana-streamer-sdk = "1.4.0"
|
solana-streamer-sdk = "1.4.4"
|
||||||
```
|
```
|
||||||
|
|
||||||
解析后端 feature:
|
解析后端 feature:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 默认:sol-parser-sdk parse-borsh 后端
|
# 默认:sol-parser-sdk parse-borsh 后端
|
||||||
solana-streamer-sdk = "1.4.0"
|
solana-streamer-sdk = "1.4.4"
|
||||||
|
|
||||||
# 面向低延迟 Bot 的 zero-copy 解析后端
|
# 面向低延迟 Bot 的 zero-copy 解析后端
|
||||||
solana-streamer-sdk = { version = "1.4.0", default-features = false, features = ["sdk-parse-zero-copy"] }
|
solana-streamer-sdk = { version = "1.4.4", default-features = false, features = ["sdk-parse-zero-copy"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
如果同时启用 `sdk-parse-borsh` 和 `sdk-parse-zero-copy`,`sol-parser-sdk 0.4.4+` 会优先使用 zero-copy 后端。
|
如果同时启用 `sdk-parse-borsh` 和 `sdk-parse-zero-copy`,`sol-parser-sdk 0.4.9+` 会优先使用 zero-copy 后端。
|
||||||
|
|
||||||
## 🔄 迁移指南
|
## 🔄 迁移指南
|
||||||
|
|
||||||
### 升级到 v1.4.0
|
### 升级到 v1.4.4
|
||||||
|
|
||||||
v1.4.0 将 streamer 的解析热路径迁移到 `sol-parser-sdk 0.4.4`,同时保留已有订阅和回调 API。大多数 Bot 只需要修改 crate 版本即可升级。
|
v1.4.4 使用 crates.io 上的 `sol-parser-sdk 0.4.9` 处理 Yellowstone gRPC、ShredStream、RPC 交易解析和账户解析中的所有当前支持协议,同时保留已有订阅和回调 API。大多数 Bot 只需要修改 crate 版本即可升级。
|
||||||
|
|
||||||
新增可选能力:
|
新增可选能力:
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ let callback = |event: DexEvent| {
|
|||||||
您可以自定义客户端配置:
|
您可以自定义客户端配置:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use solana_streamer_sdk::streaming::grpc::ClientConfig;
|
use solana_streamer_sdk::streaming::{grpc::ClientConfig, YellowstoneGrpc};
|
||||||
|
|
||||||
// 使用默认配置
|
// 使用默认配置
|
||||||
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
||||||
@@ -208,6 +209,69 @@ let grpc = YellowstoneGrpc::new_with_config(endpoint, token, config)?;
|
|||||||
- `connection.request_timeout`: 请求超时(秒)(默认:60)
|
- `connection.request_timeout`: 请求超时(秒)(默认:60)
|
||||||
- `connection.max_decoding_message_size`: 最大消息大小(字节)(默认:10MB)
|
- `connection.max_decoding_message_size`: 最大消息大小(字节)(默认:10MB)
|
||||||
|
|
||||||
|
### 最小 gRPC 订阅
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use solana_streamer_sdk::streaming::{
|
||||||
|
event_parser::{
|
||||||
|
common::{filter::EventTypeFilter, EventType},
|
||||||
|
core::EventDispatcher,
|
||||||
|
DexEvent, Protocol,
|
||||||
|
},
|
||||||
|
yellowstone_grpc::{AccountFilter, TransactionFilter},
|
||||||
|
YellowstoneGrpc,
|
||||||
|
};
|
||||||
|
|
||||||
|
let grpc = YellowstoneGrpc::new(endpoint, token)?;
|
||||||
|
|
||||||
|
let protocols = vec![
|
||||||
|
Protocol::PumpFun,
|
||||||
|
Protocol::PumpFees,
|
||||||
|
Protocol::PumpSwap,
|
||||||
|
Protocol::RaydiumLaunchpad,
|
||||||
|
Protocol::RaydiumCpmm,
|
||||||
|
Protocol::RaydiumClmm,
|
||||||
|
Protocol::RaydiumAmmV4,
|
||||||
|
Protocol::OrcaWhirlpool,
|
||||||
|
Protocol::MeteoraPools,
|
||||||
|
Protocol::MeteoraDammV2,
|
||||||
|
Protocol::MeteoraDlmm,
|
||||||
|
];
|
||||||
|
|
||||||
|
let program_ids = EventDispatcher::get_program_ids(&protocols)
|
||||||
|
.into_iter()
|
||||||
|
.map(|pubkey| pubkey.to_string())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let transaction_filter = TransactionFilter {
|
||||||
|
account_include: program_ids.clone(),
|
||||||
|
account_exclude: vec![],
|
||||||
|
account_required: vec![],
|
||||||
|
};
|
||||||
|
let account_filter = AccountFilter { account: vec![], owner: program_ids, filters: vec![] };
|
||||||
|
|
||||||
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFunBuy,
|
||||||
|
EventType::PumpSwapBuy,
|
||||||
|
EventType::BonkBuyExactIn,
|
||||||
|
EventType::RaydiumCpmmSwapBaseInput,
|
||||||
|
EventType::MeteoraDlmmSwap,
|
||||||
|
]));
|
||||||
|
|
||||||
|
grpc.subscribe_events_immediate(
|
||||||
|
protocols,
|
||||||
|
None,
|
||||||
|
vec![transaction_filter],
|
||||||
|
vec![account_filter],
|
||||||
|
event_type_filter,
|
||||||
|
None,
|
||||||
|
|event: DexEvent| {
|
||||||
|
println!("{:?}", event.metadata().event_type);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
```
|
||||||
|
|
||||||
## 📚 使用示例
|
## 📚 使用示例
|
||||||
|
|
||||||
### 使用示例概览表
|
### 使用示例概览表
|
||||||
@@ -269,14 +333,21 @@ let event_type_filter = Some(EventTypeFilter::exclude_only(vec![EventType::Block
|
|||||||
**交易机器人(专注交易事件)**
|
**交易机器人(专注交易事件)**
|
||||||
```rust
|
```rust
|
||||||
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFunBuy,
|
||||||
|
EventType::PumpFunBuyExactSolIn,
|
||||||
|
EventType::PumpFunSell,
|
||||||
EventType::PumpSwapBuy,
|
EventType::PumpSwapBuy,
|
||||||
EventType::PumpSwapSell,
|
EventType::PumpSwapSell,
|
||||||
EventType::PumpFunBuy,
|
EventType::BonkBuyExactIn,
|
||||||
EventType::PumpFunSell,
|
EventType::BonkSellExactIn,
|
||||||
EventType::RaydiumCpmmSwapBaseInput,
|
EventType::RaydiumCpmmSwapBaseInput,
|
||||||
|
EventType::RaydiumCpmmSwapBaseOutput,
|
||||||
EventType::RaydiumClmmSwap,
|
EventType::RaydiumClmmSwap,
|
||||||
EventType::RaydiumAmmV4SwapBaseIn,
|
EventType::RaydiumAmmV4SwapBaseIn,
|
||||||
|
EventType::RaydiumAmmV4SwapBaseOut,
|
||||||
EventType::OrcaWhirlpoolSwap,
|
EventType::OrcaWhirlpoolSwap,
|
||||||
|
EventType::MeteoraPoolsSwap,
|
||||||
|
EventType::MeteoraDammV2Swap,
|
||||||
EventType::MeteoraDlmmSwap,
|
EventType::MeteoraDlmmSwap,
|
||||||
]));
|
]));
|
||||||
```
|
```
|
||||||
@@ -284,6 +355,7 @@ let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
|||||||
**池监控(专注流动性事件)**
|
**池监控(专注流动性事件)**
|
||||||
```rust
|
```rust
|
||||||
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
||||||
|
EventType::PumpFeesUpdateFeeShares,
|
||||||
EventType::PumpSwapCreatePool,
|
EventType::PumpSwapCreatePool,
|
||||||
EventType::PumpSwapDeposit,
|
EventType::PumpSwapDeposit,
|
||||||
EventType::PumpSwapWithdraw,
|
EventType::PumpSwapWithdraw,
|
||||||
@@ -291,6 +363,8 @@ let event_type_filter = Some(EventTypeFilter::include_only(vec![
|
|||||||
EventType::RaydiumCpmmDeposit,
|
EventType::RaydiumCpmmDeposit,
|
||||||
EventType::RaydiumCpmmWithdraw,
|
EventType::RaydiumCpmmWithdraw,
|
||||||
EventType::RaydiumClmmCreatePool,
|
EventType::RaydiumClmmCreatePool,
|
||||||
|
EventType::OrcaWhirlpoolPoolInitialized,
|
||||||
|
EventType::MeteoraPoolsPoolCreated,
|
||||||
EventType::MeteoraDammV2AddLiquidity,
|
EventType::MeteoraDammV2AddLiquidity,
|
||||||
EventType::MeteoraPoolsAddLiquidity,
|
EventType::MeteoraPoolsAddLiquidity,
|
||||||
EventType::MeteoraDlmmAddLiquidity,
|
EventType::MeteoraDlmmAddLiquidity,
|
||||||
@@ -327,8 +401,9 @@ grpc.update_subscription(
|
|||||||
## 🔧 支持的协议
|
## 🔧 支持的协议
|
||||||
|
|
||||||
- **PumpFun**: 主要迷因币交易平台
|
- **PumpFun**: 主要迷因币交易平台
|
||||||
|
- **Pump Fees**: Pump 费用分成配置事件
|
||||||
- **PumpSwap**: PumpFun 的交换协议
|
- **PumpSwap**: PumpFun 的交换协议
|
||||||
- **Bonk**: 代币发布平台 (letsbonk.fun)
|
- **Raydium Launchpad / Bonk**: 代币发射平台 (letsbonk.fun / LaunchLab)
|
||||||
- **Raydium CPMM**: Raydium 集中池做市商协议
|
- **Raydium CPMM**: Raydium 集中池做市商协议
|
||||||
- **Raydium CLMM**: Raydium 集中流动性做市商协议
|
- **Raydium CLMM**: Raydium 集中流动性做市商协议
|
||||||
- **Raydium AMM V4**: Raydium 自动做市商 V4 协议
|
- **Raydium AMM V4**: Raydium 自动做市商 V4 协议
|
||||||
@@ -353,8 +428,8 @@ grpc.update_subscription(
|
|||||||
|
|
||||||
### 事件解析系统
|
### 事件解析系统
|
||||||
|
|
||||||
- **sol-parser-sdk 优先**: Yellowstone gRPC、RPC 交易解析、账户解析和 SDK ShredStream 集成都优先使用 SDK 实现
|
- **sol-parser-sdk facade**: Yellowstone gRPC、ShredStream、RPC 交易解析和账户解析中的协议解析都委托给 `sol-parser-sdk`
|
||||||
- **ComputeBudget 本地补充**: 本地指令解析保留用于 ComputeBudget 事件和无 meta 交易 fallback
|
- **本地非 DEX 补充**: 本地逻辑仅保留 streamer 基础设施和 ComputeBudget 元数据等非 DEX 兼容场景
|
||||||
- **可扩展桥接层**: `streaming::sdk_bridge` 暴露原始 SDK 能力,但不强迫已有 Bot 改回调 API
|
- **可扩展桥接层**: `streaming::sdk_bridge` 暴露原始 SDK 能力,但不强迫已有 Bot 改回调 API
|
||||||
|
|
||||||
### 流基础设施
|
### 流基础设施
|
||||||
@@ -370,17 +445,10 @@ src/
|
|||||||
├── common/ # 通用功能和类型
|
├── common/ # 通用功能和类型
|
||||||
├── protos/ # Protocol buffer 定义
|
├── protos/ # Protocol buffer 定义
|
||||||
├── streaming/ # 事件流系统
|
├── streaming/ # 事件流系统
|
||||||
│ ├── event_parser/ # 事件解析系统
|
│ ├── event_parser/ # 基于 sol-parser-sdk 的 streamer 兼容事件 facade
|
||||||
│ │ ├── common/ # 通用事件解析工具
|
│ │ ├── common/ # 公开事件元数据和过滤类型
|
||||||
│ │ ├── core/ # gRPC 和 compiled transaction 解析入口
|
│ │ ├── core/ # SDK 分发入口和兼容封装
|
||||||
│ │ ├── protocols/# 协议特定解析器
|
│ │ ├── protocols/# Streamer 事件类型和旧模块路径
|
||||||
│ │ │ ├── bonk/ # Bonk 事件解析
|
|
||||||
│ │ │ ├── meteora_damm_v2/ # Meteora DAMM v2 事件解析
|
|
||||||
│ │ │ ├── pumpfun/ # PumpFun 事件解析
|
|
||||||
│ │ │ ├── pumpswap/ # PumpSwap 事件解析
|
|
||||||
│ │ │ ├── raydium_amm_v4/ # Raydium AMM V4 事件解析
|
|
||||||
│ │ │ ├── raydium_clmm/ # Raydium CLMM 事件解析
|
|
||||||
│ │ │ ├── raydium_cpmm/ # Raydium CPMM 事件解析
|
|
||||||
│ │ │ └── sol_parser_forward/ # SDK 转发协议事件封装
|
│ │ │ └── sol_parser_forward/ # SDK 转发协议事件封装
|
||||||
│ ├── parser_sdk_bridge/ # sol-parser-sdk 事件适配层
|
│ ├── parser_sdk_bridge/ # sol-parser-sdk 事件适配层
|
||||||
│ ├── rpc_parse.rs # RPC 交易解析 helper
|
│ ├── rpc_parse.rs # RPC 交易解析 helper
|
||||||
|
|||||||
Reference in New Issue
Block a user