fn reverse_simulate() {
        // Initialize suite:
        // liquidity provider (lp): 2000btc + 6000cash
        let mut suite = SuiteConfig::new()
            .with_liquidity_provider("liquidity-provider", 2000, 6000)
            .with_commission(Decimal::permille(5))
            .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
//
// Equivalent of `super::reverse_simulate` with custom commission
Checks if reverse simulation works properly
Equivalent of `super::reverse_simulate` with custom commission
Checks if reverse simulation works properly Equivalent of ` super :: reverse_simulate ` with custom commission
fn reverse_simulate() {
        // Initialize suite:
        // liquidity provider (lp): 2000btc + 6000cash
        let mut suite = SuiteConfig::new()
            .with_liquidity_provider("liquidity-provider", 2000, 6000)
            .with_commission(Decimal::permille(5))
            .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 ) . with_commission ( Decimal :: permille ( 5 ) ) . 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
Equivalent of `super::reverse_simulate` with custom commission
Checks if reverse simulation works properly Equivalent of ` super :: reverse_simulate ` with custom commission