# Architecture

Tycho Orderbook SDK works as follows.

<figure><img src="/files/6Tf2ExNKkjG7W4PmwCgC" alt=""><figcaption><p>SDK flow</p></figcaption></figure>

1. The Trader opens a stream
   1. It connects to [Tycho Indexer](https://docs.propellerheads.xyz/tycho/for-solvers/indexer)
   2. It receives all updates (each block) on the state of the liquidity pools and the state for simulating the swap on
2. The Trader requests a specific orderbook, e.g. ETH-USDC (base-quote)
   1. By default, the SDK uses a simplistic single-hop solver to simulate optimal routing between pools, but any solver can be used.
   2. Multiple trades are quoted ⇒ 1, 10 or 100 ETH for bids, then 2K, 20K, 200K USDC for asks. Thousands of simulations can be performed in just a few seconds
3. Aggregate the output in bids and asks.
4. Loop to constantly monitor status updates.

For example, a Binance-formatted version of an orderbook would contain the following data on pair BTC-USDC.

<figure><img src="/files/dXQqSt741lrAsuopuILt" alt=""><figcaption><p>Binance-like onchain liquidity orderbook </p></figcaption></figure>

Expressed literally, this means that you can sell, for example, 82 BTC at a price of 76021 USDC, or you can buy 37 BTC at a price of 83098 USDC. The current price is between 81984 USDC and 82063 USDC, with a spread of 79 USDC, which is mainly due to cost of gas (on Ethereum mainnet).

On the basis of this familiar format, a trader can connect a TradFi orderbook algorithm and execute and operate onchain with ease.


---

# 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://tycho-orderbook.gitbook.io/docs/rust-sdk/architecture.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.
