fn reverse_simulate() {
    // Initialize suite:
    // liquidity provider (lp): 2000btc + 6000cash
    let mut suite = SuiteConfig::new()
        .with_liquidity_provider("liquidity-provider", 2000, 6000)
        .init()
        .unwrap();

    let lp = suite.lps[0].clone();

    suite.provide_liquidity(&lp, 2000, 6000, None).unwrap();
    let rev_simulation_resp = suite.simulate_reverse_swap(1000, suite.btc()).unwrap();
    let simulation_resp = suite
        .simulate_swap(rev_simulation_resp.offer_amount.into(), suite.cash())
        .unwrap();

    assert_eq!(simulation_resp.return_amount, Uint128::new(1000));
    assert_eq!(
        simulation_resp.spread_amount,
        rev_simulation_resp.spread_amount
    );
    assert_eq!(
        simulation_resp.commission_amount,
        rev_simulation_resp.commission_amount
    );

    let rev_simulation_resp = suite.simulate_reverse_swap(1000, suite.cash()).unwrap();
    let simulation_resp = suite
        .simulate_swap(rev_simulation_resp.offer_amount.into(), suite.btc())
        .unwrap();

    assert_eq!(simulation_resp.return_amount, Uint128::new(1000));
    assert_eq!(
        simulation_resp.spread_amount,
        rev_simulation_resp.spread_amount
    );
    assert_eq!(
        simulation_resp.commission_amount,
        rev_simulation_resp.commission_amount
    );
}
// Checks if reverse simulation works properly
// * Provide liquidity for test pair contract
// * Reverse simulate swap in both ways
// * Check, that after simulating with given results, ammounts are as expected
//
// Reverse simulation results are not validated directly, as due to calculation precision it is
// poosible, reverse simulation might return range of results.
Checks if reverse simulation works properly
Provide liquidity for test pair contract
Reverse simulate swap in both ways
Check, that after simulating with given results, ammounts are as expected

Reverse simulation results are not validated directly, as due to calculation precision it is
poosible, reverse simulation might return range of results.
Checks if reverse simulation works properly Provide liquidity for test pair contract Reverse simulate swap in both ways Check that after simulating with given results ammounts are as expected Reverse simulation results are not validated directly as due to calculation precision it is poosible reverse simulation might return range of results .
fn reverse_simulate() {
    // Initialize suite:
    // liquidity provider (lp): 2000btc + 6000cash
    let mut suite = SuiteConfig::new()
        .with_liquidity_provider("liquidity-provider", 2000, 6000)
        .init()
        .unwrap();
    let lp = suite.lps[0].clone();
    suite.provide_liquidity(&lp, 2000, 6000, None).unwrap();
    let rev_simulation_resp = suite.simulate_reverse_swap(1000, suite.btc()).unwrap();
    let simulation_resp = suite
        .simulate_swap(rev_simulation_resp.offer_amount.into(), suite.cash())
        .unwrap();
    assert_eq!(simulation_resp.return_amount, Uint128::new(1000));
    assert_eq!(
        simulation_resp.spread_amount,
        rev_simulation_resp.spread_amount
    );
    assert_eq!(
        simulation_resp.commission_amount,
        rev_simulation_resp.commission_amount
    );
    let rev_simulation_resp = suite.simulate_reverse_swap(1000, suite.cash()).unwrap();
    let simulation_resp = suite
        .simulate_swap(rev_simulation_resp.offer_amount.into(), suite.btc())
        .unwrap();
    assert_eq!(simulation_resp.return_amount, Uint128::new(1000));
    assert_eq!(
        simulation_resp.spread_amount,
        rev_simulation_resp.spread_amount
    );
    assert_eq!(
        simulation_resp.commission_amount,
        rev_simulation_resp.commission_amount
    );
}
fn reverse_simulate ( ) { // Initialize suite: // liquidity provider (lp): 2000btc + 6000cash let mut suite = SuiteConfig :: new ( ) . with_liquidity_provider ( " " , 2000 , 6000 ) . init ( ) . unwrap ( ) ; let lp = suite . lps [ 0 ] . clone ( ) ; suite . provide_liquidity ( & lp , 2000 , 6000 , None ) . unwrap ( ) ; let rev_simulation_resp = suite . simulate_reverse_swap ( 1000 , suite . btc ( ) ) . unwrap ( ) ; let simulation_resp = suite . simulate_swap ( rev_simulation_resp . offer_amount . into ( ) , suite . cash ( ) ) . unwrap ( ) ; assert_eq ! ( simulation_resp return_amount Uint128 new ( 1000 ) ) ; assert_eq ! ( simulation_resp spread_amount rev_simulation_resp spread_amount ) ; assert_eq ! ( simulation_resp commission_amount rev_simulation_resp commission_amount ) ; let rev_simulation_resp = suite . simulate_reverse_swap ( 1000 , suite . cash ( ) ) . unwrap ( ) ; let simulation_resp = suite . simulate_swap ( rev_simulation_resp . offer_amount . into ( ) , suite . btc ( ) ) . unwrap ( ) ; assert_eq ! ( simulation_resp return_amount Uint128 new ( 1000 ) ) ; assert_eq ! ( simulation_resp spread_amount rev_simulation_resp spread_amount ) ; assert_eq ! ( simulation_resp commission_amount rev_simulation_resp commission_amount ) ; }
Checks if reverse simulation works properly
 Provide liquidity for test pair contract
 Reverse simulate swap in both ways
 Check, that after simulating with given results, ammounts are as expected
Checks if reverse simulation works properly Provide liquidity for test pair contract Reverse simulate swap in both ways Check that after simulating with given results ammounts are as expected