Skip to content

Commit

Permalink
fix 349
Browse files Browse the repository at this point in the history
Now Mostro will first check the status of the order and then if the quantity requested to be taken is within the range and not the other way around.
  • Loading branch information
Catrya committed Sep 2, 2024
1 parent 41f182c commit f4474ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions src/app/take_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,7 @@ pub async fn take_buy_action(
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
return Ok(());
}

// Get amount request if user requested one for range order - fiat amount will be used below
if let Some(am) = get_fiat_amount_requested(&order, &msg) {
order.fiat_amount = am;
} else {
send_new_order_msg(
Some(order.id),
Action::OutOfRangeFiatAmount,
None,
&event.pubkey,
)
.await;
return Ok(());
}


let order_status = match Status::from_str(&order.status) {
Ok(s) => s,
Err(e) => {
Expand Down Expand Up @@ -97,6 +83,20 @@ pub async fn take_buy_action(
return Ok(());
}

// Get amount request if user requested one for range order - fiat amount will be used below
if let Some(am) = get_fiat_amount_requested(&order, &msg) {
order.fiat_amount = am;
} else {
send_new_order_msg(
Some(order.id),
Action::OutOfRangeFiatAmount,
None,
&event.pubkey,
)
.await;
return Ok(());
}

// Check market price value in sats - if order was with market price then calculate
if order.amount == 0 {
let (new_sats_amount, fee) =
Expand Down
28 changes: 14 additions & 14 deletions src/app/take_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ pub async fn take_sell_action(
}
};

// Get amount request if user requested one for range order - fiat amount will be used below
if let Some(am) = get_fiat_amount_requested(&order, &msg) {
order.fiat_amount = am;
} else {
send_new_order_msg(
Some(order.id),
Action::OutOfRangeFiatAmount,
None,
&event.pubkey,
)
.await;
return Ok(());
}

// Maker can't take own order
if order.creator_pubkey == event.pubkey.to_hex() {
send_cant_do_msg(Some(order.id), None, &event.pubkey).await;
Expand Down Expand Up @@ -141,6 +127,20 @@ pub async fn take_sell_action(
}
}

// Get amount request if user requested one for range order - fiat amount will be used below
if let Some(am) = get_fiat_amount_requested(&order, &msg) {
order.fiat_amount = am;
} else {
send_new_order_msg(
Some(order.id),
Action::OutOfRangeFiatAmount,
None,
&event.pubkey,
)
.await;
return Ok(());
}

// Check market price value in sats - if order was with market price then calculate it and send a DM to buyer
if order.amount == 0 {
let (new_sats_amount, fee) =
Expand Down

0 comments on commit f4474ce

Please sign in to comment.