-
Notifications
You must be signed in to change notification settings - Fork 74
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
Verify order executed amount in settlement encoder #164
Conversation
(true, OrderKind::Sell) => executed_amount <= order.creation.sell_amount, | ||
(true, OrderKind::Buy) => executed_amount <= order.creation.buy_amount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those conditions can be even stricter since partially fillable orders could already be partially filled.
executed_amount <= (order.creation.sell_amount - order.metadata.executed_sell_amount)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I was thinking this would be detected during simulation because the contract enforces it too but it probably makes sense to catch it as early as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bit annoying because the other number is a BigInt so would have to convert and then decide what to do if that value doesn't make sense like saturating sub so I left it out for now. Will think again how I want to do this.
@josojo could you review this since you made the original issue? Also the part I quote in the description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, great. Pr looks good. Thanks for modifying it for buy orders. Makes sense to me for sure.
Codecov Report
@@ Coverage Diff @@
## main #164 +/- ##
==========================================
+ Coverage 64.82% 64.84% +0.01%
==========================================
Files 185 185
Lines 38393 38386 -7
==========================================
+ Hits 24888 24890 +2
+ Misses 13505 13496 -9 |
Fixes #163
@josojo wrote
But I think for buy orders the executed amount refers to the buy amount.
Test Plan
Adapted the existing tests which showed that the verification worked