# Epochs - How markets begin and end

Every MOVE market lives in **epochs**. An epoch has:

* A **reference price** - the underlying's price at the start.
* An **expiry timestamp** - when the epoch ends.
* A **state** - `Active`, `Settling`, `Expired`, or `Cancelled`.

#### Active

The normal state. You can open positions, close them, increase, reduce, and place limit orders. The mark price updates continuously from the oracle:

```
mark_price = | current_underlying_price − reference_price |
```

#### Settling

The moment `block.timestamp ≥ expiry_time`, the epoch transitions to `Settling`:

* All resting orders are cancelled. Their collateral is released back to `available`.
* All open positions are **frozen** (not closed). They stay on the books at their current state, but no new actions can occur on them.
* The sequencer emits an `EpochSettled` event.

#### Expired

A keeper service (or anyone, as the function is permissionless) calls `Market.settleEpoch()`, which:

* Reads the final underlying price from the oracle.
* Computes the settlement price: `|final − reference|`.
* Persists it on-chain.
* Advances the market to a new epoch with a fresh reference price and expiry.

At this point, frozen positions are eligible to be **claimed**.

#### Claim

Each user with a frozen position calls `Market.claim()`. The contract:

* Computes the final realized PnL using the settlement price and the position's entry price and size.
* Releases the user's collateral + PnL back to the Hub.
* Removes the position.

The Hub's `availableBalance` for that user updates, and the user can deposit it into a new position or withdraw it.

{% hint style="warning" %}
**You must claim to get your money back.** Until you call `claim`, your collateral and PnL remain locked in the Market contract. There's no time pressure — you can claim weeks or months later — but unclaimed positions sit there idle.
{% endhint %}

#### Why "freeze + claim" instead of automatic settlement?

Two reasons:

1. **Gas efficiency.** Auto-settling thousands of positions in one transaction would be enormous. Letting each user claim their own position spreads the gas across users.
2. **Predictability.** You decide when to claim. If you're managing many positions across many markets, you can batch your operations on your schedule rather than being force-settled.

***


---

# 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.movex.market/architecture/epochs-how-markets-begin-and-end.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.
