Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed Nov 16, 2024
1 parent 01117b2 commit 8337717
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/agent0/hyperfuzz/system_fuzz/invariant_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8337717

Please sign in to comment.