1
0
mirror of https://github.com/payden/libwsclient synced 2026-03-02 04:09:18 +00:00

feat : add strategy

This commit is contained in:
deniyuda348
2025-05-16 15:09:24 +09:00
parent d416fcb62c
commit 17c1e2d5e0
81 changed files with 7848 additions and 2858 deletions

23
bot/simulation_engine Normal file
View File

@@ -0,0 +1,23 @@
use solana_client::rpc_client::RpcClient;
use solana_sdk::transaction::Transaction;
pub struct SimulationEngine {
rpc_client: RpcClient,
}
impl SimulationEngine {
pub fn new(rpc_client: RpcClient) -> Self {
Self { rpc_client }
}
pub async fn simulate(&self, tx: &Transaction) -> f64 {
let (result, _) = self.rpc_client.simulate_transaction(tx).await.unwrap();
let accounts_data = result.accounts.unwrap();
let mut profit = 0.0;
for account in &accounts_data {
let lamports = account.lamports.unwrap();
profit += lamports as f64 / 1e9;
}
profit
}
}