@defillama/sdk 5.0.198 → 5.0.204
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/ChainApi.d.ts +1 -0
- package/build/ChainApi.js +6 -2
- package/build/abi/abi2.js +52 -1
- package/build/abi/index.js +4 -0
- package/build/abi/multicall3.js +1 -0
- package/build/providers.json +1 -1
- package/build/types.d.ts +4 -2
- package/build/util/common.js +3 -0
- package/build/util/computeTVL.js +5 -0
- package/build/util/indexer.js +1 -0
- package/build/util/updateProviderList.js +48 -27
- package/package.json +1 -1
package/build/types.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export type CallsParams = {
|
|
|
11
11
|
};
|
|
12
12
|
export type CallOptions = {
|
|
13
13
|
target: Address;
|
|
14
|
-
abi
|
|
14
|
+
abi?: string | any;
|
|
15
|
+
abis?: string[];
|
|
15
16
|
block?: Block;
|
|
16
17
|
params?: CallParams;
|
|
17
18
|
chain?: Chain | string;
|
|
@@ -23,7 +24,8 @@ export type CallOptions = {
|
|
|
23
24
|
};
|
|
24
25
|
export type Chain = string;
|
|
25
26
|
export type MulticallOptions = {
|
|
26
|
-
abi
|
|
27
|
+
abi?: string | any;
|
|
28
|
+
abis?: string[];
|
|
27
29
|
calls: CallsParams[] | (string | number)[];
|
|
28
30
|
block?: Block;
|
|
29
31
|
target?: Address;
|
package/build/util/common.js
CHANGED
|
@@ -122,6 +122,9 @@ function sumSingleBalance(balances, token, balance, chain) {
|
|
|
122
122
|
else
|
|
123
123
|
throw new Error('Invalid balance value:' + balance + ' ' + token);
|
|
124
124
|
}
|
|
125
|
+
if (!token || token.trim() === '') {
|
|
126
|
+
throw new Error('Missing token address/symbol');
|
|
127
|
+
}
|
|
125
128
|
if (typeof balance === 'number' || (balances[token] && typeof balances[token] === 'number')) {
|
|
126
129
|
const prevBalance = +(balances.hasOwnProperty(token) ? balances[token] : 0);
|
|
127
130
|
if (typeof prevBalance !== 'number' || isNaN(prevBalance))
|
package/build/util/computeTVL.js
CHANGED
|
@@ -26,6 +26,9 @@ async function computeTVL(balances, timestamp, { debug = false } = {}) {
|
|
|
26
26
|
// if (+balance <= 0) return;
|
|
27
27
|
if (+balance === 0)
|
|
28
28
|
return;
|
|
29
|
+
if (!token || token.trim() === '') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
29
32
|
const key = tokenToKey(token).toLowerCase();
|
|
30
33
|
let { price, confidence, decimals = 0, symbol = token } = (_a = priceCache[key]) !== null && _a !== void 0 ? _a : {};
|
|
31
34
|
if (!price || confidence < confidenceThreshold)
|
|
@@ -34,6 +37,8 @@ async function computeTVL(balances, timestamp, { debug = false } = {}) {
|
|
|
34
37
|
usdTvl += value;
|
|
35
38
|
if (symbol === 'ETH')
|
|
36
39
|
symbol = 'WETH';
|
|
40
|
+
if (!symbol || symbol.trim() === '')
|
|
41
|
+
symbol = '-';
|
|
37
42
|
(0, generalUtil_1.sumSingleBalance)(usdTokenBalances, symbol, value);
|
|
38
43
|
if (debug && !isNaN(+value))
|
|
39
44
|
debugData.tokenData.push({ symbol, value, token, price, confidence, balance, decimals, });
|
package/build/util/indexer.js
CHANGED
|
@@ -10,6 +10,7 @@ const promise_pool_1 = __importDefault(require("@supercharge/promise-pool"));
|
|
|
10
10
|
const generalUtil_1 = require("../generalUtil");
|
|
11
11
|
const concurrentCheckChains = +(process.env.SDK_BUILD_CONCURRENT_CHAINS || 7);
|
|
12
12
|
const chainRemovalThreshold = +(process.env.SDK_BUILD_CHAIN_REMOVAL_THRESHOLD || 20);
|
|
13
|
+
const droppedTestnetChainsSet = new Set([]);
|
|
13
14
|
const providerList = providers_json_1.default;
|
|
14
15
|
async function getChainData() {
|
|
15
16
|
try {
|
|
@@ -38,15 +39,19 @@ async function main() {
|
|
|
38
39
|
// .filter((i: any) => !i.status || (i.status === 'active' || i.status === 'incubating'))
|
|
39
40
|
.filter((i) => i.shortName)
|
|
40
41
|
.filter((i) => {
|
|
42
|
+
var _a, _b;
|
|
41
43
|
if (currentChainsSet.has(i.shortName))
|
|
42
44
|
return true;
|
|
43
45
|
const bannedKeys = ['sepolia', 'test', 'goerli', 'devnet', 'holesky',];
|
|
44
46
|
const bannedRPCKeys = ['sepolia', 'goerli', 'devnet', 'holesky'];
|
|
45
47
|
const isTestnetKey = bannedKeys.some((j) => i.shortName.includes(j));
|
|
46
48
|
const hasTestnetRPC = i.rpc.some((rpc) => bannedRPCKeys.some((k) => rpc === null || rpc === void 0 ? void 0 : rpc.url.includes(k)));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const hasTestnetName = ((_a = i.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('testnet')) || ((_b = i.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('devnet'));
|
|
50
|
+
if (isTestnetKey || hasTestnetRPC || hasTestnetName) {
|
|
51
|
+
droppedTestnetChainsSet.add(i.shortName);
|
|
52
|
+
// console.log(`Excluding testnet chain ${i.name} (${i.shortName})`)
|
|
53
|
+
}
|
|
54
|
+
return !isTestnetKey && !hasTestnetRPC && !hasTestnetName;
|
|
50
55
|
});
|
|
51
56
|
// trim/remove mainnet|-mainnet|_mainnet from short names, preliminary rpc filtering
|
|
52
57
|
const rpcFilterRegex = /(wss\:|ws\:|terminet\.io|huobichain\.com|getblock\.io|bitstack\.com|nodereal.io\/v1|pokt\.network|histori\.xyz|chainstacklabs\.com|owlracle\.info|blastapi\.io)/;
|
|
@@ -64,7 +69,7 @@ async function main() {
|
|
|
64
69
|
if (!j.url)
|
|
65
70
|
return false;
|
|
66
71
|
if (rpcFilterRegex.test(j.url)) {
|
|
67
|
-
console.log(`Removing blacklisted rpc ${j.url} from ${i.name}`)
|
|
72
|
+
// console.log(`Removing blacklisted rpc ${j.url} from ${i.name}`)
|
|
68
73
|
return false; // remove anything with blacklisted words
|
|
69
74
|
}
|
|
70
75
|
return true;
|
|
@@ -117,16 +122,21 @@ async function main() {
|
|
|
117
122
|
providerList[key] = providerList[shorName];
|
|
118
123
|
}
|
|
119
124
|
const droppedChains = Object.keys(oldProviders).filter(oldChain => providerList[oldChain] === undefined);
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
const filteredDroppedChains = droppedChains.filter(i => !droppedTestnetChainsSet.has(i) && !i.includes('test'));
|
|
126
|
+
console.log('Dropped chains before testnet filtering:', droppedChains.length);
|
|
127
|
+
console.log('Dropped chains after testnet filtering:', filteredDroppedChains.length);
|
|
128
|
+
if (filteredDroppedChains.length > chainRemovalThreshold) {
|
|
129
|
+
throw new Error(`Following chains used to be included but is not anymore, can the devs fix please?\n${filteredDroppedChains.join(', ')}`);
|
|
122
130
|
}
|
|
123
131
|
delete providerList.bitcoin; // what were they smoking?
|
|
124
132
|
const rpcCount = Object.values(providerList).reduce((acc, i) => { var _a; return acc + ((_a = i === null || i === void 0 ? void 0 : i.rpc.length) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
133
|
+
const rpcCountOld = Object.values(oldProviders).reduce((acc, i) => { var _a; return acc + ((_a = i === null || i === void 0 ? void 0 : i.rpc.length) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
125
134
|
console.log('Final provider list:');
|
|
126
135
|
console.log('Chain count:', Object.keys(providerList).length);
|
|
127
|
-
console.log('Dropped chain count:',
|
|
136
|
+
console.log('Dropped chain count:', filteredDroppedChains.length);
|
|
128
137
|
console.log('RPC count:', rpcCount);
|
|
129
|
-
console.log('
|
|
138
|
+
console.log('RPC count current:', rpcCountOld);
|
|
139
|
+
console.log('Dropped chains:', filteredDroppedChains.join(', '));
|
|
130
140
|
fs_1.default.writeFileSync(__dirname + '/../providers.json', JSON.stringify(providerList));
|
|
131
141
|
}
|
|
132
142
|
const blacklist = [
|
|
@@ -172,29 +182,40 @@ const chainShortNameMapping = {
|
|
|
172
182
|
hydragon: 'hydra',
|
|
173
183
|
camp: 'campmainnet',
|
|
174
184
|
mantra: 'mantrachain',
|
|
185
|
+
saga: 'sagaevm',
|
|
175
186
|
};
|
|
176
187
|
async function filterForWorkingRPCs(rpc, chain, chainId) {
|
|
177
|
-
if (rpc.length <
|
|
188
|
+
if (rpc.length < 4)
|
|
178
189
|
return rpc;
|
|
179
190
|
rpc = filterRPCs(rpc);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const filteredRPCs = [];
|
|
192
|
+
await (0, generalUtil_1.runInPromisePool)({
|
|
193
|
+
items: rpc,
|
|
194
|
+
concurrency: concurrentCheckChains,
|
|
195
|
+
permitFailure: true,
|
|
196
|
+
processor: async (i) => {
|
|
197
|
+
try {
|
|
198
|
+
const data = await (0, generalUtil_1.postJson)(i, {
|
|
199
|
+
jsonrpc: '2.0',
|
|
200
|
+
method: 'eth_chainId',
|
|
201
|
+
params: [],
|
|
202
|
+
id: 1
|
|
203
|
+
}, {
|
|
204
|
+
timeout: 60000
|
|
205
|
+
});
|
|
206
|
+
if (data.result) {
|
|
207
|
+
const returnedChainId = parseInt(data.result, 16);
|
|
208
|
+
if (returnedChainId !== chainId) {
|
|
209
|
+
console.log(`RPC ${i} for ${chain} returned invalid chainId ${returnedChainId}, expected ${chainId}`);
|
|
210
|
+
}
|
|
211
|
+
filteredRPCs.push(i);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
console.log('ignoring bad rpc', chain, e === null || e === void 0 ? void 0 : e.message);
|
|
216
|
+
}
|
|
195
217
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return rpc.filter((_i, index) => promises[index]);
|
|
218
|
+
});
|
|
219
|
+
return filteredRPCs;
|
|
199
220
|
}
|
|
200
221
|
main();
|