From a1a453fe0559bc1945a81c05c341ef1a468e637a Mon Sep 17 00:00:00 2001 From: ysq Date: Fri, 22 Aug 2025 21:21:08 +0800 Subject: [PATCH] feat(bonk): Enhanced Bonk protocol event parsing support - Updated BonkTradeEvent struct with new fields: global_config, platform_config, system_program, platform_associated_account, and creator_associated_account - Modified account parsing logic in parser to support the new account fields - Updated account count check from 11 to 18 to accommodate the new protocol structure - Bumped version from 0.3.8 to 0.3.9 --- Cargo.toml | 2 +- README.md | 4 +-- README_CN.md | 4 +-- .../event_parser/protocols/bonk/events.rs | 10 +++++++ .../event_parser/protocols/bonk/parser.rs | 28 ++++++++++++++++--- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bfc3991..2cd1e2b 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-streamer-sdk" -version = "0.3.8" +version = "0.3.9" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/solana-streamer" diff --git a/README.md b/README.md index cde54a7..f0cbf14 100755 --- a/README.md +++ b/README.md @@ -45,14 +45,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.3.8" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.3.9" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -solana-streamer-sdk = "0.3.8" +solana-streamer-sdk = "0.3.9" ``` ## Usage Examples diff --git a/README_CN.md b/README_CN.md index 7a43120..d1b0e25 100644 --- a/README_CN.md +++ b/README_CN.md @@ -45,14 +45,14 @@ git clone https://github.com/0xfnzero/solana-streamer ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.3.8" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.3.9" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = "0.3.8" +solana-streamer-sdk = "0.3.9" ``` ## 使用示例 diff --git a/src/streaming/event_parser/protocols/bonk/events.rs b/src/streaming/event_parser/protocols/bonk/events.rs index 7f25067..e2a2d50 100755 --- a/src/streaming/event_parser/protocols/bonk/events.rs +++ b/src/streaming/event_parser/protocols/bonk/events.rs @@ -41,6 +41,10 @@ pub struct BonkTradeEvent { #[borsh(skip)] pub payer: Pubkey, #[borsh(skip)] + pub global_config: Pubkey, + #[borsh(skip)] + pub platform_config: Pubkey, + #[borsh(skip)] pub user_base_token: Pubkey, #[borsh(skip)] pub user_quote_token: Pubkey, @@ -60,6 +64,12 @@ pub struct BonkTradeEvent { pub is_dev_create_token_trade: bool, #[borsh(skip)] pub is_bot: bool, + #[borsh(skip)] + pub system_program: Pubkey, + #[borsh(skip)] + pub platform_associated_account: Pubkey, + #[borsh(skip)] + pub creator_associated_account: Pubkey, } pub const BONK_TRADE_EVENT_LOG_SIZE: usize = 32 + 8 * 13 + 1 + 1 + 1; diff --git a/src/streaming/event_parser/protocols/bonk/parser.rs b/src/streaming/event_parser/protocols/bonk/parser.rs index c2b3977..056b39d 100755 --- a/src/streaming/event_parser/protocols/bonk/parser.rs +++ b/src/streaming/event_parser/protocols/bonk/parser.rs @@ -156,7 +156,7 @@ impl BonkEventParser { accounts: &[Pubkey], metadata: EventMetadata, ) -> Option> { - if data.len() < 16 || accounts.len() < 11 { + if data.len() < 16 || accounts.len() < 18 { return None; } @@ -173,6 +173,8 @@ impl BonkEventParser { minimum_amount_out, share_fee_rate, payer: accounts[0], + global_config: accounts[2], + platform_config: accounts[3], pool_state: accounts[4], user_base_token: accounts[5], user_quote_token: accounts[6], @@ -182,6 +184,9 @@ impl BonkEventParser { quote_token_mint: accounts[10], base_token_program: accounts[11], quote_token_program: accounts[12], + system_program: accounts[15], + platform_associated_account: accounts[16], + creator_associated_account: accounts[17], trade_direction: TradeDirection::Buy, ..Default::default() })) @@ -192,7 +197,7 @@ impl BonkEventParser { accounts: &[Pubkey], metadata: EventMetadata, ) -> Option> { - if data.len() < 16 || accounts.len() < 11 { + if data.len() < 16 || accounts.len() < 18 { return None; } @@ -209,6 +214,8 @@ impl BonkEventParser { maximum_amount_in, share_fee_rate, payer: accounts[0], + global_config: accounts[2], + platform_config: accounts[3], pool_state: accounts[4], user_base_token: accounts[5], user_quote_token: accounts[6], @@ -218,6 +225,9 @@ impl BonkEventParser { quote_token_mint: accounts[10], base_token_program: accounts[11], quote_token_program: accounts[12], + system_program: accounts[15], + platform_associated_account: accounts[16], + creator_associated_account: accounts[17], trade_direction: TradeDirection::Buy, ..Default::default() })) @@ -228,7 +238,7 @@ impl BonkEventParser { accounts: &[Pubkey], metadata: EventMetadata, ) -> Option> { - if data.len() < 16 || accounts.len() < 11 { + if data.len() < 16 || accounts.len() < 18 { return None; } @@ -245,6 +255,8 @@ impl BonkEventParser { minimum_amount_out, share_fee_rate, payer: accounts[0], + global_config: accounts[2], + platform_config: accounts[3], pool_state: accounts[4], user_base_token: accounts[5], user_quote_token: accounts[6], @@ -254,6 +266,9 @@ impl BonkEventParser { quote_token_mint: accounts[10], base_token_program: accounts[11], quote_token_program: accounts[12], + system_program: accounts[15], + platform_associated_account: accounts[16], + creator_associated_account: accounts[17], trade_direction: TradeDirection::Sell, ..Default::default() })) @@ -264,7 +279,7 @@ impl BonkEventParser { accounts: &[Pubkey], metadata: EventMetadata, ) -> Option> { - if data.len() < 16 || accounts.len() < 11 { + if data.len() < 16 || accounts.len() < 18 { return None; } @@ -281,6 +296,8 @@ impl BonkEventParser { maximum_amount_in, share_fee_rate, payer: accounts[0], + global_config: accounts[2], + platform_config: accounts[3], pool_state: accounts[4], user_base_token: accounts[5], user_quote_token: accounts[6], @@ -290,6 +307,9 @@ impl BonkEventParser { quote_token_mint: accounts[10], base_token_program: accounts[11], quote_token_program: accounts[12], + system_program: accounts[15], + platform_associated_account: accounts[16], + creator_associated_account: accounts[17], trade_direction: TradeDirection::Sell, ..Default::default() }))