agent0.hyperfuzz.system_fuzz.invariant_checks ============================================= .. py:module:: agent0.hyperfuzz.system_fuzz.invariant_checks .. autoapi-nested-parse:: Runs invariant checks against a hyperdrive pool. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: agent0.hyperfuzz.system_fuzz.invariant_checks.LP_SHARE_PRICE_EPSILON agent0.hyperfuzz.system_fuzz.invariant_checks.TOTAL_SHARES_EPSILON agent0.hyperfuzz.system_fuzz.invariant_checks.NEGATIVE_INTEREST_ATOL agent0.hyperfuzz.system_fuzz.invariant_checks.NEGATIVE_INTEREST_RTOL agent0.hyperfuzz.system_fuzz.invariant_checks.PRESENT_VALUE_EPSILON agent0.hyperfuzz.system_fuzz.invariant_checks.EZETH_NEG_INTEREST_TIME_DELTA Classes ------- .. autoapisummary:: agent0.hyperfuzz.system_fuzz.invariant_checks.InvariantCheckResults Functions --------- .. autoapisummary:: agent0.hyperfuzz.system_fuzz.invariant_checks.run_invariant_checks Module Contents --------------- .. py:data:: LP_SHARE_PRICE_EPSILON :value: 0.0001 .. py:data:: TOTAL_SHARES_EPSILON :value: 1e-09 .. py:data:: NEGATIVE_INTEREST_ATOL .. py:data:: NEGATIVE_INTEREST_RTOL .. py:data:: PRESENT_VALUE_EPSILON .. py:data:: EZETH_NEG_INTEREST_TIME_DELTA :value: 43200 .. py:function:: run_invariant_checks(check_block_data: web3.types.BlockData, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, log_to_rollbar: bool = True, rollbar_log_level_threshold: int | None = None, rollbar_log_filter_func: Callable[[Exception], bool] | None = None, pool_name: str | None = None, lp_share_price_test: bool | None = None, crash_report_additional_info: dict[str, Any] | None = None, log_anvil_state_dump: bool = False, pending_pool_state: agent0.ethpy.hyperdrive.state.pool_state.PoolState | None = None, check_price_spike: bool = True) -> list[agent0.hyperfuzz.FuzzAssertionException] Run the invariant checks. # Invariance checks (these should be True): - hyperdrive base & eth balances are zero - the expected total shares equals the hyperdrive balance in the vault contract - the pool has more than the minimum share reserves - the system is solvent, i.e. (share reserves - long exposure in shares - min share reserves) > 0 - present value is greater than idle shares - the lp share price doesn't exceed an amount from block to block - check negative interest on yield source - Warn if a trade causes a large rate spike; which is a precursor to an attack :param check_block_data: The current block to be tested. :type check_block_data: BlockData :param interface: An instantiated HyperdriveReadInterface object constructed using the script arguments. :type interface: HyperdriveReadInterface :param log_to_rollbar: If True, log to rollbar if any invariant check fails. :type log_to_rollbar: bool :param rollbar_log_level_threshold: Threshold for logging to rollbar. :type rollbar_log_level_threshold: int | None, optional :param rollbar_log_filter_func: A function that filters exceptions to log to rollbar. The function should return `True` for exceptions that should be filtered from rollbar logging. Defaults to logging all exceptions. :type rollbar_log_filter_func: Callable[[Exception], bool] | None :param pool_name: The name of the pool for crash reporting information. :type pool_name: str | None :param lp_share_price_test: If True, only test the lp share price. If False, skips the lp share price test. If None (default), runs all tests. :type lp_share_price_test: bool | None, optional :param crash_report_additional_info: Additional information to include in the crash report. :type crash_report_additional_info: dict[str, Any] | None :param log_anvil_state_dump: If True, log anvil state dump on crash. :type log_anvil_state_dump: bool :param pending_pool_state: The pool state for the pending block. If None, assumes the block is ticking in the background and will maintain the pending block itself. :type pending_pool_state: BlockData | None, optional :param check_price_spike: If True, check price spike :type check_price_spike: bool :returns: A list of FuzzAssertionExceptions, one for each failed invariant check. :rtype: list[FuzzAssertionException] .. !! processed by numpydoc !! .. py:class:: InvariantCheckResults Bases: :py:obj:`NamedTuple` Results from an invariant check. .. !! processed by numpydoc !! .. py:attribute:: failed :type: bool .. py:attribute:: exception_message :type: str | None .. py:attribute:: exception_data :type: dict[str, Any] .. py:attribute:: log_level :type: int | None