feat: upgrade to v0.3.4 with enhanced trading system
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "sol-trade-sdk"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
edition = "2021"
|
||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||
repository = "https://github.com/0xfnzero/sol-trade-sdk"
|
||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
solana-streamer-sdk = "0.2.4"
|
||||
solana-streamer-sdk = "0.3.1"
|
||||
solana-sdk = "2.3.0"
|
||||
solana-client = "2.3.6"
|
||||
solana-program = "2.3.0"
|
||||
|
||||
@@ -31,14 +31,14 @@ Add the dependency to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
# Add to your Cargo.toml
|
||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.3.3" }
|
||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.3.4" }
|
||||
```
|
||||
|
||||
### Use crates.io
|
||||
|
||||
```toml
|
||||
# Add to your Cargo.toml
|
||||
sol-trade-sdk = "0.3.3"
|
||||
sol-trade-sdk = "0.3.4"
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
@@ -74,11 +74,21 @@ use sol_trade_sdk::solana_streamer_sdk::{
|
||||
},
|
||||
Protocol, UnifiedEvent,
|
||||
},
|
||||
yellowstone_grpc::{AccountFilter, TransactionFilter},
|
||||
YellowstoneGrpc,
|
||||
},
|
||||
match_event,
|
||||
};
|
||||
|
||||
use solana_streamer_sdk::streaming::event_parser::protocols::{
|
||||
bonk::parser::BONK_PROGRAM_ID,
|
||||
pumpfun::parser::PUMPFUN_PROGRAM_ID,
|
||||
pumpswap::parser::PUMPSWAP_PROGRAM_ID,
|
||||
raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID,
|
||||
raydium_clmm::parser::RAYDIUM_CLMM_PROGRAM_ID,
|
||||
raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID
|
||||
};
|
||||
|
||||
async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Subscribe to events using GRPC client
|
||||
println!("Subscribing to GRPC events...");
|
||||
@@ -121,6 +131,8 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
|
||||
println!("Raydium CPMM Swap event: {:?}", e);
|
||||
},
|
||||
// .....
|
||||
// For more events and documentation, please refer to https://github.com/0xfnzero/solana-streamer
|
||||
});
|
||||
};
|
||||
|
||||
@@ -135,17 +147,30 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
|
||||
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
|
||||
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
|
||||
RAYDIUM_AMM_V4_PROGRAM_ID.to_string(), // Listen to raydium_amm_v4 program ID
|
||||
"xxxxxxxx".to_string(), // Listen to xxxxx account
|
||||
];
|
||||
let account_exclude = vec![];
|
||||
let account_required = vec![];
|
||||
|
||||
grpc.subscribe_events_v2(
|
||||
protocols,
|
||||
None,
|
||||
account_include,
|
||||
// Transaction filter for monitoring transaction data
|
||||
let transaction_filter = TransactionFilter {
|
||||
account_include: account_include.clone(),
|
||||
account_exclude,
|
||||
account_required,
|
||||
};
|
||||
|
||||
// Account filter for monitoring account data owned by programs
|
||||
let account_filter = AccountFilter {
|
||||
account: vec![],
|
||||
owner: account_include.clone()
|
||||
};
|
||||
|
||||
grpc.subscribe_events_immediate(
|
||||
protocols,
|
||||
None,
|
||||
transaction_filter,
|
||||
account_filter,
|
||||
None,
|
||||
callback,
|
||||
)
|
||||
@@ -199,6 +224,8 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
|
||||
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
|
||||
println!("Raydium CPMM Swap event: {:?}", e);
|
||||
},
|
||||
// .....
|
||||
// For more events and documentation, please refer to https://github.com/0xfnzero/solana-streamer
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+40
-13
@@ -31,14 +31,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
|
||||
|
||||
```toml
|
||||
# 添加到您的 Cargo.toml
|
||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.3.3" }
|
||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.3.4" }
|
||||
```
|
||||
|
||||
### 使用 crates.io
|
||||
|
||||
```toml
|
||||
# 添加到您的 Cargo.toml
|
||||
sol-trade-sdk = "0.3.3"
|
||||
sol-trade-sdk = "0.3.4"
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
@@ -74,11 +74,21 @@ use sol_trade_sdk::solana_streamer_sdk::{
|
||||
},
|
||||
Protocol, UnifiedEvent,
|
||||
},
|
||||
yellowstone_grpc::{AccountFilter, TransactionFilter},
|
||||
YellowstoneGrpc,
|
||||
},
|
||||
match_event,
|
||||
};
|
||||
|
||||
use solana_streamer_sdk::streaming::event_parser::protocols::{
|
||||
bonk::parser::BONK_PROGRAM_ID,
|
||||
pumpfun::parser::PUMPFUN_PROGRAM_ID,
|
||||
pumpswap::parser::PUMPSWAP_PROGRAM_ID,
|
||||
raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID,
|
||||
raydium_clmm::parser::RAYDIUM_CLMM_PROGRAM_ID,
|
||||
raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID
|
||||
};
|
||||
|
||||
async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// 使用 GRPC 客户端订阅事件
|
||||
println!("正在订阅 GRPC 事件...");
|
||||
@@ -121,6 +131,8 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
|
||||
println!("Raydium CPMM Swap event: {:?}", e);
|
||||
},
|
||||
// .....
|
||||
// 更多的事件和说明请参考 https://github.com/0xfnzero/solana-streamer
|
||||
});
|
||||
};
|
||||
|
||||
@@ -128,24 +140,37 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("开始监听事件,按 Ctrl+C 停止...");
|
||||
let protocols = vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk, Protocol::RaydiumCpmm];
|
||||
|
||||
// Filter accounts
|
||||
// 过滤账户
|
||||
let account_include = vec![
|
||||
PUMPFUN_PROGRAM_ID.to_string(), // Listen to pumpfun program ID
|
||||
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to pumpswap program ID
|
||||
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
|
||||
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
|
||||
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
|
||||
"xxxxxxxx".to_string(), // Listen to xxxxx account
|
||||
PUMPFUN_PROGRAM_ID.to_string(), // 监听 pumpfun 程序 ID
|
||||
PUMPSWAP_PROGRAM_ID.to_string(), // 监听 pumpswap 程序 ID
|
||||
BONK_PROGRAM_ID.to_string(), // 监听 bonk 程序 ID
|
||||
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // 监听 raydium_cpmm 程序 ID
|
||||
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // 监听 raydium_clmm 程序 ID
|
||||
RAYDIUM_AMM_V4_PROGRAM_ID.to_string(), // 监听 raydium_amm_v4 程序 ID
|
||||
"xxxxxxxx".to_string(), // 监听特定账户
|
||||
];
|
||||
let account_exclude = vec![];
|
||||
let account_required = vec![];
|
||||
|
||||
grpc.subscribe_events_v2(
|
||||
protocols,
|
||||
None,
|
||||
account_include,
|
||||
// 监听交易数据
|
||||
let transaction_filter = TransactionFilter {
|
||||
account_include: account_include.clone(),
|
||||
account_exclude,
|
||||
account_required,
|
||||
};
|
||||
|
||||
// 监听属于owner程序的账号数据 -> 账号事件监听
|
||||
let account_filter = AccountFilter {
|
||||
account: vec![],
|
||||
owner: account_include.clone()
|
||||
};
|
||||
|
||||
grpc.subscribe_events_immediate(
|
||||
protocols,
|
||||
None,
|
||||
transaction_filter,
|
||||
account_filter,
|
||||
None,
|
||||
callback,
|
||||
)
|
||||
@@ -199,6 +224,8 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
|
||||
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
|
||||
println!("Raydium CPMM Swap event: {:?}", e);
|
||||
},
|
||||
// .....
|
||||
// 更多的事件和说明请参考 https://github.com/0xfnzero/solana-streamer
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+18
-6
@@ -24,7 +24,7 @@ use sol_trade_sdk::solana_streamer_sdk::{
|
||||
},
|
||||
};
|
||||
use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, signature::Keypair};
|
||||
use solana_streamer_sdk::streaming::event_parser::protocols::{bonk::parser::BONK_PROGRAM_ID, pumpfun::parser::PUMPFUN_PROGRAM_ID, pumpswap::parser::PUMPSWAP_PROGRAM_ID, raydium_clmm::parser::RAYDIUM_CLMM_PROGRAM_ID, raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID};
|
||||
use solana_streamer_sdk::streaming::{event_parser::protocols::{bonk::parser::BONK_PROGRAM_ID, pumpfun::parser::PUMPFUN_PROGRAM_ID, pumpswap::parser::PUMPSWAP_PROGRAM_ID, raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID, raydium_clmm::parser::RAYDIUM_CLMM_PROGRAM_ID, raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID}, yellowstone_grpc::{AccountFilter, TransactionFilter}};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -431,18 +431,28 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
|
||||
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
|
||||
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
|
||||
RAYDIUM_AMM_V4_PROGRAM_ID.to_string(), // Listen to raydium_amm_v4 program ID
|
||||
"xxxxxxxx".to_string(), // Listen to xxxxx account
|
||||
];
|
||||
let account_exclude = vec![];
|
||||
let account_required = vec![];
|
||||
|
||||
println!("开始监听事件,按 Ctrl+C 停止...");
|
||||
grpc.subscribe_events_v2(
|
||||
protocols,
|
||||
None,
|
||||
account_include,
|
||||
// 监听交易数据
|
||||
let transaction_filter = TransactionFilter {
|
||||
account_include: account_include.clone(),
|
||||
account_exclude,
|
||||
account_required,
|
||||
};
|
||||
|
||||
// 监听属于owner程序的账号数据 -> 账号事件监听
|
||||
let account_filter = AccountFilter { account: vec![], owner: account_include.clone() };
|
||||
|
||||
println!("开始监听事件,按 Ctrl+C 停止...");
|
||||
grpc.subscribe_events_immediate(
|
||||
protocols,
|
||||
None,
|
||||
transaction_filter,
|
||||
account_filter,
|
||||
None,
|
||||
callback,
|
||||
)
|
||||
@@ -497,6 +507,8 @@ fn create_event_callback() -> impl Fn(Box<dyn UnifiedEvent>) {
|
||||
RaydiumCpmmSwapEvent => |e: RaydiumCpmmSwapEvent| {
|
||||
println!("RaydiumCpmmSwapEvent: {:?}", e);
|
||||
},
|
||||
// .....
|
||||
// 更多的事件和说明请参考 https://github.com/0xfnzero/solana-streamer
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user