Skip to content

Commit

Permalink
Detach aave v3 from 1delta deployment (#176)
Browse files Browse the repository at this point in the history
* Detach aave from 1delta deployment

* Change foundry version in CI

* Change Foundry version again

* Add new changelog
  • Loading branch information
hieuh25 authored Nov 23, 2023
1 parent 4189571 commit 8f7fb51
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: 'nightly-94ae8974c1ac479f8d6c8ba5832b852afccfd0c5'
# pick a nightly release from: https://github.com/foundry-rs/foundry/releases
version: 'nightly-60ec00296f00754bc21ed68fd05ab6b54b50e024'

# We also work around race condition for setting up Aave NPM packages.
- name: Setup Aave v3 for tests
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.23.1

- Feature: Add 1delta integration position handlers

# 0.23

- Various improvements when working with low quality JSON-RPC nodes
Expand Down
5 changes: 0 additions & 5 deletions eth_defi/one_delta/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ class OneDeltaDeployment:
# DeltaBrokerProxy contract proxy
broker_proxy: Contract

# Aave v3 deployment
aave_v3: AaveV3Deployment


def fetch_deployment(
web3: Web3,
aave_v3: AaveV3Deployment,
flash_aggregator_address: HexAddress | str,
broker_proxy_address: HexAddress | str,
) -> OneDeltaDeployment:
Expand Down Expand Up @@ -83,7 +79,6 @@ def one_delta_deployment(web3, aave_v3_deployment) -> OneDeltaDeployment:

return OneDeltaDeployment(
web3=web3,
aave_v3=aave_v3,
flash_aggregator=flash_aggregator,
broker_proxy=broker_proxy,
)
5 changes: 4 additions & 1 deletion eth_defi/one_delta/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from web3.contract.contract import Contract, ContractFunction

from eth_defi.aave_v3.constants import MAX_AMOUNT, AaveV3InterestRateMode
from eth_defi.aave_v3.deployment import AaveV3Deployment
from eth_defi.one_delta.constants import Exchange, TradeOperation
from eth_defi.one_delta.deployment import OneDeltaDeployment
from eth_defi.one_delta.utils import encode_path
Expand All @@ -18,6 +19,7 @@ def approve(
borrow_token: Contract,
atoken: Contract,
vtoken: Contract,
aave_v3_deployment: AaveV3Deployment,
collateral_amount: int = MAX_AMOUNT,
borrow_amount: int = MAX_AMOUNT,
atoken_amount: int = MAX_AMOUNT,
Expand All @@ -34,11 +36,12 @@ def approve(
:param borrow_amount: amount of borrow token to be approved
:param atoken_amount: amount of aToken to be approved
:param vtoken_amount: amount of vToken to be approved
:param aave_v3_deployment: Aave V3 deployment
:return: list of approval functions
"""
trader = one_delta_deployment.flash_aggregator
proxy = one_delta_deployment.broker_proxy
aave_v3_pool = one_delta_deployment.aave_v3.pool
aave_v3_pool = aave_v3_deployment.pool

approval_functions = []

Expand Down
16 changes: 12 additions & 4 deletions tests/one_delta/test_one_delta_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def anvil_polygon_chain_fork(request, large_usdc_holder) -> str:
:return: JSON-RPC URL for Web3
"""
mainnet_rpc = os.environ["JSON_RPC_POLYGON"]
launch = fork_network_anvil(mainnet_rpc, unlocked_addresses=[large_usdc_holder])
launch = fork_network_anvil(
mainnet_rpc,
unlocked_addresses=[large_usdc_holder],
fork_block_number=49_000_000,
)
try:
yield launch.json_rpc_url
finally:
Expand Down Expand Up @@ -145,11 +149,9 @@ def aave_v3_deployment(web3):


@pytest.fixture
def one_delta_deployment(web3, aave_v3_deployment) -> OneDeltaDeployment:
def one_delta_deployment(web3) -> OneDeltaDeployment:
return fetch_1delta_deployment(
web3,
aave_v3_deployment,
# flash_aggregator_address="0x168B4C2Cc2df4635D521Aa1F8961DD7218f0f427",
flash_aggregator_address="0x74E95F3Ec71372756a01eB9317864e3fdde1AC53",
broker_proxy_address="0x74E95F3Ec71372756a01eB9317864e3fdde1AC53",
)
Expand Down Expand Up @@ -201,6 +203,7 @@ def test_1delta_only_open_short_position(
borrow_token=weth.contract,
atoken=ausdc.contract,
vtoken=vweth.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand Down Expand Up @@ -261,6 +264,7 @@ def test_1delta_open_short_position_supply_separately(
borrow_token=weth.contract,
atoken=ausdc.contract,
vtoken=vweth.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand Down Expand Up @@ -333,6 +337,7 @@ def test_1delta_open_and_close_short_position(
borrow_token=weth.contract,
atoken=ausdc.contract,
vtoken=vweth.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand Down Expand Up @@ -413,6 +418,7 @@ def test_1delta_open_and_close_short_position_separately(
borrow_token=weth.contract,
atoken=ausdc.contract,
vtoken=vweth.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand Down Expand Up @@ -530,6 +536,7 @@ def test_1delta_open_and_close_short_positions_of_2_assets(
borrow_token=weth.contract,
atoken=ausdc.contract,
vtoken=vweth.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand All @@ -539,6 +546,7 @@ def test_1delta_open_and_close_short_positions_of_2_assets(
borrow_token=wmatic.contract,
atoken=ausdc.contract,
vtoken=vwmatic.contract,
aave_v3_deployment=aave_v3_deployment,
):
_execute_tx(web3, hot_wallet, fn)

Expand Down

0 comments on commit 8f7fb51

Please sign in to comment.