use anchor_client::Cluster;
use jup_lend_sdk::borrow::read::{
    get_vault_liquidations, get_vault_liquidations_with_options, VaultLiquidationsOptions,
};
use jup_lend_sdk::borrow::simulations::get_vault_liquidations as get_simulated_liquidations;
use std::str::FromStr;
use std::time::Instant;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let rpc_url =
        dotenv::var("RPC_URL").unwrap_or("https://api.mainnet-beta.solana.com".to_string());
    let cluster = Cluster::from_str(rpc_url.as_str())?;

    let start = Instant::now();
    let simulated_liquidations =
        get_simulated_liquidations(7, 0, true, None, cluster.clone()).await?;
    let simulated_duration = start.elapsed();

    dbg!(simulated_liquidations);
    println!("Simulated liquidations took: {:?}", simulated_duration);

    let start = Instant::now();
    let liquidations = get_vault_liquidations(7, 0, true, None, cluster.clone()).await?;
    let liquidations_duration = start.elapsed();

    dbg!(liquidations);
    println!("Vault liquidations took: {:?}", liquidations_duration);

    let start = Instant::now();
    let liquidations = get_vault_liquidations_with_options(
        7,
        VaultLiquidationsOptions {
            col_per_unit_debt: 0,
            absorb: true,
            signer: None,
            oracle_price: Some(176164706020000000),
            cluster: cluster.clone(),
        },
    )
    .await?;
    let liquidations_duration = start.elapsed();

    dbg!(liquidations);
    println!(
        "Vault liquidations with options took: {:?}",
        liquidations_duration
    );

    Ok(())
}
