Protocol Spec

Settlement Logic

Changing in v3: In v3, settlement moves to hyperdex_settlement: both parties authorise the exact terms, the on-chain registry checks the maker, pair, limits and pauses, and funds move wallet to wallet. See v3 & Roadmap.

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 authorised: quote.taker.require_auth() — only the taker named in the quote can authorise its execution. Quotes are non-transferable.
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
Pay fee: fee_amount = amount_out × fee_bps / 10000. The pool sends amount_out − fee_amount to the taker and transfers fee_amount of token_out directly to fee_distributor.
HyperDex | Trade Without Limits