diff --git a/Cargo.toml b/Cargo.toml index 71f0acd..fc328fe 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-streamer-sdk" -version = "0.4.6" +version = "0.4.7" 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 00df866..6f384c9 100755 --- a/README.md +++ b/README.md @@ -107,14 +107,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.6" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.7" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -solana-streamer-sdk = "0.4.6" +solana-streamer-sdk = "0.4.7" ``` ## ⚙️ Configuration System diff --git a/README_CN.md b/README_CN.md index 939f3eb..63457fc 100644 --- a/README_CN.md +++ b/README_CN.md @@ -107,14 +107,14 @@ git clone https://github.com/0xfnzero/solana-streamer ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.6" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.7" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = "0.4.6" +solana-streamer-sdk = "0.4.7" ``` ## ⚙️ 配置系统 diff --git a/src/streaming/event_parser/common/types.rs b/src/streaming/event_parser/common/types.rs index a5328d4..d12e41c 100755 --- a/src/streaming/event_parser/common/types.rs +++ b/src/streaming/event_parser/common/types.rs @@ -97,6 +97,7 @@ pub enum EventType { BonkSellExactOut, BonkInitialize, BonkInitializeV2, + BonkInitializeWithToken2022, BonkMigrateToAmm, BonkMigrateToCpswap, @@ -187,6 +188,7 @@ impl fmt::Display for EventType { EventType::BonkSellExactOut => write!(f, "BonkSellExactOut"), EventType::BonkInitialize => write!(f, "BonkInitialize"), EventType::BonkInitializeV2 => write!(f, "BonkInitializeV2"), + EventType::BonkInitializeWithToken2022 => write!(f, "BonkInitializeWithToken2022"), EventType::BonkMigrateToAmm => write!(f, "BonkMigrateToAmm"), EventType::BonkMigrateToCpswap => write!(f, "BonkMigrateToCpswap"), EventType::RaydiumCpmmSwapBaseInput => write!(f, "RaydiumCpmmSwapBaseInput"), diff --git a/src/streaming/event_parser/protocols/bonk/events.rs b/src/streaming/event_parser/protocols/bonk/events.rs index 6571664..ed651d5 100755 --- a/src/streaming/event_parser/protocols/bonk/events.rs +++ b/src/streaming/event_parser/protocols/bonk/events.rs @@ -329,6 +329,7 @@ pub mod discriminators { pub const SELL_EXACT_OUT: &[u8] = &[95, 200, 71, 34, 8, 9, 11, 166]; pub const INITIALIZE: &[u8] = &[175, 175, 109, 31, 13, 152, 155, 237]; pub const INITIALIZE_V2: &[u8] = &[67, 153, 175, 39, 218, 16, 38, 32]; + pub const INITIALIZE_WITH_TOKEN_2022: &[u8] = &[37, 190, 126, 222, 44, 154, 171, 17]; pub const MIGRATE_TO_AMM: &[u8] = &[207, 82, 192, 145, 254, 207, 145, 223]; pub const MIGRATE_TO_CP_SWAP: &[u8] = &[136, 92, 200, 103, 28, 218, 144, 140]; diff --git a/src/streaming/event_parser/protocols/bonk/parser.rs b/src/streaming/event_parser/protocols/bonk/parser.rs index 0d57d5e..ac2eac0 100755 --- a/src/streaming/event_parser/protocols/bonk/parser.rs +++ b/src/streaming/event_parser/protocols/bonk/parser.rs @@ -93,6 +93,16 @@ impl BonkEventParser { instruction_parser: Some(Self::parse_initialize_v2_instruction), requires_inner_instruction: false, }, + GenericEventParseConfig { + program_id: BONK_PROGRAM_ID, + protocol_type: ProtocolType::Bonk, + inner_instruction_discriminator: discriminators::POOL_CREATE_EVENT, + instruction_discriminator: discriminators::INITIALIZE_WITH_TOKEN_2022, + event_type: EventType::BonkInitializeWithToken2022, + inner_instruction_parser: Some(Self::parse_pool_create_inner_instruction), + instruction_parser: Some(Self::parse_initialize_with_token_2022_instruction), + requires_inner_instruction: false, + }, GenericEventParseConfig { program_id: BONK_PROGRAM_ID, protocol_type: ProtocolType::Bonk, @@ -381,6 +391,45 @@ impl BonkEventParser { })) } + /// Parse initialize event + fn parse_initialize_with_token_2022_instruction( + data: &[u8], + accounts: &[Pubkey], + metadata: EventMetadata, + ) -> Option> { + if data.len() < 24 { + return None; + } + + let mut offset = 0; + let base_mint_param = Self::parse_mint_params(data, &mut offset)?; + let curve_param = Self::parse_curve_params(data, &mut offset)?; + let vesting_param = Self::parse_vesting_params(data, &mut offset)?; + let amm_fee_on = data[offset]; + + Some(Box::new(BonkPoolCreateEvent { + metadata, + payer: accounts[0], + creator: accounts[1], + global_config: accounts[2], + platform_config: accounts[3], + pool_state: accounts[5], + base_mint: accounts[6], + quote_mint: accounts[7], + base_vault: accounts[8], + quote_vault: accounts[9], + base_mint_param, + curve_param, + vesting_param, + amm_fee_on: if amm_fee_on == 0 { + Some(AmmFeeOn::QuoteToken) + } else { + Some(AmmFeeOn::BothToken) + }, + ..Default::default() + })) + } + /// Parse MintParams structure fn parse_mint_params(data: &[u8], offset: &mut usize) -> Option { // Read decimals (1 byte)