-
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
Scale down in-flight partially fillable orders #152
Conversation
pub fn u256_to_big_uint(input: &U256) -> BigUint { | ||
let mut bytes = [0; 32]; | ||
input.to_big_endian(&mut bytes); | ||
BigUint::from_bytes_be(&bytes) | ||
} |
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 copied this from /orderbook/src/conversions
to /shared/src/conversions
. At some point we should move everything to the shared version.
451772c
to
b8961e3
Compare
Codecov Report
@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 65.10% 65.26% +0.15%
==========================================
Files 183 183
Lines 38199 38340 +141
==========================================
+ Hits 24871 25021 +150
+ Misses 13328 13319 -9 |
.inspect(|(trade, _)| { | ||
uids.push(trade.order.metadata.uid); | ||
}) |
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.
Nit: I slightly prefer doing this in an extra for loop to make it clear that we need this side effect.
b8961e3
to
a54089b
Compare
Fixes #123
The driver currently filters out all solvable orders for which it knows that a trade referring to it is in-flight at the moment.
This is overly pessimistic for partially fillable orders because you could issue many trades using liquidity from that order as long as they don't exceed the executable amount from that order.
The improved approach is to sum up the executed amounts of all in-flight trades for a partially filled order and add that to the last "confirmed" executed amount of that order. "Confirmed" in this case means the
executed_(buy|sell|fee)_amount
fields from the order metadata. Data within that field gets calculated by our database and should probably be used as the source of truth in case trades for the same order show up across multiple auctions.If a partially fillable order is actually filled completely the order gets dropped from the
Auction
.Test Plan
Update existing unit test and extend it.