@defillama/sdk 2.3.33 → 2.3.37
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/build/abi/index.d.ts +1 -0
- package/build/abi/index.js +23 -4
- package/build/computeTVL/blocks.d.ts +3 -0
- package/build/computeTVL/blocks.js +5 -3
- package/build/general.d.ts +3 -0
- package/build/general.js +10 -4
- package/package.json +1 -1
package/build/abi/index.d.ts
CHANGED
package/build/abi/index.js
CHANGED
|
@@ -108,7 +108,7 @@ exports.call = call;
|
|
|
108
108
|
function multiCall(params) {
|
|
109
109
|
var _a;
|
|
110
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var abi, contractCalls, multicallCalls, result, _loop_1, i;
|
|
111
|
+
var abi, contractCalls, multicallCalls, result, _loop_1, i, flatResults, failed, newResults_1;
|
|
112
112
|
return __generator(this, function (_b) {
|
|
113
113
|
switch (_b.label) {
|
|
114
114
|
case 0:
|
|
@@ -156,9 +156,28 @@ function multiCall(params) {
|
|
|
156
156
|
case 4: return [4 /*yield*/, Promise.all(multicallCalls)];
|
|
157
157
|
case 5:
|
|
158
158
|
_b.sent();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
flatResults = [].concat.apply([], result);
|
|
160
|
+
if (!(params.requery === true && flatResults.some(function (r) { return !r.success; }))) return [3 /*break*/, 7];
|
|
161
|
+
failed = flatResults.map(function (r, i) { return [r, i]; }).filter(function (r) { return !r[0].success; });
|
|
162
|
+
return [4 /*yield*/, multiCall({
|
|
163
|
+
abi: params.abi,
|
|
164
|
+
chain: params.chain,
|
|
165
|
+
calls: failed.map(function (f) { return f[0].input; }),
|
|
166
|
+
block: params.block,
|
|
167
|
+
requery: params.requery,
|
|
168
|
+
}).then(function (_a) {
|
|
169
|
+
var output = _a.output;
|
|
170
|
+
return output;
|
|
171
|
+
})];
|
|
172
|
+
case 6:
|
|
173
|
+
newResults_1 = _b.sent();
|
|
174
|
+
failed.forEach(function (f, i) {
|
|
175
|
+
flatResults[f[1]] = newResults_1[i];
|
|
176
|
+
});
|
|
177
|
+
_b.label = 7;
|
|
178
|
+
case 7: return [2 /*return*/, {
|
|
179
|
+
output: flatResults, // flatten array
|
|
180
|
+
}];
|
|
162
181
|
}
|
|
163
182
|
});
|
|
164
183
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Chain } from "../general";
|
|
2
2
|
export declare const chainsForBlocks: Chain[];
|
|
3
|
+
export declare function getChainBlocks(timestamp: number, chains?: Chain[]): Promise<{
|
|
4
|
+
[chain: string]: number;
|
|
5
|
+
}>;
|
|
3
6
|
export declare function getBlocks(timestamp: number): Promise<{
|
|
4
7
|
ethereumBlock: number;
|
|
5
8
|
chainBlocks: {
|
|
@@ -36,12 +36,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getCurrentBlocks = exports.getBlocks = exports.chainsForBlocks = void 0;
|
|
39
|
+
exports.getCurrentBlocks = exports.getBlocks = exports.getChainBlocks = exports.chainsForBlocks = void 0;
|
|
40
40
|
var general_1 = require("../general");
|
|
41
41
|
var index_1 = require("../util/index");
|
|
42
42
|
exports.chainsForBlocks = ["avax", "bsc", "polygon", "xdai", "fantom", "arbitrum"];
|
|
43
43
|
var blockRetries = 5;
|
|
44
|
-
function getChainBlocks(timestamp) {
|
|
44
|
+
function getChainBlocks(timestamp, chains) {
|
|
45
|
+
if (chains === void 0) { chains = exports.chainsForBlocks; }
|
|
45
46
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
47
|
var chainBlocks;
|
|
47
48
|
var _this = this;
|
|
@@ -49,7 +50,7 @@ function getChainBlocks(timestamp) {
|
|
|
49
50
|
switch (_a.label) {
|
|
50
51
|
case 0:
|
|
51
52
|
chainBlocks = {};
|
|
52
|
-
return [4 /*yield*/, Promise.all(
|
|
53
|
+
return [4 /*yield*/, Promise.all(chains.map(function (chain) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
54
|
var i, _a, _b, e_1;
|
|
54
55
|
return __generator(this, function (_c) {
|
|
55
56
|
switch (_c.label) {
|
|
@@ -89,6 +90,7 @@ function getChainBlocks(timestamp) {
|
|
|
89
90
|
});
|
|
90
91
|
});
|
|
91
92
|
}
|
|
93
|
+
exports.getChainBlocks = getChainBlocks;
|
|
92
94
|
function getBlocks(timestamp) {
|
|
93
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
94
96
|
var _a, ethBlock, chainBlocks;
|
package/build/general.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ethers, BigNumber } from "ethers";
|
|
2
|
+
export declare const providers: {
|
|
3
|
+
[chain: string]: ethers.providers.BaseProvider;
|
|
4
|
+
};
|
|
2
5
|
export declare type Chain = "ethereum" | "bsc" | "polygon" | "heco" | "fantom" | "rsk" | "tomochain" | "xdai" | "avax" | "wan" | "iotex" | "harmony" | "thundercore" | "okexchain" | "optimism" | "arbitrum" | "energyweb" | "songbird" | "hpb" | "gochain" | "ethclassic" | "xdaiarb" | "kardia" | "fuse" | "smartbch" | "elastos" | "hoo" | "fusion" | "aurora" | "ronin" | "boba" | "cronos" | "polis" | "zyx" | "telos" | "metis" | "ubiq" | "velas" | "callisto" | "csc";
|
|
3
6
|
export declare function getProvider(chain?: Chain): ethers.providers.BaseProvider;
|
|
4
7
|
export declare const TEN: ethers.BigNumber;
|
package/build/general.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setProvider = exports.ETHER_ADDRESS = exports.handleDecimals = exports.TEN = exports.getProvider = void 0;
|
|
3
|
+
exports.setProvider = exports.ETHER_ADDRESS = exports.handleDecimals = exports.TEN = exports.getProvider = exports.providers = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
5
|
function createProvider(name, defaultRpc, chainId) {
|
|
6
6
|
var _a, _b, _c;
|
|
@@ -23,7 +23,7 @@ function createProvider(name, defaultRpc, chainId) {
|
|
|
23
23
|
}); }), 1);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
exports.providers = {
|
|
27
27
|
// https://ethereumnodes.com/
|
|
28
28
|
ethereum: createProvider("ethereum", "https://eth-mainnet.gateway.pokt.network/v1/5f3453978e354ab992c4da79,https://cloudflare-eth.com/,https://main-light.eth.linkpool.io/,https://api.mycryptoapi.com/eth", 1),
|
|
29
29
|
bsc: createProvider("bsc", "https://bsc-dataseed.binance.org/,https://bsc-dataseed1.defibit.io/,https://bsc-dataseed1.ninicoin.io/,https://bsc-dataseed2.defibit.io/,https://bsc-dataseed2.ninicoin.io/", 56),
|
|
@@ -71,10 +71,16 @@ var providers = {
|
|
|
71
71
|
callisto: createProvider("callisto", "https://clo-geth.0xinfra.com/", 820),
|
|
72
72
|
klaytn: createProvider("klaytn", "http://175.209.78.135:8551", 8217),
|
|
73
73
|
csc: createProvider("csc", "https://rpc.coinex.net/,https://rpc1.coinex.net/,https://rpc2.coinex.net/,https://rpc3.coinex.net/,https://rpc4.coinex.net/", 52),
|
|
74
|
+
nahmii: createProvider("nahmii", "https://l2.nahmii.io/", 5551),
|
|
75
|
+
liquidchain: createProvider("xlc", "https://rpc.liquidchain.net/,https://rpc.xlcscan.com/", 5050),
|
|
76
|
+
meter: createProvider("meter", 'https://rpc.meter.io', 82),
|
|
77
|
+
theta: createProvider("theta", 'https://eth-rpc-api.thetatoken.org/rpc', 361),
|
|
78
|
+
emerald: createProvider("emerald", 'https://emerald.oasis.dev/', 42262),
|
|
79
|
+
syscoin: createProvider("syscoin", 'https://rpc.syscoin.org', 57)
|
|
74
80
|
};
|
|
75
81
|
function getProvider(chain) {
|
|
76
82
|
if (chain === void 0) { chain = "ethereum"; }
|
|
77
|
-
return providers[chain];
|
|
83
|
+
return exports.providers[chain];
|
|
78
84
|
}
|
|
79
85
|
exports.getProvider = getProvider;
|
|
80
86
|
exports.TEN = ethers_1.BigNumber.from(10);
|
|
@@ -89,6 +95,6 @@ function handleDecimals(num, decimals) {
|
|
|
89
95
|
exports.handleDecimals = handleDecimals;
|
|
90
96
|
exports.ETHER_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
91
97
|
function setProvider(chain, provider) {
|
|
92
|
-
providers[chain] = provider;
|
|
98
|
+
exports.providers[chain] = provider;
|
|
93
99
|
}
|
|
94
100
|
exports.setProvider = setProvider;
|