Alice wants to trade 1 ETH for 400 DAI, and Bob would like to trade 400 DAI for 1 ETH. Both send to the off-chain app the corresponding (signed) limit order requests, which contain two
vaultId from which sold funds are taken, and the
vaultId to which bought funds should arrive), the two relevant
assetId, the two relevant (quantized)
expirationTimestamp of the order (hours since epoch), and a
nonce(to prevent replay attacks).
For information on limit order structure, see Message encodings for spot trading.
The application matches the limit orders of Alice and Bob, sending to StarkEx a Settlement transaction that includes both orders, alongside the actual transferred amounts between Alice and Bob’s vaults.
Partial fulfillment is supported. The amounts transferred between Alice and Bob may be smaller than the amounts they signed on, as long as the ratios are in line with what they signed on. We monitor the fulfillment status of the orders with the
StarkEx checks the validity of the Settlement:
assetIdof the two orders match (i.e. bought
assetIdof one is the sold
assetIdof the other)
The ratio between sell amount and buy amount for Alice and Bob is at least as good as the ratio each signed on.
Each of the orders in the Settlement was signed by a
starkKeythat corresponds to the order’s
The balance in each
vaultIdis sufficient to fulfill the trade.
Both orders are not already fulfilled (and the traded amount will not cause Alice and Bob to transfer more than what they signed on in the order)
expirationTimestampof the order refers to the future.
If the Settlement is valid, the Settlement is included in a batch to be submitted on-chain along with validity proof. See here for full details on state update on-chain.