mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-16 02:18:05 +00:00
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
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "solana-streamer-sdk"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
edition = "2021"
|
||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||
repository = "https://github.com/0xfnzero/solana-streamer"
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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"
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -156,7 +156,7 @@ impl BonkEventParser {
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<Box<dyn UnifiedEvent>> {
|
||||
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<Box<dyn UnifiedEvent>> {
|
||||
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<Box<dyn UnifiedEvent>> {
|
||||
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<Box<dyn UnifiedEvent>> {
|
||||
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()
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user