Skip to content

Conversation

@kunsonx
Copy link
Contributor

@kunsonx kunsonx commented Apr 28, 2025

Price & Quantity support u256 size calculation.

@kunsonx kunsonx requested a review from Copilot April 28, 2025 18:33
Copy link

Copilot AI left a 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 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;

@kunsonx kunsonx requested a review from Copilot April 28, 2025 18:36
Copy link

Copilot AI left a 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 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.

@kunsonx kunsonx merged commit d8b67d2 into main Apr 28, 2025
1 check passed
@kunsonx kunsonx deleted the dev-bigint256 branch April 28, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants