degenbot.curve.types¶
Curve-specific type definitions (swap style, metapool enums).
Module Contents¶
- class degenbot.curve.types.DVariant(*args, **kwds)¶
Bases:
enum.EnumWhich D-calculation formula to use in _get_d.
The original code had 5 address groups selecting different d_func and dp_func pairs. Groups 1 and 3 both use variant_alpha dp but differ on d_func: - Group 1: variant_alpha d + variant_alpha dp - Group 3: standard d + variant_alpha dp
- STANDARD¶
- VARIANT_ALPHA¶
- VARIANT_ALPHA_DP_ALPHA¶
- VARIANT_DP_ALPHA¶
- VARIANT_BETA_DP¶
- VARIANT_GAMMA_DP¶
- class degenbot.curve.types.YVariant(*args, **kwds)¶
Bases:
enum.EnumWhich Y-calculation formula to use in _get_y.
The original code had two overlapping address sets controlling independent behaviours: Y_VARIANT_GROUP_0 (amp divisor) and Y_VARIANT_GROUP_1 (c/b formula). Since Y_VARIANT_GROUP_0 ⊂ Y_VARIANT_GROUP_1, there are exactly 3 observed combinations, yielding these variants:
- STANDARD¶
- VARIANT_0¶
- VARIANT_1¶
- class degenbot.curve.types.YDVariant(*args, **kwds)¶
Bases:
enum.EnumWhich Y_D-calculation formula to use in _get_y_d.
- STANDARD¶
- VARIANT_0¶
- class degenbot.curve.types.SwapStyle(*args, **kwds)¶
Bases:
enum.EnumWhich computation path to use in get_dy.
Each value identifies a complete swap calculation path differing in rate source, balance source, fee application, and rate conversion. These are not independent axes — each path is a coherent unit.
The variants capture differences in: - How dy is computed (with or without the - 1 subtraction) - When fee is applied (before or after rate conversion) - How rate conversion is applied - What balances are used (pool state, live minus admin, raw)
- STANDARD¶
- RATE_ADJUSTED¶
- RAW_BALANCE¶
- CRYPTO¶
- LIVE_ADMIN¶
- LIVE_ADMIN_DYNAMIC¶
- LIVE_ADMIN_DYNAMIC_PRECISION¶
- LIVE_ADMIN_ORACLE¶
- NO_ONE_FEE_RATE¶
- CYTOKEN¶
- RATE_ADJUSTED_NO_ONE¶
- class degenbot.curve.types.MetapoolRateStyle(*args, **kwds)¶
Bases:
enum.EnumWhich rates to use for the metapool branch in get_dy.
- STANDARD¶
- PRECISION_VP¶
- REDEMPTION_VP¶
- class degenbot.curve.types.MetapoolUnderlyingStyle(*args, **kwds)¶
Bases:
enum.EnumWhich computation path to use in _get_dy_underlying.
- STANDARD¶
- REDEMPTION¶
- PRECISION_VP¶
- class degenbot.curve.types.LendingRateStyle(*args, **kwds)¶
Bases:
enum.EnumWhich rate-fetching method to use for lending tokens.
Used by get_dy() to select which stored-rate resolution path to call via CurveDataProvider.lending_rates().
- NONE¶
- CTOKEN¶
- YTOKEN¶
- CYTOKEN¶
- AETH¶
- RETH¶
- ORACLE¶
- class degenbot.curve.types.BasePoolPort¶
Bases:
ProtocolThe slice of the base-pool surface the metapool
DyCalculatorneeds.Names the real interface behind the lazy go-between (ADR-005): a metapool’s calc paths call exactly these six members on its base pool —
tokens/balances/feefor metadata, andcalc_token_amount/get_dy/calc_withdraw_one_coinfor delegated computation. Two adapters satisfy it: the production_LazyBasePool(handle → base companion, memoised) and a cannedStubBasePoolfor calculator unit tests (which previously couldn’t exercise.calculate()without standing up a full pool).- property tokens: tuple[degenbot.erc20.Erc20Token, ...]¶
Base-pool coin companions.
- calc_token_amount(*, amounts: collections.abc.Sequence[int], deposit: bool, block_identifier: degenbot.types.rpc_types.BlockIdentifier | None = None, override_state: CurveStableswapPoolState | None = None) int¶
Deposit/withdraw token amount (slippage-adjusted).
- get_dy(i: int, j: int, dx: int, block_identifier: degenbot.types.rpc_types.BlockIdentifier | None = None, override_state: CurveStableswapPoolState | None = None) int¶
Output
dyfor swappingdxof coini→ coinj.
- class degenbot.curve.types.DyCalculationInputs¶
Pre-resolved data for a single dy calculation.
Constructed by CurveStableswapPool.get_dy() before delegating to the injected DyCalculator. The calculator reads only from this object — never from the pool directly. All I/O, cache lookups, and rate resolution happen before this object is created.
- base_pool: BasePoolPort | None = None¶
- class degenbot.curve.types.CurveDataProvider¶
Bases:
ProtocolOn-chain data access for a Curve StableSwap pool.
Consolidates the 13 individual fetcher callbacks into a single interface. The pool checks provider availability before calling; a provider that doesn’t support a method should raise MissingCurveData.
All methods accepting block_number may use block-specific data.
- class degenbot.curve.types.CurveStableswapPoolState¶
Bases:
degenbot.types.abstract.AbstractPoolStateCurveStableswapPoolState class.
- base: CurveStableswapPoolState | None = None¶
- class degenbot.curve.types.CurveStableswapPoolExternalUpdate¶
CurveStableswapPoolExternalUpdate class.
- block_number: degenbot.types.aliases.BlockNumber¶