diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 794c80eb..28864428 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index e7eb6914..8e9fe98e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/eth_defi/one_delta/deployment.py b/eth_defi/one_delta/deployment.py index 0abb5c6f..b34ee1c6 100644 --- a/eth_defi/one_delta/deployment.py +++ b/eth_defi/one_delta/deployment.py @@ -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: @@ -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, ) diff --git a/eth_defi/one_delta/position.py b/eth_defi/one_delta/position.py index 7603d6fc..93cc2b85 100644 --- a/eth_defi/one_delta/position.py +++ b/eth_defi/one_delta/position.py @@ -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 @@ -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, @@ -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 = [] diff --git a/tests/one_delta/test_one_delta_position.py b/tests/one_delta/test_one_delta_position.py index 9fb8fe34..a4a02c4d 100644 --- a/tests/one_delta/test_one_delta_position.py +++ b/tests/one_delta/test_one_delta_position.py @@ -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: @@ -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", ) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)