For supported order types, the Broker interprets and acts on instructions as follows:
Currently supported order types are Market Orders and Limit Orders. Currently unsupported order types include Stop Orders.
A market order is an order that should be executed at the best available price in the market. Until the desired order size is reached, the Broker takes the best available order on the orderbook and fills it. If the Broker cannot execute the entire trade with the depth in the orderbook, the order is rejected by the Broker. Market orders will only ever result in Fills, and will never result in newly placed Orders.
A limit order is an order that should be executed at a price better than or equal to the specified “Limit”. The Broker will first find any orders on the orderbook at the given limit price or better, and will fill them (best price first) until the desired order size is reached. If there is not enough depth in the orderbook at the given limit price or better, the Broker will place orders with the Relayer at the given limit price for the remainder of the order size.
Note that time restrictions only apply to Limit Orders. Market Orders are always executed the same way (as though they were Fill or Kill).
Currently supported order types are Good Til Cancelled. Currently unsupported order types include Fill or Kill, Immediate or Cancel, All or None.
Good Til Cancelled
This is the “standard” order type. It will remain on the books until it is cancelled by the client. Orders of this type will continue to be attempted to be executed by the Broker until given an explicit cancel by the user via the API. In practice, this means that any orders that are placed by the Broker will be cancelled if-and-only-if they are cancelled by the user. The Relayer may unilaterally cancel orders if the Broker disconnects for too long or becomes unreachable on the Lightning Network, but the Broker will attempt to replace those orders.
Acting as a Matching Engine
Given the sparkswap design choice to force participants to stay online and take as much responsibility as possible, the Relayer does not operate as a matching engine. Instead, Brokers are responsible for getting the best execution possible for their user by monitoring the orderbook. The orderbook is expected to frequently get crossed (see Common Issues for more on this).
For order types where orders are left on the orderbook (i.e. orders are placed) (as of this writing, the Good Til Cancelled Limit Order), the Broker should monitor the orderbook. If new orders are placed that are at a price better than the Broker’s placed order, the placed order should be cancelled and the new order filled.