degenbot.aerodrome.v2_pool_calc¶

Calculation mixin for Aerodrome V2 pools.

Provides calculation methods that operate on state held by AerodromeV2PoolState. At construction time, the stable flag determines which underlying calculation functions are wired — no runtime if self._stable dispatch in hot paths.

Two calculation strategies: - Volatile: standard constant-product (x*y=k) - Stable: Solidly stable invariant (x^3*y + y^3*x >= k)

Module Contents¶

class degenbot.aerodrome.v2_pool_calc.AerodromeV2PoolCalc¶

Calculation methods for Aerodrome V2 pools.

Wires the correct calculation function at construction time based on the stable flag. All methods delegate to the pre-bound calculation function — no runtime if self._stable dispatch.

The following attributes are set in __init_subclass__ or at construction: - _calc_tokens_in_from_tokens_out: bound calc function for exact-out

reserves_token0: int¶
reserves_token1: int¶
state: degenbot.aerodrome.types.AerodromeV2PoolState¶
tokens: tuple[degenbot.erc20.Erc20Token, degenbot.erc20.Erc20Token]¶
calculate_tokens_in_from_tokens_out(token_out_quantity: int, token_out: degenbot.erc20.Erc20Token, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → int¶

Calculate the required token INPUT for a target OUTPUT at current pool reserves.

Returns:

The computed integer value.

Raises:
calculate_tokens_out_from_tokens_in(token_in: degenbot.erc20.Erc20Token, token_in_quantity: int, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → int¶

Calculate the expected token OUTPUT for a target INPUT at current pool reserves.

Returns:

The computed integer value.

Raises:
get_absolute_price(token: degenbot.erc20.Erc20Token, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → fractions.Fraction¶

Get the absolute price for the given token, expressed in units of the other.

Returns:

The computed value.

get_absolute_exchange_rate(token: degenbot.erc20.Erc20Token, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → fractions.Fraction¶

Get the absolute exchange rate for the given token.

Returns:

The computed value.

Raises:

DegenbotValueError – See function documentation.

get_nominal_price(token: degenbot.erc20.Erc20Token, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → fractions.Fraction¶

Get the nominal price, corrected for decimals.

Returns:

The computed value.

get_nominal_exchange_rate(token: degenbot.erc20.Erc20Token, override_state: degenbot.aerodrome.types.AerodromeV2PoolState | None = None) → fractions.Fraction¶

Get the nominal exchange rate, corrected for decimal place values.

Returns:

The computed value.