Skip to content

Commit

Permalink
skip price spike check if prices are zero (#1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton authored Sep 25, 2024
1 parent f3b5e9d commit 3ab7d29
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/agent0/hyperfuzz/system_fuzz/invariant_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 3ab7d29

Please sign in to comment.