degenbot.uniswap.v4_pool_calc¶

Calculation mixin for Uniswap V4 concentrated-liquidity pools.

Provides pricing and fee calculation methods that operate on state held by V4PoolState. The swap calculation methods (calculate_tokens_in/out) stay in the pool class because they’re tightly coupled to V4-specific internals (SwapDelta, Hooks, HookedPoolResult).

See: contract_reference/uniswap/V4/PoolManager.sol (PoolManager swap/modifyLiquidity, Pool, Hooks, SqrtPriceMath, SwapMath)

Module Contents¶

class degenbot.uniswap.v4_pool_calc.UniswapV4PoolCalc¶

Pricing and fee methods for Uniswap V4 pools.

Class variables that V4 subclasses may override: - FEE_DENOMINATOR

tokens: tuple[degenbot.erc20.Erc20Token, degenbot.erc20.Erc20Token]¶
state: degenbot.uniswap.v4_types.UniswapV4PoolState¶
fee: int¶
FEE_DENOMINATOR = 1000000¶
get_absolute_price(token: degenbot.erc20.Erc20Token, override_state: degenbot.uniswap.v4_types.UniswapV4PoolState | None = None) → fractions.Fraction¶

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

Returns:

The absolute price as a Fraction.

get_absolute_exchange_rate(token: degenbot.erc20.Erc20Token, override_state: degenbot.uniswap.v4_types.UniswapV4PoolState | None = None) → fractions.Fraction¶

Get the absolute exchange rate for the given token.

Returns:

The absolute exchange rate as a Fraction.

Raises:

DegenbotValueError – If the token is not held by this pool.

get_nominal_price(token: degenbot.erc20.Erc20Token, override_state: degenbot.uniswap.v4_types.UniswapV4PoolState | None = None) → fractions.Fraction¶

Get the nominal price, corrected for decimals.

Returns:

The nominal price as a Fraction.

get_nominal_exchange_rate(token: degenbot.erc20.Erc20Token, override_state: degenbot.uniswap.v4_types.UniswapV4PoolState | None = None) → fractions.Fraction¶

Get the nominal rate, corrected for decimal place values.

Returns:

The nominal exchange rate as a Fraction.