From 3ab7d29e003ad4a5d13823901a8b8cf30c603c5d Mon Sep 17 00:00:00 2001 From: Dylan Paiton Date: Tue, 24 Sep 2024 19:01:23 -0700 Subject: [PATCH] skip price spike check if prices are zero (#1695) --- .../hyperfuzz/system_fuzz/invariant_checks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py index 731c568e74..2005a70d02 100644 --- a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py +++ b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py @@ -227,12 +227,27 @@ def _check_price_spike(interface: HyperdriveReadInterface, pool_state: PoolState failed=False, exception_message=exception_message, exception_data=exception_data, log_level=log_level ) + if previous_pool_state.checkpoint.weighted_spot_price == FixedPoint(0): + # Skip this if the weighted spot price is 0 + # TODO: Is this the right thing to do? + return InvariantCheckResults( + failed=False, exception_message=exception_message, exception_data=exception_data, log_level=log_level + ) + # The checkpoint weighted spot price is updated every checkpoint and every trade. previous_weighted_spot_rate = interface.calc_rate_given_fixed_price( previous_pool_state.checkpoint.weighted_spot_price, FixedPoint(scaled_value=previous_pool_state.pool_config.position_duration), ) + current_spot_price = interface.calc_spot_price(pool_state) + if current_spot_price == FixedPoint(0): + # Skip this if the weighted spot price is 0 + # TODO: Is this the right thing to do? + return InvariantCheckResults( + failed=False, exception_message=exception_message, exception_data=exception_data, log_level=log_level + ) + current_spot_rate = interface.calc_rate_given_fixed_price( current_spot_price, FixedPoint(scaled_value=previous_pool_state.pool_config.position_duration),