Technical Implementation
Order Storage
Orders are stored using a combination of:
- Linked lists for orders at each price level
- Mappings for quick access to user orders
- Arrays for tracking price levels and volumes
Order Matching Algorithm
- The system first checks for existing orders at the specified price
- Orders are matched in FIFO (First In, First Out) order
- Partial fills are processed when exact matches aren't available
- Remaining amounts create new orders in the book
Price Discovery
The system provides functions to:
- Query current order books
- Get best available prices
- Calculate potential output amounts
- View market depth

