-
Notifications
You must be signed in to change notification settings - Fork 0
[ENG-87] Implement price library #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a new price library for encoding and decoding fixed-point decimal prices using a mantissa-exponent representation within a 32-bit integer. The library provides validation, encoding/decoding capabilities, and utilities for converting between different decimal representations.
Key Changes
- Introduces a price encoding scheme using 27 bits for mantissa and 5 bits for biased exponent
- Implements validated mantissa with strict digit bounds (8 significant digits)
- Provides macros for checked arithmetic operations and power-of-10 calculations with biased exponents
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
price/src/lib.rs |
Main library module defining constants, OrderInfo struct, and conversion logic with tests |
price/src/validated_mantissa.rs |
Wrapper type ensuring mantissa values are within valid 8-digit range |
price/src/macros.rs |
Utility macros for pow10 calculations and checked arithmetic operations |
price/src/error.rs |
Error enum for order information validation failures |
price/src/encoded_price.rs |
Encoding logic for packing mantissa and exponent into u32 |
price/src/decoded_price.rs |
Decoding logic for extracting mantissa and exponent from u32 |
price/Cargo.toml |
Package manifest with dependencies |
Cargo.toml |
Workspace update to include price crate |
Cargo.lock |
Lock file update for new price package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 17 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update unit test name to max and max plus one base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xbtmatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second round of addressing review comments and changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xbtmatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Third round of addressing review comments and fixes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xbtmatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fourth round of addressing review comments
Description
This PR introduces the standalone price representation module used for Dropset’s order and matching logic.
The implementation provides a deterministic, overflow-safe encoding of prices using a mantissa + biased exponent scheme without the usage of intermediate u128 values when storing price order info.
Summary of Changes
price_mantissavalidation and bounds checking(price_mantissa, base_scalar_exponent, quote_exponent)into the packed integer price.u128overflow using checked operationsBIASof 16