@defillama/sdk 2.3.1 → 2.3.5
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.
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.getCurrentBlocks = exports.getBlocks = void 0;
|
|
40
40
|
var general_1 = require("../general");
|
|
41
41
|
var index_1 = require("../util/index");
|
|
42
|
-
var chainsForBlocks = ["avax", "bsc", "polygon", "xdai", "fantom"];
|
|
42
|
+
var chainsForBlocks = ["avax", "bsc", "polygon", "xdai", "fantom", "arbitrum"];
|
|
43
43
|
var blockRetries = 5;
|
|
44
44
|
function getChainBlocks(timestamp) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -18,6 +18,7 @@ export declare const chainToCoingeckoId: {
|
|
|
18
18
|
harmony: string;
|
|
19
19
|
kcc: string;
|
|
20
20
|
celo: string;
|
|
21
|
+
arbitrum: string;
|
|
21
22
|
};
|
|
22
23
|
export default function (rawBalances: Balances, timestamp: number | "now", verbose?: boolean, knownTokenPrices?: TokenPrices, getCoingeckoLock?: GetCoingeckoLog, coingeckoMaxRetries?: number): Promise<{
|
|
23
24
|
usdTvl: number;
|
|
@@ -79,7 +79,8 @@ exports.chainToCoingeckoId = {
|
|
|
79
79
|
okexchain: "okex-chain",
|
|
80
80
|
harmony: "harmony-shard-0",
|
|
81
81
|
kcc: "kucoin-community-chain",
|
|
82
|
-
celo: "celo"
|
|
82
|
+
celo: "celo",
|
|
83
|
+
arbitrum: "arbitrum-one",
|
|
83
84
|
};
|
|
84
85
|
function currentCoingeckoUrls(chain) {
|
|
85
86
|
if (chain === 'coingecko') {
|
|
@@ -253,9 +254,6 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
|
|
|
253
254
|
}
|
|
254
255
|
tokenDecimals = coinData === null || coinData === void 0 ? void 0 : coinData.decimals;
|
|
255
256
|
if (tokenDecimals === undefined) {
|
|
256
|
-
if (verbose) {
|
|
257
|
-
console.warn("Couldn't query decimals() for token " + tokenSymbol + " (" + address + ") so we'll ignore and assume it's amount is 0");
|
|
258
|
-
}
|
|
259
257
|
amount = 0;
|
|
260
258
|
}
|
|
261
259
|
else {
|
|
@@ -271,7 +269,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
|
|
|
271
269
|
case 3:
|
|
272
270
|
if (price === undefined) {
|
|
273
271
|
if (verbose) {
|
|
274
|
-
console.log("
|
|
272
|
+
console.log("Token " + address + " is not on coingecko, it'll be ignored");
|
|
275
273
|
}
|
|
276
274
|
price = 0;
|
|
277
275
|
}
|
package/build/general.js
CHANGED
|
@@ -24,17 +24,18 @@ function createProvider(name, defaultRpc, chainId) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
var providers = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
// https://ethereumnodes.com/
|
|
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
|
+
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),
|
|
30
|
+
polygon: createProvider("polygon", "https://polygon-rpc.com/,https://rpc-mainnet.maticvigil.com/", 137),
|
|
31
|
+
heco: createProvider("heco", "https://http-mainnet.hecochain.com,https://http-mainnet-node.huobichain.com,https://pub001.hg.network/rpc", 128),
|
|
32
|
+
fantom: createProvider("fantom", "https://rpc.ftm.tools/,https://rpcapi.fantom.network", 250),
|
|
32
33
|
rsk: createProvider("rsk", "https://public-node.rsk.co", 30),
|
|
33
34
|
tomochain: createProvider("tomochain", "https://rpc.tomochain.com", 88),
|
|
34
|
-
xdai: createProvider("xdai", "https://xdai.poanetwork.dev", 100),
|
|
35
|
+
xdai: createProvider("xdai", "https://rpc.xdaichain.com/,https://xdai.poanetwork.dev,https://dai.poa.network,https://xdai-archive.blockscout.com", 100),
|
|
35
36
|
avax: createProvider("avax", "https://api.avax.network/ext/bc/C/rpc", 43114),
|
|
36
37
|
wan: createProvider("wan", "https://gwan-ssl.wandevs.org:56891", 888),
|
|
37
|
-
harmony: createProvider("harmony", "https://api.s0.t.hmny.io", 1666600000),
|
|
38
|
+
harmony: createProvider("harmony", "https://api.harmony.one,https://api.s0.t.hmny.io", 1666600000),
|
|
38
39
|
thundercore: createProvider("thundercore", "https://mainnet-rpc.thundercore.com", 108),
|
|
39
40
|
okexchain: createProvider("okexchain", "https://exchainrpc.okex.org", 66),
|
|
40
41
|
optimism: createProvider("optimism", "https://mainnet.optimism.io/", 10),
|
package/build/util/index.js
CHANGED
|
@@ -68,6 +68,22 @@ var terraBlockProvider = {
|
|
|
68
68
|
});
|
|
69
69
|
}); },
|
|
70
70
|
};
|
|
71
|
+
function getBlock(provider, height, chain) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var block;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0: return [4 /*yield*/, provider.getBlock(height)];
|
|
77
|
+
case 1:
|
|
78
|
+
block = _a.sent();
|
|
79
|
+
if (block === null) {
|
|
80
|
+
throw new Error("Can't get block of chain " + (chain !== null && chain !== void 0 ? chain : 'ethereum'));
|
|
81
|
+
}
|
|
82
|
+
return [2 /*return*/, block];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
71
87
|
function lookupBlock(timestamp, extraParams) {
|
|
72
88
|
var _a, _b, _c;
|
|
73
89
|
if (extraParams === void 0) { extraParams = {}; }
|
|
@@ -80,7 +96,7 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
80
96
|
provider = extraParams.chain === "terra"
|
|
81
97
|
? terraBlockProvider
|
|
82
98
|
: general_1.getProvider(extraParams.chain);
|
|
83
|
-
return [4 /*yield*/,
|
|
99
|
+
return [4 /*yield*/, getBlock(provider, "latest", extraParams.chain)];
|
|
84
100
|
case 1:
|
|
85
101
|
lastBlock = _d.sent();
|
|
86
102
|
if ((lastBlock.timestamp - timestamp) < -30 * 60) {
|
|
@@ -99,7 +115,7 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
99
115
|
_d.label = 2;
|
|
100
116
|
case 2:
|
|
101
117
|
mid = Math.floor((high + low) / 2);
|
|
102
|
-
return [4 /*yield*/,
|
|
118
|
+
return [4 /*yield*/, getBlock(provider, mid, extraParams.chain)];
|
|
103
119
|
case 3:
|
|
104
120
|
block = _d.sent();
|
|
105
121
|
if (block.timestamp < timestamp) {
|