> For the complete documentation index, see [llms.txt](https://tycho-orderbook.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tycho-orderbook.gitbook.io/docs/rust-sdk/architecture.md).

# Architecture

Tycho Orderbook SDK works as follows.

<figure><img src="https://2239164577-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkYMfZEyzdrecUDp75l9l%2Fuploads%2FkVYXhnLUpVr9jKobmELO%2FScreenshot%202025-04-14%20at%2012.18.33.png?alt=media&amp;token=f8370527-fbce-4330-9aa0-741ce19a6062" 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="https://2239164577-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkYMfZEyzdrecUDp75l9l%2Fuploads%2FwCtmq57DKiYQJ9fQqYif%2Fimage.png?alt=media&amp;token=dfbb285a-d8fb-4bca-905f-8a1331b8d19d" 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.
