diff --git a/src/common/subscription_handle.rs b/src/common/subscription_handle.rs old mode 100644 new mode 100755 diff --git a/src/constants/swqos.rs b/src/constants/swqos.rs old mode 100644 new mode 100755 diff --git a/src/lib.rs b/src/lib.rs index f7142ff..f0608e9 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,17 +1,15 @@ pub mod common; pub mod constants; -pub mod event_parser; -pub mod grpc; pub mod instruction; pub mod protos; pub mod swqos; +pub mod streaming; pub mod trading; use std::sync::Arc; use std::sync::Mutex; use rustls::crypto::{ring::default_provider, CryptoProvider}; -use solana_hash::Hash; use solana_sdk::{ pubkey::Pubkey, signature::{Keypair, Signer}, @@ -20,10 +18,9 @@ use swqos::SwqosClient; use common::{PriorityFee, SolanaRpcClient, TradeConfig}; -use constants::trade_platform::{PUMPFUN, PUMPFUN_SWAP, BONK}; -use constants::trade_type::{COPY_BUY, SNIPER_BUY}; +use constants::trade_type::COPY_BUY; -use crate::event_parser::protocols::pumpfun::PumpFunTradeEvent; +use crate::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent; use crate::swqos::SwqosConfig; use crate::trading::core::params::PumpFunParams; use crate::trading::core::params::PumpFunSellParams; diff --git a/src/main.rs b/src/main.rs index 6318fd5..ccdefe9 100755 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::{str::FromStr, sync::Arc}; use sol_trade_sdk::{ common::{bonding_curve::BondingCurveAccount, AnyResult, PriorityFee, TradeConfig}, constants::{pumpfun::global_constants::TOKEN_TOTAL_SUPPLY, trade_type}, - event_parser::{ + streaming::event_parser::{ protocols::{ bonk::{BonkPoolCreateEvent, BonkTradeEvent}, pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, pumpswap::{ PumpSwapBuyEvent, PumpSwapCreatePoolEvent, PumpSwapDepositEvent, PumpSwapSellEvent, @@ -12,7 +12,7 @@ use sol_trade_sdk::{ }, Protocol, UnifiedEvent, }, - grpc::{ShredStreamGrpc, YellowstoneGrpc}, + streaming::{ShredStreamGrpc, YellowstoneGrpc}, match_event, swqos::{SwqosConfig, SwqosRegion}, trading::{ diff --git a/src/event_parser/common/mod.rs b/src/streaming/event_parser/common/mod.rs old mode 100644 new mode 100755 similarity index 74% rename from src/event_parser/common/mod.rs rename to src/streaming/event_parser/common/mod.rs index 5eac189..a070106 --- a/src/event_parser/common/mod.rs +++ b/src/streaming/event_parser/common/mod.rs @@ -6,12 +6,12 @@ pub mod utils; macro_rules! impl_unified_event { // 带有自定义ID表达式的版本 ($struct_name:ident, $($field:ident),*) => { - impl $crate::event_parser::core::traits::UnifiedEvent for $struct_name { + impl $crate::streaming::event_parser::core::traits::UnifiedEvent for $struct_name { fn id(&self) -> &str { &self.metadata.id } - fn event_type(&self) -> $crate::event_parser::common::types::EventType { + fn event_type(&self) -> $crate::streaming::event_parser::common::types::EventType { self.metadata.event_type.clone() } @@ -35,11 +35,11 @@ macro_rules! impl_unified_event { self } - fn clone_boxed(&self) -> Box { + fn clone_boxed(&self) -> Box { Box::new(self.clone()) } - fn merge(&mut self, other: Box) { + fn merge(&mut self, other: Box) { if let Some(e) = other.as_any().downcast_ref::<$struct_name>() { $( self.$field = e.$field.clone(); diff --git a/src/event_parser/common/types.rs b/src/streaming/event_parser/common/types.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/common/types.rs rename to src/streaming/event_parser/common/types.rs diff --git a/src/event_parser/common/utils.rs b/src/streaming/event_parser/common/utils.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/common/utils.rs rename to src/streaming/event_parser/common/utils.rs diff --git a/src/event_parser/core/mod.rs b/src/streaming/event_parser/core/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/core/mod.rs rename to src/streaming/event_parser/core/mod.rs diff --git a/src/event_parser/core/traits.rs b/src/streaming/event_parser/core/traits.rs old mode 100644 new mode 100755 similarity index 98% rename from src/event_parser/core/traits.rs rename to src/streaming/event_parser/core/traits.rs index 58e0f3e..ef34626 --- a/src/event_parser/core/traits.rs +++ b/src/streaming/event_parser/core/traits.rs @@ -8,8 +8,8 @@ use solana_transaction_status::{ use std::collections::HashMap; use std::fmt::Debug; -use crate::{ - event_parser::{common::{utils::*, EventMetadata, EventType, ProtocolType}, protocols::{pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, bonk::{BonkPoolCreateEvent, BonkTradeEvent}}}, +use crate::streaming::event_parser::{ + common::{utils::*, EventMetadata, EventType, ProtocolType}, protocols::{pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, bonk::{BonkPoolCreateEvent, BonkTradeEvent}}, }; /// 统一事件接口 - 所有协议的事件都需要实现此trait diff --git a/src/event_parser/factory.rs b/src/streaming/event_parser/factory.rs old mode 100644 new mode 100755 similarity index 98% rename from src/event_parser/factory.rs rename to src/streaming/event_parser/factory.rs index 26939a8..6d47011 --- a/src/event_parser/factory.rs +++ b/src/streaming/event_parser/factory.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, Result}; use solana_sdk::pubkey::Pubkey; use std::sync::Arc; -use crate::event_parser::protocols::{ +use crate::streaming::event_parser::protocols::{ pumpfun::parser::PUMPFUN_PROGRAM_ID, pumpswap::parser::PUMPSWAP_PROGRAM_ID, bonk::parser::BONK_PROGRAM_ID, BonkEventParser, }; diff --git a/src/event_parser/mod.rs b/src/streaming/event_parser/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/mod.rs rename to src/streaming/event_parser/mod.rs diff --git a/src/event_parser/protocols/bonk/events.rs b/src/streaming/event_parser/protocols/bonk/events.rs old mode 100644 new mode 100755 similarity index 95% rename from src/event_parser/protocols/bonk/events.rs rename to src/streaming/event_parser/protocols/bonk/events.rs index 2ee82ff..83ab491 --- a/src/event_parser/protocols/bonk/events.rs +++ b/src/streaming/event_parser/protocols/bonk/events.rs @@ -1,7 +1,7 @@ -use crate::event_parser::protocols::bonk::types::{ +use crate::streaming::event_parser::protocols::bonk::types::{ CurveParams, MintParams, PoolStatus, TradeDirection, VestingParams, }; -use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; +use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; use crate::impl_unified_event; use borsh::BorshDeserialize; use serde::{Deserialize, Serialize}; diff --git a/src/event_parser/protocols/bonk/mod.rs b/src/streaming/event_parser/protocols/bonk/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/protocols/bonk/mod.rs rename to src/streaming/event_parser/protocols/bonk/mod.rs diff --git a/src/event_parser/protocols/bonk/parser.rs b/src/streaming/event_parser/protocols/bonk/parser.rs old mode 100644 new mode 100755 similarity index 99% rename from src/event_parser/protocols/bonk/parser.rs rename to src/streaming/event_parser/protocols/bonk/parser.rs index 568d723..094f749 --- a/src/event_parser/protocols/bonk/parser.rs +++ b/src/streaming/event_parser/protocols/bonk/parser.rs @@ -1,7 +1,7 @@ use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey}; use solana_transaction_status::UiCompiledInstruction; -use crate::event_parser::{ +use crate::streaming::event_parser::{ common::{utils::*, EventMetadata, EventType, ProtocolType}, core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent}, protocols::bonk::{ diff --git a/src/event_parser/protocols/bonk/types.rs b/src/streaming/event_parser/protocols/bonk/types.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/protocols/bonk/types.rs rename to src/streaming/event_parser/protocols/bonk/types.rs diff --git a/src/event_parser/protocols/mod.rs b/src/streaming/event_parser/protocols/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/protocols/mod.rs rename to src/streaming/event_parser/protocols/mod.rs diff --git a/src/event_parser/protocols/pumpfun/events.rs b/src/streaming/event_parser/protocols/pumpfun/events.rs old mode 100644 new mode 100755 similarity index 97% rename from src/event_parser/protocols/pumpfun/events.rs rename to src/streaming/event_parser/protocols/pumpfun/events.rs index 5087ddd..34be579 --- a/src/event_parser/protocols/pumpfun/events.rs +++ b/src/streaming/event_parser/protocols/pumpfun/events.rs @@ -2,7 +2,7 @@ use borsh::BorshDeserialize; use serde::{Deserialize, Serialize}; use solana_sdk::pubkey::Pubkey; -use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; +use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; use crate::impl_unified_event; #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] diff --git a/src/event_parser/protocols/pumpfun/mod.rs b/src/streaming/event_parser/protocols/pumpfun/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/protocols/pumpfun/mod.rs rename to src/streaming/event_parser/protocols/pumpfun/mod.rs diff --git a/src/event_parser/protocols/pumpfun/parser.rs b/src/streaming/event_parser/protocols/pumpfun/parser.rs old mode 100644 new mode 100755 similarity index 99% rename from src/event_parser/protocols/pumpfun/parser.rs rename to src/streaming/event_parser/protocols/pumpfun/parser.rs index a14e91b..3fcb70e --- a/src/event_parser/protocols/pumpfun/parser.rs +++ b/src/streaming/event_parser/protocols/pumpfun/parser.rs @@ -1,7 +1,7 @@ use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey}; use solana_transaction_status::UiCompiledInstruction; -use crate::event_parser::{ +use crate::streaming::event_parser::{ common::{utils::*, EventMetadata, EventType, ProtocolType}, core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent}, protocols::pumpfun::{discriminators, PumpFunCreateTokenEvent, PumpFunTradeEvent}, diff --git a/src/event_parser/protocols/pumpswap/events.rs b/src/streaming/event_parser/protocols/pumpswap/events.rs old mode 100644 new mode 100755 similarity index 99% rename from src/event_parser/protocols/pumpswap/events.rs rename to src/streaming/event_parser/protocols/pumpswap/events.rs index eec19dc..b20d7ef --- a/src/event_parser/protocols/pumpswap/events.rs +++ b/src/streaming/event_parser/protocols/pumpswap/events.rs @@ -2,7 +2,7 @@ use borsh::BorshDeserialize; use serde::{Deserialize, Serialize}; use solana_sdk::pubkey::Pubkey; -use crate::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; +use crate::streaming::event_parser::{common::EventMetadata, core::traits::UnifiedEvent}; use crate::impl_unified_event; /// 买入事件 diff --git a/src/event_parser/protocols/pumpswap/mod.rs b/src/streaming/event_parser/protocols/pumpswap/mod.rs old mode 100644 new mode 100755 similarity index 100% rename from src/event_parser/protocols/pumpswap/mod.rs rename to src/streaming/event_parser/protocols/pumpswap/mod.rs diff --git a/src/event_parser/protocols/pumpswap/parser.rs b/src/streaming/event_parser/protocols/pumpswap/parser.rs old mode 100644 new mode 100755 similarity index 99% rename from src/event_parser/protocols/pumpswap/parser.rs rename to src/streaming/event_parser/protocols/pumpswap/parser.rs index e81498f..52e56a2 --- a/src/event_parser/protocols/pumpswap/parser.rs +++ b/src/streaming/event_parser/protocols/pumpswap/parser.rs @@ -1,8 +1,8 @@ use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey}; use solana_transaction_status::UiCompiledInstruction; -use crate::event_parser::{ - common::{utils::*, EventMetadata, EventType, ProtocolType}, +use crate::streaming::event_parser::{ + common::{EventMetadata, EventType, ProtocolType, read_u64_le}, core::traits::{EventParser, GenericEventParseConfig, GenericEventParser, UnifiedEvent}, protocols::pumpswap::{ discriminators, PumpSwapBuyEvent, PumpSwapCreatePoolEvent, PumpSwapDepositEvent, diff --git a/src/grpc/mod.rs b/src/streaming/mod.rs similarity index 90% rename from src/grpc/mod.rs rename to src/streaming/mod.rs index a98071c..b2f7a22 100755 --- a/src/grpc/mod.rs +++ b/src/streaming/mod.rs @@ -1,6 +1,7 @@ pub mod yellow_stone; pub mod yellow_stone_sub_system; pub mod shred_stream; +pub mod event_parser; pub use yellow_stone::YellowstoneGrpc; pub use yellow_stone_sub_system::{SystemEvent, TransferInfo}; diff --git a/src/grpc/shred_stream.rs b/src/streaming/shred_stream.rs similarity index 93% rename from src/grpc/shred_stream.rs rename to src/streaming/shred_stream.rs index 27b1f8d..471cfdb 100755 --- a/src/grpc/shred_stream.rs +++ b/src/streaming/shred_stream.rs @@ -8,11 +8,7 @@ use log::error; use solana_sdk::transaction::VersionedTransaction; use crate::common::AnyResult; -use crate::event_parser::protocols::pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}; -use crate::event_parser::protocols::bonk::{ - BonkPoolCreateEvent, BonkTradeEvent, -}; -use crate::event_parser::{EventParserFactory, Protocol, UnifiedEvent}; +use crate::streaming::event_parser::{EventParserFactory, Protocol, UnifiedEvent}; use crate::protos::shredstream::shredstream_proxy_client::ShredstreamProxyClient; use crate::protos::shredstream::SubscribeEntriesRequest; diff --git a/src/grpc/yellow_stone.rs b/src/streaming/yellow_stone.rs similarity index 94% rename from src/grpc/yellow_stone.rs rename to src/streaming/yellow_stone.rs index 0079578..0290fca 100755 --- a/src/grpc/yellow_stone.rs +++ b/src/streaming/yellow_stone.rs @@ -16,16 +16,8 @@ use yellowstone_grpc_proto::geyser::{ SubscribeUpdateTransaction, }; -// use crate::common::pumpfun::logs_data::{DexInstruction, TransferInfo}; -// use crate::common::pumpfun::logs_events::{PumpfunEvent, SystemEvent}; -// use crate::common::pumpfun::logs_filters::LogFilter; use crate::common::AnyResult; -use crate::constants::pumpfun::trade; -use crate::event_parser::protocols::pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}; -use crate::event_parser::protocols::bonk::{ - BonkPoolCreateEvent, BonkTradeEvent, -}; -use crate::event_parser::{EventParserFactory, Protocol, UnifiedEvent}; +use crate::streaming::event_parser::{EventParserFactory, Protocol, UnifiedEvent}; type TransactionsFilterMap = HashMap; diff --git a/src/grpc/yellow_stone_sub_system.rs b/src/streaming/yellow_stone_sub_system.rs old mode 100644 new mode 100755 similarity index 97% rename from src/grpc/yellow_stone_sub_system.rs rename to src/streaming/yellow_stone_sub_system.rs index fecf604..b5db49b --- a/src/grpc/yellow_stone_sub_system.rs +++ b/src/streaming/yellow_stone_sub_system.rs @@ -1,4 +1,4 @@ -use crate::{common::AnyResult, grpc::yellow_stone::{TransactionPretty, YellowstoneGrpc}}; +use crate::{common::AnyResult, streaming::yellow_stone::{TransactionPretty, YellowstoneGrpc}}; use solana_program::pubkey; use solana_sdk::{pubkey::Pubkey, transaction::VersionedTransaction}; use futures::{channel::mpsc, sink::Sink, Stream, StreamExt, SinkExt}; diff --git a/src/swqos/bloxroute.rs b/src/swqos/bloxroute.rs old mode 100644 new mode 100755 diff --git a/src/trading/pumpfun/common.rs b/src/trading/pumpfun/common.rs index 65f02ea..9cc6730 100755 --- a/src/trading/pumpfun/common.rs +++ b/src/trading/pumpfun/common.rs @@ -8,7 +8,15 @@ use solana_sdk::{ }; use spl_associated_token_account::get_associated_token_address; use pumpfun_program::accounts::BondingCurveAccount as PumpfunBondingCurveAccount; -use crate::{common::{bonding_curve::BondingCurveAccount, global::GlobalAccount, PriorityFee, SolanaRpcClient}, constants::{self, pumpfun::{self, global_constants::{CREATOR_FEE, FEE_BASIS_POINTS}, trade::DEFAULT_SLIPPAGE}}, event_parser::protocols::pumpfun::PumpFunTradeEvent}; +use crate::{ + common::{ + bonding_curve::BondingCurveAccount, global::GlobalAccount, PriorityFee, SolanaRpcClient + }, + constants::{ + self, pumpfun::{global_constants::{CREATOR_FEE, FEE_BASIS_POINTS}, trade::DEFAULT_SLIPPAGE} + }, + streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent +}; lazy_static::lazy_static! { static ref ACCOUNT_CACHE: RwLock>> = RwLock::new(HashMap::new());