From f5ded6730ba1fcd02e59e577a0b0a852b75a796e Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:02:14 -0500 Subject: [PATCH 1/4] disallow premium with fixed order --- src/app/order.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/order.rs b/src/app/order.rs index b256ca9c..572f3546 100644 --- a/src/app/order.rs +++ b/src/app/order.rs @@ -67,6 +67,11 @@ pub async fn order_action( amount_vec.push(max); } + if order.premium != 0 && order.amount !=0 && order.fiat_amount !=0 { + send_cant_do_msg(None, None, &event.sender).await; + return Ok(()); + } + for fiat_amount in amount_vec.iter() { let quote = match order.amount { 0 => match get_bitcoin_price(&order.fiat_code) { From a8457aabae46475c4c35ff7eba2ae4e768359ec1 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:47:31 -0500 Subject: [PATCH 2/4] fix test --- src/app/order.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/order.rs b/src/app/order.rs index 572f3546..20ffd9cf 100644 --- a/src/app/order.rs +++ b/src/app/order.rs @@ -68,7 +68,7 @@ pub async fn order_action( } if order.premium != 0 && order.amount !=0 && order.fiat_amount !=0 { - send_cant_do_msg(None, None, &event.sender).await; + send_cant_do_msg(request_id, None, None, &event.sender).await; return Ok(()); } From 0a949863c8b64665bd0f1bbdbc2fd09ab6e1aea5 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:44:18 -0500 Subject: [PATCH 3/4] cargo fmt --- src/app/order.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/order.rs b/src/app/order.rs index 20ffd9cf..6edd3698 100644 --- a/src/app/order.rs +++ b/src/app/order.rs @@ -67,7 +67,7 @@ pub async fn order_action( amount_vec.push(max); } - if order.premium != 0 && order.amount !=0 && order.fiat_amount !=0 { + if order.premium != 0 && order.amount != 0 && order.fiat_amount != 0 { send_cant_do_msg(request_id, None, None, &event.sender).await; return Ok(()); } From ecb5835848f64875d2effec5c0ed6b2692513fe9 Mon Sep 17 00:00:00 2001 From: Catrya <140891948+Catrya@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:40:59 -0500 Subject: [PATCH 4/4] more idiomatic --- src/app/order.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/order.rs b/src/app/order.rs index 6edd3698..e2fa6f2c 100644 --- a/src/app/order.rs +++ b/src/app/order.rs @@ -67,7 +67,11 @@ pub async fn order_action( amount_vec.push(max); } - if order.premium != 0 && order.amount != 0 && order.fiat_amount != 0 { + let premium = (order.premium != 0).then_some(order.premium); + let amount = (order.amount != 0).then_some(order.amount); + let fiat_amount = (order.fiat_amount != 0).then_some(order.fiat_amount); + + if premium.is_some() && amount.is_some() && fiat_amount.is_some() { send_cant_do_msg(request_id, None, None, &event.sender).await; return Ok(()); }