> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inkwell.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Batch clearing

> One epoch, one price, both sides. The mechanism behind Dagon's matching, and why batching is a feature — not a workaround.

> **CONFIDENTIAL & PROPRIETARY © 2026 Inkwell Finance, Inc. All Rights Reserved.**
>
> This document is for informational purposes only and does not constitute legal, tax, or investment advice, nor an offer to sell or a solicitation to buy any security or other financial instrument. Any examples, structures, or flows described here are design intent only and may change.

Dagon clears by **batch**, not by continuous order-arrival sequence.
Inside a batch, a single clearing price `p★` applies to every fill on
both sides. There is no first-mover advantage inside a batch. There is
no last-look. There is no maker-taker asymmetry.

## The mechanism

At batch-close:

1. All submitted schedules (user curves + market-maker curves) are
   assembled into a SIMD-packed encrypted state.
2. A tâtonnement (bisection) search runs over the encrypted vector. On
   each pass, the candidate price is evaluated: aggregate demand at that
   price, aggregate supply at that price, sign of the imbalance.
3. The bracket narrows. After a bounded number of passes, it is tight
   enough that the imbalance is within tolerance.
4. The midpoint of the final bracket is `p★`.
5. Every buy curve at `p★` fills up to its curve's schedule at that
   price. Every sell curve at `p★` fills up to its curve's schedule.
6. If any lane would underflow (sell more than its balance, buy more
   than its credit), the **entire epoch reverts**. Partial fills are
   structurally impossible.

## Why uniform price

Uniform clearing price is the market-microstructure primitive that
eliminates sub-epoch timing games:

* **No first-mover advantage.** The curve that arrived in lane 2 and the
  curve that arrived in lane 31 fill at the same price. Arrival order
  inside a batch is irrelevant to fill quality.
* **No last-look.** Market makers cannot see the clearing price before
  committing their curve; the curve is evaluated as submitted.
* **No maker-taker asymmetry.** There is no distinction between maker
  and taker — every participant is a schedule submitter. The fill economics
  are symmetric.

These are not policy choices. They are structural consequences of the
mechanism. A venue that wants to reintroduce any of them would have to
abandon uniform clearing.

## Why not continuous

Continuous matching (CLOBs, AMMs) creates two classes of participant:
those who can see and react to order flow in real time, and those who
cannot. The first class — HFT firms, sophisticated MMs with co-located
infrastructure — extracts rent from the second class. This rent shows up
as price impact, as sandwich attacks, as toxic flow.

For block-size trades, the rent is larger than the saving from being
able to react within milliseconds. If you are already slicing a parent
order over twenty minutes of TWAP to avoid impact, a ten-second batch
window is free. The epoch is not a latency compromise; it is the vessel
that makes uniform clearing possible.

## What batching does not close

**Epoch-boundary timing.** The moment the batch closes is observable.
Sophisticated parties can submit near-close to react to pre-close
submissions — but any such reaction is also itself a submission, subject
to the same uniform clearing. The residual edge is bounded by the
sub-epoch time between submission and close, which is a small fraction of
the epoch duration.

**Batch composition inference.** The vector size is observable
(cipher text counts are public); the notional volume is observable in
aggregate after clearing. Fine-grained inference (which curve was whose)
remains infeasible, but aggregate demand intensity is not a secret.

**Cross-venue MEV.** If you hedge a Dagon fill on a public CEX, the CEX
sees the hedge. Dagon's encryption ends at settlement; any downstream
action in a public venue is visible there. Plan your hedge path
accordingly.

## Parameters

Lane count, bisection depth, schedule shape, and per-pass operator
count are tuned per deployment to balance latency, capacity, and
the FHE substrate's per-primitive cost. Specifics are tracked
internally and will continue to evolve as Encrypt REFHE production
substrate lands.
