fn 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 simulation_resp = suite.simulate_swap(1000, suite.btc()).unwrap();

        // cash to be left on contract: 6000 * 2000 / (2000 + 1000) = 4000
        // cash to be paid out: 6000 - 4000 = 2000
        // commission: 2000 * 0.005 = 10
        // cash to be paid out after commission: 2000 - 10 = 1990
        // spread: 1000 * 6000 / 2000 - 2000 = 3000 - 2000 = 1000
        assert_eq!(
            simulation_resp,
            SimulationResponse {
                return_amount: Uint128::new(1990),
                spread_amount: Uint128::new(1000),
                commission_amount: Uint128::new(10),
            }
        );

        let simulation_resp = suite.simulate_swap(14000, suite.cash()).unwrap();

        // btc to be left on contract: 6000 * 2000 / (6000 + 14000) = 600
        // btc to be paid out: 2000 - 600 = 1400
        // comission: 1400 * 0.005 = 7
        // btc to be paid out after commission: 1400 - 7 = 1393
        // spread: 14000 * 2000 / 6000 - 1400 = 3266
        assert_eq!(
            simulation_resp,
            SimulationResponse {
                return_amount: Uint128::new(1393),
                spread_amount: Uint128::new(3266),
                commission_amount: Uint128::new(7),
            }
        );
    }
// Checks if simulation works properly
//
// Equivalent of `super::simulate` with custom commission
Checks if simulation works properly
Equivalent of `super::simulate` with custom commission
Checks if simulation works properly Equivalent of ` super :: simulate ` with custom commission
fn 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 simulation_resp = suite.simulate_swap(1000, suite.btc()).unwrap();
        // cash to be left on contract: 6000 * 2000 / (2000 + 1000) = 4000
        // cash to be paid out: 6000 - 4000 = 2000
        // commission: 2000 * 0.005 = 10
        // cash to be paid out after commission: 2000 - 10 = 1990
        // spread: 1000 * 6000 / 2000 - 2000 = 3000 - 2000 = 1000
        assert_eq!(
            simulation_resp,
            SimulationResponse {
                return_amount: Uint128::new(1990),
                spread_amount: Uint128::new(1000),
                commission_amount: Uint128::new(10),
            }
        );
        let simulation_resp = suite.simulate_swap(14000, suite.cash()).unwrap();
        // btc to be left on contract: 6000 * 2000 / (6000 + 14000) = 600
        // btc to be paid out: 2000 - 600 = 1400
        // comission: 1400 * 0.005 = 7
        // btc to be paid out after commission: 1400 - 7 = 1393
        // spread: 14000 * 2000 / 6000 - 1400 = 3266
        assert_eq!(
            simulation_resp,
            SimulationResponse {
                return_amount: Uint128::new(1393),
                spread_amount: Uint128::new(3266),
                commission_amount: Uint128::new(7),
            }
        );
    }
fn 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 simulation_resp = suite . simulate_swap ( 1000 , suite . btc ( ) ) . unwrap ( ) ; // cash to be left on contract: 6000 * 2000 / (2000 + 1000) = 4000 // cash to be paid out: 6000 - 4000 = 2000 // commission: 2000 * 0.005 = 10 // cash to be paid out after commission: 2000 - 10 = 1990 // spread: 1000 * 6000 / 2000 - 2000 = 3000 - 2000 = 1000 assert_eq ! ( simulation_resp SimulationResponse { return_amount Uint128 new ( 1990 ) spread_amount Uint128 new ( 1000 ) commission_amount Uint128 new ( 10 ) } ) ; let simulation_resp = suite . simulate_swap ( 14000 , suite . cash ( ) ) . unwrap ( ) ; // btc to be left on contract: 6000 * 2000 / (6000 + 14000) = 600 // btc to be paid out: 2000 - 600 = 1400 // comission: 1400 * 0.005 = 7 // btc to be paid out after commission: 1400 - 7 = 1393 // spread: 14000 * 2000 / 6000 - 1400 = 3266 assert_eq ! ( simulation_resp SimulationResponse { return_amount Uint128 new ( 1393 ) spread_amount Uint128 new ( 3266 ) commission_amount Uint128 new ( 7 ) } ) ; }
Checks if simulation works properly
Equivalent of `super::simulate` with custom commission
Checks if simulation works properly Equivalent of ` super :: simulate ` with custom commission