
Limit order book
fully on chain limit order book built on arbitrum stylus using a novel bitmap algorithm
Demo
About
We are solving an open problem in DeFi- bringing limit order books on chain. This was impossible on EVM given its limitations on computation and memory-till now. Arbitrum stylus allows you to write smart contracts in rust unlocking 10x more memory and throughput. We paired it with a novel bitmap based algorithm to make limit orders possible with EVM's 256 bit K-V storage trie structure.
How it's made
Tech stack - Smart contract: rust - Chain: arbitrum stylus - Indexing: subtraphs (wip) The smart contract builds up on a large number of innovations - Bitmap tree: instead of a traditional tree structure to store orderbook nodes, we use EVM's 256 bit key value trie as the store. Encoding a full tree in EVM is wasteful as slot keys store temporary indices and every update forces large rebalancing writes. We structure data as a sparse matrix instead of a tree. The key hash encodes details like price and market ID while the state stores order state. - High througput allows us to market make dozens of orders across multiple markets in a single atomic call. We can beat Uniswap when it comes to gas and market making. Benchmarking is still wip. - The smart contract code acts as the indexer and SDK. We code will be embedded inside a rust WASM subgraph and be used for indexing.