> For the complete documentation index, see [llms.txt](https://docs.unyfy.xyz/unyfy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unyfy.xyz/unyfy/unyfy-protocol/dark-pool/representing-the-limit-order-book.md).

# Representing the Limit Order Book

We instantiate our zero knowledge proof system $(P, V)$ over the curve `bn128`. All variables are in its scalar field $F$.

An order is represented as the following object, with a transparent structure $t$ and shielded structure $s$:

```
{
    t: (ϕ, χ, d)
    s: (p, v, α)
}
```

with the following definitions:

* $\phi$: side of the order, 0 when it's a bid, 1 when it's an ask
* $\chi$: token address for the target project
* $d$: denomination, either the token address of USDC or ETH (set to `0x1` for this case)
* $p$: price, denominated in $d$, with scaling factor $10^9$ but only $10^7$ precision
* $v$: volume, amount of token to exchange, with scaling factor $10^9$
* $\alpha$: access key, randomly sampled from $F$, protects against brute force attacks, meant to be revealed to counterparties

We employ a cryptographic hash function $H$ to create hiding commitments for the shielded structure. The chain only sees the commitment $\bar O = {t: O.t, s: H(O.s)}$.

The on-chain orderbook comprises of 1) a list of these comitments ${\bar O\_i}\_{i=0}^N$ and 2) the Ethereum public keys $pk$ of the commitment owners.

When describing the protocol, we often employ an auxiliary variable $b$ to describe a balance. It is a pair with the first element specifying an amount of the target project's token and the second element specifying an amount of the denomination token. A balance will always be used in conjunction with an order $O$, so target and denomination tokens are unambiguous.

Readers will have to excuse our blend of lax notation from mathematics and lax notation from computer science. The purist descriptions grew too verbose. Scaling factors are also redacted for brevity, but must be included during implementation to handle float operations.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.unyfy.xyz/unyfy/unyfy-protocol/dark-pool/representing-the-limit-order-book.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
