hey bro can u do me a favor i need this script here to have all the functins $content = @"
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use futures_util::{SinkExt, StreamExt};
use std::sync::Arc;
use {
    std::time::{Duration, Instant},
    serde_json::{json, Value},
    anyhow::{anyhow, Result},
    log::{error, info, warn},
    dashmap::DashMap,
    solana_client::rpc_client::RpcClient,
    solana_sdk::{
        signature::{Keypair, Signer},
        commitment_config::CommitmentConfig,
    },
    tokio_tungstenite::{connect_async, WebSocketStream, MaybeTlsStream},
    tokio::net::TcpStream,
    chrono,
};

const JUPITER_API: &str = "https://quote-api.jup.ag/v6";
const HELIUS_RPC: &str = "https://marga-e56m84-fast-mainnet.helius-rpc.com/";
const WS_URL: &str = "wss://marga-e56m84-fast-mainnet.helius-rpc.com/";
const PRIORITY_FEE: u64 = 25000;

#[pyclass]
#[derive(Clone)]
struct QuantumCore {
    inner: Arc<QuantumCoreInner>,
    runtime: Arc<tokio::runtime::Runtime>,
}

#[derive(Clone)]
struct QuantumCoreInner {
    rpc_client: Arc<RpcClient>,
    keypair: Arc<Keypair>,
    active_trades: Arc<DashMap<String, TradeState>>,
    ws_connection: Arc<tokio::sync::Mutex<Option<WebSocketStream<MaybeTlsStream<TcpStream>>>>>,
    http_client: Arc<reqwest::Client>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
struct TokenInfo {
    mint: String,
    price: f64,
    liquidity: f64,
    volume_24h: f64,
    buy_pressure: f64,
    timestamp: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
struct TradeState {
    token_mint: String,
    entry_price: f64,
    position_size: f64,
    timestamp: i64,
    status: String,
}

#[derive(Debug, Clone)]
struct SwapData {
    input_mint: String,
    output_mint: String,
    input_amount: f64,
    output_amount: f64,
    timestamp: i64,
    signature: String,
}

#[derive(Debug, Clone)]
struct LiquidityData {
    pool_id: String,
    token_mint: String,
    liquidity_change: f64,
    timestamp: i64,
}

#[pymethods]
impl QuantumCore {
    #[new]
    fn new(_pool_id: String) -> PyResult<Self> {
        let rpc_client = RpcClient::new_with_commitment(
            HELIUS_RPC.to_string(),
            CommitmentConfig::confirmed(),
        );

        let inner = QuantumCoreInner {
            rpc_client: Arc::new(rpc_client),
            keypair: Arc::new(Keypair::new()),
            active_trades: Arc::new(DashMap::new()),
            ws_connection: Arc::new(tokio::sync::Mutex::new(None)),
            http_client: Arc::new(reqwest::Client::new()),
        };

        let runtime = tokio::runtime::Builder::new_multi_thread()
            .worker_threads(2)
            .enable_all()
            .build()
            .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;

        Ok(Self {
            inner: Arc::new(inner),
            runtime: Arc::new(runtime),
        })
    }

    fn start_trading(&self) -> PyResult<()> {
        let inner = self.inner.clone();
        
        self.runtime.spawn(async move {
            if let Err(e) = inner.monitor_market().await {
                error!("Trading error: {}", e);
            }
        });
        
        self.runtime.block_on(async {
            loop {
                tokio::time::sleep(Duration::from_secs(1)).await;
            }
        });

        Ok(())
    }
}

impl QuantumCoreInner {
    async fn process_swap_data(&self, swap: SwapData) -> Result<()> {
        info!("Processing swap: {} -> {} | Amount: {} -> {}", 
            swap.input_mint, 
            swap.output_mint,
            swap.input_amount,
            swap.output_amount
        );
        Ok(())
    }

    async fn process_liquidity_update(&self, liq: LiquidityData) -> Result<()> {
        info!("Liquidity update for pool {} | Token: {} | Change: {}", 
            liq.pool_id,
            liq.token_mint,
            liq.liquidity_change
        );
        Ok(())
    }

