# Bid v/s Ask Balance Updates

|                               **Bid Case ($O\_{\text{own}}.t.\phi=0$)**                               |          **Ask Case ($O\_{\text{own}}.t.\phi=1$)**          |
| :---------------------------------------------------------------------------------------------------: | :---------------------------------------------------------: |
|                                              **Initial**                                              |                         **Initial**                         |
|                  $b\_{\text{own}} = (0, (O\_{\text{own}}.s.p) (O\_{\text{own}}.s.v))$                 |               $b\_{\text{own}} = (\gamma, 0)$               |
|                                       $b\_i = (\gamma\_{i}, 0)$                                       |     $b\_i = (0, (O\_{\text{i}}.s.p)(O\_{\text{i}}.s.v))$    |
|                                               **Final**                                               |                          **Final**                          |
|                               $\gamma = \sum\_{i=0}^{n-1} \gamma\_i + k$                              |         $\gamma = \sum\_{i=0}^{n-1} O\_{i}.s.v + k$         |
|                                    Orders 0 to $n-1$ fully filled,                                    |               Orders 0 to $n-1$ fully filled,               |
|                               $n^{th}$ order at least partially filled.                               |          $n^{th}$ order at least partially filled.          |
|                                           $k \leq \gamma\_n$                                          |                      $k \leq O\_{n}.v$                      |
| $\nu=(O\_{\text{own}}.s.p)(O\_{\text{own}}.s.v)-\sum\_{i=0}^{n-1} \gamma\_i(O\_i.s.p) - k (O\_n.s.p)$ | $\nu= \sum\_{i=0}^{n-1} (O\_i.s.v)(O\_i.s.p) + k(O\_n.s.p)$ |
|                                    $b\_{\text{own}}=(\gamma, \nu)$                                    |                  $b\_{\text{own}}=(0,\nu)$                  |
|               $b\_i$ for $0\leq i < n= (0, (O\_{\text{own}}.s.p) (O\_{\text{own}}.s.v))$              |            $b\_i$ for $0\leq i < n= (O\_i.s.v,0)$           |
|                                     Here, $\gamma\_i == O\_i.s.v$                                     |                                                             |
|                                   $b\_n=(\gamma\_n-k, k (O\_n.s.p))$                                  |              $b\_n=(k, (O\_n.s.p)(O\_n.s.v-k))$             |

7. Construct $O\_{cho}$ with all attributes of $O\_{own}$, subtracting $\gamma$ from volume and replacing the access key with a newly sampled $\alpha$. If $\gamma == O\_{own}.s.v$, then use dummy values for $O\_{cho}$.
8. Construct $O\_{chn}$ with all attributes of $O\_{n}$, subtracting $\gamma - \sum\_{i=0}^{n-1} O\_i.s.v$ from volume and replacing the access key with a newly sampled $\alpha$. If $\gamma == \sum\_{i=0}^n O\_i.s.v$, then use dummy values for $O\_{chn}$.
9. Construct $\bar O\_{cho} = (O\_{cho}.t, H(O\_{cho}.s))$ and $\bar O\_{chn} = (O\_{chn}.t, H(O\_{chn}.s))$.
10. Add ${\bar O\_{own}, {\bar O\_i}*{i=0}^n, b*{own}, {b\_i}*{i=0}^n, O*{n-1}.p, \bar O\_{cho}, \bar O\_{chn}}$ as public outputs.


---

# Agent Instructions: 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:

```
GET https://docs.unyfy.xyz/unyfy/unyfy-protocol/dark-pool/bid-v-s-ask-balance-updates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
