mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-17 19:08:05 +00:00
feat: add Meteora DAMM v2 protocol support
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
use crate::streaming::event_parser::{
|
||||
common::EventMetadata,
|
||||
protocols::{
|
||||
bonk::parser as bonk, pumpfun::parser as pumpfun, pumpswap::parser as pumpswap,
|
||||
raydium_amm_v4::parser as raydium_amm_v4, raydium_clmm::parser as raydium_clmm,
|
||||
raydium_cpmm::parser as raydium_cpmm,
|
||||
bonk::parser as bonk, meteora_damm_v2::parser as meteora_damm_v2, pumpfun::parser as pumpfun,
|
||||
pumpswap::parser as pumpswap, raydium_amm_v4::parser as raydium_amm_v4,
|
||||
raydium_clmm::parser as raydium_clmm, raydium_cpmm::parser as raydium_cpmm,
|
||||
},
|
||||
DexEvent, Protocol,
|
||||
};
|
||||
@@ -52,6 +52,7 @@ impl EventDispatcher {
|
||||
Protocol::RaydiumCpmm => ProtocolType::RaydiumCpmm,
|
||||
Protocol::RaydiumClmm => ProtocolType::RaydiumClmm,
|
||||
Protocol::RaydiumAmmV4 => ProtocolType::RaydiumAmmV4,
|
||||
Protocol::MeteoraDammV2 => ProtocolType::MeteoraDammV2,
|
||||
};
|
||||
|
||||
match protocol {
|
||||
@@ -91,6 +92,12 @@ impl EventDispatcher {
|
||||
accounts,
|
||||
metadata,
|
||||
),
|
||||
Protocol::MeteoraDammV2 => meteora_damm_v2::parse_meteora_damm_v2_instruction_data(
|
||||
instruction_discriminator,
|
||||
instruction_data,
|
||||
accounts,
|
||||
metadata,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +127,7 @@ impl EventDispatcher {
|
||||
Protocol::RaydiumCpmm => ProtocolType::RaydiumCpmm,
|
||||
Protocol::RaydiumClmm => ProtocolType::RaydiumClmm,
|
||||
Protocol::RaydiumAmmV4 => ProtocolType::RaydiumAmmV4,
|
||||
Protocol::MeteoraDammV2 => ProtocolType::MeteoraDammV2,
|
||||
};
|
||||
|
||||
match protocol {
|
||||
@@ -153,6 +161,11 @@ impl EventDispatcher {
|
||||
inner_instruction_data,
|
||||
metadata,
|
||||
),
|
||||
Protocol::MeteoraDammV2 => meteora_damm_v2::parse_meteora_damm_v2_inner_instruction_data(
|
||||
inner_instruction_discriminator,
|
||||
inner_instruction_data,
|
||||
metadata,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +184,8 @@ impl EventDispatcher {
|
||||
Some(Protocol::RaydiumClmm)
|
||||
} else if program_id == &raydium_amm_v4::RAYDIUM_AMM_V4_PROGRAM_ID {
|
||||
Some(Protocol::RaydiumAmmV4)
|
||||
} else if program_id == &meteora_damm_v2::METEORA_DAMM_V2_PROGRAM_ID {
|
||||
Some(Protocol::MeteoraDammV2)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -186,6 +201,7 @@ impl EventDispatcher {
|
||||
Protocol::RaydiumCpmm => raydium_cpmm::RAYDIUM_CPMM_PROGRAM_ID,
|
||||
Protocol::RaydiumClmm => raydium_clmm::RAYDIUM_CLMM_PROGRAM_ID,
|
||||
Protocol::RaydiumAmmV4 => raydium_amm_v4::RAYDIUM_AMM_V4_PROGRAM_ID,
|
||||
Protocol::MeteoraDammV2 => meteora_damm_v2::METEORA_DAMM_V2_PROGRAM_ID,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,6 +237,7 @@ impl EventDispatcher {
|
||||
Protocol::RaydiumCpmm => ProtocolType::RaydiumCpmm,
|
||||
Protocol::RaydiumClmm => ProtocolType::RaydiumClmm,
|
||||
Protocol::RaydiumAmmV4 => ProtocolType::RaydiumAmmV4,
|
||||
Protocol::MeteoraDammV2 => ProtocolType::MeteoraDammV2,
|
||||
};
|
||||
|
||||
match protocol {
|
||||
@@ -240,6 +257,10 @@ impl EventDispatcher {
|
||||
Protocol::RaydiumAmmV4 => {
|
||||
raydium_amm_v4::parse_raydium_amm_v4_account_data(discriminator, account, metadata)
|
||||
}
|
||||
Protocol::MeteoraDammV2 => {
|
||||
// Meteora DAMM 目前不需要解析账户数据,返回 None
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +238,136 @@ pub fn merge(instruction_event: &mut DexEvent, cpi_log_event: DexEvent) {
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
DexEvent::MeteoraDammV2SwapEvent(e) => match cpi_log_event {
|
||||
DexEvent::MeteoraDammV2SwapEvent(cpie) => {
|
||||
e.pool = cpie.pool;
|
||||
e.trade_direction = cpie.trade_direction;
|
||||
e.collect_fee_mode = cpie.collect_fee_mode;
|
||||
e.has_referral = cpie.has_referral;
|
||||
e.amount_0 = cpie.amount_0;
|
||||
e.amount_1 = cpie.amount_1;
|
||||
e.swap_mode = cpie.swap_mode;
|
||||
e.included_fee_input_amount = cpie.included_fee_input_amount;
|
||||
e.excluded_fee_input_amount = cpie.excluded_fee_input_amount;
|
||||
e.amount_left = cpie.amount_left;
|
||||
e.output_amount = cpie.output_amount;
|
||||
e.next_sqrt_price = cpie.next_sqrt_price;
|
||||
e.trading_fee = cpie.trading_fee;
|
||||
e.partner_fee = cpie.partner_fee;
|
||||
e.referral_fee = cpie.referral_fee;
|
||||
e.included_transfer_fee_amount_in = cpie.included_transfer_fee_amount_in;
|
||||
e.included_transfer_fee_amount_out = cpie.included_transfer_fee_amount_out;
|
||||
e.excluded_transfer_fee_amount_out = cpie.excluded_transfer_fee_amount_out;
|
||||
e.current_timestamp = cpie.current_timestamp;
|
||||
e.reserve_a_amount = cpie.reserve_a_amount;
|
||||
e.reserve_b_amount = cpie.reserve_b_amount;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
DexEvent::MeteoraDammV2Swap2Event(e) => match cpi_log_event {
|
||||
DexEvent::MeteoraDammV2SwapEvent(cpie) => {
|
||||
e.pool = cpie.pool;
|
||||
e.trade_direction = cpie.trade_direction;
|
||||
e.collect_fee_mode = cpie.collect_fee_mode;
|
||||
e.has_referral = cpie.has_referral;
|
||||
e.amount_0 = cpie.amount_0;
|
||||
e.amount_1 = cpie.amount_1;
|
||||
e.swap_mode = cpie.swap_mode;
|
||||
e.included_fee_input_amount = cpie.included_fee_input_amount;
|
||||
e.excluded_fee_input_amount = cpie.excluded_fee_input_amount;
|
||||
e.amount_left = cpie.amount_left;
|
||||
e.output_amount = cpie.output_amount;
|
||||
e.next_sqrt_price = cpie.next_sqrt_price;
|
||||
e.trading_fee = cpie.trading_fee;
|
||||
e.partner_fee = cpie.partner_fee;
|
||||
e.referral_fee = cpie.referral_fee;
|
||||
e.included_transfer_fee_amount_in = cpie.included_transfer_fee_amount_in;
|
||||
e.included_transfer_fee_amount_out = cpie.included_transfer_fee_amount_out;
|
||||
e.excluded_transfer_fee_amount_out = cpie.excluded_transfer_fee_amount_out;
|
||||
e.current_timestamp = cpie.current_timestamp;
|
||||
e.reserve_a_amount = cpie.reserve_a_amount;
|
||||
e.reserve_b_amount = cpie.reserve_b_amount;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(e) => match cpi_log_event {
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(cpie) => {
|
||||
e.pool = cpie.pool;
|
||||
e.token_a_mint = cpie.token_a_mint;
|
||||
e.token_b_mint = cpie.token_b_mint;
|
||||
e.creator = cpie.creator;
|
||||
e.payer = cpie.payer;
|
||||
e.alpha_vault = cpie.alpha_vault;
|
||||
e.pool_fees = cpie.pool_fees;
|
||||
e.sqrt_min_price = cpie.sqrt_min_price;
|
||||
e.sqrt_max_price = cpie.sqrt_max_price;
|
||||
e.activation_type = cpie.activation_type;
|
||||
e.collect_fee_mode = cpie.collect_fee_mode;
|
||||
e.liquidity = cpie.liquidity;
|
||||
e.sqrt_price = cpie.sqrt_price;
|
||||
e.activation_point = cpie.activation_point;
|
||||
e.token_a_flag = cpie.token_a_flag;
|
||||
e.token_b_flag = cpie.token_b_flag;
|
||||
e.token_a_amount = cpie.token_a_amount;
|
||||
e.token_b_amount = cpie.token_b_amount;
|
||||
e.total_amount_a = cpie.total_amount_a;
|
||||
e.total_amount_b = cpie.total_amount_b;
|
||||
e.pool_type = cpie.pool_type;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
DexEvent::MeteoraDammV2InitializeCustomizablePoolEvent(e) => match cpi_log_event {
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(cpie) => {
|
||||
e.pool = cpie.pool;
|
||||
e.token_a_mint = cpie.token_a_mint;
|
||||
e.token_b_mint = cpie.token_b_mint;
|
||||
e.creator = cpie.creator;
|
||||
e.payer = cpie.payer;
|
||||
e.alpha_vault = cpie.alpha_vault;
|
||||
e.pool_fees = cpie.pool_fees;
|
||||
e.sqrt_min_price = cpie.sqrt_min_price;
|
||||
e.sqrt_max_price = cpie.sqrt_max_price;
|
||||
e.activation_type = cpie.activation_type;
|
||||
e.collect_fee_mode = cpie.collect_fee_mode;
|
||||
e.liquidity = cpie.liquidity;
|
||||
e.sqrt_price = cpie.sqrt_price;
|
||||
e.activation_point = cpie.activation_point;
|
||||
e.token_a_flag = cpie.token_a_flag;
|
||||
e.token_b_flag = cpie.token_b_flag;
|
||||
e.token_a_amount = cpie.token_a_amount;
|
||||
e.token_b_amount = cpie.token_b_amount;
|
||||
e.total_amount_a = cpie.total_amount_a;
|
||||
e.total_amount_b = cpie.total_amount_b;
|
||||
e.pool_type = cpie.pool_type;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
DexEvent::MeteoraDammV2InitializePoolWithDynamicConfigEvent(e) => match cpi_log_event {
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(cpie) => {
|
||||
e.pool = cpie.pool;
|
||||
e.token_a_mint = cpie.token_a_mint;
|
||||
e.token_b_mint = cpie.token_b_mint;
|
||||
e.creator = cpie.creator;
|
||||
e.payer = cpie.payer;
|
||||
e.alpha_vault = cpie.alpha_vault;
|
||||
e.pool_fees = cpie.pool_fees;
|
||||
e.sqrt_min_price = cpie.sqrt_min_price;
|
||||
e.sqrt_max_price = cpie.sqrt_max_price;
|
||||
e.activation_type = cpie.activation_type;
|
||||
e.collect_fee_mode = cpie.collect_fee_mode;
|
||||
e.liquidity = cpie.liquidity;
|
||||
e.sqrt_price = cpie.sqrt_price;
|
||||
e.activation_point = cpie.activation_point;
|
||||
e.token_a_flag = cpie.token_a_flag;
|
||||
e.token_b_flag = cpie.token_b_flag;
|
||||
e.token_a_amount = cpie.token_a_amount;
|
||||
e.token_b_amount = cpie.token_b_amount;
|
||||
e.total_amount_a = cpie.total_amount_a;
|
||||
e.total_amount_b = cpie.total_amount_b;
|
||||
e.pool_type = cpie.pool_type;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::streaming::event_parser::core::account_event_parser::{
|
||||
};
|
||||
use crate::streaming::event_parser::protocols::block::block_meta_event::BlockMetaEvent;
|
||||
use crate::streaming::event_parser::protocols::bonk::events::*;
|
||||
use crate::streaming::event_parser::protocols::meteora_damm_v2::events::*;
|
||||
use crate::streaming::event_parser::protocols::pumpfun::events::*;
|
||||
use crate::streaming::event_parser::protocols::pumpswap::events::*;
|
||||
use crate::streaming::event_parser::protocols::raydium_amm_v4::events::*;
|
||||
@@ -70,6 +71,13 @@ pub enum DexEvent {
|
||||
RaydiumCpmmAmmConfigAccountEvent(RaydiumCpmmAmmConfigAccountEvent),
|
||||
RaydiumCpmmPoolStateAccountEvent(RaydiumCpmmPoolStateAccountEvent),
|
||||
|
||||
// Meteora DAMM v2 events
|
||||
MeteoraDammV2SwapEvent(MeteoraDammV2SwapEvent),
|
||||
MeteoraDammV2Swap2Event(MeteoraDammV2Swap2Event),
|
||||
MeteoraDammV2InitializePoolEvent(MeteoraDammV2InitializePoolEvent),
|
||||
MeteoraDammV2InitializeCustomizablePoolEvent(MeteoraDammV2InitializeCustomizablePoolEvent),
|
||||
MeteoraDammV2InitializePoolWithDynamicConfigEvent(MeteoraDammV2InitializePoolWithDynamicConfigEvent),
|
||||
|
||||
// Common events
|
||||
TokenAccountEvent(TokenAccountEvent),
|
||||
NonceAccountEvent(NonceAccountEvent),
|
||||
@@ -123,6 +131,11 @@ impl DexEvent {
|
||||
DexEvent::RaydiumCpmmInitializeEvent(e) => &e.metadata,
|
||||
DexEvent::RaydiumCpmmAmmConfigAccountEvent(e) => &e.metadata,
|
||||
DexEvent::RaydiumCpmmPoolStateAccountEvent(e) => &e.metadata,
|
||||
DexEvent::MeteoraDammV2SwapEvent(e) => &e.metadata,
|
||||
DexEvent::MeteoraDammV2Swap2Event(e) => &e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(e) => &e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializeCustomizablePoolEvent(e) => &e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializePoolWithDynamicConfigEvent(e) => &e.metadata,
|
||||
DexEvent::TokenAccountEvent(e) => &e.metadata,
|
||||
DexEvent::NonceAccountEvent(e) => &e.metadata,
|
||||
DexEvent::TokenInfoEvent(e) => &e.metadata,
|
||||
@@ -175,6 +188,11 @@ impl DexEvent {
|
||||
DexEvent::RaydiumCpmmInitializeEvent(e) => &mut e.metadata,
|
||||
DexEvent::RaydiumCpmmAmmConfigAccountEvent(e) => &mut e.metadata,
|
||||
DexEvent::RaydiumCpmmPoolStateAccountEvent(e) => &mut e.metadata,
|
||||
DexEvent::MeteoraDammV2SwapEvent(e) => &mut e.metadata,
|
||||
DexEvent::MeteoraDammV2Swap2Event(e) => &mut e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializePoolEvent(e) => &mut e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializeCustomizablePoolEvent(e) => &mut e.metadata,
|
||||
DexEvent::MeteoraDammV2InitializePoolWithDynamicConfigEvent(e) => &mut e.metadata,
|
||||
DexEvent::TokenAccountEvent(e) => &mut e.metadata,
|
||||
DexEvent::NonceAccountEvent(e) => &mut e.metadata,
|
||||
DexEvent::TokenInfoEvent(e) => &mut e.metadata,
|
||||
|
||||
Reference in New Issue
Block a user