-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.rs
62 lines (51 loc) · 1.9 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::sync::Arc;
use mev_bot_solana::bot::solana_mev_bot::SolanaMevBot;
use mev_bot_solana::config::Config;
use mev_bot_solana::dex::dex_manager::DexManager;
use mev_bot_solana::monitoring::dashboard::Dashboard;
use mev_bot_solana::monitoring::metrics::Metrics;
use mev_bot_solana::strategies::copy_trade_strategy::CopyTradeStrategy;
use mev_bot_solana::strategies::sniping_strategy::SnipingStrategy;
use mev_bot_solana::utils::config_parser::parse_config;
use solana_client::rpc_client::RpcClient;
use solana_sdk::signature::read_keypair_file;
#[tokio::main]
async fn main() {
let config = parse_config("config.toml").expect("Failed to parse config");
let rpc_client = Arc::new(RpcClient::new_with_commitment(
config.solana.rpc_url.clone(),
config.solana.commitment.clone(),
));
let metrics = Arc::new(Metrics::new());
let dashboard = Dashboard::new(metrics.clone(), config.monitoring.update_interval);
let dex_manager = Arc::new(tokio::sync::Mutex::new(DexManager::new(
rpc_client.clone(),
config.dexes.clone(),
)));
let sniping_strategy = Arc::new(tokio::sync::Mutex::new(SnipingStrategy::new(
rpc_client.clone(),
dex_manager.clone(),
config.bot.max_position_size,
)));
let copy_trade_strategy = Arc::new(tokio::sync::Mutex::new(CopyTradeStrategy::new(
rpc_client.clone(),
dex_manager.clone(),
config.bot.max_position_size,
)));
let authority_keypair = read_keypair_file(config.bot.keypair_path.clone())
.expect("Failed to read keypair file");
let mut mev_bot = SolanaMevBot::new(
rpc_client,
authority_keypair,
vec![
sniping_strategy.clone(),
copy_trade_strategy.clone(),
],
config.bot.profit_threshold,
metrics,
);
tokio::spawn(async move {
dashboard.run().await;
});
mev_bot.run().await;
}