# Exchange flow

Our order book design is comprised of two parts:

**1) LayerAkira Smart Contract ("Smart Contract"):**

* The Smart Contract holds the user funds and performs necessary validation checks before any trading activity is executed, whether initiated by a user or by the Exchange on behalf of a user.
* Allows users to perform certain activities (e.g. withdrawals) on-chain without direct interaction with the Exchange
* Emits events to the blockchain for each trading activity.

**2) LayerAkira Exchange ("Exchange"):**

* Provides [endpoints](/layerakira-documentation/integration/endpoints.md) through which users can perform trading activities in a CEX-like manner
* Ensures that all trading activities are processed fairly and are valid.&#x20;

{% hint style="info" %}
fair" refers to *when* the trade arrives to the Exchange

"valid" refers to the execution semantic
{% endhint %}

* Responsible for consuming emitted events by the Smart Contract to maintain a valid state of off-chain order book and off-chain user balances.
* Responsible for batching all trading activities into the rollup and pushing it on-chain as soon as possible to keep the smart contract state updated with the off-chain state.&#x20;
* Responsible for maintaining the CLOB and providing access to it through [endpoints](/layerakira-documentation/integration/endpoints.md) for both users from our ecosystem and outside of our ecosystem through Routers.

<figure><img src="/files/68aeZpVJNCoStjjE06ut" alt=""><figcaption></figcaption></figure>


---

# 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://layer-akira.gitbook.io/layerakira-documentation/integration/technical-overview/exchange-flow.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.
