Skip to main content

Trade Flow

TL;DR

You deposit funds into the on-chain vault as a private note. You submit a hidden order, backed by that note, to the enclave. The enclave matches it in a batch auction and proves the matches, then settles them on Solana itself, moving value between notes against a zero-knowledge proof. Your order never becomes a Solana transaction. Only the result settles.

Order-to-settlement lifecycle

Step by step

StepWhereWhat happens
1. DepositWallet → VaultYou deposit tokens into the on-chain vault. The deposit becomes a UTXO-style note, a commitment added to the on-chain Merkle tree. Owner, value, and token are sealed inside the commitment.
2. Build the orderClient / SDKThe SDK selects a spendable note, generates a zero-knowledge input proof that the note is in the tree and yours, assembles the continuation anchor pool, and signs the canonical order body with your trading key.
3. SubmitClient → EnclaveThe signed order is sent over RA-TLS (REST or the trading socket). It never touches a Solana transaction. The enclave verifies the signature and that the note opening matches the committed note.
4. MatchEnclaveEach batch, the engine collects crossing orders and clears them at a single oracle-anchored price (see Clearing Price). Orders from the same trading key never match each other.
5. ProveEnclaveThe engine generates a zero-knowledge proof that the batch of matches is conservation-correct and bound to the committed notes, within the circuit-breaker band.
6. SettleEnclave → Vault (L1)The engine submits the settlement transactions to Solana itself. It locks the input notes, verifies the batch proof on-chain, executes the atomic transfers, and reclaims the batch marker. Funds move, and new notes appear in the tree.
7. NotifyEnclave → ClientThe engine pushes order-lifecycle events (Orders Channel) and fill memos (Fills Channel) so you can recover and spend your change and output notes.

What is on-chain and what is not

On-chain (public, verifiable)Off-chain (private, in the enclave)
Custody of fundsOrder intent (side, size, limit price)
The Merkle tree of note commitmentsThe order book
Nullifier and consumed-note setsThe matching computation
The Groth16 proof verifierThe clearing-price calculation
Every settlement transaction + its proofThe link from a trade to a wallet

The chain sees that value moved correctly between committed notes, proven by zero knowledge. It never sees the orders that produced the trade, and it does not see the trade's size or price either: a settlement publishes note commitments and the proof that value was conserved, not the amounts that moved. The enclave sees the orders, but cannot move funds except by submitting a proof the chain independently verifies.

Why your order never hits the chain

A common misconception is that a private DEX "encrypts orders on-chain." Darknyx does something stronger: your order is never a transaction at all. It lives only inside the attested enclave. What lands on Solana is the settlement, a transfer of value between notes accompanied by a proof that the transfer is correct. That is why an observer indexing Solana forever still learns nothing about your orders: there is nothing about them on the chain to index.

See Privacy & Attestation for how you verify the enclave is the real engine, and Settlement for the on-chain pipeline in detail.