Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hyperdrive to version 1.0.14 #1584

Merged
merged 6 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/hyperdrive/src/abis/MockLido.sol/MockLido.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies = [
"flask",
"flask-expects-json",
"hexbytes",
"hyperdrivepy==0.16.0",
"hyperdrivepy==0.16.1",
"ipython",
"matplotlib",
"mplfinance",
Expand Down
36 changes: 27 additions & 9 deletions src/agent0/core/hyperdrive/interactive/local_hyperdrive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,17 @@ def _ensure_event_matches_wallet_delta(
event: BaseHyperdriveEvent,
deploy_type: LocalHyperdrive.DeployType,
):
# pylint: disable=too-many-statements
if deploy_type == LocalHyperdrive.DeployType.ERC4626:
# We expect exact matches for erc4626
event_comparison_epsilon = FixedPoint(0)
chain_balance_comparison_epsilon = FixedPoint(0)
short_chain_balance_comparison_epsilon = FixedPoint(0)
else:
# There's known conversion errors in the steth market
event_comparison_epsilon = FixedPoint(scaled_value=10)
chain_balance_comparison_epsilon = FixedPoint(scaled_value=int(3e6))
short_chain_balance_comparison_epsilon = FixedPoint(scaled_value=50)

if isinstance(event, AddLiquidity):
assert isclose(trade_input, event.amount, abs_tol=event_comparison_epsilon)
Expand Down Expand Up @@ -199,7 +202,9 @@ def _ensure_event_matches_wallet_delta(
# so we use a tighter bound here
# TODO figure out why
assert isclose(
wallet_after.balance.amount - wallet_before.balance.amount, -event.amount, abs_tol=event_comparison_epsilon
wallet_after.balance.amount - wallet_before.balance.amount,
-event.amount,
abs_tol=short_chain_balance_comparison_epsilon,
)
if event.maturity_time in wallet_before.shorts:
assert (
Expand All @@ -214,7 +219,9 @@ def _ensure_event_matches_wallet_delta(
# so we use a tighter bound here
# TODO figure out why
assert isclose(
wallet_after.balance.amount - wallet_before.balance.amount, event.amount, abs_tol=event_comparison_epsilon
wallet_after.balance.amount - wallet_before.balance.amount,
event.amount,
abs_tol=short_chain_balance_comparison_epsilon,
)
if event.maturity_time in wallet_after.shorts:
assert (
Expand All @@ -233,10 +240,15 @@ def _ensure_event_matches_wallet_delta(
# pylint: disable=too-many-statements
# ruff: noqa: PLR0915 (too many statements)
@pytest.mark.anvil
@pytest.mark.parametrize("deploy_type", [LocalHyperdrive.DeployType.ERC4626, LocalHyperdrive.DeployType.STETH])
# @pytest.mark.parametrize("deploy_type", [LocalHyperdrive.DeployType.ERC4626, LocalHyperdrive.DeployType.STETH])
@pytest.mark.parametrize("deploy_type", [LocalHyperdrive.DeployType.STETH])
def test_funding_and_trades(fast_chain_fixture: LocalChain, deploy_type: LocalHyperdrive.DeployType):
"""Deploy 2 pools, 3 agents, and test funding and each trade type."""
# TODO DRY this up, e.g., doing the same calls while swapping the agent.
if deploy_type == LocalHyperdrive.DeployType.ERC4626:
balance_of_comparison_epsilon = FixedPoint(0)
else:
balance_of_comparison_epsilon = FixedPoint(scaled_value=3)

# Parameters for pool initialization. If empty, defaults to default values, allows for custom values if needed
# We explicitly set initial liquidity here to ensure we have withdrawal shares when trading
Expand Down Expand Up @@ -275,29 +287,35 @@ def test_funding_and_trades(fast_chain_fixture: LocalChain, deploy_type: LocalHy
hyperdrive_agent_2.add_funds(base=FixedPoint(333_333), eth=FixedPoint(333))

# Ensure agent wallet have expected balances
assert (hyperdrive_agent_0.get_wallet().balance.amount) == FixedPoint(1_111_111)
assert (hyperdrive_agent_1.get_wallet().balance.amount) == FixedPoint(222_222)
assert (hyperdrive_agent_2.get_wallet().balance.amount) == FixedPoint(333_333)
assert isclose(
hyperdrive_agent_0.get_wallet().balance.amount, FixedPoint(1_111_111), abs_tol=balance_of_comparison_epsilon
)
assert isclose(
hyperdrive_agent_1.get_wallet().balance.amount, FixedPoint(222_222), abs_tol=balance_of_comparison_epsilon
)
assert isclose(
hyperdrive_agent_2.get_wallet().balance.amount, FixedPoint(333_333), abs_tol=balance_of_comparison_epsilon
)
# Ensure chain balances are as expected
(
chain_eth_balance,
chain_base_balance,
) = hyperdrive0.interface.get_eth_base_balances(hyperdrive_agent_0.account)
assert chain_base_balance == FixedPoint(1_111_111)
assert isclose(chain_base_balance, FixedPoint(1_111_111), abs_tol=balance_of_comparison_epsilon)
# There was a little bit of gas spent to approve, so we don't do a direct comparison here
assert (FixedPoint(111) - chain_eth_balance) < FixedPoint("0.0001")
(
chain_eth_balance,
chain_base_balance,
) = hyperdrive1.interface.get_eth_base_balances(hyperdrive_agent_1.account)
assert chain_base_balance == FixedPoint(222_222)
assert isclose(chain_base_balance, FixedPoint(222_222), abs_tol=balance_of_comparison_epsilon)
# There was a little bit of gas spent to approve, so we don't do a direct comparison here
assert (FixedPoint(222) - chain_eth_balance) < FixedPoint("0.0001")
(
chain_eth_balance,
chain_base_balance,
) = hyperdrive0.interface.get_eth_base_balances(hyperdrive_agent_2.account)
assert chain_base_balance == FixedPoint(333_333)
assert isclose(chain_base_balance, FixedPoint(333_333), abs_tol=balance_of_comparison_epsilon)
# There was a little bit of gas spent to approve, so we don't do a direct comparison here
# Since we initialized without parameters, and the default is 10 eth. We then added 333 eth.
assert (FixedPoint(343) - chain_eth_balance) < FixedPoint("0.0001")
Expand Down
3 changes: 2 additions & 1 deletion src/agent0/hyperdrive.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
v1.0.12
v1.0.13
v1.0.13
v1.0.14

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/agent0/hypertypes/types/HyperdriveFactoryContract.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/agent0/hypertypes/types/HyperdriveRegistryContract.py

Large diffs are not rendered by default.

Loading
Loading