Skip to content

Commit 4b6ca0a

Browse files
authored
Merge branch 'main' into market_depth
2 parents 8d59bbe + 857b854 commit 4b6ca0a

File tree

153 files changed

+5030
-5963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+5030
-5963
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ from agent0 import LocalHyperdrive, LocalChain
3737
# Initialize
3838
chain = LocalChain()
3939
hyperdrive = LocalHyperdrive(chain)
40-
hyperdrive_agent0 = hyperdrive.init_agent(base=FixedPoint(100_000))
40+
hyperdrive_agent0 = hyperdrive.init_agent(base=FixedPoint(100_000), eth=FixedPoint(10))
4141

4242
# Run trades
4343
chain.advance_time(datetime.timedelta(weeks=1))
44-
open_long_event = hyperdrive_agent0.open_long(base=FixedPoint(100))
44+
open_long_event = hyperdrive_agent0.open_long(base=FixedPoint(100), eth=FixedPoint(10))
4545
chain.advance_time(datetime.timedelta(weeks=5))
4646
close_event = hyperdrive_agent0.close_long(
4747
maturity_time=open_long_event.maturity_time, bonds=open_long_event.bond_amount

STYLEGUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
- Write docstrings in [Numpy format](https://numpydoc.readthedocs.io/en/latest/format.html), with a few tweaks:
88
- Use "Arguments" instead of "Parameters".
99
- Don't use space before `:` in the type specification. Sphinx and VSCode render it the same, and it's closer to the signature.
10+
- Document each class attribute immediately after its declaration ([example](https://github.com/delvtech/agent0/blob/86bebba71faeefb78b2f272e3ccf28e696e1828c/src/agent0/core/hyperdrive/interactive/local_chain.py#L43))
1011
- When in doubt, lean in the direction of verbosity and readability.

account.env.sample

Lines changed: 0 additions & 4 deletions
This file was deleted.

conftest.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77

88
import pytest
99

10-
from agent0.chainsync.test_fixtures import database_engine, db_api, db_session, dummy_session, psql_docker
11-
from agent0.core.test_fixtures import chain
10+
from agent0.chainsync.test_fixtures import database_engine, db_session, dummy_session, psql_docker
1211
from agent0.core.test_utils import cycle_trade_policy
13-
from agent0.ethpy.test_fixtures import (
14-
hyperdrive_read_interface,
15-
hyperdrive_read_write_interface,
16-
init_local_hyperdrive_pool,
17-
local_chain,
18-
local_hyperdrive_pool,
12+
from agent0.test_fixtures import (
13+
chain_fixture,
14+
fast_chain_fixture,
15+
fast_hyperdrive_fixture,
16+
hyperdrive_fixture,
17+
hyperdrive_read_interface_fixture,
18+
hyperdrive_read_write_interface_fixture,
19+
init_chain,
20+
init_hyperdrive,
1921
)
2022

2123
# Hack to allow for vscode debugger to throw exception immediately
@@ -57,16 +59,17 @@ def pytest_internalerror(excinfo):
5759
# This allows for users of fixtures to not have to import all dependency fixtures when running
5860
# NOTE: this means pytest can only be ran from this directory
5961
__all__ = [
60-
"chain",
62+
"fast_chain_fixture",
63+
"chain_fixture",
64+
"init_chain",
65+
"fast_hyperdrive_fixture",
66+
"hyperdrive_fixture",
67+
"init_hyperdrive",
6168
"cycle_trade_policy",
6269
"database_engine",
63-
"db_api",
6470
"db_session",
6571
"dummy_session",
66-
"hyperdrive_read_interface",
67-
"hyperdrive_read_write_interface",
68-
"init_local_hyperdrive_pool",
69-
"local_chain",
70-
"local_hyperdrive_pool",
72+
"hyperdrive_read_interface_fixture",
73+
"hyperdrive_read_write_interface_fixture",
7174
"psql_docker",
7275
]

eth.env.sample

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/interactive_hyperdrive_forking_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Launch a local anvil chain forked from the rpc uri.
2626
chain = LocalChain(fork_uri=rpc_uri, fork_block_number=fork_block_number)
2727

28-
hyperdrive_address = Hyperdrive.get_hyperdrive_addresses_from_registry(registry_address, chain)["sdai_14_day"]
28+
hyperdrive_address = Hyperdrive.get_hyperdrive_addresses_from_registry(chain, registry_address)["sdai_14_day"]
2929

3030
# Note that we use Hyperdrive here instead of LocalHyperdrive,
3131
# as LocalHyperdrive deploys a new pool, whereas we want to connect to an existing pool

examples/interactive_local_hyperdrive_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
hyperdrive_agent0 = hyperdrive.init_agent(base=FixedPoint(100000), eth=FixedPoint(100), name="alice")
3838
hyperdrive_agent1 = hyperdrive_2.init_agent(base=FixedPoint(100000), eth=FixedPoint(100), name="bob")
3939
# Omission of name defaults to wallet address
40-
hyperdrive_agent2 = hyperdrive.init_agent(base=FixedPoint(100000))
40+
hyperdrive_agent2 = hyperdrive.init_agent(base=FixedPoint(100000), eth=FixedPoint(10))
4141

4242
# Add funds to an agent
4343
hyperdrive_agent0.add_funds(base=FixedPoint(100000), eth=FixedPoint(100))
@@ -58,7 +58,7 @@
5858
open_long_event_2 = hyperdrive_agent0.open_long(FixedPoint(22222))
5959

6060
# View current wallet
61-
print(hyperdrive_agent0.wallet)
61+
print(hyperdrive_agent0.get_positions())
6262

6363
# NOTE these calls are chainwide calls, so all pools connected to this chain gets affected.
6464
# Advance time, accepts timedelta or seconds
@@ -72,7 +72,7 @@
7272
maturity_time=open_long_event_1.maturity_time, bonds=open_long_event_1.bond_amount
7373
)
7474

75-
agent0_longs = list(hyperdrive_agent0.wallet.longs.values())
75+
agent0_longs = list(hyperdrive_agent0.get_positions().longs.values())
7676
close_long_event_2 = hyperdrive_agent0.close_long(
7777
maturity_time=agent0_longs[0].maturity_time, bonds=agent0_longs[0].balance
7878
)
@@ -85,7 +85,7 @@
8585

8686
# LP
8787
add_lp_event = hyperdrive_agent2.add_liquidity(base=FixedPoint(44444))
88-
remove_lp_event = hyperdrive_agent2.remove_liquidity(shares=hyperdrive_agent2.wallet.lp_tokens)
88+
remove_lp_event = hyperdrive_agent2.remove_liquidity(shares=hyperdrive_agent2.get_positions().lp_tokens)
8989

9090
# The above trades doesn't result in withdraw shares, but the function below allows you
9191
# to withdrawal shares from the pool.

examples/interactive_remote_hyperdrive_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# This is the registry address deployed on sepolia.
2525
registry_address = "0xba5156E697d39a03EDA824C19f375383F6b759EA"
2626

27-
hyperdrive_address = Hyperdrive.get_hyperdrive_addresses_from_registry(registry_address, chain)["sdai_14_day"]
27+
hyperdrive_address = Hyperdrive.get_hyperdrive_addresses_from_registry(chain, registry_address)["sdai_14_day"]
2828
hyperdrive_config = Hyperdrive.Config()
2929
hyperdrive_pool = Hyperdrive(chain, hyperdrive_address, hyperdrive_config)
3030

0 commit comments

Comments
 (0)