diff --git a/mm2src/docker_tests.rs b/mm2src/docker_tests.rs index 66003c74a3..c1bc429e1b 100644 --- a/mm2src/docker_tests.rs +++ b/mm2src/docker_tests.rs @@ -2234,12 +2234,13 @@ mod docker_tests { }))) .unwrap(); assert!(rc.0.is_success(), "!max_taker_vol: {}", rc.1); - let json: Json = json::from_str(&rc.1).unwrap(); + let json: MaxTakerVolResponse = json::from_str(&rc.1).unwrap(); // the result of equation `max_vol + max_vol / 777 + 0.00002 = 1` // derived from `max_vol = balance - locked - trade_fee - fee_to_send_taker_fee - dex_fee(max_vol)` // where balance = 1, locked = 0, trade_fee = fee_to_send_taker_fee = 0.00001, dex_fee = max_vol / 777 - assert_eq!(json["result"]["numer"], Json::from("38849223")); - assert_eq!(json["result"]["denom"], Json::from("38900000")); + let expected = MmNumber::from((38849223, 38900000)).to_fraction(); + assert_eq!(json.result, expected); + assert_eq!(json.coin, "MYCOIN1"); let rc = block_on(mm_alice.rpc(json! ({ "userpass": mm_alice.userpass, @@ -2247,10 +2248,7 @@ mod docker_tests { "base": "MYCOIN1", "rel": "MYCOIN", "price": 1, - "volume": { - "numer": json["result"]["numer"], - "denom": json["result"]["denom"], - } + "volume": json.result, }))) .unwrap(); assert!(rc.0.is_success(), "!sell: {}", rc.1); diff --git a/mm2src/lp_swap/taker_swap.rs b/mm2src/lp_swap/taker_swap.rs index 5663d4304b..83748c3bf9 100644 --- a/mm2src/lp_swap/taker_swap.rs +++ b/mm2src/lp_swap/taker_swap.rs @@ -1713,7 +1713,8 @@ pub async fn max_taker_vol(ctx: MmArc, req: Json) -> Result>, S }; let res = try_s!(json::to_vec(&json!({ - "result": max_vol.to_fraction() + "result": max_vol.to_fraction(), + "coin": coin.ticker(), }))); Ok(try_s!(Response::builder().body(res))) } diff --git a/mm2src/mm2_tests/structs.rs b/mm2src/mm2_tests/structs.rs index 0b3affb8c4..d9ed6fc74a 100644 --- a/mm2src/mm2_tests/structs.rs +++ b/mm2src/mm2_tests/structs.rs @@ -500,6 +500,7 @@ impl TradePreimageResponse { #[serde(deny_unknown_fields)] pub struct MaxTakerVolResponse { pub result: Fraction, + pub coin: String, } #[derive(Debug, Deserialize)]