use anyhow::Result;
use tracing::info;
use crate::sor::router::Route;
#[derive(Debug, Clone)]
pub struct SwapResult {
pub simulated_sig: String,
pub input_amount: f64,
pub output_amount: f64,
pub fee_paid: f64,
pub is_dry_run: bool,
}
#[allow(clippy::unused_async)] pub async fn simulate_swap(route: &Route, amount: f64, dry_run: bool) -> Result<SwapResult> {
info!(
venue = %route.venue,
price = route.effective_price,
amount,
dry_run,
"[JUPITER] Simulating swap"
);
if !dry_run {
anyhow::bail!("Live mode not enabled in demo. Omit --live or set DRY_RUN=true.");
}
let output = amount * route.effective_price;
let fee = amount * (f64::from(route.fee_bps) / 10_000.0);
let sig = format!("SIM_{:016x}", rand::random::<u64>());
let result = SwapResult {
simulated_sig: sig,
input_amount: amount,
output_amount: output,
fee_paid: fee,
is_dry_run: true,
};
info!(
sig = %result.simulated_sig,
input = result.input_amount,
output = result.output_amount,
fee = result.fee_paid,
"[JUPITER] Swap simulation complete (DRY RUN)"
);
Ok(result)
}