    fn extract_jupiter_swap(&self, data: &Value) -> Option<SwapData> {
        if let Some(swap_info) = data.get("value").and_then(|v| v.get("parsed")) {
            Some(SwapData {
                input_mint: swap_info.get("inputMint")?.as_str()?.to_string(),
                output_mint: swap_info.get("outputMint")?.as_str()?.to_string(),
                input_amount: swap_info.get("inputAmount")?.as_str()?.parse().ok()?,
                output_amount: swap_info.get("outputAmount")?.as_str()?.parse().ok()?,
                timestamp: chrono::Utc::now().timestamp(),
                signature: data.get("signature")?.as_str()?.to_string(),
            })
        } else {
            None
        }
    }

    fn extract_liquidity_data(&self, data: &Value) -> Option<LiquidityData> {
        if let Some(liq_info) = data.get("value").and_then(|v| v.get("parsed")) {
            Some(LiquidityData {
                pool_id: liq_info.get("poolId")?.as_str()?.to_string(),
                token_mint: liq_info.get("tokenMint")?.as_str()?.to_string(),
                liquidity_change: liq_info.get("liquidityChange")?.as_f64()?,
                timestamp: chrono::Utc::now().timestamp(),
            })
        } else {
            None
        }
    }

    // ... (rest of your existing QuantumCoreInner implementation)

    async fn setup_websocket(&self) -> Result<()> {
        let (ws_stream, _) = connect_async(WS_URL).await?;
        let mut ws = self.ws_connection.lock().await;
        *ws = Some(ws_stream);

        if let Some(ref mut ws) = *ws {
            let subscribe_msgs = vec![
                json!({
                    "jsonrpc": "2.0",
                    "id": 1,
                    "method": "programSubscribe",
                    "params": [
                        "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
                        {
                            "encoding": "jsonParsed",
                            "filters": [
                                {
                                    "dataSize": 165
                                }
                            ]
                        }
                    ]
                }),
                json!({
                    "jsonrpc": "2.0",
                    "id": 2,
                    "method": "programSubscribe",
                    "params": [
                        "JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB",
                        {
                            "encoding": "jsonParsed"
                        }
                    ]
                }),
                json!({
                    "jsonrpc": "2.0",
                    "id": 3,
                    "method": "programSubscribe",
                    "params": [
                        "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
                        {
                            "encoding": "jsonParsed"
                        }
                    ]
                })
            ];

            for msg in subscribe_msgs {
                ws.send(tokio_tungstenite::tungstenite::Message::Text(
                    msg.to_string()
                )).await?;
                
                info!("Subscribed to WebSocket feed: {}", msg["params"][0]);
            }
        }

        Ok(())
    }

