DEX Integration

Add provable fair ordering to your DEX or matching engine.

Fairseq gives DEX users cryptographic assurance that orders were processed fairly and that no hidden reordering occurred.

Integration flow

  1. Capture order ingress timestamps.
  2. Run matching to produce the ordered fill list.
  3. Generate a proof for the ordered list.
  4. Publish proof metadata for verification.

Example data model

TYPESCRIPT
interface Trade {
  id: string;
  submittedAt: number; // Unix timestamp (ms)
  price: string;
  quantity: string;
}

Example proof creation

TYPESCRIPT
const proof = await fairseq.proofs.create({
  transactions: trades.map((t) => ({
    hash: t.id,
    timestamp: t.submittedAt,
  })),
  options: { metadata: { market: 'ETH/USDC' } },
})

Best practices

  • Use a monotonic clock for ingress timestamps.
  • Keep order IDs stable across retries.
  • Persist proof metadata with batch IDs.

Common pitfalls

  • Mixing arrival time with execution time in inputs.
  • Post-proof reordering due to matching retries.
Was this page helpful? /
Back to docs