Skip to content

Commit

Permalink
rename fn & fix output type
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed Nov 12, 2024
1 parent 31c9d39 commit 20c6957
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/agent0/core/hyperdrive/interactive/local_hyperdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def __init__(

# At this point, we've deployed hyperdrive, so we want to save the block where it was deployed
# for the data pipeline
self._deploy_block_number = self.interface.get_deploy_block()
self._deploy_block_number = self.interface.get_deploy_block_number()

if deploy:
# If we're deploying, we expect the deploy block to be set
Expand Down
16 changes: 9 additions & 7 deletions src/agent0/ethpy/hyperdrive/interface/read_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import TYPE_CHECKING, cast

import eth_abi
from eth_typing import BlockNumber
from fixedpointmath import FixedPoint
from hyperdrivetypes import CheckpointFP
from hyperdrivetypes.types import (
Expand Down Expand Up @@ -85,7 +86,7 @@

if TYPE_CHECKING:
from eth_account.signers.local import LocalAccount
from eth_typing import BlockNumber, ChecksumAddress
from eth_typing import ChecksumAddress

AGENT0_SIGNATURE = bytes.fromhex("a0")

Expand Down Expand Up @@ -290,18 +291,19 @@ def __init__(
self.last_state_block_number = -1

# Cached deploy block
self._deploy_block: None | int = None
self._deploy_block: BlockNumber | None = None
self._deploy_block_checked = False

def get_deploy_block(self) -> int | None:
"""Get the block that the Hyperdrive contract was deployed on.
def get_deploy_block_number(self) -> BlockNumber | None:
"""Get the block number that the Hyperdrive contract was deployed on.
NOTE: The deploy event may get lost on e.g., anvil, so we ensure we only check once
Returns
-------
int | None
The block that the Hyperdrive contract was deployed on. Returns None if it can't be found.
BlockNumber | None
The block number that the Hyperdrive contract was deployed on.
Returns None if it can't be found.
"""
if not self._deploy_block_checked:
self._deploy_block_checked = True
Expand All @@ -318,7 +320,7 @@ def get_deploy_block(self) -> int | None:
if len(initialize_event) == 0:
logging.warning("Initialize event not found, can't set deploy_block")
elif len(initialize_event) == 1:
self._deploy_block = initialize_event[0].block_number
self._deploy_block = BlockNumber(initialize_event[0].block_number)
else:
raise ValueError("Multiple initialize events found")

Expand Down
2 changes: 1 addition & 1 deletion src/agent0/hyperfuzz/system_fuzz/invariant_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _check_negative_interest(interface: HyperdriveReadInterface, pool_state: Poo
current_block_time = pool_state.block_time
current_vault_share_price = pool_state.pool_info.vault_share_price

deploy_block = interface.get_deploy_block()
deploy_block = interface.get_deploy_block_number()
if deploy_block is None: # type narrowing
raise ValueError("Deploy block not found.")
deploy_block_time = interface.get_block_timestamp(interface.get_block(deploy_block))
Expand Down

0 comments on commit 20c6957

Please sign in to comment.