degenbot.types¶
Shared types: AddressComparable, state caches, pool enums, and aliases.
Submodules¶
Package Contents¶
- class degenbot.types.AddressComparable¶
Mixin providing address-based comparison, ordering, and hashing.
Any on-chain entity identified by a ChecksummedAddress can inherit from this to get consistent equality, ordering, and hashing by address.
- address: degenbot._ffi.ChecksummedAddress¶
- class degenbot.types.BoundedCache[KT, VT](max_items: int)¶
Bases:
collections.OrderedDict[KT,VT]A cache holding key-value pairs, tracked by entry order. The cache automatically removes old.
items if the number of items would exceed the maximum number of entries set by max_items.
Setting a value at an existing key will overwrite that value without affecting ordering.
- max_items¶
- copy() Self¶
Copy.
- Returns:
The computed value.
- class degenbot.types.KeyedDefaultDict[KT, VT](default_factory: collections.abc.Callable[[KT], VT])¶
Bases:
collections.defaultdict[KT,VT]A modified defaultdict that passes the key to default_factory at runtime and records it.
This differs from the defaultdict behavior, which calls default_factory with no arguments.
- class degenbot.types.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.
- class degenbot.types.PoolSimulation¶
Bases:
ProtocolRequired interface for all pools.
Supports exact-input swap simulation.
- property address: degenbot.types.chain.ChecksummedAddress¶
Pool contract address.
- class degenbot.types.StateManageablePool¶
Bases:
ProtocolOptional interface for pools with on-chain state management.
Curve and Balancer pools typically don’t implement this.
- class degenbot.types.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.