@defillama/sdk 2.3.49 → 2.3.50
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.
- package/LICENSE +661 -661
- package/README.md +16 -16
- package/build/abi/cachedABIs.d.ts +4 -4
- package/build/abi/cachedABIs.js +70 -70
- package/build/abi/convertResults.d.ts +2 -2
- package/build/abi/convertResults.js +56 -56
- package/build/abi/index.d.ts +26 -26
- package/build/abi/index.js +185 -185
- package/build/abi/index.test.d.ts +1 -1
- package/build/abi/index.test.js +651 -651
- package/build/abi/multicall.d.ts +21 -13
- package/build/abi/multicall.js +234 -210
- package/build/api.d.ts +10 -10
- package/build/api.js +32 -32
- package/build/cdp/compoundTokens.d.ts +68 -68
- package/build/cdp/compoundTokens.js +69 -69
- package/build/cdp/index.d.ts +29 -29
- package/build/cdp/index.js +124 -124
- package/build/cdp/index.test.d.ts +1 -1
- package/build/cdp/index.test.js +82 -82
- package/build/cdp/makerTokens.d.ts +10 -10
- package/build/cdp/makerTokens.js +244 -244
- package/build/cli.d.ts +2 -2
- package/build/cli.js +95 -95
- package/build/computeTVL/blocks.d.ts +18 -18
- package/build/computeTVL/blocks.js +138 -138
- package/build/computeTVL/blocks.test.d.ts +1 -1
- package/build/computeTVL/blocks.test.js +56 -56
- package/build/computeTVL/humanizeNumber.d.ts +1 -1
- package/build/computeTVL/humanizeNumber.js +18 -18
- package/build/computeTVL/index.d.ts +56 -55
- package/build/computeTVL/index.js +367 -366
- package/build/computeTVL/index.test.d.ts +1 -1
- package/build/computeTVL/index.test.js +107 -107
- package/build/computeTVL/prices.d.ts +9 -9
- package/build/computeTVL/prices.js +163 -163
- package/build/erc20/index.d.ts +31 -31
- package/build/erc20/index.js +144 -144
- package/build/erc20/index.test.d.ts +1 -1
- package/build/erc20/index.test.js +124 -124
- package/build/eth/index.d.ts +21 -21
- package/build/eth/index.js +90 -90
- package/build/eth/index.test.d.ts +1 -1
- package/build/eth/index.test.js +122 -122
- package/build/general.d.ts +10 -10
- package/build/general.js +105 -105
- package/build/general.test.d.ts +1 -1
- package/build/general.test.js +73 -73
- package/build/generalUtil.d.ts +19 -19
- package/build/generalUtil.js +117 -117
- package/build/generalUtil.test.d.ts +1 -1
- package/build/generalUtil.test.js +59 -59
- package/build/index.d.ts +2 -2
- package/build/index.js +24 -24
- package/build/index.test.js +69 -69
- package/build/types.d.ts +5 -5
- package/build/types.js +2 -2
- package/build/util/index.d.ts +57 -57
- package/build/util/index.js +354 -354
- package/build/util/index.test.d.ts +1 -1
- package/build/util/index.test.js +314 -314
- package/build/util/tokenList.d.ts +14 -14
- package/build/util/tokenList.js +3631 -3631
- package/package.json +41 -41
package/build/abi/multicall.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { Chain } from "../general";
|
|
2
|
-
export declare const MULTICALL_ADDRESS_MAINNET = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
|
|
3
|
-
export declare const MULTICALL_ADDRESS_KOVAN = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a";
|
|
4
|
-
export declare const MULTICALL_ADDRESS_RINKEBY = "0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821";
|
|
5
|
-
export declare const MULTICALL_ADDRESS_GOERLI = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e";
|
|
6
|
-
export declare const MULTICALL_ADDRESS_POLYGON = "0x95028E5B8a734bb7E2071F96De89BABe75be9C8E";
|
|
7
|
-
export declare const MULTICALL_ADDRESS_BSC = "0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb";
|
|
8
|
-
export declare const MULTICALL_ADDRESS_FANTOM = "0xb828C456600857abd4ed6C32FAcc607bD0464F4F";
|
|
9
|
-
export declare const
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Chain } from "../general";
|
|
2
|
+
export declare const MULTICALL_ADDRESS_MAINNET = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
|
|
3
|
+
export declare const MULTICALL_ADDRESS_KOVAN = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a";
|
|
4
|
+
export declare const MULTICALL_ADDRESS_RINKEBY = "0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821";
|
|
5
|
+
export declare const MULTICALL_ADDRESS_GOERLI = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e";
|
|
6
|
+
export declare const MULTICALL_ADDRESS_POLYGON = "0x95028E5B8a734bb7E2071F96De89BABe75be9C8E";
|
|
7
|
+
export declare const MULTICALL_ADDRESS_BSC = "0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb";
|
|
8
|
+
export declare const MULTICALL_ADDRESS_FANTOM = "0xb828C456600857abd4ed6C32FAcc607bD0464F4F";
|
|
9
|
+
export declare const MULTICALL_ADDRESS_XDAI = "0xb5b692a88BDFc81ca69dcB1d924f59f0413A602a";
|
|
10
|
+
export declare const MULTICALL_ADDRESS_HECO = "0xc9a9F768ebD123A00B52e7A0E590df2e9E998707";
|
|
11
|
+
export declare const MULTICALL_ADDRESS_HARMONY = "0xFE4980f62D708c2A84D3929859Ea226340759320";
|
|
12
|
+
export declare const MULTICALL_ADDRESS_ARBITRUM = "0x842eC2c7D803033Edf55E478F461FC547Bc54EB2";
|
|
13
|
+
export declare const MULTICALL_ADDRESS_AVAX = "0xdf2122931FEb939FB8Cf4e67Ea752D1125e18858";
|
|
14
|
+
export declare const MULTICALL_ADDRESS_MOONRIVER = "0xe05349d6fE12602F6084550995B247a5C80C0E2C";
|
|
15
|
+
export declare const MULTICALL_ADDRESS_AURORA = "0xe0e3887b158F7F9c80c835a61ED809389BC08d1b";
|
|
16
|
+
export declare const MULTICALL_ADDRESS_OPTIMISM = "0xD0E99f15B24F265074747B2A1444eB02b9E30422";
|
|
17
|
+
export declare const AGGREGATE_SELECTOR = "0x252dba42";
|
|
18
|
+
export default function makeMultiCall(functionABI: any, calls: {
|
|
19
|
+
contract: string;
|
|
20
|
+
params: any[];
|
|
21
|
+
}[], chain: Chain, block?: number): Promise<any>;
|
package/build/abi/multicall.js
CHANGED
|
@@ -1,210 +1,234 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.AGGREGATE_SELECTOR = exports.MULTICALL_ADDRESS_FANTOM = exports.MULTICALL_ADDRESS_BSC = exports.MULTICALL_ADDRESS_POLYGON = exports.MULTICALL_ADDRESS_GOERLI = exports.MULTICALL_ADDRESS_RINKEBY = exports.MULTICALL_ADDRESS_KOVAN = exports.MULTICALL_ADDRESS_MAINNET = void 0;
|
|
43
|
-
var ethers_1 = require("ethers");
|
|
44
|
-
var utils_1 = require("ethers/lib/utils");
|
|
45
|
-
var general_1 = require("../general");
|
|
46
|
-
var convertResults_1 = __importDefault(require("./convertResults"));
|
|
47
|
-
exports.MULTICALL_ADDRESS_MAINNET = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
|
|
48
|
-
exports.MULTICALL_ADDRESS_KOVAN = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a";
|
|
49
|
-
exports.MULTICALL_ADDRESS_RINKEBY = "0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821";
|
|
50
|
-
exports.MULTICALL_ADDRESS_GOERLI = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e";
|
|
51
|
-
exports.MULTICALL_ADDRESS_POLYGON = "0x95028E5B8a734bb7E2071F96De89BABe75be9C8E";
|
|
52
|
-
exports.MULTICALL_ADDRESS_BSC = "0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb";
|
|
53
|
-
exports.MULTICALL_ADDRESS_FANTOM = "0xb828C456600857abd4ed6C32FAcc607bD0464F4F";
|
|
54
|
-
exports.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
output
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
return [4 /*yield*/,
|
|
126
|
-
case
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
case
|
|
202
|
-
return exports.
|
|
203
|
-
case
|
|
204
|
-
return exports.
|
|
205
|
-
case
|
|
206
|
-
return exports.
|
|
207
|
-
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.AGGREGATE_SELECTOR = exports.MULTICALL_ADDRESS_OPTIMISM = exports.MULTICALL_ADDRESS_AURORA = exports.MULTICALL_ADDRESS_MOONRIVER = exports.MULTICALL_ADDRESS_AVAX = exports.MULTICALL_ADDRESS_ARBITRUM = exports.MULTICALL_ADDRESS_HARMONY = exports.MULTICALL_ADDRESS_HECO = exports.MULTICALL_ADDRESS_XDAI = exports.MULTICALL_ADDRESS_FANTOM = exports.MULTICALL_ADDRESS_BSC = exports.MULTICALL_ADDRESS_POLYGON = exports.MULTICALL_ADDRESS_GOERLI = exports.MULTICALL_ADDRESS_RINKEBY = exports.MULTICALL_ADDRESS_KOVAN = exports.MULTICALL_ADDRESS_MAINNET = void 0;
|
|
43
|
+
var ethers_1 = require("ethers");
|
|
44
|
+
var utils_1 = require("ethers/lib/utils");
|
|
45
|
+
var general_1 = require("../general");
|
|
46
|
+
var convertResults_1 = __importDefault(require("./convertResults"));
|
|
47
|
+
exports.MULTICALL_ADDRESS_MAINNET = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
|
|
48
|
+
exports.MULTICALL_ADDRESS_KOVAN = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a";
|
|
49
|
+
exports.MULTICALL_ADDRESS_RINKEBY = "0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821";
|
|
50
|
+
exports.MULTICALL_ADDRESS_GOERLI = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e";
|
|
51
|
+
exports.MULTICALL_ADDRESS_POLYGON = "0x95028E5B8a734bb7E2071F96De89BABe75be9C8E";
|
|
52
|
+
exports.MULTICALL_ADDRESS_BSC = "0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb";
|
|
53
|
+
exports.MULTICALL_ADDRESS_FANTOM = "0xb828C456600857abd4ed6C32FAcc607bD0464F4F";
|
|
54
|
+
exports.MULTICALL_ADDRESS_XDAI = "0xb5b692a88BDFc81ca69dcB1d924f59f0413A602a";
|
|
55
|
+
exports.MULTICALL_ADDRESS_HECO = "0xc9a9F768ebD123A00B52e7A0E590df2e9E998707";
|
|
56
|
+
exports.MULTICALL_ADDRESS_HARMONY = "0xFE4980f62D708c2A84D3929859Ea226340759320";
|
|
57
|
+
exports.MULTICALL_ADDRESS_ARBITRUM = "0x842eC2c7D803033Edf55E478F461FC547Bc54EB2";
|
|
58
|
+
exports.MULTICALL_ADDRESS_AVAX = "0xdf2122931FEb939FB8Cf4e67Ea752D1125e18858";
|
|
59
|
+
exports.MULTICALL_ADDRESS_MOONRIVER = "0xe05349d6fE12602F6084550995B247a5C80C0E2C";
|
|
60
|
+
exports.MULTICALL_ADDRESS_AURORA = "0xe0e3887b158F7F9c80c835a61ED809389BC08d1b";
|
|
61
|
+
exports.MULTICALL_ADDRESS_OPTIMISM = "0xD0E99f15B24F265074747B2A1444eB02b9E30422";
|
|
62
|
+
exports.AGGREGATE_SELECTOR = "0x252dba42";
|
|
63
|
+
function makeMultiCall(functionABI, calls, chain, block) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var contractInterface, fd, contractCalls, returnValues;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
contractInterface = new ethers_1.ethers.utils.Interface([functionABI]);
|
|
70
|
+
fd = Object.values(contractInterface.functions)[0];
|
|
71
|
+
contractCalls = calls.map(function (call) {
|
|
72
|
+
var data = contractInterface.encodeFunctionData(fd, call.params);
|
|
73
|
+
return {
|
|
74
|
+
to: call.contract,
|
|
75
|
+
data: data,
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
return [4 /*yield*/, executeCalls(contractCalls, chain, block)];
|
|
79
|
+
case 1:
|
|
80
|
+
returnValues = _a.sent();
|
|
81
|
+
return [2 /*return*/, returnValues.map(function (values, index) {
|
|
82
|
+
var output;
|
|
83
|
+
try {
|
|
84
|
+
output = convertResults_1.default(contractInterface.decodeFunctionResult(fd, values));
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
output = null;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
input: {
|
|
91
|
+
params: calls[index].params,
|
|
92
|
+
target: calls[index].contract,
|
|
93
|
+
},
|
|
94
|
+
success: output !== null,
|
|
95
|
+
output: output,
|
|
96
|
+
};
|
|
97
|
+
})];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.default = makeMultiCall;
|
|
103
|
+
function executeCalls(contractCalls, chain, block) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
var multicallData, address, callData, tx, returnData, _a, blockNumber, returnValues, e_1, values;
|
|
106
|
+
var _this = this;
|
|
107
|
+
return __generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, networkSupportsMulticall(chain)];
|
|
110
|
+
case 1:
|
|
111
|
+
if (!_b.sent()) return [3 /*break*/, 6];
|
|
112
|
+
_b.label = 2;
|
|
113
|
+
case 2:
|
|
114
|
+
_b.trys.push([2, 5, , 6]);
|
|
115
|
+
multicallData = ethers_1.ethers.utils.defaultAbiCoder.encode([
|
|
116
|
+
utils_1.ParamType.fromObject({
|
|
117
|
+
components: [
|
|
118
|
+
{ name: "target", type: "address" },
|
|
119
|
+
{ name: "callData", type: "bytes" },
|
|
120
|
+
],
|
|
121
|
+
name: "data",
|
|
122
|
+
type: "tuple[]",
|
|
123
|
+
}),
|
|
124
|
+
], [contractCalls.map(function (call) { return [call.to, call.data]; })]);
|
|
125
|
+
return [4 /*yield*/, multicallAddressOrThrow(chain)];
|
|
126
|
+
case 3:
|
|
127
|
+
address = _b.sent();
|
|
128
|
+
callData = exports.AGGREGATE_SELECTOR + multicallData.substr(2);
|
|
129
|
+
tx = {
|
|
130
|
+
to: address,
|
|
131
|
+
data: callData,
|
|
132
|
+
};
|
|
133
|
+
return [4 /*yield*/, general_1.getProvider(chain).call(tx, block !== null && block !== void 0 ? block : "latest")];
|
|
134
|
+
case 4:
|
|
135
|
+
returnData = _b.sent();
|
|
136
|
+
_a = ethers_1.ethers.utils.defaultAbiCoder.decode(["uint256", "bytes[]"], returnData), blockNumber = _a[0], returnValues = _a[1];
|
|
137
|
+
return [2 /*return*/, returnValues];
|
|
138
|
+
case 5:
|
|
139
|
+
e_1 = _b.sent();
|
|
140
|
+
if (!process.env.DEFILLAMA_SDK_MUTED) {
|
|
141
|
+
console.log("Multicall failed, defaulting to single transactions...");
|
|
142
|
+
}
|
|
143
|
+
return [3 /*break*/, 6];
|
|
144
|
+
case 6: return [4 /*yield*/, Promise.all(contractCalls.map(function (call) { return __awaiter(_this, void 0, void 0, function () {
|
|
145
|
+
var e_2;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0:
|
|
149
|
+
_a.trys.push([0, 2, , 3]);
|
|
150
|
+
return [4 /*yield*/, general_1.getProvider(chain).call({ to: call.to, data: call.data }, block !== null && block !== void 0 ? block : "latest")];
|
|
151
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
152
|
+
case 2:
|
|
153
|
+
e_2 = _a.sent();
|
|
154
|
+
return [2 /*return*/, null];
|
|
155
|
+
case 3: return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); }))];
|
|
159
|
+
case 7:
|
|
160
|
+
values = _b.sent();
|
|
161
|
+
return [2 /*return*/, values];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function multicallAddressOrThrow(chain) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var network, address, msg;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0: return [4 /*yield*/, general_1.getProvider(chain).getNetwork()];
|
|
172
|
+
case 1:
|
|
173
|
+
network = _a.sent();
|
|
174
|
+
address = multicallAddress(network.chainId);
|
|
175
|
+
if (address === null) {
|
|
176
|
+
msg = "multicall is not available on the network " + network.chainId;
|
|
177
|
+
console.error(msg);
|
|
178
|
+
throw new Error(msg);
|
|
179
|
+
}
|
|
180
|
+
return [2 /*return*/, address];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function networkSupportsMulticall(chain) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
+
var network, address;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4 /*yield*/, general_1.getProvider(chain).network];
|
|
191
|
+
case 1:
|
|
192
|
+
network = _a.sent();
|
|
193
|
+
address = multicallAddress(network.chainId);
|
|
194
|
+
return [2 /*return*/, address !== null];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function multicallAddress(chainId) {
|
|
200
|
+
switch (chainId) {
|
|
201
|
+
case 1:
|
|
202
|
+
return exports.MULTICALL_ADDRESS_MAINNET;
|
|
203
|
+
case 42:
|
|
204
|
+
return exports.MULTICALL_ADDRESS_KOVAN;
|
|
205
|
+
case 4:
|
|
206
|
+
return exports.MULTICALL_ADDRESS_RINKEBY;
|
|
207
|
+
case 5:
|
|
208
|
+
return exports.MULTICALL_ADDRESS_GOERLI;
|
|
209
|
+
case 137:
|
|
210
|
+
return exports.MULTICALL_ADDRESS_POLYGON;
|
|
211
|
+
case 56:
|
|
212
|
+
return exports.MULTICALL_ADDRESS_BSC;
|
|
213
|
+
case 250:
|
|
214
|
+
return exports.MULTICALL_ADDRESS_FANTOM;
|
|
215
|
+
case 100:
|
|
216
|
+
return exports.MULTICALL_ADDRESS_XDAI;
|
|
217
|
+
case 128:
|
|
218
|
+
return exports.MULTICALL_ADDRESS_HECO;
|
|
219
|
+
case 1666600000:
|
|
220
|
+
return exports.MULTICALL_ADDRESS_HARMONY;
|
|
221
|
+
case 42161:
|
|
222
|
+
return exports.MULTICALL_ADDRESS_ARBITRUM;
|
|
223
|
+
case 43114:
|
|
224
|
+
return exports.MULTICALL_ADDRESS_AVAX;
|
|
225
|
+
case 1285:
|
|
226
|
+
return exports.MULTICALL_ADDRESS_MOONRIVER;
|
|
227
|
+
case 1313161554:
|
|
228
|
+
return exports.MULTICALL_ADDRESS_AURORA;
|
|
229
|
+
case 10:
|
|
230
|
+
return exports.MULTICALL_ADDRESS_OPTIMISM;
|
|
231
|
+
default:
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
package/build/api.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * as util from "./util";
|
|
2
|
-
export * as eth from "./eth";
|
|
3
|
-
export * as erc20 from "./erc20";
|
|
4
|
-
export * as cdp from "./cdp";
|
|
5
|
-
export * as abi from "./abi";
|
|
6
|
-
import { setProvider } from "./general";
|
|
7
|
-
declare const config: {
|
|
8
|
-
setProvider: typeof setProvider;
|
|
9
|
-
};
|
|
10
|
-
export { config };
|
|
1
|
+
export * as util from "./util";
|
|
2
|
+
export * as eth from "./eth";
|
|
3
|
+
export * as erc20 from "./erc20";
|
|
4
|
+
export * as cdp from "./cdp";
|
|
5
|
+
export * as abi from "./abi";
|
|
6
|
+
import { setProvider } from "./general";
|
|
7
|
+
declare const config: {
|
|
8
|
+
setProvider: typeof setProvider;
|
|
9
|
+
};
|
|
10
|
+
export { config };
|
package/build/api.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.config = exports.abi = exports.cdp = exports.erc20 = exports.eth = exports.util = void 0;
|
|
23
|
-
exports.util = __importStar(require("./util"));
|
|
24
|
-
exports.eth = __importStar(require("./eth"));
|
|
25
|
-
exports.erc20 = __importStar(require("./erc20"));
|
|
26
|
-
exports.cdp = __importStar(require("./cdp"));
|
|
27
|
-
exports.abi = __importStar(require("./abi"));
|
|
28
|
-
var general_1 = require("./general");
|
|
29
|
-
var config = {
|
|
30
|
-
setProvider: general_1.setProvider,
|
|
31
|
-
};
|
|
32
|
-
exports.config = config;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.config = exports.abi = exports.cdp = exports.erc20 = exports.eth = exports.util = void 0;
|
|
23
|
+
exports.util = __importStar(require("./util"));
|
|
24
|
+
exports.eth = __importStar(require("./eth"));
|
|
25
|
+
exports.erc20 = __importStar(require("./erc20"));
|
|
26
|
+
exports.cdp = __importStar(require("./cdp"));
|
|
27
|
+
exports.abi = __importStar(require("./abi"));
|
|
28
|
+
var general_1 = require("./general");
|
|
29
|
+
var config = {
|
|
30
|
+
setProvider: general_1.setProvider,
|
|
31
|
+
};
|
|
32
|
+
exports.config = config;
|