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

# Parimutuel Markets

> Understanding order flow, odds calculation, and settlement logic.

## Market Mechanics

Baru uses a dynamic parimutuel model to ensure liquidity is pooled efficiently. Below is a breakdown of how orders are processed and how odds are determined in real-time.

### Order Flow

Orders are treated as **signed prices** to differentiate between outcomes:

* **Positive Values:** Add liquidity to the **YES** pool.
* **Negative Values:** Add liquidity to the **NO** pool.

The system maintains a running state with separate liquidity for each side alongside an overall volume total.

### Odds Calculation

The market moves through two distinct states based on available liquidity:

1. **Fixed State:** The odds remain pinned at **50/50** until *both* pools have received liquidity.
2. **Dynamic State:** Once both the YES and NO sides have volume, the probability floats based on the ratio of the pools:

$$
P(Yes) = \frac{Liquidity_{Yes}}{Volume_{Total}}
$$

### Profit Sharing (Gamma)

To ensure fair distribution of profits upon resolution, every order is assigned a **Gamma Coefficient** at the moment it is placed. This coefficient is stored and used later to apportion the payout.

The Gamma is calculated as:

$$
\gamma = \frac{1}{Volume_{current} + Odds_{current}}
$$

## Market Resolution

Markets are watched by our AI agents which determine the outcome based on the
very same stream you are watching. When our AI agents reach a consensus, the
market is resolved.

Our AI agents have \~10s to agree on the outcome before the market is considered
completely resolved. Any trades placed during this time will be rolled back.

Refer to the following image for a visual representation of the resolution
process:

<img src="https://mintcdn.com/baru/37fjqgmYTTq4cyT0/images/timeline-image.png?fit=max&auto=format&n=37fjqgmYTTq4cyT0&q=85&s=24466d98876160f59d496348a4f81e9a" alt="Timeline Diagram" width="1593" height="365" data-path="images/timeline-image.png" />

<Warning>
  If you place a trade after a stream event is observed which proves the market
  prompt, *your trade will be rolled back and your contract refunded*.
</Warning>

### Settlement Rules

Upon resolution, the system calculates payouts based on the final odds and
the Gamma coefficients assigned to each order. Before settlement, we have
strict rules in place to ensure market integrity.

#### Logical Rules

Since everyone, including you, is able to create markets, our system evaluates
whether the market prompt is logically sound before opening the market.
However, in certain contexts, our AI system may determine that the market
prompt is illogical after the market has been opened. In such rare cases, the
market will be cancelled and all contracts fully refunded.

#### Liquidity Requirements

To prevent manipulation or invalid market states, the engine enforces strict
liquidity requirements before closing a market.

<Warning>
  **Minimum Liquidity Requirements**

  To successfully settle, a market must have:

  * **Total Volume:** At least **\$5.00**
  * **Per-Side Volume:** At least **\$1.00** in both the YES and NO pools.

  If these conditions are not met, the market will be cancelled and all contracts
  completely refunded.
</Warning>

### Settlement Summary

1. **Outcome Determination:** AI agents analyze the stream to reach a
   consensus on the market outcome.
2. **Logical Evaluation:** The system checks if the market prompt remains
   logically sound.
3. **Liquidity Verification:** Ensures minimum liquidity requirements are met.
4. **Late Trade Rollback:** Any trades placed between outcome observation and
   AI resolution are rolled back.
