Release v1.5.5 parser SDK sync

This commit is contained in:
0xfnzero
2026-06-01 20:20:01 +08:00
parent 5a282bd84d
commit 83c5476ff3
45 changed files with 979 additions and 211 deletions
+70 -36
View File
@@ -136,17 +136,18 @@ pub(crate) fn build_sdk_shred_parse_event_filter(
protocols: &[Protocol],
filter: Option<&EventTypeFilter>,
) -> Option<SdkGrpcEventTypeFilter> {
if protocols.is_empty() {
return build_sdk_parse_event_filter(filter);
}
if let Some(f) = filter.filter(|f| !f.include.is_empty()) {
if let Some(exact) = build_sdk_parse_event_filter(Some(f)) {
return Some(exact);
}
if !f.include_transaction_event() {
return Some(SdkGrpcEventTypeFilter::include_only(Vec::new()));
}
if protocols.is_empty() {
return build_sdk_parse_event_filter(Some(f));
}
if let Some(exact) = build_sdk_parse_event_filter(Some(f)) {
return Some(exact);
}
} else if protocols.is_empty() {
return build_sdk_parse_event_filter(filter);
}
let mut raw = Vec::with_capacity(protocols.len() * 8);
@@ -229,12 +230,12 @@ fn push_streamer_event_sdk_grpc_types(
St::PumpSwapDeposit => out.push(Sdk::PumpSwapLiquidityAdded),
St::PumpSwapWithdraw => out.push(Sdk::PumpSwapLiquidityRemoved),
St::BonkBuyExactIn | St::BonkBuyExactOut | St::BonkSellExactIn | St::BonkSellExactOut => {
out.push(Sdk::BonkTrade)
out.push(Sdk::RaydiumLaunchlabTrade)
}
St::BonkInitialize | St::BonkInitializeV2 | St::BonkInitializeWithToken2022 => {
out.push(Sdk::BonkPoolCreate)
out.push(Sdk::RaydiumLaunchlabPoolCreate)
}
St::BonkMigrateToAmm => out.push(Sdk::BonkMigrateAmm),
St::BonkMigrateToAmm => out.push(Sdk::RaydiumLaunchlabMigrateAmm),
St::RaydiumCpmmSwapBaseInput | St::RaydiumCpmmSwapBaseOutput => {
out.push(Sdk::RaydiumCpmmSwap)
}
@@ -278,8 +279,12 @@ fn push_streamer_event_sdk_grpc_types(
St::MeteoraDammV2Swap | St::MeteoraDammV2Swap2 => out.push(Sdk::MeteoraDammV2Swap),
St::MeteoraDammV2AddLiquidity => out.push(Sdk::MeteoraDammV2AddLiquidity),
St::MeteoraDammV2RemoveLiquidity => out.push(Sdk::MeteoraDammV2RemoveLiquidity),
St::MeteoraDammV2InitializePool => out.push(Sdk::MeteoraDammV2InitializePool),
St::MeteoraDammV2CreatePosition => out.push(Sdk::MeteoraDammV2CreatePosition),
St::MeteoraDammV2ClosePosition => out.push(Sdk::MeteoraDammV2ClosePosition),
St::MeteoraDbcSwap => out.push(Sdk::MeteoraDbcSwap),
St::MeteoraDbcInitializePool => out.push(Sdk::MeteoraDbcInitializePool),
St::MeteoraDbcCurveComplete => out.push(Sdk::MeteoraDbcCurveComplete),
St::MeteoraDlmmSwap => out.push(Sdk::MeteoraDlmmSwap),
St::MeteoraDlmmAddLiquidity => out.push(Sdk::MeteoraDlmmAddLiquidity),
St::MeteoraDlmmRemoveLiquidity => out.push(Sdk::MeteoraDlmmRemoveLiquidity),
@@ -302,6 +307,16 @@ fn push_streamer_event_sdk_grpc_types(
}
St::AccountPumpSwapGlobalConfig => out.push(Sdk::AccountPumpSwapGlobalConfig),
St::AccountPumpSwapPool => out.push(Sdk::AccountPumpSwapPool),
St::AccountRaydiumClmmAmmConfig => out.push(Sdk::AccountRaydiumClmmAmmConfig),
St::AccountRaydiumClmmPoolState => out.push(Sdk::AccountRaydiumClmmPoolState),
St::AccountRaydiumClmmTickArrayState => out.push(Sdk::AccountRaydiumClmmTickArrayState),
St::AccountRaydiumCpmmAmmConfig => out.push(Sdk::AccountRaydiumCpmmAmmConfig),
St::AccountRaydiumCpmmPoolState => out.push(Sdk::AccountRaydiumCpmmPoolState),
St::AccountOrcaWhirlpool => out.push(Sdk::AccountOrcaWhirlpool),
St::AccountOrcaPosition => out.push(Sdk::AccountOrcaPosition),
St::AccountOrcaTickArray => out.push(Sdk::AccountOrcaTickArray),
St::AccountOrcaFeeTier => out.push(Sdk::AccountOrcaFeeTier),
St::AccountOrcaWhirlpoolsConfig => out.push(Sdk::AccountOrcaWhirlpoolsConfig),
_ => return false,
}
true
@@ -351,9 +366,11 @@ fn push_protocol_sdk_grpc_event_types(protocol: &Protocol, out: &mut Vec<SdkGrpc
Sdk::PumpSwapLiquidityAdded,
Sdk::PumpSwapLiquidityRemoved,
]),
StProtocol::Bonk | StProtocol::RaydiumLaunchpad => {
out.extend_from_slice(&[Sdk::BonkTrade, Sdk::BonkPoolCreate, Sdk::BonkMigrateAmm])
}
StProtocol::Bonk | StProtocol::RaydiumLaunchpad => out.extend_from_slice(&[
Sdk::RaydiumLaunchlabTrade,
Sdk::RaydiumLaunchlabPoolCreate,
Sdk::RaydiumLaunchlabMigrateAmm,
]),
StProtocol::RaydiumCpmm => out.extend_from_slice(&[
Sdk::RaydiumCpmmSwap,
Sdk::RaydiumCpmmDeposit,
@@ -390,9 +407,15 @@ fn push_protocol_sdk_grpc_event_types(protocol: &Protocol, out: &mut Vec<SdkGrpc
Sdk::MeteoraDammV2Swap,
Sdk::MeteoraDammV2AddLiquidity,
Sdk::MeteoraDammV2RemoveLiquidity,
Sdk::MeteoraDammV2InitializePool,
Sdk::MeteoraDammV2CreatePosition,
Sdk::MeteoraDammV2ClosePosition,
]),
StProtocol::MeteoraDbc => out.extend_from_slice(&[
Sdk::MeteoraDbcSwap,
Sdk::MeteoraDbcInitializePool,
Sdk::MeteoraDbcCurveComplete,
]),
StProtocol::OrcaWhirlpool => out.extend_from_slice(&[
Sdk::OrcaWhirlpoolSwap,
Sdk::OrcaWhirlpoolLiquidityIncreased,
@@ -499,11 +522,7 @@ mod tests {
#[test]
fn exclude_blocks_even_when_include_empty() {
let f = EventTypeFilter {
include: vec![],
exclude: vec![EventType::PumpFunSell],
..Default::default()
};
let f = EventTypeFilter { include: vec![], exclude: vec![EventType::PumpFunSell] };
let ev = DexEvent::ParserSdkErrorEvent(ParserSdkErrorEvent {
metadata: mk_meta(EventType::PumpFunSell),
message: "x".into(),
@@ -528,7 +547,6 @@ mod tests {
let f = EventTypeFilter {
include: vec![EventType::PumpFunBuy, EventType::PumpFunSell],
exclude: vec![EventType::PumpFunSell],
..Default::default()
};
let buy = DexEvent::ParserSdkErrorEvent(ParserSdkErrorEvent {
metadata: mk_meta(EventType::PumpFunBuy),
@@ -544,11 +562,7 @@ mod tests {
#[test]
fn build_sdk_filter_exclude_only_pumpfun_sell() {
let f = EventTypeFilter {
include: vec![],
exclude: vec![EventType::PumpFunSell],
..Default::default()
};
let f = EventTypeFilter { include: vec![], exclude: vec![EventType::PumpFunSell] };
let sdk_f = build_sdk_parse_event_filter(Some(&f)).expect("mapped");
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunBuy));
assert!(!sdk_f.should_include(SdkGrpcEventType::PumpFunSell));
@@ -725,8 +739,12 @@ mod tests {
EventType::MeteoraDammV2Swap2,
EventType::MeteoraDammV2AddLiquidity,
EventType::MeteoraDammV2RemoveLiquidity,
EventType::MeteoraDammV2InitializePool,
EventType::MeteoraDammV2CreatePosition,
EventType::MeteoraDammV2ClosePosition,
EventType::MeteoraDbcSwap,
EventType::MeteoraDbcInitializePool,
EventType::MeteoraDbcCurveComplete,
EventType::MeteoraDlmmSwap,
EventType::MeteoraDlmmAddLiquidity,
EventType::MeteoraDlmmRemoveLiquidity,
@@ -746,6 +764,16 @@ mod tests {
EventType::AccountPumpFunUserVolumeAccumulator,
EventType::AccountPumpSwapGlobalConfig,
EventType::AccountPumpSwapPool,
EventType::AccountRaydiumClmmAmmConfig,
EventType::AccountRaydiumClmmPoolState,
EventType::AccountRaydiumClmmTickArrayState,
EventType::AccountRaydiumCpmmAmmConfig,
EventType::AccountRaydiumCpmmPoolState,
EventType::AccountOrcaWhirlpool,
EventType::AccountOrcaPosition,
EventType::AccountOrcaTickArray,
EventType::AccountOrcaFeeTier,
EventType::AccountOrcaWhirlpoolsConfig,
];
for event_type in sdk_filter_backed {
@@ -760,7 +788,10 @@ mod tests {
#[test]
fn build_sdk_filter_none_when_public_sdk_filter_enum_cannot_express_requested_type() {
let f = EventTypeFilter {
include: vec![EventType::PumpFunBuy, EventType::MeteoraDammV2InitializePool],
include: vec![
EventType::PumpFunBuy,
EventType::MeteoraDammV2InitializeCustomizablePool,
],
..Default::default()
};
assert!(build_sdk_parse_event_filter(Some(&f)).is_none());
@@ -769,7 +800,7 @@ mod tests {
#[test]
fn build_sdk_shred_filter_falls_back_to_protocol_group_for_sdk_enum_gap() {
let f = EventTypeFilter {
include: vec![EventType::MeteoraDammV2InitializePool],
include: vec![EventType::MeteoraDammV2InitializeCustomizablePool],
..Default::default()
};
let sdk_f =
@@ -792,12 +823,20 @@ mod tests {
}
#[test]
fn build_sdk_filter_exclude_only_orca_maps_upstream() {
fn build_sdk_shred_filter_skips_transaction_parse_for_account_only_without_protocols() {
let f = EventTypeFilter {
include: vec![],
exclude: vec![EventType::OrcaWhirlpoolSwap],
include: vec![EventType::AccountRaydiumClmmPoolState],
..Default::default()
};
let sdk_f = build_sdk_shred_parse_event_filter(&[], Some(&f)).unwrap();
assert!(!sdk_f.should_include(SdkGrpcEventType::RaydiumClmmSwap));
assert!(!sdk_f.should_include(SdkGrpcEventType::PumpFunBuy));
}
#[test]
fn build_sdk_filter_exclude_only_orca_maps_upstream() {
let f = EventTypeFilter { include: vec![], exclude: vec![EventType::OrcaWhirlpoolSwap] };
let sdk_f = build_sdk_parse_event_filter(Some(&f)).expect("mapped");
assert!(!sdk_f.should_include(SdkGrpcEventType::OrcaWhirlpoolSwap));
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunBuy));
@@ -807,19 +846,14 @@ mod tests {
fn build_sdk_filter_exclude_only_none_when_only_sdk_filter_enum_gap() {
let f = EventTypeFilter {
include: vec![],
exclude: vec![EventType::MeteoraDammV2InitializePool],
..Default::default()
exclude: vec![EventType::MeteoraDammV2InitializeCustomizablePool],
};
assert!(build_sdk_parse_event_filter(Some(&f)).is_none());
}
#[test]
fn build_sdk_filter_exclude_only_none_when_only_unmapped_types() {
let f = EventTypeFilter {
include: vec![],
exclude: vec![EventType::SetComputeUnitLimit],
..Default::default()
};
let f = EventTypeFilter { include: vec![], exclude: vec![EventType::SetComputeUnitLimit] };
assert!(build_sdk_parse_event_filter(Some(&f)).is_none());
}
}
@@ -49,6 +49,7 @@ pub enum ProtocolType {
RaydiumClmm,
RaydiumAmmV4,
MeteoraDammV2,
MeteoraDbc,
OrcaWhirlpool,
MeteoraPools,
MeteoraDlmm,
@@ -153,6 +154,11 @@ pub enum EventType {
MeteoraDammV2AddLiquidity,
MeteoraDammV2RemoveLiquidity,
// Meteora DBC
MeteoraDbcSwap,
MeteoraDbcInitializePool,
MeteoraDbcCurveComplete,
// Orca Whirlpool
OrcaWhirlpoolSwap,
OrcaWhirlpoolLiquidityIncreased,
@@ -196,6 +202,11 @@ pub enum EventType {
AccountRaydiumClmmTickArrayState,
AccountRaydiumCpmmAmmConfig,
AccountRaydiumCpmmPoolState,
AccountOrcaWhirlpool,
AccountOrcaPosition,
AccountOrcaTickArray,
AccountOrcaFeeTier,
AccountOrcaWhirlpoolsConfig,
NonceAccount,
TokenAccount,
@@ -228,6 +239,11 @@ pub const ACCOUNT_EVENT_TYPES: &[EventType] = &[
EventType::AccountRaydiumClmmTickArrayState,
EventType::AccountRaydiumCpmmAmmConfig,
EventType::AccountRaydiumCpmmPoolState,
EventType::AccountOrcaWhirlpool,
EventType::AccountOrcaPosition,
EventType::AccountOrcaTickArray,
EventType::AccountOrcaFeeTier,
EventType::AccountOrcaWhirlpoolsConfig,
EventType::TokenAccount,
EventType::TokenInfo,
EventType::NonceAccount,
+10 -3
View File
@@ -70,7 +70,7 @@ impl EventDispatcher {
}
Protocol::PumpFees => all_inner::pump_fees::parse(&disc, inner_instruction_data, pm),
Protocol::Bonk | Protocol::RaydiumLaunchpad => {
all_inner::bonk::parse(&disc, inner_instruction_data, pm)
all_inner::raydium_launchlab::parse(&disc, inner_instruction_data, pm)
}
Protocol::RaydiumCpmm => {
all_inner::raydium_cpmm::parse(&disc, inner_instruction_data, pm)
@@ -86,6 +86,8 @@ impl EventDispatcher {
Protocol::MeteoraDammV2 => {
all_inner::meteora_damm::parse(&disc, inner_instruction_data, pm)
}
// Meteora DBC is currently log-side in sol-parser-sdk; direct inner dispatch is absent.
Protocol::MeteoraDbc => None,
Protocol::OrcaWhirlpool => all_inner::orca::parse(&disc, inner_instruction_data, pm),
Protocol::MeteoraPools => {
all_inner::meteora_amm::parse(&disc, inner_instruction_data, pm)
@@ -108,7 +110,7 @@ impl EventDispatcher {
Some(Protocol::PumpFees)
} else if program_id == &program_ids::PUMPSWAP_PROGRAM_ID {
Some(Protocol::PumpSwap)
} else if program_id == &program_ids::BONK_PROGRAM_ID {
} else if program_id == &program_ids::RAYDIUM_LAUNCHLAB_PROGRAM_ID {
Some(Protocol::Bonk)
} else if program_id == &program_ids::RAYDIUM_CPMM_PROGRAM_ID {
Some(Protocol::RaydiumCpmm)
@@ -118,6 +120,8 @@ impl EventDispatcher {
Some(Protocol::RaydiumAmmV4)
} else if program_id == &program_ids::METEORA_DAMM_V2_PROGRAM_ID {
Some(Protocol::MeteoraDammV2)
} else if program_id == &program_ids::METEORA_DBC_PROGRAM_ID {
Some(Protocol::MeteoraDbc)
} else if program_id == &program_ids::ORCA_WHIRLPOOL_PROGRAM_ID {
Some(Protocol::OrcaWhirlpool)
} else if program_id == &program_ids::METEORA_POOLS_PROGRAM_ID {
@@ -148,11 +152,14 @@ impl EventDispatcher {
Protocol::PumpFun => program_ids::PUMPFUN_PROGRAM_ID,
Protocol::PumpFees => program_ids::PUMP_FEES_PROGRAM_ID,
Protocol::PumpSwap => program_ids::PUMPSWAP_PROGRAM_ID,
Protocol::Bonk | Protocol::RaydiumLaunchpad => program_ids::BONK_PROGRAM_ID,
Protocol::Bonk | Protocol::RaydiumLaunchpad => {
program_ids::RAYDIUM_LAUNCHLAB_PROGRAM_ID
}
Protocol::RaydiumCpmm => program_ids::RAYDIUM_CPMM_PROGRAM_ID,
Protocol::RaydiumClmm => program_ids::RAYDIUM_CLMM_PROGRAM_ID,
Protocol::RaydiumAmmV4 => program_ids::RAYDIUM_AMM_V4_PROGRAM_ID,
Protocol::MeteoraDammV2 => program_ids::METEORA_DAMM_V2_PROGRAM_ID,
Protocol::MeteoraDbc => program_ids::METEORA_DBC_PROGRAM_ID,
Protocol::OrcaWhirlpool => program_ids::ORCA_WHIRLPOOL_PROGRAM_ID,
Protocol::MeteoraPools => program_ids::METEORA_POOLS_PROGRAM_ID,
Protocol::MeteoraDlmm => program_ids::METEORA_DLMM_PROGRAM_ID,
@@ -9,6 +9,7 @@ pub(crate) mod helpers;
pub struct EventParser;
impl EventParser {
#[allow(clippy::too_many_arguments)]
pub async fn parse_grpc_transaction(
protocols: &[crate::streaming::event_parser::Protocol],
event_type_filter: Option<&crate::streaming::event_parser::common::filter::EventTypeFilter>,
@@ -32,7 +33,6 @@ impl EventParser {
let update = yellowstone_grpc_proto::geyser::SubscribeUpdateTransaction {
slot: slot.unwrap_or(0),
transaction: Some(grpc_tx),
..Default::default()
};
let sdk_parse_filter =
crate::streaming::event_parser::common::filter::build_sdk_parse_event_filter(
@@ -1,3 +1,5 @@
#![allow(clippy::single_match)]
use crate::streaming::event_parser::DexEvent;
use solana_sdk::{pubkey, pubkey::Pubkey};
+26 -7
View File
@@ -14,14 +14,16 @@ use crate::streaming::event_parser::protocols::raydium_amm_v4::events::*;
use crate::streaming::event_parser::protocols::raydium_clmm::events::*;
use crate::streaming::event_parser::protocols::raydium_cpmm::events::*;
use crate::streaming::event_parser::protocols::sol_parser_forward::events::{
MeteoraDbcCurveCompleteEvent, MeteoraDbcInitializePoolEvent, MeteoraDbcSwapEvent,
MeteoraDlmmAddLiquidityEvent, MeteoraDlmmClaimFeeEvent, MeteoraDlmmClosePositionEvent,
MeteoraDlmmCreatePositionEvent, MeteoraDlmmInitializeBinArrayEvent,
MeteoraDlmmInitializePoolEvent, MeteoraDlmmRemoveLiquidityEvent, MeteoraDlmmSwapEvent,
MeteoraPoolsAddLiquidityEvent, MeteoraPoolsBootstrapLiquidityEvent,
MeteoraPoolsPoolCreatedEvent, MeteoraPoolsRemoveLiquidityEvent, MeteoraPoolsSetPoolFeesEvent,
MeteoraPoolsSwapEvent, OrcaWhirlpoolLiquidityDecreasedEvent,
MeteoraPoolsSwapEvent, OrcaFeeTierAccountEvent, OrcaPositionAccountEvent,
OrcaTickArrayAccountEvent, OrcaWhirlpoolAccountEvent, OrcaWhirlpoolLiquidityDecreasedEvent,
OrcaWhirlpoolLiquidityIncreasedEvent, OrcaWhirlpoolPoolInitializedEvent,
OrcaWhirlpoolSwapEvent, ParserSdkErrorEvent,
OrcaWhirlpoolSwapEvent, OrcaWhirlpoolsConfigAccountEvent, ParserSdkErrorEvent,
};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
@@ -96,17 +98,17 @@ pub enum DexEvent {
RaydiumClmmCreatePoolEvent(RaydiumClmmCreatePoolEvent),
RaydiumClmmOpenPositionWithToken22NftEvent(RaydiumClmmOpenPositionWithToken22NftEvent),
RaydiumClmmOpenPositionV2Event(RaydiumClmmOpenPositionV2Event),
RaydiumClmmAmmConfigAccountEvent(RaydiumClmmAmmConfigAccountEvent),
RaydiumClmmPoolStateAccountEvent(RaydiumClmmPoolStateAccountEvent),
RaydiumClmmTickArrayStateAccountEvent(RaydiumClmmTickArrayStateAccountEvent),
RaydiumClmmAmmConfigAccountEvent(Box<RaydiumClmmAmmConfigAccountEvent>),
RaydiumClmmPoolStateAccountEvent(Box<RaydiumClmmPoolStateAccountEvent>),
RaydiumClmmTickArrayStateAccountEvent(Box<RaydiumClmmTickArrayStateAccountEvent>),
// Raydium CPMM events
RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent),
RaydiumCpmmDepositEvent(RaydiumCpmmDepositEvent),
RaydiumCpmmWithdrawEvent(RaydiumCpmmWithdrawEvent),
RaydiumCpmmInitializeEvent(RaydiumCpmmInitializeEvent),
RaydiumCpmmAmmConfigAccountEvent(RaydiumCpmmAmmConfigAccountEvent),
RaydiumCpmmPoolStateAccountEvent(RaydiumCpmmPoolStateAccountEvent),
RaydiumCpmmAmmConfigAccountEvent(Box<RaydiumCpmmAmmConfigAccountEvent>),
RaydiumCpmmPoolStateAccountEvent(Box<RaydiumCpmmPoolStateAccountEvent>),
// Meteora DAMM v2 events
MeteoraDammV2SwapEvent(MeteoraDammV2SwapEvent),
@@ -122,10 +124,19 @@ pub enum DexEvent {
MeteoraDammV2CreatePositionEvent(MeteoraDammV2CreatePositionEvent),
MeteoraDammV2ClosePositionEvent(MeteoraDammV2ClosePositionEvent),
MeteoraDbcSwapEvent(MeteoraDbcSwapEvent),
MeteoraDbcInitializePoolEvent(MeteoraDbcInitializePoolEvent),
MeteoraDbcCurveCompleteEvent(MeteoraDbcCurveCompleteEvent),
OrcaWhirlpoolSwapEvent(OrcaWhirlpoolSwapEvent),
OrcaWhirlpoolLiquidityIncreasedEvent(OrcaWhirlpoolLiquidityIncreasedEvent),
OrcaWhirlpoolLiquidityDecreasedEvent(OrcaWhirlpoolLiquidityDecreasedEvent),
OrcaWhirlpoolPoolInitializedEvent(OrcaWhirlpoolPoolInitializedEvent),
OrcaWhirlpoolAccountEvent(Box<OrcaWhirlpoolAccountEvent>),
OrcaPositionAccountEvent(Box<OrcaPositionAccountEvent>),
OrcaTickArrayAccountEvent(Box<OrcaTickArrayAccountEvent>),
OrcaFeeTierAccountEvent(Box<OrcaFeeTierAccountEvent>),
OrcaWhirlpoolsConfigAccountEvent(Box<OrcaWhirlpoolsConfigAccountEvent>),
MeteoraPoolsSwapEvent(MeteoraPoolsSwapEvent),
MeteoraPoolsAddLiquidityEvent(MeteoraPoolsAddLiquidityEvent),
@@ -256,10 +267,18 @@ impl_dex_event_metadata!(
MeteoraDammV2RemoveLiquidityEvent,
MeteoraDammV2CreatePositionEvent,
MeteoraDammV2ClosePositionEvent,
MeteoraDbcSwapEvent,
MeteoraDbcInitializePoolEvent,
MeteoraDbcCurveCompleteEvent,
OrcaWhirlpoolSwapEvent,
OrcaWhirlpoolLiquidityIncreasedEvent,
OrcaWhirlpoolLiquidityDecreasedEvent,
OrcaWhirlpoolPoolInitializedEvent,
OrcaWhirlpoolAccountEvent,
OrcaPositionAccountEvent,
OrcaTickArrayAccountEvent,
OrcaFeeTierAccountEvent,
OrcaWhirlpoolsConfigAccountEvent,
MeteoraPoolsSwapEvent,
MeteoraPoolsAddLiquidityEvent,
MeteoraPoolsRemoveLiquidityEvent,
@@ -3,7 +3,7 @@ use crate::streaming::event_parser::{
};
use solana_sdk::pubkey::Pubkey;
pub use sol_parser_sdk::instr::program_ids::BONK_PROGRAM_ID;
pub use sol_parser_sdk::instr::program_ids::RAYDIUM_LAUNCHLAB_PROGRAM_ID as BONK_PROGRAM_ID;
pub fn parse_bonk_instruction_data(
discriminator: &[u8],
@@ -32,32 +32,22 @@ pub struct VestingParams {
pub unlock_period: u64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub enum AmmFeeOn {
#[default]
QuoteToken,
BothToken,
}
impl Default for AmmFeeOn {
fn default() -> Self {
Self::QuoteToken
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
#[borsh(use_discriminant = true)]
#[repr(u8)]
pub enum AmmCreatorFeeOn {
#[default]
QuoteToken = 0,
BothToken = 1,
}
impl Default for AmmCreatorFeeOn {
fn default() -> Self {
Self::QuoteToken
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct ConstantCurve {
pub supply: u64,
@@ -170,7 +160,7 @@ impl Default for PoolState {
}
}
pub const POOL_STATE_SIZE: usize = 8 + 1 * 5 + 8 * 10 + 32 * 7 + 8 * 8 + 8 * 5 + 1 + 1 + 8 + 54;
pub const POOL_STATE_SIZE: usize = 8 + 5 + 8 * 10 + 32 * 7 + 8 * 8 + 8 * 5 + 1 + 1 + 8 + 54;
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct GlobalConfig {
pub epoch: u64,
@@ -168,10 +168,10 @@ pub mod discriminators {
// 指令鉴别器
pub const SWAP_BASE_IN: &[u8] = &[9];
pub const SWAP_BASE_OUT: &[u8] = &[11];
pub const DEPOSIT: &[u8] = &[03];
pub const INITIALIZE2: &[u8] = &[01];
pub const WITHDRAW: &[u8] = &[04];
pub const WITHDRAW_PNL: &[u8] = &[07];
pub const DEPOSIT: &[u8] = &[3];
pub const INITIALIZE2: &[u8] = &[1];
pub const WITHDRAW: &[u8] = &[4];
pub const WITHDRAW_PNL: &[u8] = &[7];
/// 池信息鉴别器
pub const AMM_INFO: &[u8] = &[6];
@@ -105,7 +105,7 @@ pub struct PoolState {
pub const POOL_STATE_SIZE: usize = 1536;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct TickState {
pub tick: i32,
pub liquidity_net: i128,
@@ -120,24 +120,6 @@ pub struct TickState {
pub padding: [u32; 3],
}
impl Default for TickState {
fn default() -> Self {
Self {
tick: 0,
liquidity_net: 0,
liquidity_gross: 0,
fee_growth_outside0_x64: 0,
fee_growth_outside1_x64: 0,
reward_growths_outside_x64: [0; 3],
order_phase: 0,
orders_amount: 0,
part_filled_orders_remaining: 0,
unfilled_ratio_x64: 0,
padding: [0; 3],
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
pub struct TickArrayState {
pub pool_id: Pubkey,
@@ -69,6 +69,185 @@ pub struct OrcaWhirlpoolPoolInitializedEvent {
pub initial_sqrt_price: u128,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaWhirlpoolAccountEvent {
pub metadata: EventMetadata,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: Pubkey,
pub rent_epoch: u64,
pub whirlpool: OrcaWhirlpoolAccount,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaWhirlpoolAccount {
pub whirlpools_config: Pubkey,
pub whirlpool_bump: u8,
pub tick_spacing: u16,
pub tick_spacing_seed: [u8; 2],
pub fee_rate: u16,
pub protocol_fee_rate: u16,
pub liquidity: u128,
pub sqrt_price: u128,
pub tick_current_index: i32,
pub protocol_fee_owed_a: u64,
pub protocol_fee_owed_b: u64,
pub token_mint_a: Pubkey,
pub token_vault_a: Pubkey,
pub fee_growth_global_a: u128,
pub token_mint_b: Pubkey,
pub token_vault_b: Pubkey,
pub fee_growth_global_b: u128,
pub reward_last_updated_timestamp: u64,
pub reward_infos: [OrcaWhirlpoolRewardInfo; 3],
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaWhirlpoolRewardInfo {
pub mint: Pubkey,
pub vault: Pubkey,
pub authority: Pubkey,
pub emissions_per_second_x64: u128,
pub growth_global_x64: u128,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaPositionAccountEvent {
pub metadata: EventMetadata,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: Pubkey,
pub rent_epoch: u64,
pub position: OrcaPositionAccount,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaPositionAccount {
pub whirlpool: Pubkey,
pub position_mint: Pubkey,
pub liquidity: u128,
pub tick_lower_index: i32,
pub tick_upper_index: i32,
pub fee_growth_checkpoint_a: u128,
pub fee_owed_a: u64,
pub fee_growth_checkpoint_b: u128,
pub fee_owed_b: u64,
pub reward_infos: [OrcaPositionRewardInfo; 3],
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaPositionRewardInfo {
pub growth_inside_checkpoint: u128,
pub amount_owed: u64,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaTickArrayAccountEvent {
pub metadata: EventMetadata,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: Pubkey,
pub rent_epoch: u64,
pub tick_array: OrcaTickArrayAccount,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaTickArrayAccount {
pub start_tick_index: i32,
pub ticks: Vec<OrcaTick>,
pub whirlpool: Pubkey,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaTick {
pub initialized: bool,
pub liquidity_net: i128,
pub liquidity_gross: u128,
pub fee_growth_outside_a: u128,
pub fee_growth_outside_b: u128,
pub reward_growths_outside: [u128; 3],
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaFeeTierAccountEvent {
pub metadata: EventMetadata,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: Pubkey,
pub rent_epoch: u64,
pub fee_tier: OrcaFeeTierAccount,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaFeeTierAccount {
pub whirlpools_config: Pubkey,
pub tick_spacing: u16,
pub default_fee_rate: u16,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaWhirlpoolsConfigAccountEvent {
pub metadata: EventMetadata,
pub pubkey: Pubkey,
pub executable: bool,
pub lamports: u64,
pub owner: Pubkey,
pub rent_epoch: u64,
pub config: OrcaWhirlpoolsConfigAccount,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrcaWhirlpoolsConfigAccount {
pub fee_authority: Pubkey,
pub collect_protocol_fees_authority: Pubkey,
pub reward_emissions_super_authority: Pubkey,
pub default_protocol_fee_rate: u16,
}
// --- Meteora DBC ---
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct MeteoraDbcSwapEvent {
pub metadata: EventMetadata,
pub pool: Pubkey,
pub config: Pubkey,
pub trade_direction: u8,
pub has_referral: bool,
pub amount_in: u64,
pub minimum_amount_out: u64,
pub actual_input_amount: u64,
pub output_amount: u64,
pub next_sqrt_price: u128,
pub trading_fee: u64,
pub protocol_fee: u64,
pub referral_fee: u64,
pub current_timestamp: u64,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct MeteoraDbcInitializePoolEvent {
pub metadata: EventMetadata,
pub pool: Pubkey,
pub config: Pubkey,
pub creator: Pubkey,
pub base_mint: Pubkey,
pub pool_type: u8,
pub activation_point: u64,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct MeteoraDbcCurveCompleteEvent {
pub metadata: EventMetadata,
pub pool: Pubkey,
pub config: Pubkey,
pub base_reserve: u64,
pub quote_reserve: u64,
}
// --- Meteora Pools ---
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
+10 -3
View File
@@ -1,8 +1,9 @@
use anyhow::{anyhow, Result};
use sol_parser_sdk::instr::program_ids::{
BONK_PROGRAM_ID, METEORA_DAMM_V2_PROGRAM_ID, METEORA_DLMM_PROGRAM_ID, METEORA_POOLS_PROGRAM_ID,
ORCA_WHIRLPOOL_PROGRAM_ID, PUMPFUN_PROGRAM_ID, PUMPSWAP_PROGRAM_ID, PUMP_FEES_PROGRAM_ID,
RAYDIUM_AMM_V4_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID, RAYDIUM_CPMM_PROGRAM_ID,
METEORA_DAMM_V2_PROGRAM_ID, METEORA_DBC_PROGRAM_ID, METEORA_DLMM_PROGRAM_ID,
METEORA_POOLS_PROGRAM_ID, ORCA_WHIRLPOOL_PROGRAM_ID, PUMPFUN_PROGRAM_ID, PUMPSWAP_PROGRAM_ID,
PUMP_FEES_PROGRAM_ID, RAYDIUM_AMM_V4_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID,
RAYDIUM_CPMM_PROGRAM_ID, RAYDIUM_LAUNCHLAB_PROGRAM_ID as BONK_PROGRAM_ID,
};
use solana_sdk::pubkey::Pubkey;
@@ -19,6 +20,7 @@ pub enum Protocol {
RaydiumClmm,
RaydiumAmmV4,
MeteoraDammV2,
MeteoraDbc,
OrcaWhirlpool,
MeteoraPools,
MeteoraDlmm,
@@ -36,6 +38,7 @@ impl Protocol {
Protocol::RaydiumClmm => vec![RAYDIUM_CLMM_PROGRAM_ID],
Protocol::RaydiumAmmV4 => vec![RAYDIUM_AMM_V4_PROGRAM_ID],
Protocol::MeteoraDammV2 => vec![METEORA_DAMM_V2_PROGRAM_ID],
Protocol::MeteoraDbc => vec![METEORA_DBC_PROGRAM_ID],
Protocol::OrcaWhirlpool => vec![ORCA_WHIRLPOOL_PROGRAM_ID],
Protocol::MeteoraPools => vec![METEORA_POOLS_PROGRAM_ID],
Protocol::MeteoraDlmm => vec![METEORA_DLMM_PROGRAM_ID],
@@ -55,6 +58,7 @@ impl std::fmt::Display for Protocol {
Protocol::RaydiumClmm => write!(f, "RaydiumClmm"),
Protocol::RaydiumAmmV4 => write!(f, "RaydiumAmmV4"),
Protocol::MeteoraDammV2 => write!(f, "MeteoraDammV2"),
Protocol::MeteoraDbc => write!(f, "MeteoraDbc"),
Protocol::OrcaWhirlpool => write!(f, "OrcaWhirlpool"),
Protocol::MeteoraPools => write!(f, "MeteoraPools"),
Protocol::MeteoraDlmm => write!(f, "MeteoraDlmm"),
@@ -77,6 +81,7 @@ impl std::str::FromStr for Protocol {
"raydiumclmm" | "raydium_clmm" => Ok(Protocol::RaydiumClmm),
"raydiumammv4" | "raydium_amm_v4" => Ok(Protocol::RaydiumAmmV4),
"meteoradammv2" | "meteoradamm_v2" | "meteora_damm_v2" => Ok(Protocol::MeteoraDammV2),
"meteoradbc" | "meteora_dbc" => Ok(Protocol::MeteoraDbc),
"orcawhirlpool" | "orca_whirlpool" | "orca" => Ok(Protocol::OrcaWhirlpool),
"meteorapools" | "meteora_pools" => Ok(Protocol::MeteoraPools),
"meteoradlmm" | "meteora_dlmm" => Ok(Protocol::MeteoraDlmm),
@@ -99,6 +104,7 @@ mod tests {
Protocol::RaydiumClmm,
Protocol::RaydiumAmmV4,
Protocol::MeteoraDammV2,
Protocol::MeteoraDbc,
Protocol::OrcaWhirlpool,
Protocol::MeteoraPools,
Protocol::MeteoraDlmm,
@@ -116,6 +122,7 @@ mod tests {
assert_eq!(Protocol::from_str("raydium_clmm").unwrap(), Protocol::RaydiumClmm);
assert_eq!(Protocol::from_str("raydium_amm_v4").unwrap(), Protocol::RaydiumAmmV4);
assert_eq!(Protocol::from_str("meteora_damm_v2").unwrap(), Protocol::MeteoraDammV2);
assert_eq!(Protocol::from_str("meteora_dbc").unwrap(), Protocol::MeteoraDbc);
assert_eq!(Protocol::from_str("orca_whirlpool").unwrap(), Protocol::OrcaWhirlpool);
assert_eq!(Protocol::from_str("meteora_pools").unwrap(), Protocol::MeteoraPools);
assert_eq!(Protocol::from_str("meteora_dlmm").unwrap(), Protocol::MeteoraDlmm);