This commit is contained in:
2026-08-06 08:29:10 +02:00
parent ce923c4438
commit 42071163d0
5 changed files with 43 additions and 3 deletions
Generated
+12
View File
@@ -84,6 +84,17 @@ version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
[[package]]
name = "async-trait"
version = "0.1.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae36dc4177970ef04fde5178d3e2429882def40e57a451f919c098f72baa6cec"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.3",
]
[[package]]
name = "atomic-waker"
version = "1.1.2"
@@ -1712,6 +1723,7 @@ name = "sol-hunter"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"env_logger",
"futures-util",
"log",
+1
View File
@@ -21,3 +21,4 @@ log = "0.4.33"
env_logger = "0.11.11"
rust_decimal = "1.42.1"
reqwest = { version = "0.13.4", features = ["json"] }
async-trait = "0.1.91"
+27 -1
View File
@@ -1,12 +1,15 @@
use anyhow::Context;
use futures_util::{SinkExt, StreamExt};
use serde_json::json;
use tokio::net::TcpStream;
use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, connect_async};
use crate::types::NewToken;
use crate::{account::AccountManager, executor::Executor, types::NewToken};
pub struct Bot {
pub ws: WebSocketStream<MaybeTlsStream<TcpStream>>,
pub accounts: AccountManager,
pub executor: Box<dyn Executor>,
}
impl Bot {
@@ -17,11 +20,34 @@ impl Bot {
impl Bot {
pub async fn new() -> anyhow::Result<Self> {
let accounts = AccountManager::get().await?;
let account = accounts
.accounts
.get(&accounts.active)
.context("Failed to get account")?
.clone();
Ok(Self {
ws: connect_async("wss://pumpdev.io/ws").await?.0,
executor: Box::new(account.executor()),
accounts,
})
}
pub async fn refresh_account(&mut self) -> anyhow::Result<()> {
let account = self
.accounts
.accounts
.get(&self.accounts.active)
.context("Failed to get account")?
.clone();
self.executor = Box::new(account.executor());
Ok(())
}
pub async fn initialize_websocket_subscribe(&mut self) -> anyhow::Result<()> {
self.ws
.send(tokio_tungstenite::tungstenite::Message::Text(
+2 -2
View File
@@ -4,8 +4,8 @@ use rust_decimal::Decimal;
use crate::account::Account;
#[allow(async_fn_in_trait, unused_variables)]
#[allow(unused_variables)]
#[async_trait::async_trait]
pub trait Executor {
async fn buy(
&self,
+1
View File
@@ -84,6 +84,7 @@ impl PumpDev {
}
}
#[async_trait::async_trait]
impl Executor for PumpDev {
async fn buy(
&self,