    // ... (rest of your existing methods)
}

#[pymodule]
fn solana_rust_bot(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
    m.add_class::<QuantumCore>()?;
    Ok(())
}
"@

Set-Content -Path "C:\solana_rust_bot\src\lib.rs" -Value $content this one + i need the stuff inside here to go in there also . use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use futures_util::{SinkExt, StreamExt};
use std::sync::Arc;
use {
    std::time::{Duration, Instant},
    serde_json::{json, Value},
    anyhow::{anyhow, Result},
    log::{error, info, warn},
    dashmap::DashMap,
    solana_client::rpc_client::RpcClient,
    solana_sdk::{
        signature::{Keypair, Signer},
        commitment_config::CommitmentConfig,
    },
    tokio_tungstenite::{connect_async, WebSocketStream, MaybeTlsStream},
    tokio::net::TcpStream,
    chrono,
};

const JUPITER_API: &str = "https://quote-api.jup.ag/v6";
const HELIUS_RPC: &str = "https://marga-e56m84-fast-mainnet.helius-rpc.com/";
const WS_URL: &str = "wss://marga-e56m84-fast-mainnet.helius-rpc.com/";
const PRIORITY_FEE: u64 = 25000;

#[derive(Debug, Clone)]
struct SwapData {
    input_mint: String,
    output_mint: String,
    input_amount: f64,
    output_amount: f64,
    timestamp: i64,
    signature: String,
}

#[derive(Debug, Clone)]
struct LiquidityData {
    pool_id: String,
    token_mint: String,
    liquidity_change: f64,
    timestamp: i64,
}

#[pymethods]
impl QuantumCore {
    #[new]
    fn new(_pool_id: String) -> PyResult<Self> {
        let rpc_client = RpcClient::new_with_commitment(
            HELIUS_RPC.to_string(),
            CommitmentConfig::confirmed(),
        );

        let inner = QuantumCoreInner {
            rpc_client: Arc::new(rpc_client),
            keypair: Arc::new(Keypair::new()),
            active_trades: Arc::new(DashMap::new()),
            ws_connection: Arc::new(tokio::sync::Mutex::new(None)),
            http_client: Arc::new(reqwest::Client::new()),
        };

        // Create the runtime
        let runtime = tokio::runtime::Builder::new_multi_thread()
            .worker_threads(2)
            .enable_all()
            .build()
            .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;

        Ok(Self {
            inner: Arc::new(inner),
            runtime: Arc::new(runtime),
        })
    }

    fn start_trading(&self) -> PyResult<()> {
        let inner = self.inner.clone();
        
        // Use the existing runtime to spawn the trading task
        self.runtime.spawn(async move {
            if let Err(e) = inner.monitor_market().await {
                error!("Trading error: {}", e);
            }
        });
        
        // Keep the runtime alive
        self.runtime.block_on(async {
            loop {
                tokio::time::sleep(Duration::from_secs(1)).await;
            }
        });

        Ok(())
    }
}

impl QuantumCoreInner { 
    async fn validate_token(&self, token: &TokenInfo) -> Result<bool> {
        if token.volume_24h < 3000.0 || token.liquidity < 250.0 || token.buy_pressure < 0.51 {
            return Ok(false);
        }

        let recent_prices = self.get_recent_prices(&token.mint).await?;
        if recent_prices.is_empty() {
            return Ok(false);
        }

        let momentum = self.calculate_momentum(&recent_prices);
        if momentum < 1.2 {
            return Ok(false);
        }

        Ok(true)
    }
    
    async fn process_swap_data(&self, swap: SwapData) -> Result<()> {
        info!("Processing swap: {} -> {} | Amount: {} -> {}", 
            swap.input_mint, 
            swap.output_mint,
            swap.input_amount,
            swap.output_amount
        );
        Ok(())
    }
    
    async fn process_liquidity_update(&self, liq: LiquidityData) -> Result<()> {
        info!("Liquidity update for pool {} | Token: {} | Change: {}", 
            liq.pool_id,
            liq.token_mint,
            liq.liquidity_change
        );
        Ok(())
    }
    
    fn extract_jupiter_swap(&self, data: &Value) -> Option<SwapData> {
        if let Some(swap_info) = data.get("value").and_then(|v| v.get("parsed")) {
            Some(SwapData {
                input_mint: swap_info.get("inputMint")?.as_str()?.to_string(),
                output_mint: swap_info.get("outputMint")?.as_str()?.to_string(),
                input_amount: swap_info.get("inputAmount")?.as_str()?.parse().ok()?,
                output_amount: swap_info.get("outputAmount")?.as_str()?.parse().ok()?,
                timestamp: chrono::Utc::now().timestamp(),
                signature: data.get("signature")?.as_str()?.to_string(),
            })
        } else {
            None
        }
    }
    
