Flip orders on the Kuru orderbook work the same as a normal order in a taker’s perspective, maintaining price-time priority. However, these are conditional orders which allow makers to use the funds credited from an order to place another order on the other side (i.e, buy vs sell).

The structure of an order looks like this :

  1. Order ID
  2. Price
  3. Flip Price
  4. Flip Order ID
  5. Size
  6. Is Buy?
  7. prev
  8. next

Note: Flip orders are distinguished from regular orders on the condition flip price ≠ 0.

The lifecycle of a flip order looks like this :

  1. A maker places a flip order with price $p$ and flip price $p_f$ , where $p_f > p$ for a buy flip order and vice versa. For this case, let us assume that the flip order placed is a buy flip order. This means that on fill, it has to flip to the sell side. Let us also assume that the order id of this order is 1 and there are no other makers making on this market. Let us assume that the size of this order is 100.
  2. Now, if a taker order of size 50 comes in and takes 50 off order 1 , the remaining size of the order would be 50. Quote eligible for size of 50, i.e, $p * 50$ is credited to the taker.
  3. An order of size 50 is placed on the other side in the same transaction on behalf of the maker of order 1 at price $p_f$. Both the orders are attached to each other with the flip ID parameter. The new order at price $p_f$ is order 2 .
  4. Now, if a taker sell order of size 25 comes in and takes off another 25 from order 1 , the filled size of 25 is added to order 2 , and 25 is subtracted from 1.
  5. This goes on till the maker decides to cancel the order.

We get two major unlocks from this :