|
138 | 138 | ] |
139 | 139 |
|
140 | 140 | MULTICALL_ADDRESS = ( |
141 | | - "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" # Ethereum mainnet address |
| 141 | + "0xcA11bde05977b3631167028862bE2a173976CA11" # Ethereum mainnet address |
142 | 142 | ) |
143 | 143 | MULTICALL_ADDRESS_BY_CHAIN = { |
144 | 144 | Chain.SWELL: "0xcA11bde05977b3631167028862bE2a173976CA11", |
@@ -245,12 +245,28 @@ def multicall_by_address( |
245 | 245 | result = [] |
246 | 246 | for i in range(0, len(aggregate_calls), batch_size): |
247 | 247 | batch = aggregate_calls[i : i + batch_size] |
248 | | - result.extend( |
249 | | - call_with_retry( |
250 | | - multicall_contract.functions.aggregate3(batch), |
251 | | - block=block_identifier, |
| 248 | + |
| 249 | + if allow_failure: |
| 250 | + # When allowing failures, catch contract reverts and return None for failed batches |
| 251 | + try: |
| 252 | + batch_result = call_with_retry( |
| 253 | + multicall_contract.functions.aggregate3(batch), |
| 254 | + block=block_identifier, |
| 255 | + ) |
| 256 | + result.extend(batch_result) |
| 257 | + except Exception as e: |
| 258 | + print( |
| 259 | + f"Multicall batch failed, returning None for {len(batch)} calls: {e}" |
| 260 | + ) |
| 261 | + # Return None for each call in the failed batch |
| 262 | + result.extend([(False, b"")] * len(batch)) |
| 263 | + else: |
| 264 | + result.extend( |
| 265 | + call_with_retry( |
| 266 | + multicall_contract.functions.aggregate3(batch), |
| 267 | + block=block_identifier, |
| 268 | + ) |
252 | 269 | ) |
253 | | - ) |
254 | 270 |
|
255 | 271 | decoded_results: List[Union[Tuple, None]] = [] |
256 | 272 | for i, call in enumerate(calls): |
|
0 commit comments