degenbot.balancer.libraries.constants ===================================== .. py:module:: degenbot.balancer.libraries.constants .. autoapi-nested-parse:: Balancer V2 math constants (ONE, MIN_TOKEN_BALANCES, PowVersion). Module Contents --------------- .. py:data:: ONE :value: 1000000000000000000 .. py:data:: TWO :value: 2000000000000000000 .. py:data:: FOUR :value: 4000000000000000000 .. py:data:: MAX_POW_RELATIVE_ERROR :value: 10000 .. py:class:: PowVersion(*args, **kwds) Bases: :py:obj:`enum.Enum` Identifies which FixedPoint.pow implementation a deployed pool contract uses. Different deployed versions of Balancer V2 WeightedPool contracts embed different versions of the FixedPoint library: - V1 (no fast paths): older contracts like WeightedPool2Tokens use the general LogExpMath.pow path with MAX_POW_RELATIVE_ERROR error bound for all exponent values. This was the original implementation. - V2 (with fast paths): newer WeightedPool contracts include fast paths for y == 1, y == 2, and y == 4 that bypass the error-bound calculation, producing different rounding behavior. The version is detected from the pool's deployed bytecode at build time and stored on the pool instance so swap calculations match the on-chain contract exactly. .. py:attribute:: V1 :value: 'v1' .. py:attribute:: V2 :value: 'v2' .. py:method:: to_u8() -> int Return the `u8` discriminant threaded across the Rust seam (1 = V1, 2 = V2). Mirrors `degenbot_balancer_math::PowVersion::to_u8` so the bytecode-detected version crosses the FFI boundary to the Rust math leaf as a plain `u8`. :returns: `1` for `V1`, `2` for `V2`.