1// REF: https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol23// fullmath implements Uniswap V3's FullMath library.4//5// This library provides advanced fixed-point math operations that are essential6// for Uniswap V3's tick math and liquidity calculations. It enables precise7// calculations of (a * b / denominator) with full 512-bit intermediate precision.
Functions
not supported for pure packages by the node (vm/qfuncs)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
8//
9// NOTE: Unlike the base arithmetic methods in the uint256 package, which return
10// low-256-bit values (or values plus overflow flags in their `*Overflow`
11// variants), functions in this file panic on invalid inputs to maintain
12// behavioral compatibility with the original Solidity implementation.
13//
14// This design choice is intentional because:
15// 1. These functions are typically used in hot paths where error handling would add overhead
16// 2. Invalid inputs (like zero denominator) represent programming errors, not runtime conditions
17// 3. Staying close to the Solidity implementation makes protocol porting more reliable
18//
19// If you need error-returning versions, wrap these functions with appropriate error handling.
20package uint256
21
22// MulDiv computes floor((a * b) / denominator) with a full 512-bit intermediate product.
23//
24// Parameters:
25// - a: First non-negative 256-bit multiplicand.
26// - b: Second non-negative 256-bit multiplicand.
27// - denominator: Non-zero 256-bit divisor.
28//
29// Returns:
30// - quotient: The exact floor quotient when it fits in 256 bits.
31//
32// Panics if denominator is zero or the quotient is at least 2^256.