Expand description
Orderbook and tick level management for the stablecoin DEX.
Modules§
Structs§
- Orderbook
- Orderbook for token pair with price-time priority Uses tick-based pricing with bitmaps for price discovery
- Orderbook
Handler - Type-safe handler for accessing
#struct_namein storage. - Tick
Level - Represents a price level in the orderbook with a doubly-linked list of orders Orders are maintained in FIFO order at each tick level
- Tick
Level Handler - Type-safe handler for accessing
#struct_namein storage.
Enums§
- Rounding
Direction - Rounding direction for price conversions.
Constants§
- MAX_
PRICE 🔒 - Highest representable scaled price (
PRICE_SCALE + MAX_TICK). - MAX_
TICK - Maximum allowed tick value (corresponds to
MAX_PRICE). - MIN_
PRICE 🔒 - Lowest representable scaled price (
PRICE_SCALE + MIN_TICK). - MIN_
TICK - Minimum allowed tick value (corresponds to
MIN_PRICE). - PRICE_
SCALE - Scaling factor for tick-to-price conversion. A tick of 0 maps to
PRICE_SCALE(peg).
Functions§
- base_
to_ quote - Convert base token amount to quote token amount at a given tick.
- compute_
book_ key - Compute deterministic book key from ordered (base, quote) token pair
- price_
to_ tick - Converts a scaled price back to a relative tick.
- quote_
to_ base - Convert quote token amount to base token amount at a given tick.
- tick_
to_ price - Convert relative tick to scaled price
- validate_
tick_ spacing - Validates that a tick is aligned to
TICK_SPACING.