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 2563=224256^3=2^{24} slots at the bottom of the tree, corresponding to the theoretical maximum of 2242^{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.

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.

Last updated