Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_withdrawable_assets #359

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions src/validators/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
from web3 import Web3
from web3.types import EventData, Wei

from src.common.contracts import validators_registry_contract, vault_contract
from src.common.contracts import (
multicall_contract,
validators_registry_contract,
vault_contract,
)
from src.common.metrics import metrics
from src.common.typings import HarvestParams
from src.common.vault import Vault
Expand Down Expand Up @@ -108,7 +112,8 @@ async def get_withdrawable_assets(harvest_params: HarvestParams | None) -> Wei:
calls = await get_update_state_calls(harvest_params)
withdrawable_assets_call = vault_contract.encode_abi(fn_name='withdrawableAssets', args=[])
calls.append((vault_contract.address, withdrawable_assets_call))
multicall = await vault_contract.functions.multicall(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
Loading