Introduction
Last updated
Was this helpful?
Last updated
Was this helpful?
Tycho Orderbook is an application based on a Rust SDK and , currently deployed at .
This application bridges the gap between centralised exchanges orderbooks and the onchain liquidity complex structure. Why ?
In DeFi, liquidity is typically provided by AMMs, which use continuous formulas to distribute liquidity, unlike orderbooks that aggregate discrete limit orders. Despite their differences, both approaches ultimately produce strictly increasing supply curves.
The key insight is that if onchain liquidity can be seen as a strictly increasing supply curve, it’s possible to replicate that curve with a series of limit orders.
By running simulations (with tool), one can derive the incremental supply—essentially, the price levels at which liquidity is available—and then reconstruct an equivalent orderbook.
There are many reasons for building such a tool
Bring more traders on-chain: In the familiar format of an orderbook, on-chain liquidity will be easier to read and execute over for a wider set of traders. This can bring new traders, e.g. those with existing strategies for orderbook markets, to use on-chain liquidity.
Strengthen on-chain liquidity: Making on-chain liquidity more accessible can increase on-chain volumes, and consequently revenues, and incentivise deeper on-chain liquidity, and the resulting deeper books further incentivises more on-chain trading through better prices.
Aggregate liquidity: Another high barrier for traders to trade efficiently against on-chain liquidity is to use the liquidity fragmented over different pools and protocols. A unified orderbook also abstracts the different protocols and pools – and presents them in a unified form.
Save time: Unless you have a specifically optimised setup – its hard to do all the simulations required for running sophisticated trading strategies (e.g. determining the supply for 1000 different tokens at 10 different trading volumes). A unified orderbook includes pre-simulated trade amounts that traders can use directly, or as a starting point for "final mile" simulations.
It is illustrated by the following graphs. An orderbook presents discrete limit orders with an increasing quantity offered, while an AMM offers continuous liquidity.
Since no single liquidity pool fully represents all on-chain liquidity, a router or solver can be used to gather the best price at any depth across various pools, ultimately building an aggregate on-chain liquidity book (Uniswap, Curve, etc).
Doing so, we can recalculate, or approximate, all the data in a centralised orderbook, but for all onchain liquidity. It transposes an classic orderbook (executable via API) like the following ⇒
This reconstructed orderbook allows traders to:
Visualise the shape of on-chain liquidity
Make informed trade decisions based on precise price levels
Query the expected price for a given trade size or the available depth at a specific price
An important caveat is that gas costs can cause the supply curve to deviate slightly from being strictly increasing. Unlike traditional orderbooks where costs scale proportionally. Gas fees introduce discrete jumps—especially noticeable at very small trade amounts or when new liquidity pools (or ticks) are added. You'll see them if you zoom in.
Initially, these costs can worsen the price before improving it as the trade size increases, adding a layer of complexity to the simulated orderbook.
To an onchain liquidity orderbook (also executable with a wallet and the Rust SDK) like ⇒
Under the hood, can simulate trades across any liquidity pool in microseconds.
Moreover, with , we can convert any market order on this synthetic onchain orderbook into onchain calldata, enabling execution with a wallet.