degenbot.types.pool_type¶

PoolFamily and kind enums for pool type resolution.

Module Contents¶

class degenbot.types.pool_type.PoolProbe¶

Bases: enum.IntEnum

The on-chain probe outcome BotIo.probe_pool_type returns.

The Rust probe (pool_builder::builder) classifies a contract by which read-only call answers. The enum crosses the PyO3 seam as a 1-based u8 (auto() values, the curve_math try_from_u8 crossing convention); an unrecognized code is seam drift and must raise, never silently classify.

Member order is the wire contract - keep in lock-step with the PoolFamily match in py_bot_io.rs::probe_pool_type (a new Rust variant fails that match to compile until a code is assigned here).

V2 = 1¶
V3 = 2¶
BALANCER_WEIGHTED = 3¶
BALANCER_STABLE = 4¶
STABLESWAP = 5¶
class degenbot.types.pool_type.PoolFamily(*args, **kwds)¶

Bases: enum.Enum

The mathematical family governing swap pricing.

Used for pool type identification (build_pool dispatch, DB kind derivation). Each DEX pool class belongs to exactly one family.

CONSTANT_PRODUCT = 'constant_product'¶
CONCENTRATED_LIQUIDITY = 'concentrated_liquidity'¶
STABLESWAP = 'stableswap'¶
WEIGHTED = 'weighted'¶
class degenbot.types.pool_type.PoolVariant¶

Bases: enum.StrEnum

The KNOWN pool-variant vocabulary — an intentionally OPEN set.

The variant is the DEX identity string carried on PoolTypeDescriptor and persisted into the DB kind (via derive_kind()). Third-party DEXes register their own spellings (PoolRegistration.variant, the variant key of deployments.json overlays), so the set cannot be closed: unknown strings surface as UNRECOGNIZED at the conversion point (classify_pool_variant()) and raise loudly at the decision points that must act on variant semantics — never silently guessed.

Members enumerate the variants shipped in this repository.

BALANCER_STABLE = 'balancer_stable'¶
BALANCER_WEIGHTED = 'balancer_weighted'¶
AERODROME = 'aerodrome'¶
CAMELOT = 'camelot'¶
PANCAKESWAP = 'pancakeswap'¶
SUSHISWAP = 'sushiswap'¶
SWAPBASED = 'swapbased'¶
UNRECOGNIZED = 'unrecognized'¶
degenbot.types.pool_type.BALANCER_VARIANTS¶
degenbot.types.pool_type.classify_pool_variant(variant: str | None) → PoolVariant | None¶

Classify one raw variant string into the variant taxonomy — the ONE conversion point.

Parameters:

variant – The descriptor’s raw variant string, or None for the canonical Uniswap / no-variant identity.

Returns:

None for None input, the matching PoolVariant member for a known spelling, or PoolVariant.UNRECOGNIZED for an open-set string this process does not know.

class degenbot.types.pool_type.PoolTypeDescriptor¶

Describes the resolved type of a pool.

Produced by the type resolver, consumed by the dispatch in build_pool.

family: PoolFamily¶
variant: str | None¶
kind: str¶
factory: degenbot._ffi.ChecksummedAddress | None¶
degenbot.types.pool_type.derive_kind(family: PoolFamily, variant: str | None) → str¶

Derive the DB kind string from family + variant.

Examples

CONSTANT_PRODUCT + None → “uniswap_v2” CONCENTRATED_LIQUIDITY + “sushiswap” → “sushiswap_v3” CONSTANT_PRODUCT + “camelot” → “camelot_v2” STABLESWAP + None → “stableswap”

Returns:

The computed value.