    fn extract_liquidity_data(&self, data: &Value) -> Option<LiquidityData> {
        if let Some(liq_info) = data.get("value").and_then(|v| v.get("parsed")) {
            Some(LiquidityData {
                pool_id: liq_info.get("poolId")?.as_str()?.to_string(),
                token_mint: liq_info.get("tokenMint")?.as_str()?.to_string(),
                liquidity_change: liq_info.get("liquidityChange")?.as_f64()?,
                timestamp: chrono::Utc::now().timestamp(),
            })
        } else {
            None
        }
    }
    fn calculate_momentum(&self, prices: &[f64]) -> f64 {
        if prices.len() < 15 {
            return 0.0;
        }

        let sma_short: f64 = prices[..5].iter().sum::<f64>() / 5.0;
        let sma_long: f64 = prices[..15].iter().sum::<f64>() / 15.0;

        sma_short / sma_long
    }

    async fn get_recent_prices(&self, token_mint: &str) -> Result<Vec<f64>> {
        let request = json!({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "getPriceHistory",
            "params": [token_mint, {"limit": 15}]
        });

        let response = self.http_client
            .post(HELIUS_RPC)
            .json(&request)
            .send()
            .await?
            .json::<Value>()
            .await?;

        Ok(response["result"]
            .as_array()
            .ok_or_else(|| anyhow!("Invalid price history"))?
            .iter()
            .filter_map(|p| p.as_f64())
            .collect())
    }

    fn calculate_position_size(&self, token: &TokenInfo) -> f64 {
        let base_size = 0.01;
        let liquidity_factor = (token.liquidity / 1000.0).min(2.0);
        let volume_factor = (token.volume_24h / 5000.0).min(2.0);
        let pressure_factor = (token.buy_pressure * 2.0).min(1.5);
        
        base_size * liquidity_factor * volume_factor * pressure_factor
    }

    async fn execute_trade(&self, token_mint: &str, side: &str, amount: f64) -> Result<String> {
        let start = Instant::now();
        
        let quote = self.get_jupiter_quote(token_mint, amount, side).await?;

        let swap_request = json!({
            "quoteResponse": quote,
            "userPublicKey": self.keypair.pubkey().to_string(),
            "wrapUnwrapSOL": true,
            "computeUnitPriceMicroLamports": PRIORITY_FEE,
            "priorityFeeLamports": PRIORITY_FEE,
            "asLegacyTransaction": false,
            "maxAccounts": 64
        });

        let swap_response = self.http_client
            .post(format!("{}/swap", JUPITER_API))
            .json(&swap_request)
            .send()
            .await?
            .json::<Value>()
            .await?;

        let swap_tx = swap_response["swapTransaction"]
            .as_str()
            .ok_or_else(|| anyhow!("Invalid swap transaction"))?;

        let helius_request = json!({
            "jsonrpc": "2.0",
            "id": "helius-priority",
            "method": "sendTransaction",
            "params": [
                swap_tx,
                {
                    "encoding": "base64",
                    "maxRetries": 0,
                    "skipPreflight": true,
                    "preflightCommitment": "processed",
                    "priorityFee": PRIORITY_FEE
                }
            ]
        });

        let response = self.http_client
            .post(HELIUS_RPC)
            .json(&helius_request)
            .send()
            .await?
            .json::<Value>()
            .await?;

        let signature = response["result"]
            .as_str()
            .ok_or_else(|| anyhow!("Invalid transaction response"))?
            .to_string();

        if side == "buy" {
            self.active_trades.insert(token_mint.to_string(), TradeState {
                token_mint: token_mint.to_string(),
                entry_price: quote["price"].as_f64().unwrap_or(0.0),
                position_size: amount,
                timestamp: chrono::Utc::now().timestamp(),
                status: "ACTIVE".to_string(),
            });
        }

        info!(
            " Trade executed: {} | Side: {} | Amount: {} SOL | Time: {:?}",
            signature, side, amount, start.elapsed()
        );

        Ok(signature)
    }

