The OrderBook contract essentially contains and manages a particular market. It adds limit orders, matches market orders and works in close conjunction with the Kuru AMM vault.
Structures Used:
The order not only stores the order data but also stores a reference to the previous and next order in its price DLL. Refer to the bellow doc for further details regarding the tree and the DLL.
It is recommended to read the short doc below to understand flip orders if you understand order books. However, the technical read on flip orders requires some knowledge about the order book contract.
initialize
function.For security testing reasons, it would be wise to categorize orders into these following categories:
Head of a PricePoint :
Tail of a PricePoint :
Middle of an order :
Note: In a PP with a single order, both head and tail are the same order ID. In this case, next
will never be NON NULL.