Fix order matching max volume #1041#1047
Conversation
shamardy
left a comment
There was a problem hiding this comment.
Thank you for the fix :)
I have only one comment.
| let rel_amount = taker_base_amount.clone(); | ||
| // If `taker_base_amount == max_base_amount`, then `taker_price` has to be equal to [`MakerOrder::price`], | ||
| // otherwise the result base volume will be greater than [`MakerOrder::max_base_amount`]. | ||
| if base_amount > self.max_base_vol { |
There was a problem hiding this comment.
I think we should move this check here https://github.com/KomodoPlatform/atomicDEX-API/blob/6b0e648b76512edb02212e01997e5f00531895ff/mm2src/lp_ordermatch.rs#L1618 as it should probably check with available_amount. Also base_amount = taker_base_amount / &self.price will always be greater than or equal to taker_rel_amount.
Also since base_amount is always greater than or equal to taker_rel_amount we can use it for this check too https://github.com/KomodoPlatform/atomicDEX-API/blob/6b0e648b76512edb02212e01997e5f00531895ff/mm2src/lp_ordermatch.rs#L1619 because the taker may have requested a lower volume than min_base_vol but the maker can offer a higher amount because the maker price is lower, so taker_rel_amount >= &self.min_base_vol may prevent matching an order that can be matched with a better price for the taker without violating the min_base_vol for the maker, a test case for this should be added too.
Please correct me if I am wrong.
There was a problem hiding this comment.
Everything is correct. I'm working on this right now, thanks :)
* Extend test_match_maker_order_and_taker_request
artemii235
left a comment
There was a problem hiding this comment.
Thanks for the fix! I have one question.
No description provided.