Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions mm2src/docker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,23 +2234,21 @@ 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,
"method": "sell",
"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);
Expand Down
3 changes: 2 additions & 1 deletion mm2src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,8 @@ pub async fn max_taker_vol(ctx: MmArc, req: Json) -> Result<Response<Vec<u8>>, 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)))
}
Expand Down
1 change: 1 addition & 0 deletions mm2src/mm2_tests/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ impl TradePreimageResponse {
#[serde(deny_unknown_fields)]
pub struct MaxTakerVolResponse {
pub result: Fraction,
pub coin: String,
}

#[derive(Debug, Deserialize)]
Expand Down