Skip to content

Commit 8f7fb51

Browse files
authored
Detach aave v3 from 1delta deployment (#176)
* Detach aave from 1delta deployment * Change foundry version in CI * Change Foundry version again * Add new changelog
1 parent 4189571 commit 8f7fb51

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

.github/workflows/test.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ jobs:
4747
- name: Install Foundry
4848
uses: foundry-rs/foundry-toolchain@v1
4949
with:
50-
version: 'nightly-94ae8974c1ac479f8d6c8ba5832b852afccfd0c5'
50+
# pick a nightly release from: https://github.com/foundry-rs/foundry/releases
51+
version: 'nightly-60ec00296f00754bc21ed68fd05ab6b54b50e024'
5152

5253
# We also work around race condition for setting up Aave NPM packages.
5354
- name: Setup Aave v3 for tests

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.23.1
2+
3+
- Feature: Add 1delta integration position handlers
4+
15
# 0.23
26

37
- Various improvements when working with low quality JSON-RPC nodes

eth_defi/one_delta/deployment.py

-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ class OneDeltaDeployment:
2828
# DeltaBrokerProxy contract proxy
2929
broker_proxy: Contract
3030

31-
# Aave v3 deployment
32-
aave_v3: AaveV3Deployment
33-
3431

3532
def fetch_deployment(
3633
web3: Web3,
37-
aave_v3: AaveV3Deployment,
3834
flash_aggregator_address: HexAddress | str,
3935
broker_proxy_address: HexAddress | str,
4036
) -> OneDeltaDeployment:
@@ -83,7 +79,6 @@ def one_delta_deployment(web3, aave_v3_deployment) -> OneDeltaDeployment:
8379

8480
return OneDeltaDeployment(
8581
web3=web3,
86-
aave_v3=aave_v3,
8782
flash_aggregator=flash_aggregator,
8883
broker_proxy=broker_proxy,
8984
)

eth_defi/one_delta/position.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from web3.contract.contract import Contract, ContractFunction
77

88
from eth_defi.aave_v3.constants import MAX_AMOUNT, AaveV3InterestRateMode
9+
from eth_defi.aave_v3.deployment import AaveV3Deployment
910
from eth_defi.one_delta.constants import Exchange, TradeOperation
1011
from eth_defi.one_delta.deployment import OneDeltaDeployment
1112
from eth_defi.one_delta.utils import encode_path
@@ -18,6 +19,7 @@ def approve(
1819
borrow_token: Contract,
1920
atoken: Contract,
2021
vtoken: Contract,
22+
aave_v3_deployment: AaveV3Deployment,
2123
collateral_amount: int = MAX_AMOUNT,
2224
borrow_amount: int = MAX_AMOUNT,
2325
atoken_amount: int = MAX_AMOUNT,
@@ -34,11 +36,12 @@ def approve(
3436
:param borrow_amount: amount of borrow token to be approved
3537
:param atoken_amount: amount of aToken to be approved
3638
:param vtoken_amount: amount of vToken to be approved
39+
:param aave_v3_deployment: Aave V3 deployment
3740
:return: list of approval functions
3841
"""
3942
trader = one_delta_deployment.flash_aggregator
4043
proxy = one_delta_deployment.broker_proxy
41-
aave_v3_pool = one_delta_deployment.aave_v3.pool
44+
aave_v3_pool = aave_v3_deployment.pool
4245

4346
approval_functions = []
4447

tests/one_delta/test_one_delta_position.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def anvil_polygon_chain_fork(request, large_usdc_holder) -> str:
5353
:return: JSON-RPC URL for Web3
5454
"""
5555
mainnet_rpc = os.environ["JSON_RPC_POLYGON"]
56-
launch = fork_network_anvil(mainnet_rpc, unlocked_addresses=[large_usdc_holder])
56+
launch = fork_network_anvil(
57+
mainnet_rpc,
58+
unlocked_addresses=[large_usdc_holder],
59+
fork_block_number=49_000_000,
60+
)
5761
try:
5862
yield launch.json_rpc_url
5963
finally:
@@ -145,11 +149,9 @@ def aave_v3_deployment(web3):
145149

146150

147151
@pytest.fixture
148-
def one_delta_deployment(web3, aave_v3_deployment) -> OneDeltaDeployment:
152+
def one_delta_deployment(web3) -> OneDeltaDeployment:
149153
return fetch_1delta_deployment(
150154
web3,
151-
aave_v3_deployment,
152-
# flash_aggregator_address="0x168B4C2Cc2df4635D521Aa1F8961DD7218f0f427",
153155
flash_aggregator_address="0x74E95F3Ec71372756a01eB9317864e3fdde1AC53",
154156
broker_proxy_address="0x74E95F3Ec71372756a01eB9317864e3fdde1AC53",
155157
)
@@ -201,6 +203,7 @@ def test_1delta_only_open_short_position(
201203
borrow_token=weth.contract,
202204
atoken=ausdc.contract,
203205
vtoken=vweth.contract,
206+
aave_v3_deployment=aave_v3_deployment,
204207
):
205208
_execute_tx(web3, hot_wallet, fn)
206209

@@ -261,6 +264,7 @@ def test_1delta_open_short_position_supply_separately(
261264
borrow_token=weth.contract,
262265
atoken=ausdc.contract,
263266
vtoken=vweth.contract,
267+
aave_v3_deployment=aave_v3_deployment,
264268
):
265269
_execute_tx(web3, hot_wallet, fn)
266270

@@ -333,6 +337,7 @@ def test_1delta_open_and_close_short_position(
333337
borrow_token=weth.contract,
334338
atoken=ausdc.contract,
335339
vtoken=vweth.contract,
340+
aave_v3_deployment=aave_v3_deployment,
336341
):
337342
_execute_tx(web3, hot_wallet, fn)
338343

@@ -413,6 +418,7 @@ def test_1delta_open_and_close_short_position_separately(
413418
borrow_token=weth.contract,
414419
atoken=ausdc.contract,
415420
vtoken=vweth.contract,
421+
aave_v3_deployment=aave_v3_deployment,
416422
):
417423
_execute_tx(web3, hot_wallet, fn)
418424

@@ -530,6 +536,7 @@ def test_1delta_open_and_close_short_positions_of_2_assets(
530536
borrow_token=weth.contract,
531537
atoken=ausdc.contract,
532538
vtoken=vweth.contract,
539+
aave_v3_deployment=aave_v3_deployment,
533540
):
534541
_execute_tx(web3, hot_wallet, fn)
535542

@@ -539,6 +546,7 @@ def test_1delta_open_and_close_short_positions_of_2_assets(
539546
borrow_token=wmatic.contract,
540547
atoken=ausdc.contract,
541548
vtoken=vwmatic.contract,
549+
aave_v3_deployment=aave_v3_deployment,
542550
):
543551
_execute_tx(web3, hot_wallet, fn)
544552

0 commit comments

Comments
 (0)