[Orderbook]: Implement Fill Limit Order #47
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #42
What is the purpose of the change
When a limit order is placed that passes the next tick of the oppossing order direction we can fill that order with any previously placed limit orders for every tick leading up to the placed order's tick. Once an order has been filled as much as possible, if there is a remainder we can store the order with the remainder on the given tick.
This process makes use of the previously created market order filling logic by converting the limit order to a market order when conditions are met. The generated fulfillments from this logic are resolved to bank messages and sent accordingly.
Testing and Verifying
This change added tests and can be verified as follows:
These tests are a replication of various tests from #40 that have been adapted for the order placement logic. These are contained in
contracts/orderbook/src/tests/test_order.rs
.