@@ -31,9 +31,9 @@ class MultiCall:
31
31
CALLER_ADDRESS = "0x0000000000000000000000000000000000000123"
32
32
33
33
MULTICALL_DEPLOYMENTS : dict [int , str ] = {
34
- 56 : "0xE396FfB7aa3123E3D742e50Ad409d212f87ADfA6 " ,
35
- 1116 : "0xf7bfc56C50e544ba035d0b27978aF2f072b096f7 " ,
36
- 40 : "0x4E1F64D55cD51E8D8D2125A5c1Fa613E78921C51 " ,
34
+ 56 : "0x06EF84EE8E60fA7d95277E8232Dd3aEEb1377e17 " ,
35
+ 1116 : "0x66BF74f6Afe41fd10a5343B39Dae017EF9CceF1b " ,
36
+ 40 : "0x84C2fb5A4F7219688AF475e74b2ac189966Cc9ba " ,
37
37
}
38
38
39
39
@classmethod
@@ -124,24 +124,27 @@ def _inner_call(
124
124
multicall_call = multicall_call ,
125
125
retry = len (calls_with_calldata ) == 1
126
126
)
127
- except Exception as e :
127
+ except Exception :
128
128
if len (calls_with_calldata ) == 1 :
129
- print (f"Multicall with single call got Exception '{ repr (e )} ', last retry" )
130
- sleep (1 )
131
129
try :
132
130
raw_returns , gas_usages = self ._call_multicall (
133
131
multicall_call = multicall_call ,
134
132
retry = len (calls_with_calldata ) == 1
135
133
)
136
134
except Exception as e :
137
- print (f"Multicall with single call got Exception '{ repr (e )} ', returning Exception" )
138
135
raw_returns = [e ]
139
136
gas_usages = [None ]
140
137
else :
141
- print (f"Multicall got Exception '{ repr (e )} ', splitting and retrying" )
142
138
left_results , left_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [:len (calls_with_calldata ) // 2 ])
143
139
right_results , right_gas_usages = self ._inner_call (** kwargs , calls_with_calldata = calls_with_calldata [len (calls_with_calldata ) // 2 :])
144
140
return left_results + right_results , left_gas_usages + right_gas_usages
141
+ else :
142
+ if len (raw_returns ) != len (calls_with_calldata ) and len (raw_returns ) > 1 :
143
+ # multicall stopped in the middle due to running out of gas.
144
+ # better remove the last result.
145
+ raw_returns = raw_returns [:- 1 ]
146
+ gas_usages = gas_usages [:- 1 ]
147
+ assert len (raw_returns ) == len (gas_usages )
145
148
results = self .decode_contract_function_results (raw_returns = raw_returns , contract_functions = [call for call , _ in calls_with_calldata ])
146
149
if len (results ) == len (calls_with_calldata ):
147
150
return results , gas_usages
@@ -354,9 +357,7 @@ def _call_multicall(self, multicall_call: ContractConstructor | ContractFunction
354
357
"data" : calldata ,
355
358
"no_retry" : not retry ,
356
359
})
357
- _ , multicall_result , completed_calls = eth_abi .decode (get_abi_output_types (multicall_call .abi ), raw_response )
358
-
359
- multicall_result = multicall_result [:completed_calls ]
360
+ _ , multicall_result = eth_abi .decode (get_abi_output_types (multicall_call .abi ), raw_response )
360
361
361
362
if len (multicall_result ) > 0 and self .undeployed_contract_constructor is not None :
362
363
# remove first call result as that's the deployment of the undeployed contract
0 commit comments