degenbot.curve.per_block_cache ============================== .. py:module:: degenbot.curve.per_block_cache .. autoapi-nested-parse:: Per-block on-chain cache for CurveStableswapPool. Owns all BoundedCache instances and their accessor methods, extracting the cache subsystem from the pool class. Each accessor follows the pure try/cache/store/return pattern — no accessor mutates state read by another accessor. get_cached_virtual_price() resolves its own dependencies inline (calling get_cached_base_cache_updated() and get_cached_base_virtual_price()), eliminating the need for side-effect mirrors or call-ordering contracts. Module Contents --------------- .. py:class:: PerBlockCache(data_provider: degenbot.curve.types.CurveDataProvider | None, address: degenbot.types.chain.ChecksummedAddress, *, base_pool_is_set: bool, state_cache_depth: int = 8) Owns all per-block on-chain caches for a CurveStableswapPool. Each accessor implements the try-cache → call-provider → store → return pattern. No accessor mutates state read by another accessor. get_cached_virtual_price() resolves its own dependencies internally, eliminating the need for side-effect mirrors or call-ordering contracts. The pool holds one instance of this class instead of nine separate BoundedCache fields. .. py:attribute:: BASE_CACHE_EXPIRES :type: int :value: 600 .. py:method:: get_cached_block_timestamp(block_number: degenbot.types.aliases.BlockNumber) -> int Fetch or retrieve cached block timestamp. :returns: The block timestamp as an integer. :raises MissingCurveData: If the value is not cached and no provider is available. .. py:method:: get_cached_base_cache_updated(block_number: degenbot.types.aliases.BlockNumber) -> int Fetch or retrieve cached base_cache_updated block number. Pure try/cache/store/return. No mirror side effect. :returns: The base_cache_updated timestamp as an integer. :raises MissingCurveData: If the value is not cached and no provider is available. .. py:method:: get_cached_base_virtual_price(block_number: degenbot.types.aliases.BlockNumber) -> int Fetch or retrieve cached base pool virtual price. Pure try/cache/store/return. No mirror side effect. :returns: The base pool virtual price as an integer. :raises MissingCurveData: If the value is not cached and no provider is available. .. py:method:: get_cached_virtual_price(block_number: degenbot.types.aliases.BlockNumber) -> int Resolve virtual price with self-contained expiry logic. For metapools, internally resolves base_cache_updated and base_virtual_price (calling their accessors) to determine whether to use the cached base_virtual_price or fetch live. No side-effect mirrors — all dependency resolution is inline. :returns: The virtual price as an integer. :raises MissingCurveData: If the value is not cached and no provider is available.