degenbot.balancer.libraries.constants¶
Balancer V2 math constants (ONE, MIN_TOKEN_BALANCES, PowVersion).
Module Contents¶
- degenbot.balancer.libraries.constants.ONE = 1000000000000000000¶
- degenbot.balancer.libraries.constants.TWO = 2000000000000000000¶
- degenbot.balancer.libraries.constants.FOUR = 4000000000000000000¶
- degenbot.balancer.libraries.constants.MAX_POW_RELATIVE_ERROR = 10000¶
- class degenbot.balancer.libraries.constants.PowVersion(*args, **kwds)¶
Bases:
enum.EnumIdentifies 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.
- V1 = 'v1'¶
- V2 = 'v2'¶