Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the code to support 256‐bit calculations for prices and quantities by replacing u64 with crypto-bigint’s U256. The key changes are:
- Converting Price and Quantity types in production code and tests.
- Updating order update calls, assertions, and arithmetic operations to use U256 and U512.
- Adding dependencies (num-bigint and crypto-bigint) to support big integer arithmetic.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apex-core/tests/modify.rs | Updated order update calls to wrap numeric literals with Price::from. |
| apex-core/tests/market_orders.rs | Adjusted test values to compare using Quantity::from for market order slippage and quantity. |
| apex-core/tests/limit_orders.rs | Updated assertions to use Quantity::from for remaining unit checks. |
| apex-core/tests/common.rs | Modified order creation helpers to convert raw values via Price::from and Quantity::from. |
| apex-core/src/engine/types.rs | Changed Price and Quantity types to U256 and revised slippage calculation using U512. |
| apex-core/src/engine/engine.rs | Updated arithmetic and zero checks to work with U256 methods. |
| apex-core/benches/common.rs | Updated benchmark helpers for order creation reflecting the new type conversion. |
| apex-core/Cargo.toml | Added dependencies for num-bigint and crypto-bigint. |
Comments suppressed due to low confidence (2)
apex-core/src/engine/types.rs:17
- Consider updating the associated comment for 'Price' to indicate that it is now a 256-bit unsigned integer rather than a 64-bit value, to clarify its purpose in big integer calculations.
pub type Price = U256;
apex-core/src/engine/types.rs:21
- Update the comment for 'Quantity' to reflect that it is now a 256-bit unsigned integer, ensuring consistency with the new arithmetic size and clarifying its usage.
pub type Quantity = U256;
There was a problem hiding this comment.
Pull Request Overview
This PR updates the codebase so that Price and Quantity calculations now use 256‐bit integers via the crypto‑bigint library, enabling support for u256 size arithmetic.
- Refactored order creation functions and tests to use Price::from and Quantity::from conversions instead of direct integer types.
- Updated arithmetic and zero‑checks in engine logic to work with U256, and renamed the slippage tolerance constant for clarity.
- Added necessary dependency updates in Cargo.toml.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apex-core/tests/modify.rs | Updated update_order calls to convert primitive prices into U256 values. |
| apex-core/tests/market_orders.rs | Adjusted slippage tolerance and quantity assertions to use the U256 conversion. |
| apex-core/tests/limit_orders.rs | Updated assertions in tuple comparisons to use Quantity::from conversions. |
| apex-core/tests/common.rs | Modified helpers for order creation to accept u64 and convert to U256 for price and quantity. |
| apex-core/src/engine/types.rs | Changed Price and Quantity types to U256 and updated related arithmetic and constant naming. |
| apex-core/src/engine/engine.rs | Updated arithmetic operations and zero‑checks to handle U256 values in order processing logic. |
| apex-core/benches/common.rs | Updated benchmark helpers to use U256 conversion in order creation. |
| apex-core/Cargo.toml | Added crypto‑bigint and num‑bigint dependencies for big integer support. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Price & Quantity support u256 size calculation.