    async fn get_jupiter_quote(&self, token_mint: &str, amount: f64, side: &str) -> Result<Value> {
        let (input_mint, output_mint) = if side == "buy" {
            ("So11111111111111111111111111111111111111112", token_mint)
        } else {
            (token_mint, "So11111111111111111111111111111111111111112")
        };

        let url = format!(
            "{}/quote?inputMint={}&outputMint={}&amount={}&slippageBps=50&onlyDirectRoutes=true&wrapUnwrapSOL=true",
            JUPITER_API,
            input_mint,
            output_mint,
            (amount * 1e9) as u64
        );

        let response = self.http_client
            .get(&url)
            .send()
            .await?
            .json::<Value>()
            .await?;

        Ok(response)
    }

    // Add this to your lib.rs WebSocket setup
async fn setup_websocket(&self) -> Result<()> {
    let (ws_stream, _) = connect_async(WS_URL).await?;
    let mut ws = self.ws_connection.lock().await;
    *ws = Some(ws_stream);

    if let Some(ref mut ws) = *ws {
        // Subscribe to SPL token program events
        let subscribe_msgs = vec![
            // Token program subscription
            json!({
                "jsonrpc": "2.0",
                "id": 1,
                "method": "programSubscribe",
                "params": [
                    "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // SPL Token program
                    {
                        "encoding": "jsonParsed",
                        "filters": [
                            {
                                "dataSize": 165 // Size of TokenAccount data
                            }
                        ]
                    }
                ]
            }),
            // Jupiter program subscription
            json!({
                "jsonrpc": "2.0",
                "id": 2,
                "method": "programSubscribe",
                "params": [
                    "JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB", // Jupiter aggregator
                    {
                        "encoding": "jsonParsed"
                    }
                ]
            }),
            // Raydium CLMM program for liquidity
            json!({
                "jsonrpc": "2.0",
                "id": 3,
                "method": "programSubscribe",
                "params": [
                    "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
                    {
                        "encoding": "jsonParsed"
                    }
                ]
            })
        ];

        for msg in subscribe_msgs {
            ws.send(tokio_tungstenite::tungstenite::Message::Text(
                msg.to_string()
            )).await?;
            
            info!("Subscribed to WebSocket feed: {}", msg["params"][0]);
        }
    }

    Ok(())
}

// Update monitor_market function to handle WebSocket messages
async fn monitor_market(&self) -> Result<()> {
    self.setup_websocket().await?;
    
    let mut buy_pressure_map: DashMap<String, (f64, f64)> = DashMap::new(); // (buys, sells)
    
    if let Some(ws) = &mut *self.ws_connection.lock().await {
        while let Some(msg) = ws.next().await {
            let msg = msg?;
            if let Ok(data) = serde_json::from_str::<Value>(&msg.to_string()) {
                // Process SPL token transfers
                if let Some(result) = data.get("params").and_then(|p| p.get("result")) {
                    if let Some(program_id) = result.get("value").and_then(|v| v.get("pubkey")) {
                        match program_id.as_str() {
                            Some("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") => {
                                // Process SPL token transfer
                                if let Some(token_data) = self.extract_token_transfer(&result) {
                                    let (mint, amount, is_buy) = token_data;
                                    let entry = buy_pressure_map.entry(mint).or_insert((0.0, 0.0));
                                    if is_buy {
                                        entry.0 += amount;
                                    } else {
                                        entry.1 += amount;
                                    }
                                }
                            },
                            Some("JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB") => {
                                // Process Jupiter swap
                                if let Some(swap_data) = self.extract_jupiter_swap(&result) {
                                    self.process_swap_data(swap_data).await?;
                                }
                            },
                            Some("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8") => {
                                // Process Raydium liquidity
                                if let Some(liq_data) = self.extract_liquidity_data(&result) {
                                    self.process_liquidity_update(liq_data).await?;
                                }
                            },
                            _ => {}
                        }
                    }
                }

                // Calculate buy pressure and check for trading opportunities
                for entry in buy_pressure_map.iter() {
                    let mint = entry.key();
                    let (buys, sells) = *entry.value();
                    let total = buys + sells;
                    if total > 0.0 {
                        let buy_pressure = buys / total;
                        
                        // Create TokenInfo with real-time data
                        let token = TokenInfo {
                            mint: mint.clone(),
                            price: 0.0, // Will be filled from Jupiter API
                            liquidity: total,
                            volume_24h: total,
                            buy_pressure,
                            timestamp: chrono::Utc::now().timestamp(),
                        };

                        // Check if we should trade
                        if self.validate_token(&token).await? {
                            let result = self.execute_trade(
                                &token.mint,
                                "buy",
                                self.calculate_position_size(&token)
                            ).await?;
                            
                            info!("⚡ Trade executed: {}", result);
                        }
                    }
                }
            }
        }
    }

    Ok(())
}

// Helper function to extract token transfer data
fn extract_token_transfer(&self, data: &Value) -> Option<(String, f64, bool)> {
    // Attempt to extract mint address, amount, and direction
    if let Some(parsed_data) = data.get("parsed").and_then(|p| p.get("info")) {
        let mint = parsed_data.get("mint")?.as_str()?.to_string();
        let amount = parsed_data.get("amount")?.as_str()?.parse::<f64>().ok()?;
        let source = parsed_data.get("source")?.as_str()?;
        let destination = parsed_data.get("destination")?.as_str()?;
        
        // Determine if it's a buy (transfer to user wallet) or sell
        let is_buy = !source.starts_with("Jupiter") && destination.starts_with("Jupiter");
        
        Some((mint, amount, is_buy))
    } else {
        None
    }
}

// Helper function to extract Jupiter swap data
fn extract_jupiter_swap(&self, data: &Value) -> Option<SwapData> {
    // Add swap data extraction logic
    None // Placeholder
}

// Helper function to extract liquidity data
fn extract_liquidity_data(&self, data: &Value) -> Option<LiquidityData> {
    // Add liquidity data extraction logic
    None // Placeholder
}

