Skip to main content

liquidity_math_add

Function liquidity_math_add 

Source
pub fn liquidity_math_add(x: u128, y: i128) -> u128
Expand description

Adds a signed liquidity delta to liquidity, panicking on overflow or underflow.

Prefer try_liquidity_math_add in event-replay paths where a structured error with surrounding context is preferred. This panic-style variant is kept for in-pool invariants where overflow is treated as a contract bug rather than an expected runtime error.

§Returns

The resulting liquidity after applying the delta.

§Panics

This function panics if:

  • Adding positive delta causes overflow.
  • Subtracting causes underflow.