From b412c13c09459ed9b3fc86e8e5d12fa3bfc05680 Mon Sep 17 00:00:00 2001 From: Evgeny Gusarov Date: Fri, 28 Jun 2024 16:16:01 +0300 Subject: [PATCH] Add aggregate, del aggregate3 --- src/common/contracts.py | 6 +++--- src/common/execution.py | 10 +++++----- src/validators/execution.py | 3 +-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/common/contracts.py b/src/common/contracts.py index 11b8afcc..9cd0b86d 100644 --- a/src/common/contracts.py +++ b/src/common/contracts.py @@ -285,10 +285,10 @@ class MulticallContract(ContractWrapper): async def aggregate( self, - data: list[tuple[ChecksumAddress, bool, HexStr]], + data: list[tuple[ChecksumAddress, HexStr]], block_number: BlockNumber | None = None, - ) -> list: - return await self.contract.functions.aggregate3(data).call(block_identifier=block_number) + ) -> tuple[BlockNumber, list]: + return await self.contract.functions.aggregate(data).call(block_identifier=block_number) @functools.cache diff --git a/src/common/execution.py b/src/common/execution.py index 1e712e42..96c56af4 100644 --- a/src/common/execution.py +++ b/src/common/execution.py @@ -82,15 +82,15 @@ async def update_oracles_cache() -> None: rewards_threshold_call = keeper_contract.encode_abi(fn_name='rewardsMinOracles', args=[]) validators_threshold_call = keeper_contract.encode_abi(fn_name='validatorsMinOracles', args=[]) - multicall_response = await multicall_contract.aggregate( + _, multicall_response = await multicall_contract.aggregate( [ - (keeper_contract.address, False, rewards_threshold_call), - (keeper_contract.address, False, validators_threshold_call), + (keeper_contract.address, rewards_threshold_call), + (keeper_contract.address, validators_threshold_call), ], block_number=to_block, ) - rewards_threshold = Web3.to_int(multicall_response[0][1]) - validators_threshold = Web3.to_int(multicall_response[1][1]) + rewards_threshold = Web3.to_int(multicall_response[0]) + validators_threshold = Web3.to_int(multicall_response[1]) app_state.oracles_cache = OraclesCache( config=config, diff --git a/src/validators/execution.py b/src/validators/execution.py index e8705a7c..47d65c28 100644 --- a/src/validators/execution.py +++ b/src/validators/execution.py @@ -113,8 +113,7 @@ async def get_withdrawable_assets(harvest_params: HarvestParams | None) -> Wei: withdrawable_assets_call = vault_contract.encode_abi(fn_name='withdrawableAssets', args=[]) calls.append((vault_contract.address, withdrawable_assets_call)) - # aggregate returns (uint256 blockNumber, bytes[] memory returnData) - _, multicall = await multicall_contract.functions.aggregate(calls).call() + _, multicall = await multicall_contract.aggregate(calls) after_update_assets = Web3.to_int(multicall[-1]) before_update_validators = before_update_assets // DEPOSIT_AMOUNT