    async fn manage_positions(&self) -> Result<()> {
        let mut to_remove = Vec::new();
        
        for trade in self.active_trades.iter() {
            let token_mint = trade.key().clone();
            let trade_state = trade.value().clone();
    
            let prices = self.get_recent_prices(&token_mint).await?;
            if let Some(&current_price) = prices.first() {
                let pl_percent = (current_price - trade_state.entry_price) / trade_state.entry_price * 100.0;
    
                if pl_percent >= 3.0 || pl_percent <= -1.5 {
                    match self.execute_trade(&token_mint, "sell", trade_state.position_size).await {
                        Ok(_) => {
                            to_remove.push(token_mint.clone());
                            info!(" Position closed: {} | P/L: {:.2}%", token_mint, pl_percent);
                        }
                        Err(e) => error!("Error closing position: {}", e),
                    }
                }
            } else {
                warn!("No recent prices available for token: {}", token_mint);
            }
        }
    
        for mint in to_remove {
            self.active_trades.remove(&mint);
        }
        
        Ok(())
    }

    fn extract_pool_tokens(&self, data: &Value) -> Option<Vec<TokenInfo>> {
        let tokens = data.get("params")?
            .get("result")?
            .get("data")?
            .get("tokens")?
            .as_array()?;
        
        let result = tokens.iter()
            .filter_map(|token| {
                Some(TokenInfo {
                    mint: token.get("mint")?.as_str()?.to_string(),
                    price: token.get("price")?.as_f64()?,
                    liquidity: token.get("liquidity")?.as_f64()?,
                    volume_24h: token.get("volume24h")?.as_f64()?,
                    buy_pressure: token.get("buyPressure")
                        .and_then(|v| v.as_f64())
                        .unwrap_or(0.5),
                    timestamp: chrono::Utc::now().timestamp(),
                })
            })
            .collect::<Vec<_>>();

        if result.is_empty() {
            None
        } else {
            Some(result)
        }
    }
}

#[pymodule]
fn solana_rust_bot(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
    m.add_class::<QuantumCore>()?;
    Ok(())
}
// Add this at the top of lib.rs
mod types;
use types::*;
 so please if u can produce the full coded end script just make nessasary edits please