Skip to content

Commit e19e1c5

Browse files
committed
review: move base amount calc to a variable
1 parent 011798a commit e19e1c5

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

mm2src/mm2_main/src/lp_ordermatch.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,22 +1645,19 @@ impl TakerOrder {
16451645
return MatchReservedResult::NotMatched;
16461646
}
16471647

1648-
if self.request.swap_version.is_legacy() || reserved.swap_version.is_legacy() {
1649-
if my_rel_amount <= other_base_amount {
1650-
MatchReservedResult::Matched
1651-
} else {
1652-
MatchReservedResult::NotMatched
1653-
}
1648+
let other_base_amount = if self.request.swap_version.is_legacy() || reserved.swap_version.is_legacy() {
1649+
other_base_amount.clone()
16541650
} else {
16551651
let premium = &reserved.premium.clone().unwrap_or_default();
16561652
let other_price = &(my_base_amount - premium) / other_base_amount;
16571653
// In match_with_request function, we allowed maker to send fewer coins for taker sell action
1658-
let result_other_base_amount = other_base_amount + &(premium / &other_price);
1659-
if my_rel_amount <= &result_other_base_amount {
1660-
MatchReservedResult::Matched
1661-
} else {
1662-
MatchReservedResult::NotMatched
1663-
}
1654+
other_base_amount + &(premium / &other_price)
1655+
};
1656+
1657+
if my_rel_amount <= &other_base_amount {
1658+
MatchReservedResult::Matched
1659+
} else {
1660+
MatchReservedResult::NotMatched
16641661
}
16651662
},
16661663
}

0 commit comments

Comments
 (0)