|
2 | 2 | import logging |
3 | 3 | import sys |
4 | 4 | from dataclasses import replace |
| 5 | +from itertools import batched |
5 | 6 | from pathlib import Path |
6 | 7 |
|
7 | 8 | import click |
|
30 | 31 | from src.common.utils import log_verbose |
31 | 32 | from src.common.wallet import wallet |
32 | 33 | from src.config.networks import AVAILABLE_NETWORKS, ZERO_CHECKSUM_ADDRESS |
33 | | -from src.config.settings import settings |
| 34 | +from src.config.settings import MULTICALL_CHUNK_SIZE, settings |
34 | 35 | from src.meta_vault.graph import graph_get_vaults |
35 | 36 | from src.meta_vault.service import is_meta_vault, is_meta_vault_state_update_required |
36 | 37 | from src.meta_vault.tasks import meta_vault_tree_update_state |
@@ -358,18 +359,19 @@ async def update_vaults_state( |
358 | 359 | if not vault_to_harvest_params: |
359 | 360 | return |
360 | 361 |
|
361 | | - tx_hash = await os_token_redeemer_contract.batch_update_vault_state(vault_to_harvest_params) |
362 | | - logger.info( |
363 | | - 'Waiting for OsTokenRedeemer updateVaultState multicall tx %s confirmation', tx_hash |
364 | | - ) |
365 | | - tx_receipt = await execution_client.eth.wait_for_transaction_receipt( |
366 | | - HexBytes(Web3.to_bytes(hexstr=tx_hash)), timeout=settings.execution_transaction_timeout |
367 | | - ) |
368 | | - if not tx_receipt['status']: |
369 | | - raise RuntimeError( |
370 | | - f'OsTokenRedeemer updateVaultState multicall tx failed. Tx Hash: {tx_hash}' |
| 362 | + for chunk_items in batched(vault_to_harvest_params.items(), MULTICALL_CHUNK_SIZE): |
| 363 | + tx_hash = await os_token_redeemer_contract.batch_update_vault_state(dict(chunk_items)) |
| 364 | + logger.info( |
| 365 | + 'Waiting for OsTokenRedeemer updateVaultState multicall tx %s confirmation', tx_hash |
371 | 366 | ) |
372 | | - logger.info('OsTokenRedeemer updateVaultState multicall confirmed. Tx Hash: %s', tx_hash) |
| 367 | + tx_receipt = await execution_client.eth.wait_for_transaction_receipt( |
| 368 | + HexBytes(Web3.to_bytes(hexstr=tx_hash)), timeout=settings.execution_transaction_timeout |
| 369 | + ) |
| 370 | + if not tx_receipt['status']: |
| 371 | + raise RuntimeError( |
| 372 | + f'OsTokenRedeemer updateVaultState multicall tx failed. Tx Hash: {tx_hash}' |
| 373 | + ) |
| 374 | + logger.info('OsTokenRedeemer updateVaultState multicall confirmed. Tx Hash: %s', tx_hash) |
373 | 375 |
|
374 | 376 |
|
375 | 377 | async def redeem_positions( |
|
0 commit comments