degenbot.builders.type_resolution¶
Shared type resolution for pool construction.
Functions extracted from Bot so that pool type resolution logic (DB lookup, factory fetch, on-chain probing, class dispatch) is defined once and used by the Bot build path.
Pure functions (no I/O): - pool_class_for_descriptor() - _descriptor_from_probing_result()
Sync functions (accept BotIo): - fetch_factory_from_chain() - resolve_pool_type_by_probing() - resolve_pool_type()
Module Contents¶
- degenbot.builders.type_resolution.pool_class_for_descriptor(pool_type: degenbot.types.pool_type.PoolTypeDescriptor, *, chain_id: degenbot.types.aliases.ChainId) type[degenbot.types.abstract.liquidity_pool.AbstractLiquidityPool]¶
Resolve a PoolTypeDescriptor to a concrete pool class.
Consults the pool_type_registry to find the registered class for this factory on this chain. Falls back to a default class based on the family if no specific registration exists.
- Returns:
The computed value.
- Raises:
DegenbotValueError – If the operation fails.
- degenbot.builders.type_resolution.fetch_factory_from_chain(address: degenbot.types.chain.ChecksummedAddress, *, chain_id: degenbot.types.aliases.ChainId, io: degenbot._ffi.BotIo) degenbot.types.chain.ChecksummedAddress | None¶
Fetch the factory address from the pool contract’s factory() method.
The encode → call → decode → checksum choreography is Rust-owned (
BotIo.fetch_factory_address, ADR-005 slice 14b). BotIo is the only executor; the Python parity-gate fallback is retired.- Returns:
The computed value.
- degenbot.builders.type_resolution.resolve_pool_type_by_probing(address: degenbot.types.chain.ChecksummedAddress, *, chain_id: degenbot.types.aliases.ChainId, factory: degenbot.types.chain.ChecksummedAddress, io: degenbot._ffi.BotIo) degenbot.types.pool_type.PoolTypeDescriptor¶
Determine pool type by probing the contract on-chain.
Tries V3 first (slot0), then V2 (getReserves), then Balancer (getPoolId + getNormalizedWeights), then Curve (coins(uint256)). When no probe answers, the Rust probe raises UnknownPoolIdentity, which this function surfaces as DegenbotValueError — an unverified contract is not silently classified as Curve.
- Returns:
The computed value.
- Raises:
DegenbotValueError – When the seam reports no identity selector answered, or on a probe code outside the PoolProbe space — Rust/Python wire-order drift, never silently classified.
- degenbot.builders.type_resolution.resolve_pool_type(address: degenbot.types.chain.ChecksummedAddress, *, chain_id: degenbot.types.aliases.ChainId, io: degenbot._ffi.BotIo) degenbot.types.pool_type.PoolTypeDescriptor¶
Resolve the pool type for the given address.
Consults these sources in order: 1. Database kind column (exact polymorphic type) 2. PoolTypeRegistry registration (factory address → descriptor) 3. On-chain probing (slot0 vs getReserves) when factory is unknown
Raises DegenbotValueError if the type cannot be determined.
- Returns:
The computed value.
- Raises:
DegenbotValueError – If the operation fails.