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 prune order function #88

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

Henry-E
Copy link

@Henry-E Henry-E commented Aug 26, 2022

Still a work in progress, needs a test + some clean up. But the core logic is here.

Let's say you have an order book you want to shut down. One option is to find all of the open order accounts, and then cancel all the open orders on that account. This requires writing a whole other crank, separate to whatever existing consume_events crank someone already has. Instead the process can be simplified by removing all the orders from the order book and placing them as out_events/cancelled orders on the event queue. This means it fits in with the existing consume_events cranks someone might have.

prune_orders

args:

  • number of orders to prune

function:

  • iterates over all open orders on both sides of the order book
    • removes the order
    • adds an out_event for the cancelled order to the event queue
  • has some checks so that it doesn't add more events to the event queue than it can fit

@ellttBen Aside from adding pub mod prune_orders to the process.rs file, is there other structural code that's needed for a new function? e.g. does it need to have an entry added to process_instruction in the same process.rs file or is that just left over code from when the AOB processed instructions like a regular program? Looks like it is required for importing the functions to another program.

@Henry-E
Copy link
Author

Henry-E commented Sep 22, 2022

I've done some tests locally and it appears to work well. It will depend on each implementation's own use case at to what the number_of_orders_to_prune argument should be set at. Presumably there will be a limit to the number of orders that can be processed in one block based on the compute unit usage but again this will vary. It should be very possible to prune a couple of hundred orders in 200k and even more if the extra compute is enabled and the limit goes up to 1.4m units.

@Henry-E Henry-E changed the title WIP: Add prune order function Add prune order function Sep 22, 2022
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

1 participant