It is assumed that the reader has already read the documentation on the OrderBook contract before starting with this. Refer to the OrderBook contract documentation here :
To understand why flip orders exist, please refer here :
Before delving into how flip orders function, we will first look at what encompasses an order:
struct Order {
address ownerAddress;
uint96 size;
uint40 prev;
uint40 next;
uint40 flippedId;
uint32 price;
uint32 flippedPrice;
bool isBuy;
}
Non-flip orders are all orders where $flippedPrice = 0$. This means that flip orders aren’t necessarily a new type of order, but a subset of an order itself.
A brief overview of the lifecycle of a flip order is given in the non-technical documentation. Here, we will deep dive into the technical lifecycle of a flip order.
The main entry points for placing a flip order are addFlipBuyOrder
and addFlipSellOrder
.
Both of them have the same input parameters :
price
- The price at which the order should be placedflippedPrice
- The price to which the order should be flipped