@defisaver/automation-sdk 3.3.9 → 3.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,20 +19,27 @@ const utils_1 = require("./utils");
|
|
|
19
19
|
function multicall(web3, chainId, calls, block = 'latest') {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const multicallContract = (0, contractService_1.makeUniMulticallContract)(web3, chainId).contract;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
formattedResult = [
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const MAX_CALLS_PER_BATCH = 1000;
|
|
23
|
+
const allResults = [];
|
|
24
|
+
// Process each chunk
|
|
25
|
+
for (let i = 0; i < calls.length; i += MAX_CALLS_PER_BATCH) {
|
|
26
|
+
const chunk = calls.slice(i, i + MAX_CALLS_PER_BATCH);
|
|
27
|
+
const formattedCalls = chunk.map((call) => ({
|
|
28
|
+
callData: web3_eth_abi_1.default.encodeFunctionCall(call.abiItem, call.params),
|
|
29
|
+
target: call.target || '0x0',
|
|
30
|
+
gasLimit: call.gasLimit || 1e6,
|
|
31
|
+
}));
|
|
32
|
+
const callResult = yield multicallContract.methods.multicall(formattedCalls).call({}, block);
|
|
33
|
+
let formattedResult = [];
|
|
34
|
+
callResult.returnData.forEach(([success, , result], j) => {
|
|
35
|
+
const formattedRes = (success && result !== '0x'
|
|
36
|
+
? web3_eth_abi_1.default.decodeParameters(chunk[j].abiItem.outputs, result)
|
|
37
|
+
: undefined);
|
|
38
|
+
formattedResult = [...formattedResult, formattedRes];
|
|
39
|
+
});
|
|
40
|
+
allResults.push(...formattedResult);
|
|
41
|
+
}
|
|
42
|
+
return allResults;
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
45
|
exports.multicall = multicall;
|
|
@@ -13,20 +13,27 @@ import { addToObjectIf, isDefined } from './utils';
|
|
|
13
13
|
export function multicall(web3, chainId, calls, block = 'latest') {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const multicallContract = makeUniMulticallContract(web3, chainId).contract;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
formattedResult = [
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
const MAX_CALLS_PER_BATCH = 1000;
|
|
17
|
+
const allResults = [];
|
|
18
|
+
// Process each chunk
|
|
19
|
+
for (let i = 0; i < calls.length; i += MAX_CALLS_PER_BATCH) {
|
|
20
|
+
const chunk = calls.slice(i, i + MAX_CALLS_PER_BATCH);
|
|
21
|
+
const formattedCalls = chunk.map((call) => ({
|
|
22
|
+
callData: AbiCoder.encodeFunctionCall(call.abiItem, call.params),
|
|
23
|
+
target: call.target || '0x0',
|
|
24
|
+
gasLimit: call.gasLimit || 1e6,
|
|
25
|
+
}));
|
|
26
|
+
const callResult = yield multicallContract.methods.multicall(formattedCalls).call({}, block);
|
|
27
|
+
let formattedResult = [];
|
|
28
|
+
callResult.returnData.forEach(([success, , result], j) => {
|
|
29
|
+
const formattedRes = (success && result !== '0x'
|
|
30
|
+
? AbiCoder.decodeParameters(chunk[j].abiItem.outputs, result)
|
|
31
|
+
: undefined);
|
|
32
|
+
formattedResult = [...formattedResult, formattedRes];
|
|
33
|
+
});
|
|
34
|
+
allResults.push(...formattedResult);
|
|
35
|
+
}
|
|
36
|
+
return allResults;
|
|
30
37
|
});
|
|
31
38
|
}
|
|
32
39
|
export function getEventsFromContract(contractWithMeta, contractWithMetaFork, event, options) {
|
package/package.json
CHANGED
|
@@ -18,27 +18,34 @@ export async function multicall(
|
|
|
18
18
|
block: BlockNumber = 'latest',
|
|
19
19
|
): Promise<Multicall.Payload> {
|
|
20
20
|
const multicallContract = makeUniMulticallContract(web3, chainId).contract;
|
|
21
|
+
const MAX_CALLS_PER_BATCH = 1000;
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
callData: AbiCoder.encodeFunctionCall(call.abiItem, call.params),
|
|
24
|
-
target: call.target || '0x0',
|
|
25
|
-
gasLimit: call.gasLimit || 1e6,
|
|
26
|
-
}));
|
|
23
|
+
const allResults: Multicall.Payload = [];
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// Process each chunk
|
|
26
|
+
for (let i = 0; i < calls.length; i += MAX_CALLS_PER_BATCH) {
|
|
27
|
+
const chunk = calls.slice(i, i + MAX_CALLS_PER_BATCH);
|
|
28
|
+
const formattedCalls: Multicall.FormattedCalls[] = chunk.map((call) => ({
|
|
29
|
+
callData: AbiCoder.encodeFunctionCall(call.abiItem, call.params),
|
|
30
|
+
target: call.target || '0x0',
|
|
31
|
+
gasLimit: call.gasLimit || 1e6,
|
|
32
|
+
}));
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
const callResult = await multicallContract.methods.multicall(
|
|
35
|
+
formattedCalls,
|
|
36
|
+
).call({}, block);
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
let formattedResult: Multicall.Payload = [];
|
|
39
|
+
callResult.returnData.forEach(([success,, result], j) => {
|
|
40
|
+
const formattedRes = (success && result !== '0x'
|
|
41
|
+
? AbiCoder.decodeParameters(chunk[j].abiItem.outputs!, result)
|
|
42
|
+
: undefined);
|
|
43
|
+
formattedResult = [...formattedResult, formattedRes];
|
|
44
|
+
});
|
|
45
|
+
allResults.push(...formattedResult);
|
|
46
|
+
}
|
|
40
47
|
|
|
41
|
-
return
|
|
48
|
+
return allResults;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export async function getEventsFromContract<T extends BaseContract>(
|