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

Remove cancel event for limit order when all size fills, enable posts below min size #347

Merged
merged 6 commits into from
Jul 21, 2023

Conversation

alnoki
Copy link
Member

@alnoki alnoki commented Jul 19, 2023

Summary of changes

Previously, if a NO_RESTRICTION limit order fully filled across the spread, it would emit a CancelOrderEvent with CANCEL_REASON_TOO_SMALL_AFTER_MATCHING.

Now, if a NO_RESTRICTION limit order fills across the spread it will not emit a CancelOrderEvent for a full fill. Additionally, limit orders that first fill across the spread can post to the book at any nonzero size.

Versus market orders and swaps

Now, cancel event behavior is consistent across limit orders, market orders, and swap orders. If an order fully fills during the transaction in which it was placed, it will emit A Place<Limit | Market | Swap>OrderEvent and FillEvent(s), but not a CancelOrderEvent.

Testing

Move source code has been tested to 100% coverage, but there is no way to validate event fields inside a Move unit test. I documented Aptos' event testing deficiency in October (aptos-labs/aptos-core#5369), and in May I cited insufficient event testing as the likely reason for an error in Aptos' own code that I corrected through a PR (aptos-labs/aptos-core#8448).

The inability to write Move unit tests that assert event emissions is a contributing factor to this PR's changes not getting slated into #321 , and seeing as this issue was uncovered during discussions about projected event emission schedules, it is suggested that all event emission cases and field be asserted during end-to-end tests in Python and/or Rust.

@vercel
Copy link

vercel bot commented Jul 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
econia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 21, 2023 0:02am

@vercel vercel bot temporarily deployed to Preview July 19, 2023 16:55 Inactive
The inline modifier needs to be commented out for
coverage testing per

aptos-labs/aptos-core#9154
@alnoki alnoki force-pushed the limit-order-cancel-reason branch from 6b27fd3 to f5d5c13 Compare July 19, 2023 17:04
@vercel vercel bot temporarily deployed to Preview July 19, 2023 17:05 Inactive
src/move/econia/sources/market.move Outdated Show resolved Hide resolved
@@ -3470,7 +3469,7 @@ module econia::market {
let market_order_id =
((order_book_ref_mut.counter as u128) << SHIFT_COUNTER);
// If order eligible to post:
if (option::is_none(&cancel_reason_option)) {
if (option::is_none(&cancel_reason_option) && (remaining_size > 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This combined with

// If not eligible to post, no remaining size.
remaining_size = 0;

mean that any order that is cancelled here will have remaining_size set to zero. However, this shouldn't be the case. If, for instance, an IOC order partially filled and then cancelled due to the entire order not being immediately fillable, the remaining size should still not be zero as the order was not fully filled.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogberry addressed as of f2c1777

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, but in the future please link the commit in which the fix was made so I can look at the diff

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogberry will do, thanks for clarifying

@vercel vercel bot temporarily deployed to Preview July 20, 2023 22:43 Inactive
@alnoki alnoki force-pushed the limit-order-cancel-reason branch from 96bd399 to 4e864ee Compare July 20, 2023 22:43
@vercel vercel bot temporarily deployed to Preview July 20, 2023 22:44 Inactive
@vercel vercel bot temporarily deployed to Preview July 20, 2023 22:53 Inactive
@vercel vercel bot temporarily deployed to Preview July 21, 2023 00:02 Inactive
@bogberry bogberry merged commit d7b4348 into main Jul 21, 2023
@bogberry bogberry deleted the limit-order-cancel-reason branch July 21, 2023 10:17
@alnoki alnoki changed the title Remove cancel event for limit order when all size fills Remove cancel event for limit order when all size fills, enable posts below min size Aug 17, 2023
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.

2 participants