degenbot.aerodrome.v2_pool_calc =============================== .. py:module:: degenbot.aerodrome.v2_pool_calc .. autoapi-nested-parse:: 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 --------------- .. py:class:: 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 .. py:attribute:: reserves_token0 :type: int .. py:attribute:: reserves_token1 :type: int .. py:attribute:: state :type: degenbot.aerodrome.types.AerodromeV2PoolState .. py:attribute:: tokens :type: tuple[degenbot.erc20.Erc20Token, degenbot.erc20.Erc20Token] .. py:method:: 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 DegenbotValueError: See function documentation. :raises InvalidSwapInputAmount: See function documentation. :raises LiquidityPoolError: See function documentation. .. py:method:: 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 DegenbotValueError: See function documentation. :raises InvalidSwapInputAmount: See function documentation. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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.