Skip to content

Commit

Permalink
Add aggregate, del aggregate3
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Jun 28, 2024
1 parent ebffe28 commit b412c13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/common/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/common/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/validators/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b412c13

Please sign in to comment.