mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-02 20:37:42 +00:00
feat: add Bonk Token2022 initialization support
Add support for Token2022 standard in Bonk protocol event parsing, including new event type, discriminator, and instruction parser.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "solana-streamer-sdk"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
edition = "2021"
|
||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||
repository = "https://github.com/0xfnzero/solana-streamer"
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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"
|
||||
```
|
||||
|
||||
## ⚙️ 配置系统
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
@@ -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<Box<dyn UnifiedEvent>> {
|
||||
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<MintParams> {
|
||||
// Read decimals (1 byte)
|
||||
|
||||
Reference in New Issue
Block a user