Skip to main content

Square-root price

The current contract stores square-root price as u256::U256 in Q128.128 form.
At tick zero, sqrt_price_x128 = 2^128. The value is { hi: 1, lo: 0 } in u256::U256 limbs. Display price must also account for canonical token order and token display decimals. The contract itself uses native base units and stores no decimal scale.

Fee growth

Global, outside, and inside fee growth also use Q128.128 u256::U256 values:
Growth subtraction wraps modulo 2^256. Whole token amounts must still fit u128.

Wide arithmetic

Price and liquidity formulas use full-width multiplication and division. The contract selects floor or ceiling rounding for each operation. A quote engine must copy that order. Floating-point algebra is not transaction-safe.