diff --git a/src/agent0/ethpy/hyperdrive/interface/read_interface.py b/src/agent0/ethpy/hyperdrive/interface/read_interface.py index 3633b1ed18..00008ec40c 100644 --- a/src/agent0/ethpy/hyperdrive/interface/read_interface.py +++ b/src/agent0/ethpy/hyperdrive/interface/read_interface.py @@ -384,24 +384,23 @@ def get_vault_shares(self, block_number: BlockNumber | None) -> FixedPoint: block_number = self.get_block_number(self.get_current_block()) return _get_vault_shares(self.vault_shares_token_contract, self.hyperdrive_contract, block_number) - def get_idle_shares(self, block_number: BlockNumber | None) -> FixedPoint: + def get_idle_shares(self, pool_state: PoolState | None) -> FixedPoint: """Get the balance of idle shares that the Hyperdrive pool has. Arguments --------- - block_number: BlockNumber, optional - The number for any minted block. - Defaults to the current block number. + pool_state: PoolState, optional + The state of the pool, which includes block details, pool config, and pool info. + If not given, use the current pool state. Returns ------- FixedPoint The quantity of vault shares for the yield source at the provided block. """ - if block_number is None: - block_number = self.get_block_number(self.get_current_block()) - pool_state = self.current_pool_state - long_exposure_shares = self.current_pool_state.pool_info.long_exposure / pool_state.pool_info.vault_share_price + if pool_state is None: + pool_state = self.current_pool_state + long_exposure_shares = pool_state.pool_info.long_exposure / pool_state.pool_info.vault_share_price idle_shares = ( pool_state.pool_info.share_reserves - long_exposure_shares - pool_state.pool_config.minimum_share_reserves ) diff --git a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py index ba11537527..9e0b5ceecf 100644 --- a/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py +++ b/src/agent0/hyperfuzz/system_fuzz/invariant_checks.py @@ -282,8 +282,7 @@ def _check_present_value_greater_than_idle_shares( exception_data: dict[str, Any] = {} present_value = interface.calc_present_value(pool_state) - block_number = pool_state.block_number - idle_shares = interface.get_idle_shares(block_number) + idle_shares = interface.get_idle_shares(pool_state) if not present_value >= idle_shares: difference_in_wei = abs(present_value.scaled_value - idle_shares.scaled_value) diff --git a/src/agent0/hyperfuzz/unit_fuzz/fuzz_present_value.py b/src/agent0/hyperfuzz/unit_fuzz/fuzz_present_value.py index 73abac2af6..a23c5a8e0e 100644 --- a/src/agent0/hyperfuzz/unit_fuzz/fuzz_present_value.py +++ b/src/agent0/hyperfuzz/unit_fuzz/fuzz_present_value.py @@ -306,7 +306,7 @@ def invariant_check( # idle shares are the shares that are not reserved by open positions # TODO: Add calculate_idle_share_reserves to hyperdrivepy and use that here. current_present_value = interactive_hyperdrive.interface.calc_present_value(pool_state) - idle_shares = interactive_hyperdrive.interface.get_idle_shares(pool_state.block_number) + idle_shares = interactive_hyperdrive.interface.get_idle_shares(pool_state) if current_present_value < idle_shares: difference_in_wei = abs(current_present_value.scaled_value - idle_shares.scaled_value) exception_message.append("The present value is not greater than or equal to the idle.")