
mina-dark-pool
Dark pool using hybrid execution model for private order matching with delayed execution
About
This project makes use of Protokit to create a custom sequencer, which enables private order matching. My implementation is based off of a constant product liquidity pool (see acknowledgements), where users can provide liquidity in any LP. For each LP, I have also added a whitelist mechanism, which is in line with what a dark pool is. In this project, here are the features of the Dark Pool I have implemented - private order matching (using custom sequencer) - delayed order execution (based on block heights) - expiration of orders (based on block heights) - public LP operations - public order submission - public token registry for pools (unique based on token pair) - hooks for users to setup callbacks once orders are matched / before orders are matched
How it's made
Based off of the Protokit starter template, I have created a DarkPool and TokenRegistry runtime module for pool and token management. Additionally, I created a DarkPoolMempool sequencer module to match orders whenever an incoming order is submitted. This checks against incoming method IDs and also stores a simple set in memory to avoid matching orders multiple time in a block. This will eventually be done in a cronjob. The frontend is built using shadcn and Next.js. I have detailed my other approaches in the README.md, for your perusal.