degenbot.types.pool_protocols¶
Pool simulation protocols.
Define structural interfaces for pool behavior. Pools satisfy these protocols by implementing the required methods — no inheritance needed.
Three pool-shape protocols: - ConstantProductPool — V2-family pools - ConcentratedLiquidityPool — V3/V4-family pools - StableswapPool — Curve-family pools
Module Contents¶
- class degenbot.types.pool_protocols.ConstantProductPool¶
Bases:
ProtocolAny pool using the x*y=k invariant (V2-style, Aerodrome volatile/stable).
Replaces AbstractUniswapV2Pool and AbstractAerodromeV2Pool for isinstance dispatch. Aerodrome pools satisfy this protocol too — they have the same structural shape (directional fees, reserves). The stable flag is accessed separately when needed.
- property address: degenbot.types.chain.ChecksummedAddress¶
Pool contract address.
- property token0: degenbot.erc20.erc20.Erc20Token¶
The lower-addressed token in the pair.
- property token1: degenbot.erc20.erc20.Erc20Token¶
The higher-addressed token in the pair.
- property fee_token0: fractions.Fraction¶
Fee ratio for token0 swaps.
- property fee_token1: fractions.Fraction¶
Fee ratio for token1 swaps.
- class degenbot.types.pool_protocols.ConcentratedLiquidityPool¶
Bases:
ProtocolAny pool using concentrated liquidity (tick-based: V3, V4).
Replaces AbstractConcentratedLiquidityPool for isinstance dispatch.
- property address: degenbot.types.chain.ChecksummedAddress¶
Pool contract address.
- property token0: degenbot.erc20.erc20.Erc20Token¶
The lower-addressed token in the pair.
- property token1: degenbot.erc20.erc20.Erc20Token¶
The higher-addressed token in the pair.
- class degenbot.types.pool_protocols.StableswapPool¶
Bases:
ProtocolAny pool using the Curve StableSwap invariant.
Structural check for multi-token stable pools. Used sparingly since Curve pools are typically dispatched by concrete type in the builder registry.
- property tokens: tuple[degenbot.erc20.erc20.Erc20Token, ...]¶
Tuple of all pool tokens.
- class degenbot.types.pool_protocols.PoolSimulation¶
Bases:
ProtocolRequired interface for all pools.
Supports exact-input swap simulation.
- property address: degenbot.types.chain.ChecksummedAddress¶
Pool contract address.
- class degenbot.types.pool_protocols.StateManageablePool¶
Bases:
ProtocolOptional interface for pools with on-chain state management.
Curve and Balancer pools typically don’t implement this.
- class degenbot.types.pool_protocols.TwoTokenSwapCalculation¶
Bases:
ProtocolA 2-token pool that can calculate output from input.
token_out is implied by token_in since there are exactly two tokens.
- calculate_tokens_out_from_tokens_in(token_in: degenbot.erc20.erc20.Erc20Token, token_in_quantity: int, override_state: degenbot.types.abstract.AbstractPoolState | None = None) int¶
Calculate output token amount for a given input.
- class degenbot.types.pool_protocols.MultiTokenSwapCalculation¶
Bases:
ProtocolAn N-token pool requiring explicit token_out for swap calculation.
Curve and Balancer pools need token_out specified because they have more than two tokens.
- calculate_tokens_out_from_tokens_in(token_in: degenbot.erc20.erc20.Erc20Token, token_out: degenbot.erc20.erc20.Erc20Token, token_in_quantity: int, override_state: degenbot.types.abstract.AbstractPoolState | None = None) int¶
Calculate output token amount for a given input with explicit token_out.