This is a protocol for matching state contingent contracts that give a payoff linear between an upper and lower bound and at a particular expiry.
For example the contract might pay 1 for each 10mm of rainfall above 30mm. If the amount of rainfall is above 30mm the payoff is $1 and if the outcome is below 30mm the outcome is zero.
These contracts can be combined to construct standard forward and option contracts or event markets (payoffs depending on a discrete set of outcomes).
The protocol uses a chain of signatures to organize buy and sell orders for these contracts. Orders are accepted if they have a valid signature and the trader's positions satisfiy a collateral check across all possible worst outcomes. To maintain an appropriate record of the order book, trades can only be added, and the validity of any trade can be checked by anyone using public keys provided by each participant.
Markets are settled by the market owner adding a new equal upper and lower bound for a market. For example, the lower bound for each market is the highest lower bound for itself of any sub-market or any previous bound on the same market. Market bounds telescope, making a market the underlying asset of its sub-markets.
Since orders can only be added to the order book and not subtracted, creating a matched order requires an offset of the unmatched order and a new matched order of equal size.
Consider an order '(p=0.5, q=1)'. For the trade to successfully be matched it requires at minimum:
Primary (p=0.5, q=1, tradeBranchId = 1)
Offset (p=0.5, q=-1, tradeBranchId = 2)
Match (p=0.5, q=1, tradeBranchId = 3)
Geometrically, this set of trades can be represented in (p,q) space with with offset (blue) and match (green):
The offset and match trades are initally held in a separate cache order book and are promoted to the order book when the trade is matched. The cache order book is a place for signed but unused trades and has no implact on collateral calculations.
With a small loss of generality, the mechanics of orders here are all 1 or -1 quantity and there are no partial fills.
Each trade is chained to a previous trade according to a rule. The order book will require a valid signature (valid signature for message and valid previous trade) and a collateral check to ensure the trader has sufficient collateral. Primary orders are chained to a previous valid order, offset are chained to the primary trade.
The figure below is an order to buy at 0.5 with associated offset and match trades.
If the order is matched by a sell contract at 0.5 the the offset and match contracts are removed from the cache and added to the order book.
Example sequence of orders: Single order perfect match¶
The simplest case is a perfect match of primary trades. Trader 1 enters the market and posts a bid for 1 contracts at 0.5 into the order book, and a corresponding offset and match order into the cache. Offsets and matches share the same root id.
Now consider a case where trader 1 has a bid at 0.5 and trader 2 offers at 0.4. The trade still matches at 0.5 since trader 1 was there first. Trader 2's offset for the p=0.4 trade is promoted to the order book.
Example sequence of orders: Chaining to a previous valid order¶
Continuing from the previous example after the first trade is matched, now suppose trader 3 enters the market with an offer to sell at 0.7 or 0.8. The order is chained to the highest number trade existing in the order book which is (2.3 from the p=0.5 trade). If another trade arrives into the order book it would be chained to 3.1 since it is the furtherst branch on the highest tree of the order book.
The columns of the matrix are the collateral outcomes for each of the two traders in the four possible states. For example the first entry in NC is trader 1's collateral if both markets settle at 0 (-0.5 + - 0.4 + -0.4 = -1.3).