perf: add object pooling and enhanced metrics for streaming optimization

- Implement gRPC/shred connection pools for memory efficiency
- Add atomic processing time stats with auto-calibration clock
- Optimize event parsers and protocol handlers
- Refactor metrics system for advanced performance monitoring
This commit is contained in:
ysq
2025-09-02 17:27:27 +08:00
parent 07bb110dc0
commit b71a83bf66
30 changed files with 920 additions and 273 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ macro_rules! impl_unified_event {
self.metadata.event_type.clone()
}
fn signature(&self) -> &str {
fn signature(&self) -> &solana_sdk::signature::Signature {
&self.metadata.signature
}
+9 -11
View File
@@ -1,7 +1,7 @@
use borsh::{BorshDeserialize, BorshSerialize};
use crossbeam_queue::ArrayQueue;
use serde::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::{pubkey::Pubkey, signature::Signature};
use std::{borrow::Cow, fmt, str::FromStr, sync::Arc};
use crate::{
@@ -282,15 +282,13 @@ pub struct SwapData {
pub to_mint: Pubkey,
pub from_amount: u64,
pub to_amount: u64,
pub description: Option<String>,
pub description: Option<Cow<'static, str>>,
}
/// Event metadata
#[derive(
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize,
)]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct EventMetadata {
pub signature: Cow<'static, str>,
pub signature: Signature,
pub slot: u64,
pub transaction_index: Option<u64>, // 新增:交易在slot中的索引
pub block_time: i64,
@@ -308,7 +306,7 @@ pub struct EventMetadata {
impl EventMetadata {
#[allow(clippy::too_many_arguments)]
pub fn new(
signature: Cow<'static, str>,
signature: Signature,
slot: u64,
block_time: i64,
block_time_ms: i64,
@@ -413,7 +411,7 @@ pub fn parse_swap_data_from_next_instructions(
},
RaydiumClmmSwapEvent => |e: RaydiumClmmSwapEvent| {
user = Some(e.payer);
swap_data.description = Some("Unable to get from_mint and to_mint from RaydiumClmmSwapEvent".to_string());
swap_data.description = Some("Unable to get from_mint and to_mint from RaydiumClmmSwapEvent".into());
user_from_token = Some(e.input_token_account);
user_to_token = Some(e.output_token_account);
from_vault = Some(e.input_vault);
@@ -430,7 +428,7 @@ pub fn parse_swap_data_from_next_instructions(
},
RaydiumAmmV4SwapEvent => |e: RaydiumAmmV4SwapEvent| {
user = Some(e.user_source_owner);
swap_data.description = Some("Unable to get from_mint and to_mint from RaydiumAmmV4SwapEvent".to_string());
swap_data.description = Some("Unable to get from_mint and to_mint from RaydiumAmmV4SwapEvent".into());
user_from_token = Some(e.user_source_token_account);
user_to_token = Some(e.user_destination_token_account);
from_vault = Some(e.pool_pc_token_account);
@@ -453,12 +451,12 @@ pub fn parse_swap_data_from_next_instructions(
break;
}
let data = &compiled.data;
// 使用 SIMD 验证数据格式
if !SimdUtils::validate_data_format(data, 8) {
continue;
}
let get_pubkey = |i: usize| accounts[compiled.accounts[i] as usize];
let (source, destination, amount) = match data[0] {
12 if compiled.accounts.len() >= 4 => {
@@ -1,4 +1,3 @@
use std::borrow::Cow;
use std::collections::HashMap;
use std::sync::OnceLock;
@@ -7,7 +6,7 @@ use solana_sdk::pubkey::Pubkey;
use crate::streaming::common::SimdUtils;
use crate::streaming::event_parser::common::filter::EventTypeFilter;
use crate::streaming::event_parser::common::{EventMetadata, EventType, ProtocolType};
use crate::streaming::event_parser::core::traits::{UnifiedEvent, get_high_perf_clock};
use crate::streaming::event_parser::core::traits::{elapsed_micros_since, UnifiedEvent};
use crate::streaming::event_parser::protocols::bonk::parser::BONK_PROGRAM_ID;
use crate::streaming::event_parser::protocols::pumpfun::parser::PUMPFUN_PROGRAM_ID;
use crate::streaming::event_parser::protocols::pumpswap::parser::PUMPSWAP_PROGRAM_ID;
@@ -177,12 +176,11 @@ impl AccountEventParser {
if account.owner == config.program_id
&& SimdUtils::fast_discriminator_match(&account.data, config.account_discriminator)
{
let signature_str = Cow::Owned(account.signature.to_string());
let event = (config.account_parser)(
&account,
EventMetadata {
slot: account.slot,
signature: signature_str,
signature: account.signature,
protocol: config.protocol_type,
event_type: config.event_type,
program_id: config.program_id,
@@ -191,9 +189,9 @@ impl AccountEventParser {
},
);
if let Some(mut event) = event {
event.set_program_handle_time_consuming_us(
get_high_perf_clock().elapsed_micros_since(account.program_received_time_us),
);
event.set_program_handle_time_consuming_us(elapsed_micros_since(
account.program_received_time_us,
));
return Some(event);
}
}
@@ -1,4 +1,4 @@
use crate::streaming::event_parser::core::traits::{UnifiedEvent, get_high_perf_clock};
use crate::streaming::event_parser::core::traits::{elapsed_micros_since, UnifiedEvent};
use crate::streaming::event_parser::protocols::block::block_meta_event::BlockMetaEvent;
pub struct CommonEventParser {}
@@ -6,19 +6,14 @@ pub struct CommonEventParser {}
impl CommonEventParser {
pub fn generate_block_meta_event(
slot: u64,
block_hash: &str,
block_hash: String,
block_time_ms: i64,
program_received_time_us: i64,
) -> Box<dyn UnifiedEvent> {
let mut block_meta_event = BlockMetaEvent::new(
slot,
block_hash.to_string(),
block_time_ms,
program_received_time_us,
);
block_meta_event.set_program_handle_time_consuming_us(
get_high_perf_clock().elapsed_micros_since(program_received_time_us),
);
let mut block_meta_event =
BlockMetaEvent::new(slot, block_hash, block_time_ms, program_received_time_us);
block_meta_event
.set_program_handle_time_consuming_us(elapsed_micros_since(program_received_time_us));
Box::new(block_meta_event)
}
}
+95 -17
View File
@@ -29,22 +29,53 @@ use crate::streaming::event_parser::{
},
};
/// 高性能时钟管理器,减少系统调用开销
/// 高性能时钟管理器,减少系统调用开销并最小化延迟
#[derive(Debug)]
pub struct HighPerformanceClock {
/// 基准时间点(程序启动时的单调时钟时间)
base_instant: Instant,
/// 基准时间点对应的UTC时间戳(微秒)
base_timestamp_us: i64,
/// 上次校准时间(用于检测是否需要重新校准)
last_calibration: Instant,
/// 校准间隔(秒)
calibration_interval_secs: u64,
}
impl HighPerformanceClock {
/// 创建新的高性能时钟
pub fn new() -> Self {
let base_instant = Instant::now();
let base_timestamp_us = chrono::Utc::now().timestamp_micros();
Self::new_with_calibration_interval(300) // 默认5分钟校准一次
}
Self { base_instant, base_timestamp_us }
/// 创建带自定义校准间隔的高性能时钟
pub fn new_with_calibration_interval(calibration_interval_secs: u64) -> Self {
// 通过多次采样来减少初始化误差
let mut best_offset = i64::MAX;
let mut best_instant = Instant::now();
let mut best_timestamp = chrono::Utc::now().timestamp_micros();
// 进行3次采样,选择延迟最小的
for _ in 0..3 {
let instant_before = Instant::now();
let timestamp = chrono::Utc::now().timestamp_micros();
let instant_after = Instant::now();
let sample_latency = instant_after.duration_since(instant_before).as_nanos() as i64;
if sample_latency < best_offset {
best_offset = sample_latency;
best_instant = instant_before;
best_timestamp = timestamp;
}
}
Self {
base_instant: best_instant,
base_timestamp_us: best_timestamp,
last_calibration: best_instant,
calibration_interval_secs,
}
}
/// 获取当前时间戳(微秒),使用单调时钟计算,避免系统调用
@@ -54,11 +85,53 @@ impl HighPerformanceClock {
self.base_timestamp_us + elapsed.as_micros() as i64
}
/// 获取高精度当前时间戳(微秒),在必要时进行校准
pub fn now_micros_with_calibration(&mut self) -> i64 {
// 检查是否需要重新校准
if self.last_calibration.elapsed().as_secs() >= self.calibration_interval_secs {
self.recalibrate();
}
self.now_micros()
}
/// 重新校准时钟,减少累积漂移
fn recalibrate(&mut self) {
let current_monotonic = Instant::now();
let current_utc = chrono::Utc::now().timestamp_micros();
// 计算预期的UTC时间戳(基于单调时钟)
let expected_utc = self.base_timestamp_us
+ current_monotonic.duration_since(self.base_instant).as_micros() as i64;
// 计算漂移量
let drift_us = current_utc - expected_utc;
// 如果漂移超过1毫秒,进行校准
if drift_us.abs() > 1000 {
self.base_instant = current_monotonic;
self.base_timestamp_us = current_utc;
}
self.last_calibration = current_monotonic;
}
/// 计算从指定时间戳到现在的消耗时间(微秒)
#[inline(always)]
pub fn elapsed_micros_since(&self, start_timestamp_us: i64) -> i64 {
self.now_micros() - start_timestamp_us
}
/// 获取高精度纳秒时间戳
#[inline(always)]
pub fn now_nanos(&self) -> i128 {
let elapsed = self.base_instant.elapsed();
(self.base_timestamp_us as i128 * 1000) + elapsed.as_nanos() as i128
}
/// 重置时钟(强制重新初始化)
pub fn reset(&mut self) {
*self = Self::new_with_calibration_interval(self.calibration_interval_secs);
}
}
impl Default for HighPerformanceClock {
@@ -67,14 +140,21 @@ impl Default for HighPerformanceClock {
}
}
/// 全局高性能时钟实例(使用OnceCell避免重复初始化)
/// 全局高性能时钟实例
static HIGH_PERF_CLOCK: once_cell::sync::OnceCell<HighPerformanceClock> =
once_cell::sync::OnceCell::new();
/// 获取全局高性能时钟实例
/// 获取全局高性能时钟实例(最简单的实现)
#[inline(always)]
pub fn get_high_perf_clock() -> &'static HighPerformanceClock {
HIGH_PERF_CLOCK.get_or_init(HighPerformanceClock::new)
pub fn get_high_perf_clock() -> i64 {
let clock = HIGH_PERF_CLOCK.get_or_init(HighPerformanceClock::new);
clock.now_micros()
}
/// 计算从指定时间戳到现在的消耗时间(微秒)
#[inline(always)]
pub fn elapsed_micros_since(start_timestamp_us: i64) -> i64 {
get_high_perf_clock() - start_timestamp_us
}
/// 轻量级事件包装器,避免频繁的Box分配
@@ -147,7 +227,7 @@ pub trait UnifiedEvent: Debug + Send + Sync {
fn event_type(&self) -> EventType;
/// Get transaction signature
fn signature(&self) -> &str;
fn signature(&self) -> &Signature;
/// Get slot number
fn slot(&self) -> u64;
@@ -535,7 +615,7 @@ pub trait EventParser: Send + Sync {
let slot = transaction.slot;
let block_time = transaction.block_time.map(|t| Timestamp { seconds: t as i64, nanos: 0 });
let program_received_time_us = chrono::Utc::now().timestamp_micros();
let program_received_time_us = get_high_perf_clock();
let bot_wallet = None;
let transaction_index = None;
// 解析指令事件
@@ -714,11 +794,10 @@ impl GenericEventParser {
transaction_index: Option<u64>,
) -> Option<Box<dyn UnifiedEvent>> {
if let Some(parser) = config.inner_instruction_parser {
let signature_str = Cow::Owned(signature.to_string());
let timestamp = block_time.unwrap_or(Timestamp { seconds: 0, nanos: 0 });
let block_time_ms = timestamp.seconds * 1000 + (timestamp.nanos as i64) / 1_000_000;
let metadata = EventMetadata::new(
signature_str,
signature,
slot,
timestamp.seconds,
block_time_ms,
@@ -752,11 +831,10 @@ impl GenericEventParser {
transaction_index: Option<u64>,
) -> Option<Box<dyn UnifiedEvent>> {
if let Some(parser) = config.instruction_parser {
let signature_str = Cow::Owned(signature.to_string());
let timestamp = block_time.unwrap_or(Timestamp { seconds: 0, nanos: 0 });
let block_time_ms = timestamp.seconds * 1000 + (timestamp.nanos as i64) / 1_000_000;
let metadata = EventMetadata::new(
signature_str,
signature,
slot,
timestamp.seconds,
block_time_ms,
@@ -941,9 +1019,9 @@ impl EventParser for GenericEventParser {
event.merge(&*inner_instruction_event);
}
// 设置处理时间(使用高性能时钟)
event.set_program_handle_time_consuming_us(
get_high_perf_clock().elapsed_micros_since(program_received_time_us),
);
event.set_program_handle_time_consuming_us(elapsed_micros_since(
program_received_time_us,
));
event = process_event(event, bot_wallet);
callback(&event);
}
@@ -1,9 +1,8 @@
use std::borrow::Cow;
use crate::impl_unified_event;
use crate::streaming::event_parser::common::{types::EventType, EventMetadata};
use borsh::BorshDeserialize;
use serde::{Deserialize, Serialize};
use solana_sdk::signature::Signature;
/// Block元数据事件
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
@@ -22,7 +21,7 @@ impl BlockMetaEvent {
program_received_time_us: i64,
) -> Self {
let metadata = EventMetadata::new(
Cow::Borrowed(""),
Signature::default(),
slot,
block_time_ms / 1000,
block_time_ms,
@@ -237,6 +237,7 @@ impl_unified_event!(
// Migrate to CP Swap event
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct BonkMigrateToCpswapEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub payer: Pubkey,
pub base_mint: Pubkey,
@@ -276,10 +277,10 @@ impl_unified_event!(BonkMigrateToCpswapEvent,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct BonkPoolStateAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub pool_state: PoolState,
}
@@ -289,10 +290,10 @@ impl_unified_event!(BonkPoolStateAccountEvent,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct BonkGlobalConfigAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub global_config: GlobalConfig,
}
@@ -302,10 +303,10 @@ impl_unified_event!(BonkGlobalConfigAccountEvent,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct BonkPlatformConfigAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub platform_config: PlatformConfig,
}
@@ -142,10 +142,10 @@ pub fn pool_state_parser(
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
Some(Box::new(BonkPoolStateAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
pool_state,
}))
@@ -193,10 +193,10 @@ pub fn global_config_parser(
if let Some(global_config) = global_config_decode(&account.data[8..GLOBAL_CONFIG_SIZE + 8]) {
Some(Box::new(BonkGlobalConfigAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
global_config,
}))
@@ -241,10 +241,10 @@ pub fn platform_config_parser(
{
Some(Box::new(BonkPlatformConfigAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
platform_config,
}))
@@ -228,10 +228,10 @@ impl_unified_event!(
pub struct PumpFunBondingCurveAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub bonding_curve: BondingCurve,
}
@@ -243,10 +243,10 @@ impl_unified_event!(PumpFunBondingCurveAccountEvent,);
pub struct PumpFunGlobalAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub global: Global,
}
@@ -41,10 +41,10 @@ pub fn bonding_curve_parser(
if let Some(bonding_curve) = bonding_curve_decode(&account.data[8..BONDING_CURVE_SIZE + 8]) {
Some(Box::new(PumpFunBondingCurveAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
bonding_curve,
}))
@@ -91,10 +91,10 @@ pub fn global_parser(
if let Some(global) = global_decode(&account.data[8..GLOBAL_SIZE + 8]) {
Some(Box::new(PumpFunGlobalAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
global,
}))
@@ -366,11 +366,12 @@ impl_unified_event!(
/// 全局配置
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct PumpSwapGlobalConfigAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub global_config: GlobalConfig,
}
@@ -379,11 +380,12 @@ impl_unified_event!(PumpSwapGlobalConfigAccountEvent,);
/// 池
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct PumpSwapPoolAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub pool: Pool,
}
@@ -43,10 +43,10 @@ pub fn global_config_parser(
if let Some(config) = global_config_decode(&account.data[8..GLOBAL_CONFIG_SIZE + 8]) {
Some(Box::new(PumpSwapGlobalConfigAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
global_config: config,
}))
@@ -88,10 +88,10 @@ pub fn pool_parser(
if let Some(pool) = pool_decode(&account.data[8..POOL_SIZE + 8]) {
Some(Box::new(PumpSwapPoolAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
pool: pool,
}))
@@ -9,6 +9,7 @@ use solana_sdk::pubkey::Pubkey;
/// 交易
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4SwapEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
// base in
pub amount_in: u64,
@@ -42,6 +43,7 @@ impl_unified_event!(RaydiumAmmV4SwapEvent,);
/// 添加流动性
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4DepositEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub max_coin_amount: u64,
pub max_pc_amount: u64,
@@ -67,6 +69,7 @@ impl_unified_event!(RaydiumAmmV4DepositEvent,);
/// 初始化
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4Initialize2Event {
#[borsh(skip)]
pub metadata: EventMetadata,
pub nonce: u8,
pub open_time: u64,
@@ -100,6 +103,7 @@ impl_unified_event!(RaydiumAmmV4Initialize2Event,);
/// 移除流动性
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4WithdrawEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub amount: u64,
@@ -131,6 +135,7 @@ impl_unified_event!(RaydiumAmmV4WithdrawEvent,);
/// 提现
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4WithdrawPnlEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub token_program: Pubkey,
@@ -156,11 +161,12 @@ impl_unified_event!(RaydiumAmmV4WithdrawPnlEvent,);
/// 池信息
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumAmmV4AmmInfoAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub amm_info: AmmInfo,
}
@@ -96,10 +96,10 @@ pub fn amm_info_parser(
if let Some(amm_info) = amm_info_decode(&account.data[..AMM_INFO_SIZE]) {
Some(Box::new(RaydiumAmmV4AmmInfoAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
amm_info: amm_info,
}))
@@ -223,10 +223,10 @@ impl_unified_event!(RaydiumClmmOpenPositionV2Event,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct RaydiumClmmAmmConfigAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub amm_config: AmmConfig,
}
@@ -236,10 +236,10 @@ impl_unified_event!(RaydiumClmmAmmConfigAccountEvent,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct RaydiumClmmPoolStateAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub pool_state: PoolState,
}
@@ -249,10 +249,10 @@ impl_unified_event!(RaydiumClmmPoolStateAccountEvent,);
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct RaydiumClmmTickArrayStateAccountEvent {
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub tick_array_state: TickArrayState,
}
@@ -47,10 +47,10 @@ pub fn amm_config_parser(
if let Some(amm_config) = amm_config_decode(&account.data[8..AMM_CONFIG_SIZE + 8]) {
Some(Box::new(RaydiumClmmAmmConfigAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
amm_config: amm_config,
}))
@@ -135,10 +135,10 @@ pub fn pool_state_parser(
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
Some(Box::new(RaydiumClmmPoolStateAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
pool_state: pool_state,
}))
@@ -218,10 +218,10 @@ pub fn tick_array_state_parser(
{
Some(Box::new(RaydiumClmmTickArrayStateAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
tick_array_state: tick_array_state,
}))
@@ -10,6 +10,7 @@ use solana_sdk::pubkey::Pubkey;
/// 交易
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmSwapEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub amount_in: u64,
pub minimum_amount_out: u64,
@@ -35,6 +36,7 @@ impl_unified_event!(RaydiumCpmmSwapEvent,);
/// 存款
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmDepositEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub lp_token_amount: u64,
pub maximum_token0_amount: u64,
@@ -59,6 +61,7 @@ impl_unified_event!(RaydiumCpmmDepositEvent,);
/// 初始化
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmInitializeEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub init_amount0: u64,
pub init_amount1: u64,
@@ -90,6 +93,7 @@ impl_unified_event!(RaydiumCpmmInitializeEvent,);
/// 提款
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmWithdrawEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub lp_token_amount: u64,
pub minimum_token0_amount: u64,
@@ -115,11 +119,12 @@ impl_unified_event!(RaydiumCpmmWithdrawEvent,);
/// 池配置
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmAmmConfigAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub amm_config: AmmConfig,
}
@@ -128,11 +133,12 @@ impl_unified_event!(RaydiumCpmmAmmConfigAccountEvent,);
/// 池状态
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct RaydiumCpmmPoolStateAccountEvent {
#[borsh(skip)]
pub metadata: EventMetadata,
pub pubkey: String,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: String,
pub owner: Pubkey,
pub rent_epoch: u64,
pub pool_state: PoolState,
}
@@ -46,10 +46,10 @@ pub fn amm_config_parser(
if let Some(amm_config) = amm_config_decode(&account.data[8..AMM_CONFIG_SIZE + 8]) {
Some(Box::new(RaydiumCpmmAmmConfigAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
amm_config: amm_config,
}))
@@ -104,10 +104,10 @@ pub fn pool_state_parser(
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
Some(Box::new(RaydiumCpmmPoolStateAccountEvent {
metadata,
pubkey: account.pubkey.to_string(),
pubkey: account.pubkey,
executable: account.executable,
lamports: account.lamports,
owner: account.owner.to_string(),
owner: account.owner,
rent_epoch: account.rent_epoch,
pool_state: pool_state,
}))