Protocol Spec

Settlement Logic

On-chain settlement is handled exclusively by the quote_verifier contract. It performs the following checks in order — any failure reverts the entire transaction:

1
Signature verification: Retrieve the maker's registered signing key from pool_registry. Compute SHA256(XDR(quote)). Verify the ed25519 signature against this hash. Reject if invalid.
2
Maker is active: Check pool_registry that the maker is not deactivated. Reject if maker is suspended or unregistered.
3
Quote not expired: Compare quote.expiry against the current ledger timestamp. Reject if expired.
4
Taker matches invoker: Verify that the transaction invoker matches quote.taker. Quotes are non-transferable — only the specific taker can use a quote.
5
Quote ID not replayed: Check a spent-quote ledger set. Reject if quote_id has already been used. Each quote can only settle once.
6
Execute pool swap: Call the maker's maker_pool.execute_swap(quote): move amount_in from taker to the pool, move amount_out from the pool to taker.
7
Collect fee: Calculate fee_amount = amount_out × fee_bps / 10000. Call fee_distributor.collect_fee(token_out, fee_amount).
HyperDex | Trade Without Limits