> For the complete documentation index, see [llms.txt](https://midaswap.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://midaswap.gitbook.io/docs/technical-reference/liquidity-tracking.md).

# Liquidity Tracking

To facilitate query liquidity Midas uses a 3-layer tree structure. Each node is a 256bit array recorded with uint256. There are exactly $$256^3=2^{24}$$ slots at the bottom of the tree, corresponding to the theoretical maximum of $$2^{24}$$ slots in our bin. We record this underlying slot as 1 when there is liquidity in a bin, and label it as 0 otherwise. When a parent node has a 1 in the 256 slots it contains, the parent node is also marked as 1, and so on.

<figure><img src="https://2168851602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuwaY8haSEb817dI8YhV1%2Fuploads%2FMz5HHaXfI7rUcR5VWxxE%2Fimage.png?alt=media&amp;token=28e28e8c-4675-4e65-86bf-0bc321129d1d" alt=""><figcaption></figcaption></figure>

This structure can help us efficiently find the next bin with liquidity in a given direction and update the current floor price and best offer.
