Skip to content

Conversation

@lambdart
Copy link
Contributor

@lambdart lambdart commented Feb 5, 2025

This is the OrderBook contract implementation.

The operations supported are:

  • add limit sell order
  • add limit buy order
  • delete limit sell order
  • delete limit buy order
  • add market sell order
  • add market buy order
  • get first limit sell order
  • get first limit buy order
  • get limit sell orders
  • get limit buy orders

We should remember that market orders will be not include in the orders list, i.e, will be executed or discarded. The interface for the contract creation is very simples and straightforward. See examples at the correspondent test file. We still need to implement the stop limit order, for this pull request to be completed and update the related documentation.

@lambdart lambdart requested a review from itamarcps February 6, 2025 14:32
@lambdart lambdart requested review from Jean-Lessa, fcecin and itamarcps and removed request for Jean-Lessa, fcecin and itamarcps February 6, 2025 14:32
Copy link
Collaborator

@Jean-Lessa Jean-Lessa left a comment

Choose a reason for hiding this comment

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

All good to me. Comments are optional but recommended if merge is not urgent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just realized this SafeVar is using old commit/revert logic (as in "write changes to copy by default", commit() does real = copy and revert() clears the copy).

At some point in the past we switched that to a more "optimistic" approach (as in "write changes to the real value by default" instead and keep copy as a "snapshot" of the initial value, so the logic is reversed - commit() clears the copy and revert() does real = copy). IIRC this has a lesser overhead - commit() has a higher probability of being called overall than revert(), and clearing data is faster than rewriting it (same logic as "keep your most probable outcome in the if branch, not the else branch"). This might also be the reason why check() was removed and other SafeVars did if (copy == nullptr) copy = ... manually, but my memory fails me.

I suppose this is working as-is though, so it's not an urgent problem. If it has to be merged ASAP then by all means go for it, but I would suggest having a look at how the other SafeVars do it just so we keep the pattern. Since this is abstracting a container, you might also need to create an undo stack or a similar functionality to make it work as intended (see SafeVector or SafeUnorderedMap).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to update that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest also having unit tests for SafeMultiSet, mostly for SonarQube coverage, but like the other comments, it's not a priority right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll add them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC the SafeVar tests were isolated under a CMake macro due to their taking a lot of time and RAM to compile due to heavy template usage. Check the halley branch later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do, thanks.

@itamarcps itamarcps changed the base branch from development to testnet-0.2 April 22, 2025 19:00
@itamarcps itamarcps merged commit 3ac7463 into testnet-0.2 Apr 22, 2025
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.

5 participants