diff --git a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py index ddd754cdb..4395ddc2b 100644 --- a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py +++ b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py @@ -280,6 +280,13 @@ def _check_price_spike(interface: HyperdriveReadInterface, pool_state: PoolState def _check_negative_interest(interface: HyperdriveReadInterface, pool_state: PoolState) -> InvariantCheckResults: + """Check for negative interest in the pool. + + If the rate went down, post a log + If the pool is paused, log is warning regardless of relative rate change + If the pool is not paused and the rate went down by more than the relative tol, log is critical + If the pool is not paused, but the rate did not go down by more than the relative tol, log is warning + """ # Hyperdrive base & eth balances should always be zero failed = False exception_message: str | None = None @@ -304,19 +311,15 @@ def _check_negative_interest(interface: HyperdriveReadInterface, pool_state: Poo previous_pool_state = interface.get_hyperdrive_state(block_identifier=previous_block_number) previous_vault_share_price = previous_pool_state.pool_info.vault_share_price - # If the rate went down, post a log - # If the pool is paused, log is warning regardless of relative rate change - # If the pool is not paused and the rate went down by more than the relative tol, log is critical - # if the pool is not paused, but the rate did not go down by more than the relative tol, log is warning - if current_vault_share_price - previous_vault_share_price <= -NEGATIVE_INTEREST_ATOL: # rate went down + # Absolute check to see if the rate went down + if current_vault_share_price - previous_vault_share_price <= -NEGATIVE_INTEREST_ATOL: log_level = logging.WARNING if interface.get_pool_is_paused(): paused_str = "paused" else: paused_str = "unpaused" - if ( - previous_vault_share_price * NEGATIVE_INTEREST_RTOL <= current_vault_share_price - ): # rate went down by a lot + # relative check to see if the rate went down by a lot + if previous_vault_share_price * NEGATIVE_INTEREST_RTOL <= current_vault_share_price: log_level = logging.CRITICAL failed = True exception_data["invariance_check:current_vault_share_price"] = current_vault_share_price