mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-17 02:48:05 +00:00
refactor: rename UnifiedEvent to DexEvent
This commit is contained in:
@@ -80,28 +80,6 @@ pub fn bonk_trade_event_log_decode(data: &[u8]) -> Option<BonkTradeEvent> {
|
||||
borsh::from_slice::<BonkTradeEvent>(&data[..BONK_TRADE_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// Macro to generate UnifiedEvent implementation, specifying the fields to be merged
|
||||
// impl_unified_event!(
|
||||
// BonkTradeEvent,
|
||||
// pool_state,
|
||||
// total_base_sell,
|
||||
// virtual_base,
|
||||
// virtual_quote,
|
||||
// real_base_before,
|
||||
// real_quote_before,
|
||||
// real_base_after,
|
||||
// real_quote_after,
|
||||
// amount_in,
|
||||
// amount_out,
|
||||
// protocol_fee,
|
||||
// platform_fee,
|
||||
// creator_fee,
|
||||
// share_fee,
|
||||
// trade_direction,
|
||||
// pool_status,
|
||||
// exact_in
|
||||
// );
|
||||
|
||||
/// Create pool event
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct BonkPoolCreateEvent {
|
||||
@@ -139,18 +117,6 @@ pub fn bonk_pool_create_event_log_decode(data: &[u8]) -> Option<BonkPoolCreateEv
|
||||
borsh::from_slice::<BonkPoolCreateEvent>(&data[..BONK_POOL_CREATE_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// Macro to generate UnifiedEvent implementation, specifying the fields to be merged
|
||||
// impl_unified_event!(
|
||||
// BonkPoolCreateEvent,
|
||||
// pool_state,
|
||||
// creator,
|
||||
// config,
|
||||
// base_mint_param,
|
||||
// curve_param,
|
||||
// vesting_param,
|
||||
// amm_fee_on
|
||||
// );
|
||||
|
||||
/// Create pool event
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct BonkMigrateToAmmEvent {
|
||||
@@ -225,14 +191,6 @@ pub struct BonkMigrateToAmmEvent {
|
||||
pub rent_program: Pubkey,
|
||||
}
|
||||
|
||||
// Macro to generate UnifiedEvent implementation, specifying the fields to be merged
|
||||
// impl_unified_event!(
|
||||
// BonkMigrateToAmmEvent,
|
||||
// base_lot_size,
|
||||
// quote_lot_size,
|
||||
// market_vault_signer_nonce
|
||||
// );
|
||||
|
||||
// Migrate to CP Swap event
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct BonkMigrateToCpswapEvent {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::streaming::event_parser::{
|
||||
ConstantCurve, CurveParams, FixedCurve, LinearCurve, MintParams, TradeDirection,
|
||||
VestingParams,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
|
||||
/// Bonk Program ID
|
||||
@@ -113,16 +113,16 @@ pub const CONFIGS: &[GenericEventParseConfig] = &[
|
||||
fn parse_pool_create_inner_instruction(
|
||||
data: &[u8],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if let Some(event) = bonk_pool_create_event_log_decode(data) {
|
||||
Some(UnifiedEvent::BonkPoolCreateEvent(BonkPoolCreateEvent { metadata, ..event }))
|
||||
Some(DexEvent::BonkPoolCreateEvent(BonkPoolCreateEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse trade event
|
||||
fn parse_trade_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_trade_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = bonk_trade_event_log_decode(data) {
|
||||
if metadata.event_type == EventType::BonkBuyExactIn
|
||||
|| metadata.event_type == EventType::BonkBuyExactOut
|
||||
@@ -136,7 +136,7 @@ fn parse_trade_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::BonkTradeEvent(BonkTradeEvent { metadata, ..event }))
|
||||
Some(DexEvent::BonkTradeEvent(BonkTradeEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -147,7 +147,7 @@ fn parse_buy_exact_in_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 18 {
|
||||
return None;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ fn parse_buy_exact_in_instruction(
|
||||
let minimum_amount_out = read_u64_le(data, 8)?;
|
||||
let share_fee_rate = read_u64_le(data, 16)?;
|
||||
|
||||
Some(UnifiedEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
Some(DexEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
metadata,
|
||||
amount_in,
|
||||
minimum_amount_out,
|
||||
@@ -185,7 +185,7 @@ fn parse_buy_exact_out_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 18 {
|
||||
return None;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ fn parse_buy_exact_out_instruction(
|
||||
let maximum_amount_in = read_u64_le(data, 8)?;
|
||||
let share_fee_rate = read_u64_le(data, 16)?;
|
||||
|
||||
Some(UnifiedEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
Some(DexEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
metadata,
|
||||
amount_out,
|
||||
maximum_amount_in,
|
||||
@@ -223,7 +223,7 @@ fn parse_sell_exact_in_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 18 {
|
||||
return None;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ fn parse_sell_exact_in_instruction(
|
||||
let minimum_amount_out = read_u64_le(data, 8)?;
|
||||
let share_fee_rate = read_u64_le(data, 16)?;
|
||||
|
||||
Some(UnifiedEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
Some(DexEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
metadata,
|
||||
amount_in,
|
||||
minimum_amount_out,
|
||||
@@ -261,7 +261,7 @@ fn parse_sell_exact_out_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 18 {
|
||||
return None;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ fn parse_sell_exact_out_instruction(
|
||||
let maximum_amount_in = read_u64_le(data, 8)?;
|
||||
let share_fee_rate = read_u64_le(data, 16)?;
|
||||
|
||||
Some(UnifiedEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
Some(DexEvent::BonkTradeEvent(BonkTradeEvent {
|
||||
metadata,
|
||||
amount_out,
|
||||
maximum_amount_in,
|
||||
@@ -300,7 +300,7 @@ fn parse_initialize_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 {
|
||||
return None;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ fn parse_initialize_instruction(
|
||||
let curve_param = parse_curve_params(data, &mut offset)?;
|
||||
let vesting_param = parse_vesting_params(data, &mut offset)?;
|
||||
|
||||
Some(UnifiedEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
Some(DexEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
metadata,
|
||||
payer: accounts[0],
|
||||
creator: accounts[1],
|
||||
@@ -333,7 +333,7 @@ fn parse_initialize_v2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 {
|
||||
return None;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ fn parse_initialize_v2_instruction(
|
||||
let vesting_param = parse_vesting_params(data, &mut offset)?;
|
||||
let amm_fee_on = data[offset];
|
||||
|
||||
Some(UnifiedEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
Some(DexEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
metadata,
|
||||
payer: accounts[0],
|
||||
creator: accounts[1],
|
||||
@@ -372,7 +372,7 @@ fn parse_initialize_with_token_2022_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 {
|
||||
return None;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ fn parse_initialize_with_token_2022_instruction(
|
||||
let vesting_param = parse_vesting_params(data, &mut offset)?;
|
||||
let amm_fee_on = data[offset];
|
||||
|
||||
Some(UnifiedEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
Some(DexEvent::BonkPoolCreateEvent(BonkPoolCreateEvent {
|
||||
metadata,
|
||||
payer: accounts[0],
|
||||
creator: accounts[1],
|
||||
@@ -516,7 +516,7 @@ fn parse_migrate_to_amm_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 {
|
||||
return None;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ fn parse_migrate_to_amm_instruction(
|
||||
let quote_lot_size = u64::from_le_bytes(data[8..16].try_into().unwrap());
|
||||
let market_vault_signer_nonce = data[16];
|
||||
|
||||
Some(UnifiedEvent::BonkMigrateToAmmEvent(BonkMigrateToAmmEvent {
|
||||
Some(DexEvent::BonkMigrateToAmmEvent(BonkMigrateToAmmEvent {
|
||||
metadata,
|
||||
base_lot_size,
|
||||
quote_lot_size,
|
||||
@@ -571,8 +571,8 @@ fn parse_migrate_to_cpswap_instruction(
|
||||
_data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
Some(UnifiedEvent::BonkMigrateToCpswapEvent(BonkMigrateToCpswapEvent {
|
||||
) -> Option<DexEvent> {
|
||||
Some(DexEvent::BonkMigrateToCpswapEvent(BonkMigrateToCpswapEvent {
|
||||
metadata,
|
||||
payer: accounts[0],
|
||||
base_mint: accounts[1],
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::streaming::{
|
||||
protocols::bonk::{
|
||||
BonkGlobalConfigAccountEvent, BonkPlatformConfigAccountEvent, BonkPoolStateAccountEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -132,12 +132,12 @@ pub fn pool_state_decode(data: &[u8]) -> Option<PoolState> {
|
||||
borsh::from_slice::<PoolState>(&data[..POOL_STATE_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < POOL_STATE_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
|
||||
Some(UnifiedEvent::BonkPoolStateAccountEvent(BonkPoolStateAccountEvent {
|
||||
Some(DexEvent::BonkPoolStateAccountEvent(BonkPoolStateAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -183,12 +183,12 @@ pub fn global_config_decode(data: &[u8]) -> Option<GlobalConfig> {
|
||||
pub fn global_config_parser(
|
||||
account: &AccountPretty,
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if account.data.len() < GLOBAL_CONFIG_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(global_config) = global_config_decode(&account.data[8..GLOBAL_CONFIG_SIZE + 8]) {
|
||||
Some(UnifiedEvent::BonkGlobalConfigAccountEvent(BonkGlobalConfigAccountEvent {
|
||||
Some(DexEvent::BonkGlobalConfigAccountEvent(BonkGlobalConfigAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -229,14 +229,14 @@ pub fn platform_config_decode(data: &[u8]) -> Option<PlatformConfig> {
|
||||
pub fn platform_config_parser(
|
||||
account: &AccountPretty,
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if account.data.len() < PLATFORM_CONFIG_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(platform_config) =
|
||||
platform_config_decode(&account.data[8..PLATFORM_CONFIG_SIZE + 8])
|
||||
{
|
||||
Some(UnifiedEvent::BonkPlatformConfigAccountEvent(BonkPlatformConfigAccountEvent {
|
||||
Some(DexEvent::BonkPlatformConfigAccountEvent(BonkPlatformConfigAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
|
||||
@@ -36,19 +36,6 @@ pub fn pumpfun_create_token_event_log_decode(data: &[u8]) -> Option<PumpFunCreat
|
||||
borsh::from_slice::<PumpFunCreateTokenEvent>(&data[..PUMPFUN_CREATE_TOKEN_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpFunCreateTokenEvent,
|
||||
// mint,
|
||||
// bonding_curve,
|
||||
// user,
|
||||
// creator,
|
||||
// timestamp,
|
||||
// virtual_token_reserves,
|
||||
// virtual_sol_reserves,
|
||||
// real_token_reserves,
|
||||
// token_total_supply
|
||||
// );
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpFunTradeEvent {
|
||||
#[borsh(skip)]
|
||||
@@ -125,26 +112,6 @@ pub fn pumpfun_trade_event_log_decode(data: &[u8]) -> Option<PumpFunTradeEvent>
|
||||
borsh::from_slice::<PumpFunTradeEvent>(&data[..PUMPFUN_TRADE_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpFunTradeEvent,
|
||||
// mint,
|
||||
// sol_amount,
|
||||
// token_amount,
|
||||
// is_buy,
|
||||
// user,
|
||||
// timestamp,
|
||||
// virtual_sol_reserves,
|
||||
// virtual_token_reserves,
|
||||
// real_sol_reserves,
|
||||
// real_token_reserves,
|
||||
// fee_recipient,
|
||||
// fee_basis_points,
|
||||
// fee,
|
||||
// creator,
|
||||
// creator_fee_basis_points,
|
||||
// creator_fee
|
||||
// );
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpFunMigrateEvent {
|
||||
#[borsh(skip)]
|
||||
@@ -210,18 +177,6 @@ pub fn pumpfun_migrate_event_log_decode(data: &[u8]) -> Option<PumpFunMigrateEve
|
||||
borsh::from_slice::<PumpFunMigrateEvent>(&data[..PUMPFUN_MIGRATE_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpFunMigrateEvent,
|
||||
// user,
|
||||
// mint,
|
||||
// mint_amount,
|
||||
// sol_amount,
|
||||
// pool_migration_fee,
|
||||
// bonding_curve,
|
||||
// timestamp,
|
||||
// pool
|
||||
// );
|
||||
|
||||
/// 铸币曲线
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpFunBondingCurveAccountEvent {
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::streaming::event_parser::{
|
||||
pumpfun_trade_event_log_decode, PumpFunCreateTokenEvent, PumpFunMigrateEvent,
|
||||
PumpFunTradeEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
@@ -60,9 +60,9 @@ pub const CONFIGS: &[GenericEventParseConfig] = &[
|
||||
];
|
||||
|
||||
/// 解析迁移事件
|
||||
fn parse_migrate_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_migrate_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pumpfun_migrate_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpFunMigrateEvent(PumpFunMigrateEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpFunMigrateEvent(PumpFunMigrateEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -72,18 +72,18 @@ fn parse_migrate_inner_instruction(data: &[u8], metadata: EventMetadata) -> Opti
|
||||
fn parse_create_token_inner_instruction(
|
||||
data: &[u8],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if let Some(event) = pumpfun_create_token_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpFunCreateTokenEvent(PumpFunCreateTokenEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpFunCreateTokenEvent(PumpFunCreateTokenEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// 解析交易事件
|
||||
fn parse_trade_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_trade_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pumpfun_trade_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpFunTradeEvent(PumpFunTradeEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpFunTradeEvent(PumpFunTradeEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -94,7 +94,7 @@ fn parse_create_token_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ fn parse_create_token_instruction(
|
||||
Pubkey::default()
|
||||
};
|
||||
|
||||
Some(UnifiedEvent::PumpFunCreateTokenEvent(PumpFunCreateTokenEvent {
|
||||
Some(DexEvent::PumpFunCreateTokenEvent(PumpFunCreateTokenEvent {
|
||||
metadata,
|
||||
name: name.to_string(),
|
||||
symbol: symbol.to_string(),
|
||||
@@ -155,13 +155,13 @@ fn parse_buy_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
let amount = u64::from_le_bytes(data[0..8].try_into().unwrap());
|
||||
let max_sol_cost = u64::from_le_bytes(data[8..16].try_into().unwrap());
|
||||
Some(UnifiedEvent::PumpFunTradeEvent(PumpFunTradeEvent {
|
||||
Some(DexEvent::PumpFunTradeEvent(PumpFunTradeEvent {
|
||||
metadata,
|
||||
global: accounts[0],
|
||||
fee_recipient: accounts[1],
|
||||
@@ -189,13 +189,13 @@ fn parse_sell_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
let amount = u64::from_le_bytes(data[0..8].try_into().unwrap());
|
||||
let min_sol_output = u64::from_le_bytes(data[8..16].try_into().unwrap());
|
||||
Some(UnifiedEvent::PumpFunTradeEvent(PumpFunTradeEvent {
|
||||
Some(DexEvent::PumpFunTradeEvent(PumpFunTradeEvent {
|
||||
metadata,
|
||||
global: accounts[0],
|
||||
fee_recipient: accounts[1],
|
||||
@@ -223,11 +223,11 @@ fn parse_migrate_instruction(
|
||||
_data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if accounts.len() < 24 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::PumpFunMigrateEvent(PumpFunMigrateEvent {
|
||||
Some(DexEvent::PumpFunMigrateEvent(PumpFunMigrateEvent {
|
||||
metadata,
|
||||
global: accounts[0],
|
||||
withdraw_authority: accounts[1],
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::streaming::{
|
||||
event_parser::{
|
||||
common::EventMetadata,
|
||||
protocols::pumpfun::{PumpFunBondingCurveAccountEvent, PumpFunGlobalAccountEvent},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -34,12 +34,12 @@ pub fn bonding_curve_decode(data: &[u8]) -> Option<BondingCurve> {
|
||||
pub fn bonding_curve_parser(
|
||||
account: &AccountPretty,
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if account.data.len() < BONDING_CURVE_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(bonding_curve) = bonding_curve_decode(&account.data[8..BONDING_CURVE_SIZE + 8]) {
|
||||
Some(UnifiedEvent::PumpFunBondingCurveAccountEvent(PumpFunBondingCurveAccountEvent {
|
||||
Some(DexEvent::PumpFunBondingCurveAccountEvent(PumpFunBondingCurveAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -81,12 +81,12 @@ pub fn global_decode(data: &[u8]) -> Option<Global> {
|
||||
borsh::from_slice::<Global>(&data[..GLOBAL_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn global_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn global_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < GLOBAL_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(global) = global_decode(&account.data[8..GLOBAL_SIZE + 8]) {
|
||||
Some(UnifiedEvent::PumpFunGlobalAccountEvent(PumpFunGlobalAccountEvent {
|
||||
Some(DexEvent::PumpFunGlobalAccountEvent(PumpFunGlobalAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
|
||||
@@ -65,34 +65,6 @@ pub fn pump_swap_buy_event_log_decode(data: &[u8]) -> Option<PumpSwapBuyEvent> {
|
||||
borsh::from_slice::<PumpSwapBuyEvent>(&data[..PUMP_SWAP_BUY_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// 使用宏生成UnifiedEvent实现,指定需要合并的字段
|
||||
// impl_unified_event!(
|
||||
// PumpSwapBuyEvent,
|
||||
// timestamp,
|
||||
// base_amount_out,
|
||||
// max_quote_amount_in,
|
||||
// user_base_token_reserves,
|
||||
// user_quote_token_reserves,
|
||||
// pool_base_token_reserves,
|
||||
// pool_quote_token_reserves,
|
||||
// quote_amount_in,
|
||||
// lp_fee_basis_points,
|
||||
// lp_fee,
|
||||
// protocol_fee_basis_points,
|
||||
// protocol_fee,
|
||||
// quote_amount_in_with_lp_fee,
|
||||
// user_quote_amount_in,
|
||||
// pool,
|
||||
// user,
|
||||
// user_base_token_account,
|
||||
// user_quote_token_account,
|
||||
// protocol_fee_recipient,
|
||||
// protocol_fee_recipient_token_account,
|
||||
// coin_creator,
|
||||
// coin_creator_fee_basis_points,
|
||||
// coin_creator_fee
|
||||
// );
|
||||
|
||||
/// 卖出事件
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpSwapSellEvent {
|
||||
@@ -148,34 +120,6 @@ pub fn pump_swap_sell_event_log_decode(data: &[u8]) -> Option<PumpSwapSellEvent>
|
||||
borsh::from_slice::<PumpSwapSellEvent>(&data[..PUMP_SWAP_SELL_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// 使用宏生成UnifiedEvent实现,指定需要合并的字段
|
||||
// impl_unified_event!(
|
||||
// PumpSwapSellEvent,
|
||||
// timestamp,
|
||||
// base_amount_in,
|
||||
// min_quote_amount_out,
|
||||
// user_base_token_reserves,
|
||||
// user_quote_token_reserves,
|
||||
// pool_base_token_reserves,
|
||||
// pool_quote_token_reserves,
|
||||
// quote_amount_out,
|
||||
// lp_fee_basis_points,
|
||||
// lp_fee,
|
||||
// protocol_fee_basis_points,
|
||||
// protocol_fee,
|
||||
// quote_amount_out_without_lp_fee,
|
||||
// user_quote_amount_out,
|
||||
// pool,
|
||||
// user,
|
||||
// user_base_token_account,
|
||||
// user_quote_token_account,
|
||||
// protocol_fee_recipient,
|
||||
// protocol_fee_recipient_token_account,
|
||||
// coin_creator,
|
||||
// coin_creator_fee_basis_points,
|
||||
// coin_creator_fee
|
||||
// );
|
||||
|
||||
/// 创建池子事件
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpSwapCreatePoolEvent {
|
||||
@@ -218,30 +162,6 @@ pub fn pump_swap_create_pool_event_log_decode(data: &[u8]) -> Option<PumpSwapCre
|
||||
borsh::from_slice::<PumpSwapCreatePoolEvent>(&data[..PUMP_SWAP_CREATE_POOL_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpSwapCreatePoolEvent,
|
||||
// timestamp,
|
||||
// index,
|
||||
// creator,
|
||||
// base_mint,
|
||||
// quote_mint,
|
||||
// base_mint_decimals,
|
||||
// quote_mint_decimals,
|
||||
// base_amount_in,
|
||||
// quote_amount_in,
|
||||
// pool_base_amount,
|
||||
// pool_quote_amount,
|
||||
// minimum_liquidity,
|
||||
// initial_liquidity,
|
||||
// lp_token_amount_out,
|
||||
// pool_bump,
|
||||
// pool,
|
||||
// lp_mint,
|
||||
// user_base_token_account,
|
||||
// user_quote_token_account,
|
||||
// coin_creator
|
||||
// );
|
||||
|
||||
/// 存款事件
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpSwapDepositEvent {
|
||||
@@ -282,26 +202,6 @@ pub fn pump_swap_deposit_event_log_decode(data: &[u8]) -> Option<PumpSwapDeposit
|
||||
borsh::from_slice::<PumpSwapDepositEvent>(&data[..PUMP_SWAP_DEPOSIT_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpSwapDepositEvent,
|
||||
// timestamp,
|
||||
// lp_token_amount_out,
|
||||
// max_base_amount_in,
|
||||
// max_quote_amount_in,
|
||||
// user_base_token_reserves,
|
||||
// user_quote_token_reserves,
|
||||
// pool_base_token_reserves,
|
||||
// pool_quote_token_reserves,
|
||||
// base_amount_in,
|
||||
// quote_amount_in,
|
||||
// lp_mint_supply,
|
||||
// pool,
|
||||
// user,
|
||||
// user_base_token_account,
|
||||
// user_quote_token_account,
|
||||
// user_pool_token_account
|
||||
// );
|
||||
|
||||
/// 提款事件
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpSwapWithdrawEvent {
|
||||
@@ -342,26 +242,6 @@ pub fn pump_swap_withdraw_event_log_decode(data: &[u8]) -> Option<PumpSwapWithdr
|
||||
borsh::from_slice::<PumpSwapWithdrawEvent>(&data[..PUMP_SWAP_WITHDRAW_EVENT_LOG_SIZE]).ok()
|
||||
}
|
||||
|
||||
// impl_unified_event!(
|
||||
// PumpSwapWithdrawEvent,
|
||||
// timestamp,
|
||||
// lp_token_amount_in,
|
||||
// min_base_amount_out,
|
||||
// min_quote_amount_out,
|
||||
// user_base_token_reserves,
|
||||
// user_quote_token_reserves,
|
||||
// pool_base_token_reserves,
|
||||
// pool_quote_token_reserves,
|
||||
// base_amount_out,
|
||||
// quote_amount_out,
|
||||
// lp_mint_supply,
|
||||
// pool,
|
||||
// user,
|
||||
// user_base_token_account,
|
||||
// user_quote_token_account,
|
||||
// user_pool_token_account
|
||||
// );
|
||||
|
||||
/// 全局配置
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
||||
pub struct PumpSwapGlobalConfigAccountEvent {
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::streaming::event_parser::{
|
||||
pump_swap_withdraw_event_log_decode, PumpSwapBuyEvent, PumpSwapCreatePoolEvent,
|
||||
PumpSwapDepositEvent, PumpSwapSellEvent, PumpSwapWithdrawEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
@@ -70,18 +70,18 @@ pub const CONFIGS: &[GenericEventParseConfig] = &[
|
||||
];
|
||||
|
||||
/// 解析买入日志事件
|
||||
fn parse_buy_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_buy_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pump_swap_buy_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpSwapBuyEvent(PumpSwapBuyEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpSwapBuyEvent(PumpSwapBuyEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// 解析卖出日志事件
|
||||
fn parse_sell_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_sell_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pump_swap_sell_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpSwapSellEvent(PumpSwapSellEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpSwapSellEvent(PumpSwapSellEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -91,27 +91,27 @@ fn parse_sell_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<
|
||||
fn parse_create_pool_inner_instruction(
|
||||
data: &[u8],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if let Some(event) = pump_swap_create_pool_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// 解析存款日志事件
|
||||
fn parse_deposit_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_deposit_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pump_swap_deposit_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpSwapDepositEvent(PumpSwapDepositEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpSwapDepositEvent(PumpSwapDepositEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// 解析提款日志事件
|
||||
fn parse_withdraw_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
fn parse_withdraw_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if let Some(event) = pump_swap_withdraw_event_log_decode(data) {
|
||||
Some(UnifiedEvent::PumpSwapWithdrawEvent(PumpSwapWithdrawEvent { metadata, ..event }))
|
||||
Some(DexEvent::PumpSwapWithdrawEvent(PumpSwapWithdrawEvent { metadata, ..event }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -122,7 +122,7 @@ fn parse_buy_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ fn parse_buy_instruction(
|
||||
let base_amount_out = read_u64_le(data, 0)?;
|
||||
let max_quote_amount_in = read_u64_le(data, 8)?;
|
||||
|
||||
Some(UnifiedEvent::PumpSwapBuyEvent(PumpSwapBuyEvent {
|
||||
Some(DexEvent::PumpSwapBuyEvent(PumpSwapBuyEvent {
|
||||
metadata,
|
||||
base_amount_out,
|
||||
max_quote_amount_in,
|
||||
@@ -157,7 +157,7 @@ fn parse_sell_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ fn parse_sell_instruction(
|
||||
let base_amount_in = read_u64_le(data, 0)?;
|
||||
let min_quote_amount_out = read_u64_le(data, 8)?;
|
||||
|
||||
Some(UnifiedEvent::PumpSwapSellEvent(PumpSwapSellEvent {
|
||||
Some(DexEvent::PumpSwapSellEvent(PumpSwapSellEvent {
|
||||
metadata,
|
||||
base_amount_in,
|
||||
min_quote_amount_out,
|
||||
@@ -192,7 +192,7 @@ fn parse_create_pool_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 18 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ fn parse_create_pool_instruction(
|
||||
Pubkey::default()
|
||||
};
|
||||
|
||||
Some(UnifiedEvent::PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent {
|
||||
Some(DexEvent::PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent {
|
||||
metadata,
|
||||
index,
|
||||
base_amount_in,
|
||||
@@ -231,7 +231,7 @@ fn parse_deposit_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ fn parse_deposit_instruction(
|
||||
let max_base_amount_in = u64::from_le_bytes(data[8..16].try_into().ok()?);
|
||||
let max_quote_amount_in = u64::from_le_bytes(data[16..24].try_into().ok()?);
|
||||
|
||||
Some(UnifiedEvent::PumpSwapDepositEvent(PumpSwapDepositEvent {
|
||||
Some(DexEvent::PumpSwapDepositEvent(PumpSwapDepositEvent {
|
||||
metadata,
|
||||
lp_token_amount_out,
|
||||
max_base_amount_in,
|
||||
@@ -263,7 +263,7 @@ fn parse_withdraw_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 11 {
|
||||
return None;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ fn parse_withdraw_instruction(
|
||||
let min_base_amount_out = u64::from_le_bytes(data[8..16].try_into().ok()?);
|
||||
let min_quote_amount_out = u64::from_le_bytes(data[16..24].try_into().ok()?);
|
||||
|
||||
Some(UnifiedEvent::PumpSwapWithdrawEvent(PumpSwapWithdrawEvent {
|
||||
Some(DexEvent::PumpSwapWithdrawEvent(PumpSwapWithdrawEvent {
|
||||
metadata,
|
||||
lp_token_amount_in,
|
||||
min_base_amount_out,
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::streaming::{
|
||||
event_parser::{
|
||||
common::EventMetadata,
|
||||
protocols::pumpswap::{PumpSwapGlobalConfigAccountEvent, PumpSwapPoolAccountEvent},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -34,12 +34,12 @@ pub fn global_config_decode(data: &[u8]) -> Option<GlobalConfig> {
|
||||
pub fn global_config_parser(
|
||||
account: &AccountPretty,
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if account.data.len() < GLOBAL_CONFIG_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(config) = global_config_decode(&account.data[8..GLOBAL_CONFIG_SIZE + 8]) {
|
||||
Some(UnifiedEvent::PumpSwapGlobalConfigAccountEvent(PumpSwapGlobalConfigAccountEvent {
|
||||
Some(DexEvent::PumpSwapGlobalConfigAccountEvent(PumpSwapGlobalConfigAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -76,12 +76,12 @@ pub fn pool_decode(data: &[u8]) -> Option<Pool> {
|
||||
borsh::from_slice::<Pool>(&data[..POOL_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn pool_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < POOL_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(pool) = pool_decode(&account.data[8..POOL_SIZE + 8]) {
|
||||
Some(UnifiedEvent::PumpSwapPoolAccountEvent(PumpSwapPoolAccountEvent {
|
||||
Some(DexEvent::PumpSwapPoolAccountEvent(PumpSwapPoolAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::streaming::event_parser::{
|
||||
discriminators, RaydiumAmmV4DepositEvent, RaydiumAmmV4Initialize2Event,
|
||||
RaydiumAmmV4SwapEvent, RaydiumAmmV4WithdrawEvent, RaydiumAmmV4WithdrawPnlEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
@@ -82,12 +82,12 @@ fn parse_withdraw_pnl_instruction(
|
||||
_data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if accounts.len() < 17 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4WithdrawPnlEvent(RaydiumAmmV4WithdrawPnlEvent {
|
||||
Some(DexEvent::RaydiumAmmV4WithdrawPnlEvent(RaydiumAmmV4WithdrawPnlEvent {
|
||||
metadata,
|
||||
token_program: accounts[0],
|
||||
amm: accounts[1],
|
||||
@@ -114,13 +114,13 @@ fn parse_withdraw_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 8 || accounts.len() < 22 {
|
||||
return None;
|
||||
}
|
||||
let amount = read_u64_le(data, 0)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4WithdrawEvent(RaydiumAmmV4WithdrawEvent {
|
||||
Some(DexEvent::RaydiumAmmV4WithdrawEvent(RaydiumAmmV4WithdrawEvent {
|
||||
metadata,
|
||||
amount,
|
||||
|
||||
@@ -154,7 +154,7 @@ fn parse_initialize2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 25 || accounts.len() < 21 {
|
||||
return None;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ fn parse_initialize2_instruction(
|
||||
let init_pc_amount = read_u64_le(data, 9)?;
|
||||
let init_coin_amount = read_u64_le(data, 17)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4Initialize2Event(RaydiumAmmV4Initialize2Event {
|
||||
Some(DexEvent::RaydiumAmmV4Initialize2Event(RaydiumAmmV4Initialize2Event {
|
||||
metadata,
|
||||
nonce,
|
||||
open_time,
|
||||
@@ -199,7 +199,7 @@ fn parse_deposit_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 14 {
|
||||
return None;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ fn parse_deposit_instruction(
|
||||
let max_pc_amount = read_u64_le(data, 8)?;
|
||||
let base_side = read_u64_le(data, 16)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4DepositEvent(RaydiumAmmV4DepositEvent {
|
||||
Some(DexEvent::RaydiumAmmV4DepositEvent(RaydiumAmmV4DepositEvent {
|
||||
metadata,
|
||||
max_coin_amount,
|
||||
max_pc_amount,
|
||||
@@ -235,7 +235,7 @@ fn parse_swap_base_output_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 17 {
|
||||
return None;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ fn parse_swap_base_output_instruction(
|
||||
accounts.insert(4, Pubkey::default());
|
||||
}
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4SwapEvent(RaydiumAmmV4SwapEvent {
|
||||
Some(DexEvent::RaydiumAmmV4SwapEvent(RaydiumAmmV4SwapEvent {
|
||||
metadata,
|
||||
max_amount_in,
|
||||
amount_out,
|
||||
@@ -282,7 +282,7 @@ fn parse_swap_base_input_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 17 {
|
||||
return None;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ fn parse_swap_base_input_instruction(
|
||||
accounts.insert(4, Pubkey::default());
|
||||
}
|
||||
|
||||
Some(UnifiedEvent::RaydiumAmmV4SwapEvent(RaydiumAmmV4SwapEvent {
|
||||
Some(DexEvent::RaydiumAmmV4SwapEvent(RaydiumAmmV4SwapEvent {
|
||||
metadata,
|
||||
amount_in,
|
||||
minimum_amount_out,
|
||||
|
||||
@@ -5,7 +5,7 @@ use solana_sdk::pubkey::Pubkey;
|
||||
use crate::streaming::{
|
||||
event_parser::{
|
||||
common::EventMetadata, protocols::raydium_amm_v4::RaydiumAmmV4AmmInfoAccountEvent,
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -86,12 +86,12 @@ pub fn amm_info_decode(data: &[u8]) -> Option<AmmInfo> {
|
||||
borsh::from_slice::<AmmInfo>(&data[..AMM_INFO_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn amm_info_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn amm_info_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < AMM_INFO_SIZE {
|
||||
return None;
|
||||
}
|
||||
if let Some(amm_info) = amm_info_decode(&account.data[..AMM_INFO_SIZE]) {
|
||||
Some(UnifiedEvent::RaydiumAmmV4AmmInfoAccountEvent(RaydiumAmmV4AmmInfoAccountEvent {
|
||||
Some(DexEvent::RaydiumAmmV4AmmInfoAccountEvent(RaydiumAmmV4AmmInfoAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::streaming::event_parser::{
|
||||
RaydiumClmmOpenPositionV2Event, RaydiumClmmOpenPositionWithToken22NftEvent,
|
||||
RaydiumClmmSwapEvent, RaydiumClmmSwapV2Event,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
@@ -107,11 +107,11 @@ fn parse_open_position_v2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 51 || accounts.len() < 22 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmOpenPositionV2Event(RaydiumClmmOpenPositionV2Event {
|
||||
Some(DexEvent::RaydiumClmmOpenPositionV2Event(RaydiumClmmOpenPositionV2Event {
|
||||
metadata,
|
||||
tick_lower_index: read_i32_le(data, 0)?,
|
||||
tick_upper_index: read_i32_le(data, 4)?,
|
||||
@@ -153,11 +153,11 @@ fn parse_open_position_with_token_22_nft_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 51 || accounts.len() < 20 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmOpenPositionWithToken22NftEvent(
|
||||
Some(DexEvent::RaydiumClmmOpenPositionWithToken22NftEvent(
|
||||
RaydiumClmmOpenPositionWithToken22NftEvent {
|
||||
metadata,
|
||||
tick_lower_index: read_i32_le(data, 0)?,
|
||||
@@ -198,11 +198,11 @@ fn parse_increase_liquidity_v2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 34 || accounts.len() < 15 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmIncreaseLiquidityV2Event(RaydiumClmmIncreaseLiquidityV2Event {
|
||||
Some(DexEvent::RaydiumClmmIncreaseLiquidityV2Event(RaydiumClmmIncreaseLiquidityV2Event {
|
||||
metadata,
|
||||
liquidity: read_u128_le(data, 0)?,
|
||||
amount0_max: read_u64_le(data, 16)?,
|
||||
@@ -231,11 +231,11 @@ fn parse_create_pool_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmCreatePoolEvent(RaydiumClmmCreatePoolEvent {
|
||||
Some(DexEvent::RaydiumClmmCreatePoolEvent(RaydiumClmmCreatePoolEvent {
|
||||
metadata,
|
||||
sqrt_price_x64: read_u128_le(data, 0)?,
|
||||
open_time: read_u64_le(data, 16)?,
|
||||
@@ -260,11 +260,11 @@ fn parse_decrease_liquidity_v2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 32 || accounts.len() < 16 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmDecreaseLiquidityV2Event(RaydiumClmmDecreaseLiquidityV2Event {
|
||||
Some(DexEvent::RaydiumClmmDecreaseLiquidityV2Event(RaydiumClmmDecreaseLiquidityV2Event {
|
||||
metadata,
|
||||
liquidity: read_u128_le(data, 0)?,
|
||||
amount0_min: read_u64_le(data, 16)?,
|
||||
@@ -294,11 +294,11 @@ fn parse_close_position_instruction(
|
||||
_data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if accounts.len() < 6 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumClmmClosePositionEvent(RaydiumClmmClosePositionEvent {
|
||||
Some(DexEvent::RaydiumClmmClosePositionEvent(RaydiumClmmClosePositionEvent {
|
||||
metadata,
|
||||
nft_owner: accounts[0],
|
||||
position_nft_mint: accounts[1],
|
||||
@@ -314,7 +314,7 @@ fn parse_swap_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 33 || accounts.len() < 10 {
|
||||
return None;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ fn parse_swap_instruction(
|
||||
let sqrt_price_limit_x64 = read_u128_le(data, 16)?;
|
||||
let is_base_input = read_u8_le(data, 32)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumClmmSwapEvent(RaydiumClmmSwapEvent {
|
||||
Some(DexEvent::RaydiumClmmSwapEvent(RaydiumClmmSwapEvent {
|
||||
metadata,
|
||||
amount,
|
||||
other_amount_threshold,
|
||||
@@ -348,7 +348,7 @@ fn parse_swap_v2_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 33 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ fn parse_swap_v2_instruction(
|
||||
let sqrt_price_limit_x64 = read_u128_le(data, 16)?;
|
||||
let is_base_input = read_u8_le(data, 32)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumClmmSwapV2Event(RaydiumClmmSwapV2Event {
|
||||
Some(DexEvent::RaydiumClmmSwapV2Event(RaydiumClmmSwapV2Event {
|
||||
metadata,
|
||||
amount,
|
||||
other_amount_threshold,
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::streaming::{
|
||||
RaydiumClmmAmmConfigAccountEvent, RaydiumClmmPoolStateAccountEvent,
|
||||
RaydiumClmmTickArrayStateAccountEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -37,12 +37,12 @@ pub fn amm_config_decode(data: &[u8]) -> Option<AmmConfig> {
|
||||
borsh::from_slice::<AmmConfig>(&data[..AMM_CONFIG_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn amm_config_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn amm_config_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < AMM_CONFIG_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(amm_config) = amm_config_decode(&account.data[8..AMM_CONFIG_SIZE + 8]) {
|
||||
Some(UnifiedEvent::RaydiumClmmAmmConfigAccountEvent(RaydiumClmmAmmConfigAccountEvent {
|
||||
Some(DexEvent::RaydiumClmmAmmConfigAccountEvent(RaydiumClmmAmmConfigAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -122,12 +122,12 @@ pub fn pool_state_decode(data: &[u8]) -> Option<PoolState> {
|
||||
borsh::from_slice::<PoolState>(&data[..POOL_STATE_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < POOL_STATE_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
|
||||
Some(UnifiedEvent::RaydiumClmmPoolStateAccountEvent(RaydiumClmmPoolStateAccountEvent {
|
||||
Some(DexEvent::RaydiumClmmPoolStateAccountEvent(RaydiumClmmPoolStateAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -203,14 +203,14 @@ pub fn tick_array_state_decode(data: &[u8]) -> Option<TickArrayState> {
|
||||
pub fn tick_array_state_parser(
|
||||
account: &AccountPretty,
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if account.data.len() < TICK_ARRAY_STATE_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(tick_array_state) =
|
||||
tick_array_state_decode(&account.data[8..TICK_ARRAY_STATE_SIZE + 8])
|
||||
{
|
||||
Some(UnifiedEvent::RaydiumClmmTickArrayStateAccountEvent(
|
||||
Some(DexEvent::RaydiumClmmTickArrayStateAccountEvent(
|
||||
RaydiumClmmTickArrayStateAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::streaming::event_parser::{
|
||||
discriminators, RaydiumCpmmDepositEvent, RaydiumCpmmInitializeEvent, RaydiumCpmmSwapEvent,
|
||||
RaydiumCpmmWithdrawEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
};
|
||||
|
||||
/// Raydium CPMM程序ID
|
||||
@@ -73,11 +73,11 @@ fn parse_withdraw_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 14 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumCpmmWithdrawEvent(RaydiumCpmmWithdrawEvent {
|
||||
Some(DexEvent::RaydiumCpmmWithdrawEvent(RaydiumCpmmWithdrawEvent {
|
||||
metadata,
|
||||
lp_token_amount: read_u64_le(data, 0)?,
|
||||
minimum_token0_amount: read_u64_le(data, 8)?,
|
||||
@@ -104,11 +104,11 @@ fn parse_initialize_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 20 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumCpmmInitializeEvent(RaydiumCpmmInitializeEvent {
|
||||
Some(DexEvent::RaydiumCpmmInitializeEvent(RaydiumCpmmInitializeEvent {
|
||||
metadata,
|
||||
init_amount0: read_u64_le(data, 0)?,
|
||||
init_amount1: read_u64_le(data, 8)?,
|
||||
@@ -141,11 +141,11 @@ fn parse_deposit_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 24 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
Some(UnifiedEvent::RaydiumCpmmDepositEvent(RaydiumCpmmDepositEvent {
|
||||
Some(DexEvent::RaydiumCpmmDepositEvent(RaydiumCpmmDepositEvent {
|
||||
metadata,
|
||||
lp_token_amount: read_u64_le(data, 0)?,
|
||||
maximum_token0_amount: read_u64_le(data, 8)?,
|
||||
@@ -171,7 +171,7 @@ fn parse_swap_base_input_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ fn parse_swap_base_input_instruction(
|
||||
let amount_in = read_u64_le(data, 0)?;
|
||||
let minimum_amount_out = read_u64_le(data, 8)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent {
|
||||
Some(DexEvent::RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent {
|
||||
metadata,
|
||||
amount_in,
|
||||
minimum_amount_out,
|
||||
@@ -204,7 +204,7 @@ fn parse_swap_base_output_instruction(
|
||||
data: &[u8],
|
||||
accounts: &[Pubkey],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<UnifiedEvent> {
|
||||
) -> Option<DexEvent> {
|
||||
if data.len() < 16 || accounts.len() < 13 {
|
||||
return None;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ fn parse_swap_base_output_instruction(
|
||||
let max_amount_in = read_u64_le(data, 0)?;
|
||||
let amount_out = read_u64_le(data, 8)?;
|
||||
|
||||
Some(UnifiedEvent::RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent {
|
||||
Some(DexEvent::RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent {
|
||||
metadata,
|
||||
max_amount_in,
|
||||
amount_out,
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::streaming::{
|
||||
protocols::raydium_cpmm::{
|
||||
RaydiumCpmmAmmConfigAccountEvent, RaydiumCpmmPoolStateAccountEvent,
|
||||
},
|
||||
UnifiedEvent,
|
||||
DexEvent,
|
||||
},
|
||||
grpc::AccountPretty,
|
||||
};
|
||||
@@ -36,12 +36,12 @@ pub fn amm_config_decode(data: &[u8]) -> Option<AmmConfig> {
|
||||
borsh::from_slice::<AmmConfig>(&data[..AMM_CONFIG_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn amm_config_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn amm_config_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < AMM_CONFIG_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(amm_config) = amm_config_decode(&account.data[8..AMM_CONFIG_SIZE + 8]) {
|
||||
Some(UnifiedEvent::RaydiumCpmmAmmConfigAccountEvent(RaydiumCpmmAmmConfigAccountEvent {
|
||||
Some(DexEvent::RaydiumCpmmAmmConfigAccountEvent(RaydiumCpmmAmmConfigAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
@@ -91,12 +91,12 @@ pub fn pool_state_decode(data: &[u8]) -> Option<PoolState> {
|
||||
borsh::from_slice::<PoolState>(&data[..POOL_STATE_SIZE]).ok()
|
||||
}
|
||||
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<UnifiedEvent> {
|
||||
pub fn pool_state_parser(account: &AccountPretty, metadata: EventMetadata) -> Option<DexEvent> {
|
||||
if account.data.len() < POOL_STATE_SIZE + 8 {
|
||||
return None;
|
||||
}
|
||||
if let Some(pool_state) = pool_state_decode(&account.data[8..POOL_STATE_SIZE + 8]) {
|
||||
Some(UnifiedEvent::RaydiumCpmmPoolStateAccountEvent(RaydiumCpmmPoolStateAccountEvent {
|
||||
Some(DexEvent::RaydiumCpmmPoolStateAccountEvent(RaydiumCpmmPoolStateAccountEvent {
|
||||
metadata,
|
||||
pubkey: account.pubkey,
|
||||
executable: account.executable,
|
||||
|
||||
Reference in New Issue
Block a user