Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update_maker_order RPC #926

Merged
merged 10 commits into from May 6, 2021
Merged

Add update_maker_order RPC #926

merged 10 commits into from May 6, 2021

Conversation

shamardy
Copy link
Collaborator

fixes #814

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comments 🙂

mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few more change proposals 🙂

mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
@artemii235 artemii235 requested a review from tonymorony May 3, 2021 07:38
artemii235
artemii235 previously approved these changes May 3, 2021
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🔥

@tonymorony Could you please arrange a test of the following case:

  1. Setup a maker order on the node.
  2. Ensure that it's displayed on other nodes' order books.
  3. Call update_maker_order.
  4. Check that order books are updated.

It's not required for all nodes to use the mm2.1-update-maker-order. Only the order creator node should be on this branch.

@tonymorony tonymorony requested a review from SirSevenG May 3, 2021 08:52
SirSevenG
SirSevenG previously approved these changes May 4, 2021
Copy link

@SirSevenG SirSevenG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following requested case: #926 (review)

No issues found, order is updated on all nodes.

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed 1 tricky situation, cc @tonymorony @cipig I would like to know your opinion on this, please check the comment below 🙂

mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
@shamardy shamardy dismissed stale reviews from SirSevenG and artemii235 via 2e4ce65 May 5, 2021 08:59
@shamardy
Copy link
Collaborator Author

shamardy commented May 5, 2021

After discussion with @artemii235 Request now should be:

{
  "method":"update_maker_order",
  "params":{
    "uuid": "123e4567-e89b-12d3-a456-426614174000",
    "new_price": "1", (optional, can be supplied as decimal/fraction/rational)
    "volume_delta": "-1", (optional, can be supplied as decimal/fraction/rational, can be positive/negative number to increase/decrease the volume, ignored if max = true)
    "max": true, (optional, whether to use max available volume)
    "base_confs": 1, (optional)
    "base_nota": false, (optional)
    "rel_confs": 1, (optional)
    "rel_nota": false (optional)
  }
}

"new_volume" is now "volume_delta" which will be more beneficial for the GUI as well.

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last of the last review iteration 😄

mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, this is really the last review iteration.

reserved_amount
);
}
update_msg = update_msg.with_new_max_volume((new_volume - order.reserved_amount()).into());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in invalid volume being set for order:

  1. Let's say the current max_base_vol = 5, reserved = 3 so available = 2.
  2. We set volume_delta = 2 in the request. The new_volume = original_volume + volume_delta = 7.
  3. Then we deduct new_volume - reserved_amount so max_base_vol = 7 - 3 = 4, which is even lower than initial one.

You also have let reserved_amount = order.reserved_amount(); in a couple of lines above, you can reuse it to avoid calculation duplication overhead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I had it after order.apply_updated(&update_msg) but must have messed it up later. Will fix it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also use reserved_amount from here https://github.com/KomodoPlatform/atomicDEX-API/blob/db9c095995cc586c65573a68eada05752189f95c/mm2src/lp_ordermatch.rs#L3370
avoiding calculation in let reserved_amount = order.reserved_amount(); too, since we made sure It won't change through the update call.

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did it, great! 😄

@artemii235 artemii235 merged commit aa3194d into dev May 6, 2021
@artemii235 artemii235 deleted the mm2.1-update-maker-order branch May 6, 2021 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants