mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-14 17:38:05 +00:00
Release v1.5.5 parser SDK sync
This commit is contained in:
@@ -11,7 +11,7 @@ use super::convert_parser_event;
|
||||
use super::filter::event_matches_protocol;
|
||||
|
||||
pub(crate) enum AccountParseResult {
|
||||
Event(DexEvent),
|
||||
Event(Box<DexEvent>),
|
||||
Filtered,
|
||||
Unsupported,
|
||||
}
|
||||
@@ -22,7 +22,7 @@ pub(crate) fn parse_account_event(
|
||||
event_type_filter: Option<&EventTypeFilter>,
|
||||
) -> Option<DexEvent> {
|
||||
match parse_account_event_for_streamer(account, protocols, event_type_filter) {
|
||||
AccountParseResult::Event(event) => Some(event),
|
||||
AccountParseResult::Event(event) => Some(*event),
|
||||
AccountParseResult::Filtered | AccountParseResult::Unsupported => None,
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ pub(crate) fn parse_account_event_for_streamer(
|
||||
return AccountParseResult::Filtered;
|
||||
}
|
||||
normalize_account_event(&mut event, account);
|
||||
AccountParseResult::Event(event)
|
||||
AccountParseResult::Event(Box::new(event))
|
||||
}
|
||||
|
||||
fn build_sdk_account_event_filter(filter: Option<&EventTypeFilter>) -> SdkGrpcEventTypeFilter {
|
||||
@@ -124,6 +124,19 @@ fn streamer_account_event_to_sdk_types(t: &EventType) -> Vec<SdkGrpcEventType> {
|
||||
EventType::AccountRaydiumClmmTickArrayState => {
|
||||
vec![SdkGrpcEventType::AccountRaydiumClmmTickArrayState]
|
||||
}
|
||||
EventType::AccountRaydiumCpmmAmmConfig => {
|
||||
vec![SdkGrpcEventType::AccountRaydiumCpmmAmmConfig]
|
||||
}
|
||||
EventType::AccountRaydiumCpmmPoolState => {
|
||||
vec![SdkGrpcEventType::AccountRaydiumCpmmPoolState]
|
||||
}
|
||||
EventType::AccountOrcaWhirlpool => vec![SdkGrpcEventType::AccountOrcaWhirlpool],
|
||||
EventType::AccountOrcaPosition => vec![SdkGrpcEventType::AccountOrcaPosition],
|
||||
EventType::AccountOrcaTickArray => vec![SdkGrpcEventType::AccountOrcaTickArray],
|
||||
EventType::AccountOrcaFeeTier => vec![SdkGrpcEventType::AccountOrcaFeeTier],
|
||||
EventType::AccountOrcaWhirlpoolsConfig => {
|
||||
vec![SdkGrpcEventType::AccountOrcaWhirlpoolsConfig]
|
||||
}
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -195,6 +208,48 @@ fn normalize_account_event(event: &mut DexEvent, account: &AccountPretty) {
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::RaydiumCpmmAmmConfigAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::RaydiumCpmmPoolStateAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::OrcaWhirlpoolAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::OrcaPositionAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::OrcaTickArrayAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::OrcaFeeTierAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
DexEvent::OrcaWhirlpoolsConfigAccountEvent(e) => {
|
||||
e.executable = account.executable;
|
||||
e.lamports = account.lamports;
|
||||
e.owner = account.owner;
|
||||
e.rent_epoch = account.rent_epoch;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::streaming::event_parser::protocols::pumpswap::events::{
|
||||
};
|
||||
use crate::streaming::event_parser::protocols::pumpswap::types::{GlobalConfig, Pool};
|
||||
use sol_parser_sdk::core::events::{
|
||||
BonkTradeEvent as PbBonkTrade, TradeDirection as PbBonkTradeDirection,
|
||||
RaydiumLaunchlabTradeEvent as PbBonkTrade, TradeDirection as PbBonkTradeDirection,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
@@ -43,7 +43,7 @@ pub(crate) fn sdk_bonk_trade_event_type(
|
||||
/// SDK Bonk trade events do not expose reserves or fee rates; keep those fields at streamer
|
||||
/// defaults.
|
||||
pub(crate) fn bonk_trade_from_parser(
|
||||
b: sol_parser_sdk::core::events::BonkTradeEvent,
|
||||
b: sol_parser_sdk::core::events::RaydiumLaunchlabTradeEvent,
|
||||
meta: EventMetadata,
|
||||
) -> BonkTradeEvent {
|
||||
BonkTradeEvent {
|
||||
@@ -71,7 +71,7 @@ pub(crate) fn bonk_trade_from_parser(
|
||||
}
|
||||
|
||||
pub(crate) fn bonk_pool_create_from_parser(
|
||||
p: sol_parser_sdk::core::events::BonkPoolCreateEvent,
|
||||
p: sol_parser_sdk::core::events::RaydiumLaunchlabPoolCreateEvent,
|
||||
meta: EventMetadata,
|
||||
) -> BonkPoolCreateEvent {
|
||||
BonkPoolCreateEvent {
|
||||
@@ -93,7 +93,7 @@ pub(crate) fn bonk_pool_create_from_parser(
|
||||
}
|
||||
|
||||
pub(crate) fn bonk_migrate_to_amm_from_parser(
|
||||
m: sol_parser_sdk::core::events::BonkMigrateAmmEvent,
|
||||
m: sol_parser_sdk::core::events::RaydiumLaunchlabMigrateAmmEvent,
|
||||
meta: EventMetadata,
|
||||
) -> BonkMigrateToAmmEvent {
|
||||
BonkMigrateToAmmEvent {
|
||||
|
||||
@@ -338,7 +338,7 @@ pub(crate) fn convert_parser_event(
|
||||
Some(DexEvent::PumpSwapWithdrawEvent(pumpswap_liquidity_removed_to_withdraw(r, meta)))
|
||||
}
|
||||
|
||||
PbDexEvent::BonkTrade(b) => {
|
||||
PbDexEvent::RaydiumLaunchlabTrade(b) => {
|
||||
let et = sdk_bonk_trade_event_type(&b);
|
||||
let meta = adapt_pm(
|
||||
b.metadata.clone(),
|
||||
@@ -350,7 +350,7 @@ pub(crate) fn convert_parser_event(
|
||||
);
|
||||
Some(DexEvent::BonkTradeEvent(bonk_trade_from_parser(b, meta)))
|
||||
}
|
||||
PbDexEvent::BonkPoolCreate(p) => {
|
||||
PbDexEvent::RaydiumLaunchlabPoolCreate(p) => {
|
||||
let meta = adapt_pm(
|
||||
p.metadata.clone(),
|
||||
bt,
|
||||
@@ -361,7 +361,7 @@ pub(crate) fn convert_parser_event(
|
||||
);
|
||||
Some(DexEvent::BonkPoolCreateEvent(bonk_pool_create_from_parser(p, meta)))
|
||||
}
|
||||
PbDexEvent::BonkMigrateAmm(m) => {
|
||||
PbDexEvent::RaydiumLaunchlabMigrateAmm(m) => {
|
||||
let meta = adapt_pm(
|
||||
m.metadata.clone(),
|
||||
bt,
|
||||
@@ -422,6 +422,32 @@ pub(crate) fn convert_parser_event(
|
||||
);
|
||||
Some(DexEvent::RaydiumCpmmInitializeEvent(raydium_cpmm_initialize_from_parser(e, meta)))
|
||||
}
|
||||
PbDexEvent::RaydiumCpmmAmmConfigAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::RaydiumCpmm,
|
||||
EventType::AccountRaydiumCpmmAmmConfig,
|
||||
raydium_cpmm_program(),
|
||||
);
|
||||
Some(DexEvent::RaydiumCpmmAmmConfigAccountEvent(Box::new(
|
||||
raydium_cpmm_amm_config_account_from_parser(*e, meta),
|
||||
)))
|
||||
}
|
||||
PbDexEvent::RaydiumCpmmPoolStateAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::RaydiumCpmm,
|
||||
EventType::AccountRaydiumCpmmPoolState,
|
||||
raydium_cpmm_program(),
|
||||
);
|
||||
Some(DexEvent::RaydiumCpmmPoolStateAccountEvent(Box::new(
|
||||
raydium_cpmm_pool_state_account_from_parser(*e, meta),
|
||||
)))
|
||||
}
|
||||
|
||||
PbDexEvent::RaydiumClmmSwap(e) => {
|
||||
let meta = adapt_pm(
|
||||
@@ -651,9 +677,9 @@ pub(crate) fn convert_parser_event(
|
||||
EventType::AccountRaydiumClmmAmmConfig,
|
||||
raydium_clmm_program(),
|
||||
);
|
||||
Some(DexEvent::RaydiumClmmAmmConfigAccountEvent(
|
||||
raydium_clmm_amm_config_account_from_parser(e, meta),
|
||||
))
|
||||
Some(DexEvent::RaydiumClmmAmmConfigAccountEvent(Box::new(
|
||||
raydium_clmm_amm_config_account_from_parser(*e, meta),
|
||||
)))
|
||||
}
|
||||
PbDexEvent::RaydiumClmmPoolStateAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
@@ -664,9 +690,9 @@ pub(crate) fn convert_parser_event(
|
||||
EventType::AccountRaydiumClmmPoolState,
|
||||
raydium_clmm_program(),
|
||||
);
|
||||
Some(DexEvent::RaydiumClmmPoolStateAccountEvent(
|
||||
raydium_clmm_pool_state_account_from_parser(e, meta),
|
||||
))
|
||||
Some(DexEvent::RaydiumClmmPoolStateAccountEvent(Box::new(
|
||||
raydium_clmm_pool_state_account_from_parser(*e, meta),
|
||||
)))
|
||||
}
|
||||
PbDexEvent::RaydiumClmmTickArrayStateAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
@@ -677,9 +703,9 @@ pub(crate) fn convert_parser_event(
|
||||
EventType::AccountRaydiumClmmTickArrayState,
|
||||
raydium_clmm_program(),
|
||||
);
|
||||
Some(DexEvent::RaydiumClmmTickArrayStateAccountEvent(
|
||||
raydium_clmm_tick_array_state_account_from_parser(e, meta),
|
||||
))
|
||||
Some(DexEvent::RaydiumClmmTickArrayStateAccountEvent(Box::new(
|
||||
raydium_clmm_tick_array_state_account_from_parser(*e, meta),
|
||||
)))
|
||||
}
|
||||
|
||||
PbDexEvent::RaydiumAmmV4Swap(e) => {
|
||||
@@ -758,6 +784,19 @@ pub(crate) fn convert_parser_event(
|
||||
);
|
||||
Some(DexEvent::MeteoraDammV2SwapEvent(meteora_damm_v2_swap_from_parser(e, meta)))
|
||||
}
|
||||
PbDexEvent::MeteoraDammV2InitializePool(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::MeteoraDammV2,
|
||||
EventType::MeteoraDammV2InitializePool,
|
||||
meteora_damm_program(),
|
||||
);
|
||||
Some(DexEvent::MeteoraDammV2InitializePoolEvent(
|
||||
meteora_damm_v2_initialize_pool_from_parser(e, meta),
|
||||
))
|
||||
}
|
||||
PbDexEvent::MeteoraDammV2AddLiquidity(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
@@ -811,6 +850,44 @@ pub(crate) fn convert_parser_event(
|
||||
)))
|
||||
}
|
||||
|
||||
PbDexEvent::MeteoraDbcSwap(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::MeteoraDbc,
|
||||
EventType::MeteoraDbcSwap,
|
||||
meteora_dbc_program(),
|
||||
);
|
||||
Some(DexEvent::MeteoraDbcSwapEvent(meteora_dbc_swap_from_pb(e, meta)))
|
||||
}
|
||||
PbDexEvent::MeteoraDbcInitializePool(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::MeteoraDbc,
|
||||
EventType::MeteoraDbcInitializePool,
|
||||
meteora_dbc_program(),
|
||||
);
|
||||
Some(DexEvent::MeteoraDbcInitializePoolEvent(meteora_dbc_initialize_pool_from_pb(
|
||||
e, meta,
|
||||
)))
|
||||
}
|
||||
PbDexEvent::MeteoraDbcCurveComplete(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::MeteoraDbc,
|
||||
EventType::MeteoraDbcCurveComplete,
|
||||
meteora_dbc_program(),
|
||||
);
|
||||
Some(DexEvent::MeteoraDbcCurveCompleteEvent(meteora_dbc_curve_complete_from_pb(
|
||||
e, meta,
|
||||
)))
|
||||
}
|
||||
|
||||
PbDexEvent::TokenAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
@@ -943,6 +1020,71 @@ pub(crate) fn convert_parser_event(
|
||||
e, meta,
|
||||
)))
|
||||
}
|
||||
PbDexEvent::OrcaWhirlpoolAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::OrcaWhirlpool,
|
||||
EventType::AccountOrcaWhirlpool,
|
||||
orca_whirlpool_program(),
|
||||
);
|
||||
Some(DexEvent::OrcaWhirlpoolAccountEvent(Box::new(orca_whirlpool_account_from_pb(
|
||||
*e, meta,
|
||||
))))
|
||||
}
|
||||
PbDexEvent::OrcaPositionAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::OrcaWhirlpool,
|
||||
EventType::AccountOrcaPosition,
|
||||
orca_whirlpool_program(),
|
||||
);
|
||||
Some(DexEvent::OrcaPositionAccountEvent(Box::new(orca_position_account_from_pb(
|
||||
*e, meta,
|
||||
))))
|
||||
}
|
||||
PbDexEvent::OrcaTickArrayAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::OrcaWhirlpool,
|
||||
EventType::AccountOrcaTickArray,
|
||||
orca_whirlpool_program(),
|
||||
);
|
||||
Some(DexEvent::OrcaTickArrayAccountEvent(Box::new(orca_tick_array_account_from_pb(
|
||||
*e, meta,
|
||||
))))
|
||||
}
|
||||
PbDexEvent::OrcaFeeTierAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::OrcaWhirlpool,
|
||||
EventType::AccountOrcaFeeTier,
|
||||
orca_whirlpool_program(),
|
||||
);
|
||||
Some(DexEvent::OrcaFeeTierAccountEvent(Box::new(orca_fee_tier_account_from_pb(
|
||||
*e, meta,
|
||||
))))
|
||||
}
|
||||
PbDexEvent::OrcaWhirlpoolsConfigAccount(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
bt,
|
||||
recv_wall_us,
|
||||
ProtocolType::OrcaWhirlpool,
|
||||
EventType::AccountOrcaWhirlpoolsConfig,
|
||||
orca_whirlpool_program(),
|
||||
);
|
||||
Some(DexEvent::OrcaWhirlpoolsConfigAccountEvent(Box::new(
|
||||
orca_whirlpools_config_account_from_pb(*e, meta),
|
||||
)))
|
||||
}
|
||||
PbDexEvent::MeteoraPoolsSwap(e) => {
|
||||
let meta = adapt_pm(
|
||||
e.metadata.clone(),
|
||||
|
||||
@@ -25,6 +25,7 @@ fn is_protocol_independent_event(ev: &DexEvent) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
fn protocol_matches_event(p: &Protocol, ev: &DexEvent) -> bool {
|
||||
match (p, ev) {
|
||||
(Protocol::PumpFun, DexEvent::PumpFunCreateTokenEvent(_))
|
||||
@@ -122,10 +123,18 @@ fn protocol_matches_event(p: &Protocol, ev: &DexEvent) -> bool {
|
||||
| (Protocol::MeteoraDammV2, DexEvent::MeteoraDammV2RemoveLiquidityEvent(_))
|
||||
| (Protocol::MeteoraDammV2, DexEvent::MeteoraDammV2CreatePositionEvent(_))
|
||||
| (Protocol::MeteoraDammV2, DexEvent::MeteoraDammV2ClosePositionEvent(_)) => true,
|
||||
(Protocol::MeteoraDbc, DexEvent::MeteoraDbcSwapEvent(_))
|
||||
| (Protocol::MeteoraDbc, DexEvent::MeteoraDbcInitializePoolEvent(_))
|
||||
| (Protocol::MeteoraDbc, DexEvent::MeteoraDbcCurveCompleteEvent(_)) => true,
|
||||
(Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolSwapEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolLiquidityIncreasedEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolLiquidityDecreasedEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolPoolInitializedEvent(_)) => true,
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolPoolInitializedEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolAccountEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaPositionAccountEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaTickArrayAccountEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaFeeTierAccountEvent(_))
|
||||
| (Protocol::OrcaWhirlpool, DexEvent::OrcaWhirlpoolsConfigAccountEvent(_)) => true,
|
||||
(Protocol::MeteoraPools, DexEvent::MeteoraPoolsSwapEvent(_))
|
||||
| (Protocol::MeteoraPools, DexEvent::MeteoraPoolsAddLiquidityEvent(_))
|
||||
| (Protocol::MeteoraPools, DexEvent::MeteoraPoolsRemoveLiquidityEvent(_))
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
//! Orca Whirlpool and Meteora Pools / DLMM events with SDK-shaped payloads.
|
||||
use crate::streaming::event_parser::common::EventMetadata;
|
||||
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,
|
||||
OrcaWhirlpoolLiquidityIncreasedEvent, OrcaWhirlpoolPoolInitializedEvent,
|
||||
OrcaWhirlpoolSwapEvent,
|
||||
MeteoraPoolsSwapEvent, OrcaFeeTierAccount, OrcaFeeTierAccountEvent, OrcaPositionAccount,
|
||||
OrcaPositionAccountEvent, OrcaPositionRewardInfo, OrcaTick, OrcaTickArrayAccount,
|
||||
OrcaTickArrayAccountEvent, OrcaWhirlpoolAccount, OrcaWhirlpoolAccountEvent,
|
||||
OrcaWhirlpoolLiquidityDecreasedEvent, OrcaWhirlpoolLiquidityIncreasedEvent,
|
||||
OrcaWhirlpoolPoolInitializedEvent, OrcaWhirlpoolRewardInfo, OrcaWhirlpoolSwapEvent,
|
||||
OrcaWhirlpoolsConfigAccount, OrcaWhirlpoolsConfigAccountEvent,
|
||||
};
|
||||
|
||||
pub(crate) fn orca_swap_from_pb(
|
||||
@@ -85,6 +89,192 @@ pub(crate) fn orca_pool_initialized_from_pb(
|
||||
}
|
||||
}
|
||||
|
||||
fn orca_whirlpool_reward_from_pb(
|
||||
r: sol_parser_sdk::core::events::OrcaWhirlpoolRewardInfo,
|
||||
) -> OrcaWhirlpoolRewardInfo {
|
||||
OrcaWhirlpoolRewardInfo {
|
||||
mint: r.mint,
|
||||
vault: r.vault,
|
||||
authority: r.authority,
|
||||
emissions_per_second_x64: r.emissions_per_second_x64,
|
||||
growth_global_x64: r.growth_global_x64,
|
||||
}
|
||||
}
|
||||
|
||||
fn orca_position_reward_from_pb(
|
||||
r: sol_parser_sdk::core::events::OrcaPositionRewardInfo,
|
||||
) -> OrcaPositionRewardInfo {
|
||||
OrcaPositionRewardInfo {
|
||||
growth_inside_checkpoint: r.growth_inside_checkpoint,
|
||||
amount_owed: r.amount_owed,
|
||||
}
|
||||
}
|
||||
|
||||
fn orca_tick_from_pb(t: sol_parser_sdk::core::events::OrcaTick) -> OrcaTick {
|
||||
OrcaTick {
|
||||
initialized: t.initialized,
|
||||
liquidity_net: t.liquidity_net,
|
||||
liquidity_gross: t.liquidity_gross,
|
||||
fee_growth_outside_a: t.fee_growth_outside_a,
|
||||
fee_growth_outside_b: t.fee_growth_outside_b,
|
||||
reward_growths_outside: t.reward_growths_outside,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn orca_whirlpool_account_from_pb(
|
||||
e: sol_parser_sdk::core::events::OrcaWhirlpoolAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> OrcaWhirlpoolAccountEvent {
|
||||
OrcaWhirlpoolAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
whirlpool: OrcaWhirlpoolAccount {
|
||||
whirlpools_config: e.whirlpool.whirlpools_config,
|
||||
whirlpool_bump: e.whirlpool.whirlpool_bump,
|
||||
tick_spacing: e.whirlpool.tick_spacing,
|
||||
tick_spacing_seed: e.whirlpool.tick_spacing_seed,
|
||||
fee_rate: e.whirlpool.fee_rate,
|
||||
protocol_fee_rate: e.whirlpool.protocol_fee_rate,
|
||||
liquidity: e.whirlpool.liquidity,
|
||||
sqrt_price: e.whirlpool.sqrt_price,
|
||||
tick_current_index: e.whirlpool.tick_current_index,
|
||||
protocol_fee_owed_a: e.whirlpool.protocol_fee_owed_a,
|
||||
protocol_fee_owed_b: e.whirlpool.protocol_fee_owed_b,
|
||||
token_mint_a: e.whirlpool.token_mint_a,
|
||||
token_vault_a: e.whirlpool.token_vault_a,
|
||||
fee_growth_global_a: e.whirlpool.fee_growth_global_a,
|
||||
token_mint_b: e.whirlpool.token_mint_b,
|
||||
token_vault_b: e.whirlpool.token_vault_b,
|
||||
fee_growth_global_b: e.whirlpool.fee_growth_global_b,
|
||||
reward_last_updated_timestamp: e.whirlpool.reward_last_updated_timestamp,
|
||||
reward_infos: e.whirlpool.reward_infos.map(orca_whirlpool_reward_from_pb),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn orca_position_account_from_pb(
|
||||
e: sol_parser_sdk::core::events::OrcaPositionAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> OrcaPositionAccountEvent {
|
||||
OrcaPositionAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
position: OrcaPositionAccount {
|
||||
whirlpool: e.position.whirlpool,
|
||||
position_mint: e.position.position_mint,
|
||||
liquidity: e.position.liquidity,
|
||||
tick_lower_index: e.position.tick_lower_index,
|
||||
tick_upper_index: e.position.tick_upper_index,
|
||||
fee_growth_checkpoint_a: e.position.fee_growth_checkpoint_a,
|
||||
fee_owed_a: e.position.fee_owed_a,
|
||||
fee_growth_checkpoint_b: e.position.fee_growth_checkpoint_b,
|
||||
fee_owed_b: e.position.fee_owed_b,
|
||||
reward_infos: e.position.reward_infos.map(orca_position_reward_from_pb),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn orca_tick_array_account_from_pb(
|
||||
e: sol_parser_sdk::core::events::OrcaTickArrayAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> OrcaTickArrayAccountEvent {
|
||||
OrcaTickArrayAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
tick_array: OrcaTickArrayAccount {
|
||||
start_tick_index: e.tick_array.start_tick_index,
|
||||
ticks: e.tick_array.ticks.into_iter().map(orca_tick_from_pb).collect(),
|
||||
whirlpool: e.tick_array.whirlpool,
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn orca_fee_tier_account_from_pb(
|
||||
e: sol_parser_sdk::core::events::OrcaFeeTierAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> OrcaFeeTierAccountEvent {
|
||||
OrcaFeeTierAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
fee_tier: OrcaFeeTierAccount {
|
||||
whirlpools_config: e.fee_tier.whirlpools_config,
|
||||
tick_spacing: e.fee_tier.tick_spacing,
|
||||
default_fee_rate: e.fee_tier.default_fee_rate,
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn orca_whirlpools_config_account_from_pb(
|
||||
e: sol_parser_sdk::core::events::OrcaWhirlpoolsConfigAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> OrcaWhirlpoolsConfigAccountEvent {
|
||||
OrcaWhirlpoolsConfigAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
config: OrcaWhirlpoolsConfigAccount {
|
||||
fee_authority: e.config.fee_authority,
|
||||
collect_protocol_fees_authority: e.config.collect_protocol_fees_authority,
|
||||
reward_emissions_super_authority: e.config.reward_emissions_super_authority,
|
||||
default_protocol_fee_rate: e.config.default_protocol_fee_rate,
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_dbc_swap_from_pb(
|
||||
e: sol_parser_sdk::core::events::MeteoraDbcSwapEvent,
|
||||
meta: EventMetadata,
|
||||
) -> MeteoraDbcSwapEvent {
|
||||
MeteoraDbcSwapEvent {
|
||||
metadata: meta,
|
||||
pool: e.pool,
|
||||
config: e.config,
|
||||
trade_direction: e.trade_direction,
|
||||
has_referral: e.has_referral,
|
||||
amount_in: e.amount_in,
|
||||
minimum_amount_out: e.minimum_amount_out,
|
||||
actual_input_amount: e.actual_input_amount,
|
||||
output_amount: e.output_amount,
|
||||
next_sqrt_price: e.next_sqrt_price,
|
||||
trading_fee: e.trading_fee,
|
||||
protocol_fee: e.protocol_fee,
|
||||
referral_fee: e.referral_fee,
|
||||
current_timestamp: e.current_timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_dbc_initialize_pool_from_pb(
|
||||
e: sol_parser_sdk::core::events::MeteoraDbcInitializePoolEvent,
|
||||
meta: EventMetadata,
|
||||
) -> MeteoraDbcInitializePoolEvent {
|
||||
MeteoraDbcInitializePoolEvent {
|
||||
metadata: meta,
|
||||
pool: e.pool,
|
||||
config: e.config,
|
||||
creator: e.creator,
|
||||
base_mint: e.base_mint,
|
||||
pool_type: e.pool_type,
|
||||
activation_point: e.activation_point,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_dbc_curve_complete_from_pb(
|
||||
e: sol_parser_sdk::core::events::MeteoraDbcCurveCompleteEvent,
|
||||
meta: EventMetadata,
|
||||
) -> MeteoraDbcCurveCompleteEvent {
|
||||
MeteoraDbcCurveCompleteEvent {
|
||||
metadata: meta,
|
||||
pool: e.pool,
|
||||
config: e.config,
|
||||
base_reserve: e.base_reserve,
|
||||
quote_reserve: e.quote_reserve,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_pools_swap_from_pb(
|
||||
e: sol_parser_sdk::core::events::MeteoraPoolsSwapEvent,
|
||||
meta: EventMetadata,
|
||||
|
||||
@@ -32,6 +32,7 @@ pub(crate) use adapt::{block_timestamp_from_stream_meta, fuse_streamer_ix_ctx};
|
||||
pub(crate) use convert::{adapt_parser_event, adapt_parser_events_list, convert_parser_event};
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::field_reassign_with_default)]
|
||||
mod tests {
|
||||
use super::filter::event_matches_protocol;
|
||||
use super::{adapt_parser_event, convert_parser_event};
|
||||
@@ -40,9 +41,9 @@ mod tests {
|
||||
use crate::streaming::event_parser::core::account_event_parser::TokenInfoEvent;
|
||||
use crate::streaming::event_parser::{DexEvent, Protocol};
|
||||
use sol_parser_sdk::core::events::{
|
||||
BonkTradeEvent as PbBonkTrade, EventMetadata, MeteoraDlmmSwapEvent as PbDlmmSwap,
|
||||
OrcaWhirlpoolSwapEvent as PbOrcaSwap, PumpFunCreateV2TokenEvent as PbPumpCreateV2,
|
||||
PumpFunTradeEvent as PbPumpTrade, TokenInfoEvent as PbTokenInfo,
|
||||
EventMetadata, MeteoraDlmmSwapEvent as PbDlmmSwap, OrcaWhirlpoolSwapEvent as PbOrcaSwap,
|
||||
PumpFunCreateV2TokenEvent as PbPumpCreateV2, PumpFunTradeEvent as PbPumpTrade,
|
||||
RaydiumLaunchlabTradeEvent as PbBonkTrade, TokenInfoEvent as PbTokenInfo,
|
||||
TradeDirection as PbBonkDir,
|
||||
};
|
||||
use sol_parser_sdk::DexEvent as PbDexEvent;
|
||||
@@ -370,7 +371,8 @@ mod tests {
|
||||
trade_direction: PbBonkDir::Buy,
|
||||
exact_in: true,
|
||||
};
|
||||
let dex = convert_parser_event(PbDexEvent::BonkTrade(b), None, 0).expect("convert");
|
||||
let dex =
|
||||
convert_parser_event(PbDexEvent::RaydiumLaunchlabTrade(b), None, 0).expect("convert");
|
||||
match dex {
|
||||
DexEvent::BonkTradeEvent(e) => {
|
||||
assert_eq!(e.metadata.event_type, EventType::BonkBuyExactIn)
|
||||
@@ -391,7 +393,8 @@ mod tests {
|
||||
trade_direction: PbBonkDir::Sell,
|
||||
exact_in: false,
|
||||
};
|
||||
let dex = convert_parser_event(PbDexEvent::BonkTrade(b), None, 0).expect("convert");
|
||||
let dex =
|
||||
convert_parser_event(PbDexEvent::RaydiumLaunchlabTrade(b), None, 0).expect("convert");
|
||||
match dex {
|
||||
DexEvent::BonkTradeEvent(e) => {
|
||||
assert_eq!(e.metadata.event_type, EventType::BonkSellExactOut)
|
||||
|
||||
@@ -12,7 +12,7 @@ pub(crate) fn pump_fees_program() -> Pubkey {
|
||||
program_ids::PUMP_FEES_PROGRAM_ID
|
||||
}
|
||||
pub(crate) fn bonk_program() -> Pubkey {
|
||||
program_ids::BONK_PROGRAM_ID
|
||||
program_ids::RAYDIUM_LAUNCHLAB_PROGRAM_ID
|
||||
}
|
||||
pub(crate) fn raydium_cpmm_program() -> Pubkey {
|
||||
program_ids::RAYDIUM_CPMM_PROGRAM_ID
|
||||
@@ -27,6 +27,10 @@ pub(crate) fn meteora_damm_program() -> Pubkey {
|
||||
program_ids::METEORA_DAMM_V2_PROGRAM_ID
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_dbc_program() -> Pubkey {
|
||||
program_ids::METEORA_DBC_PROGRAM_ID
|
||||
}
|
||||
|
||||
pub(crate) fn orca_whirlpool_program() -> Pubkey {
|
||||
program_ids::ORCA_WHIRLPOOL_PROGRAM_ID
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
use crate::streaming::event_parser::common::EventMetadata;
|
||||
use crate::streaming::event_parser::protocols::meteora_damm_v2::events::{
|
||||
MeteoraDammV2AddLiquidityEvent, MeteoraDammV2ClosePositionEvent,
|
||||
MeteoraDammV2CreatePositionEvent, MeteoraDammV2RemoveLiquidityEvent, MeteoraDammV2SwapEvent,
|
||||
MeteoraDammV2CreatePositionEvent, MeteoraDammV2InitializePoolEvent,
|
||||
MeteoraDammV2RemoveLiquidityEvent, MeteoraDammV2SwapEvent,
|
||||
};
|
||||
use crate::streaming::event_parser::protocols::raydium_amm_v4::events::{
|
||||
RaydiumAmmV4DepositEvent, RaydiumAmmV4Initialize2Event, RaydiumAmmV4SwapEvent,
|
||||
@@ -24,8 +25,11 @@ use crate::streaming::event_parser::protocols::raydium_clmm::types::{
|
||||
RewardInfo as ClmmRewardInfo, TickArrayState as ClmmTickArrayState, TickState as ClmmTickState,
|
||||
};
|
||||
use crate::streaming::event_parser::protocols::raydium_cpmm::events::{
|
||||
RaydiumCpmmDepositEvent, RaydiumCpmmInitializeEvent, RaydiumCpmmSwapEvent,
|
||||
RaydiumCpmmWithdrawEvent,
|
||||
RaydiumCpmmAmmConfigAccountEvent, RaydiumCpmmDepositEvent, RaydiumCpmmInitializeEvent,
|
||||
RaydiumCpmmPoolStateAccountEvent, RaydiumCpmmSwapEvent, RaydiumCpmmWithdrawEvent,
|
||||
};
|
||||
use crate::streaming::event_parser::protocols::raydium_cpmm::types::{
|
||||
AmmConfig as CpmmAmmConfig, PoolState as CpmmPoolState,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
pub(crate) fn meteora_damm_v2_swap_from_parser(
|
||||
@@ -72,6 +76,38 @@ pub(crate) fn meteora_damm_v2_swap_from_parser(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn meteora_damm_v2_initialize_pool_from_parser(
|
||||
e: sol_parser_sdk::core::events::MeteoraDammV2InitializePoolEvent,
|
||||
meta: EventMetadata,
|
||||
) -> MeteoraDammV2InitializePoolEvent {
|
||||
MeteoraDammV2InitializePoolEvent {
|
||||
metadata: meta,
|
||||
pool: e.pool,
|
||||
token_a_mint: e.token_a_mint,
|
||||
token_b_mint: e.token_b_mint,
|
||||
creator: e.creator,
|
||||
payer: e.payer,
|
||||
alpha_vault: e.alpha_vault,
|
||||
sqrt_min_price: e.sqrt_min_price,
|
||||
sqrt_max_price: e.sqrt_max_price,
|
||||
activation_type: e.activation_type,
|
||||
collect_fee_mode: e.collect_fee_mode,
|
||||
liquidity: e.liquidity,
|
||||
sqrt_price: e.sqrt_price,
|
||||
activation_point: e.activation_point.unwrap_or(0),
|
||||
token_a_flag: e.token_a_flag,
|
||||
token_b_flag: e.token_b_flag,
|
||||
token_a_amount: e.token_a_amount,
|
||||
token_b_amount: e.token_b_amount,
|
||||
total_amount_a: e.total_amount_a,
|
||||
total_amount_b: e.total_amount_b,
|
||||
pool_type: e.pool_type,
|
||||
position: e.position,
|
||||
position_nft_mint: e.position_nft_mint,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn raydium_cpmm_swap_from_parser(
|
||||
e: sol_parser_sdk::core::events::RaydiumCpmmSwapEvent,
|
||||
meta: EventMetadata,
|
||||
@@ -164,6 +200,85 @@ pub(crate) fn raydium_cpmm_initialize_from_parser(
|
||||
}
|
||||
}
|
||||
|
||||
fn raydium_cpmm_amm_config_from_parser(
|
||||
c: sol_parser_sdk::core::events::RaydiumCpmmAmmConfig,
|
||||
) -> CpmmAmmConfig {
|
||||
CpmmAmmConfig {
|
||||
bump: c.bump,
|
||||
disable_create_pool: c.disable_create_pool,
|
||||
index: c.index,
|
||||
trade_fee_rate: c.trade_fee_rate,
|
||||
protocol_fee_rate: c.protocol_fee_rate,
|
||||
fund_fee_rate: c.fund_fee_rate,
|
||||
create_pool_fee: c.create_pool_fee,
|
||||
protocol_owner: c.protocol_owner,
|
||||
fund_owner: c.fund_owner,
|
||||
creator_fee_rate: c.creator_fee_rate,
|
||||
padding: c.padding,
|
||||
}
|
||||
}
|
||||
|
||||
fn raydium_cpmm_pool_state_from_parser(
|
||||
p: sol_parser_sdk::core::events::RaydiumCpmmPoolState,
|
||||
) -> CpmmPoolState {
|
||||
CpmmPoolState {
|
||||
amm_config: p.amm_config,
|
||||
pool_creator: p.pool_creator,
|
||||
token_0_vault: p.token_0_vault,
|
||||
token_1_vault: p.token_1_vault,
|
||||
lp_mint: p.lp_mint,
|
||||
token_0_mint: p.token_0_mint,
|
||||
token_1_mint: p.token_1_mint,
|
||||
token_0_program: p.token_0_program,
|
||||
token_1_program: p.token_1_program,
|
||||
observation_key: p.observation_key,
|
||||
auth_bump: p.auth_bump,
|
||||
status: p.status,
|
||||
lp_mint_decimals: p.lp_mint_decimals,
|
||||
mint_0_decimals: p.mint_0_decimals,
|
||||
mint_1_decimals: p.mint_1_decimals,
|
||||
lp_supply: p.lp_supply,
|
||||
protocol_fees_token_0: p.protocol_fees_token_0,
|
||||
protocol_fees_token_1: p.protocol_fees_token_1,
|
||||
fund_fees_token_0: p.fund_fees_token_0,
|
||||
fund_fees_token_1: p.fund_fees_token_1,
|
||||
open_time: p.open_time,
|
||||
recent_epoch: p.recent_epoch,
|
||||
creator_fee_on: p.creator_fee_on,
|
||||
enable_creator_fee: p.enable_creator_fee,
|
||||
padding1: p.padding1,
|
||||
creator_fees_token_0: p.creator_fees_token_0,
|
||||
creator_fees_token_1: p.creator_fees_token_1,
|
||||
padding: p.padding,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn raydium_cpmm_amm_config_account_from_parser(
|
||||
e: sol_parser_sdk::core::events::RaydiumCpmmAmmConfigAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> RaydiumCpmmAmmConfigAccountEvent {
|
||||
RaydiumCpmmAmmConfigAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
owner: super::program_ids::raydium_cpmm_program(),
|
||||
amm_config: raydium_cpmm_amm_config_from_parser(e.amm_config),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn raydium_cpmm_pool_state_account_from_parser(
|
||||
e: sol_parser_sdk::core::events::RaydiumCpmmPoolStateAccountEvent,
|
||||
meta: EventMetadata,
|
||||
) -> RaydiumCpmmPoolStateAccountEvent {
|
||||
RaydiumCpmmPoolStateAccountEvent {
|
||||
metadata: meta,
|
||||
pubkey: e.pubkey,
|
||||
owner: super::program_ids::raydium_cpmm_program(),
|
||||
pool_state: raydium_cpmm_pool_state_from_parser(e.pool_state),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn raydium_amm_v4_swap_from_parser(
|
||||
e: sol_parser_sdk::core::events::RaydiumAmmV4SwapEvent,
|
||||
meta: EventMetadata,
|
||||
|
||||
Reference in New Issue
Block a user