Skip to content

Commit

Permalink
rename fn
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed Nov 4, 2024
1 parent 9c6adb7 commit 7ec1ba4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions check_ezeth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dotenv import load_dotenv

from agent0 import Chain, Hyperdrive
from agent0.utils import block_before_timestamp
from agent0.utils import block_number_before_timestamp

load_dotenv(".env")
DEV_RPC_URI = os.getenv("DEV_RPC_URI", "")
Expand All @@ -31,13 +31,13 @@ def main(start_block_timestamp: int, lookback_length: int):
start_block_number = chain.block_number()
# Otherwise, find the block with the given blocktime
else:
start_block_number = block_before_timestamp(web3, start_block_timestamp)
start_block_number = block_number_before_timestamp(web3, start_block_timestamp)

start_pool_state = ezeth_pool.interface.get_hyperdrive_state(block_identifier=start_block_number)
start_vault_share_price = start_pool_state.pool_info.vault_share_price

lookback_timestamp = start_block_timestamp - lookback_length
lookback_block_number = block_before_timestamp(web3, lookback_timestamp)
lookback_block_number = block_number_before_timestamp(web3, lookback_timestamp)
lookback_pool_state = ezeth_pool.interface.get_hyperdrive_state(block_identifier=lookback_block_number)
lookback_vault_share_price = lookback_pool_state.pool_info.vault_share_price

Expand Down
2 changes: 1 addition & 1 deletion src/agent0/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""General utility functions"""

from .async_runner import async_runner
from .block_before_timestamp import block_before_timestamp
from .block_before_timestamp import block_number_before_timestamp
4 changes: 2 additions & 2 deletions src/agent0/utils/block_before_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# pylint: disable=too-many-locals


def block_before_timestamp(web3: Web3, block_timestamp: Timestamp | int) -> BlockNumber:
"""Finds the closest block that is before or at the given block time.
def block_number_before_timestamp(web3: Web3, block_timestamp: Timestamp | int) -> BlockNumber:
"""Finds the closest block number that is before or at the given block time.
Arguments
---------
Expand Down
6 changes: 3 additions & 3 deletions src/agent0/utils/block_before_timestamp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from agent0 import LocalChain, LocalHyperdrive

from .block_before_timestamp import block_before_timestamp
from .block_before_timestamp import block_number_before_timestamp


@pytest.mark.docker
@pytest.mark.anvil
def test_block_before_timestamp(fast_chain_fixture: LocalChain):
def test_block_number_before_timestamp(fast_chain_fixture: LocalChain):
"""Test that ensures block_before_timestamp always returns a block number
with a timestamp that is closest to but before the provided timestamp.
"""
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_block_before_timestamp(fast_chain_fixture: LocalChain):
time_delta = int(np.random.randint(0, time_between_blocks - 1))

# Find the block that was closest to this timestamp
inferred_block_number = block_before_timestamp(hyperdrive_interface.web3, test_block_time + time_delta)
inferred_block_number = block_number_before_timestamp(hyperdrive_interface.web3, test_block_time + time_delta)
inferred_block_time = hyperdrive_interface.get_block_timestamp(
hyperdrive_interface.get_block(inferred_block_number)
)
Expand Down

0 comments on commit 7ec1ba4

Please sign in to comment.