Skip to content
HIVE

HIVE

Decentralized Limit Orderbook

Created on 16th May 2025

•

HIVE

HIVE

Decentralized Limit Orderbook

The problem HIVE solves

Hive bridges the gap between traditional finance and DeFi by bringing familiar orderbook trading to the blockchain.

Challenges I ran into

Hive (Orderbook) is not dependent on a formula — it relies on the data structure of our smart contract. The most challenging part of building Hive has been ensuring that the contract is gas-efficient, especially since every event or action involves reading from and writing to storage.

We successfully implemented an on-chain matching engine, so every time a limit order is placed, it gets matched automatically. However, handling market orders presents a bigger challenge. To execute a market order, we need to identify the best bid and ask, which is computationally expensive. Even the most efficient sorting algorithms with a time complexity of O(n log n) were not fast or cheap enough for our needs.

Ultimately, we decided to move this logic off-chain. Our current approach allows the off-chain system to determine the price levels, which are then passed to the on-chain function for execution.

Discussion

Builders also viewed

See more projects on Devfolio