@defillama/sdk 5.0.235 → 5.0.236

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.
Files changed (60) hide show
  1. package/build/ChainApi.d.ts +23 -1
  2. package/build/chains/algorand.d.ts +277 -0
  3. package/build/chains/algorand.js +618 -0
  4. package/build/chains/aptos.d.ts +230 -0
  5. package/build/chains/aptos.js +612 -0
  6. package/build/chains/cardano.d.ts +242 -0
  7. package/build/chains/cardano.js +407 -0
  8. package/build/chains/cosmos.d.ts +252 -0
  9. package/build/chains/cosmos.js +618 -0
  10. package/build/chains/icp.d.ts +235 -0
  11. package/build/chains/icp.js +1040 -0
  12. package/build/chains/index.d.ts +23 -0
  13. package/build/chains/index.js +59 -0
  14. package/build/chains/near.d.ts +192 -0
  15. package/build/chains/near.js +446 -0
  16. package/build/chains/rpc.d.ts +125 -0
  17. package/build/chains/rpc.js +326 -0
  18. package/build/chains/starknet.d.ts +205 -0
  19. package/build/chains/starknet.js +884 -0
  20. package/build/chains/stellar.d.ts +410 -0
  21. package/build/chains/stellar.js +1082 -0
  22. package/build/chains/substrate.d.ts +333 -0
  23. package/build/chains/substrate.js +1042 -0
  24. package/build/chains/sui.d.ts +365 -0
  25. package/build/chains/sui.js +1135 -0
  26. package/build/chains/svm.d.ts +340 -0
  27. package/build/chains/svm.js +760 -0
  28. package/build/chains/tezos.d.ts +225 -0
  29. package/build/chains/tezos.js +412 -0
  30. package/build/chains/ton.d.ts +353 -0
  31. package/build/chains/ton.js +788 -0
  32. package/build/chains/tron.d.ts +45 -0
  33. package/build/chains/tron.js +110 -0
  34. package/build/chains/utxo.d.ts +202 -0
  35. package/build/chains/utxo.js +592 -0
  36. package/build/chains/xrpl.d.ts +179 -0
  37. package/build/chains/xrpl.js +467 -0
  38. package/build/index.d.ts +2 -1
  39. package/build/index.js +3 -1
  40. package/build/providers.json +1 -1
  41. package/build/util/chainUtils/data.json +11 -0
  42. package/build/util/chainUtils/index.d.ts +1 -0
  43. package/build/util/chainUtils/index.js +23 -0
  44. package/build/util/common.js +2 -3
  45. package/build/util/cosmos.d.ts +1 -11
  46. package/build/util/cosmos.js +6 -66
  47. package/build/util/env.js +1 -0
  48. package/build/util/indexer.compatibility.d.ts +6 -0
  49. package/build/util/indexer.compatibility.js +64 -0
  50. package/build/util/indexer.d.ts +24 -2
  51. package/build/util/indexer.js +215 -282
  52. package/build/util/indexerSql.d.ts +8 -1
  53. package/build/util/indexerSql.js +53 -22
  54. package/build/util/logs.decode.shared.js +5 -4
  55. package/build/util/transactions.d.ts +23 -1
  56. package/build/util/updateChainLabels.d.ts +1 -0
  57. package/build/util/updateChainLabels.js +5 -0
  58. package/build/util/updateProviderList.js +38 -17
  59. package/package.json +20 -7
  60. package/README.md +0 -41
@@ -235,6 +235,7 @@
235
235
  "hemi": "Hemi",
236
236
  "hibachi": "Hibachi",
237
237
  "hoo": "Hoo",
238
+ "horizen": "Horizen L3",
238
239
  "horizen eon": "Horizen EON",
239
240
  "hotstuff": "Hotstuff",
240
241
  "hpb": "HPB",
@@ -320,6 +321,7 @@
320
321
  "megaeth": "MegaETH",
321
322
  "merlin": "Merlin",
322
323
  "meta": "Meta",
324
+ "metall2": "MetalL2",
323
325
  "meter": "Meter",
324
326
  "metis": "Metis",
325
327
  "mezo": "Mezo",
@@ -835,6 +837,7 @@
835
837
  "Hibachi": "hibachi",
836
838
  "Hoo": "hoo",
837
839
  "Horizen EON": "eon",
840
+ "Horizen L3": "horizen",
838
841
  "Hotstuff": "hotstuff",
839
842
  "Hydra": "hydra",
840
843
  "Hydra Chain": "hydragon",
@@ -923,6 +926,7 @@
923
926
  "MemeCore": "m",
924
927
  "Merlin": "merlin",
925
928
  "Meta": "meta",
929
+ "MetalL2": "metall2",
926
930
  "Meter": "meter",
927
931
  "Metis": "metis",
928
932
  "Mezo": "mezo",
@@ -1240,8 +1244,10 @@
1240
1244
  "bouncebit": "2026-08-24",
1241
1245
  "btnx": "2026-07-09",
1242
1246
  "callisto": "2026-07-01",
1247
+ "canto": "2026-08-10",
1243
1248
  "capx": "2026-09-03",
1244
1249
  "chainx": "2026-01-20",
1250
+ "clv": "2025-11-22",
1245
1251
  "corn": "2026-06-30",
1246
1252
  "crab": "2026-01-01",
1247
1253
  "crossfi": "2026-09-09",
@@ -1281,10 +1287,12 @@
1281
1287
  "inevm": "2026-04-08",
1282
1288
  "inri": "2026-08-03",
1283
1289
  "interlay": "2026-07-22",
1290
+ "jbc": "2026-09-01",
1284
1291
  "kadena": "2026-02-12",
1285
1292
  "kardia": "2026-01-20",
1286
1293
  "kinto": "2026-03-06",
1287
1294
  "kintsugi": "2026-07-22",
1295
+ "kopi": "2026-05-16",
1288
1296
  "kroma": "2026-01-20",
1289
1297
  "kujira": "2026-08-03",
1290
1298
  "loop": "2026-08-03",
@@ -1306,6 +1314,7 @@
1306
1314
  "odyssey": "2026-09-02",
1307
1315
  "onus": "2026-06-05",
1308
1316
  "parex": "2026-08-12",
1317
+ "perennial": "2026-06-30",
1309
1318
  "planq": "2026-06-05",
1310
1319
  "plume": "2026-02-12",
1311
1320
  "polygon_zkevm": "2026-07-01",
@@ -1326,6 +1335,7 @@
1326
1335
  "spn": "2026-09-08",
1327
1336
  "srx": "2026-08-03",
1328
1337
  "stargaze": "2026-06-01",
1338
+ "step": "2026-08-21",
1329
1339
  "svm": "2026-01-09",
1330
1340
  "swellchain": "2026-06-23",
1331
1341
  "sx": "2026-04-23",
@@ -1333,6 +1343,7 @@
1333
1343
  "tenet": "2026-04-22",
1334
1344
  "thundercore": "2026-09-01",
1335
1345
  "titan": "2026-05-05",
1346
+ "tombchain": "2026-09-19",
1336
1347
  "ubiq": "2023-01-01",
1337
1348
  "umee": "2026-07-10",
1338
1349
  "vision": "2026-02-20",
@@ -1,6 +1,7 @@
1
1
  import { chainKeyToChainLabelMap, chainLabelsToKeyMap } from './data.json';
2
2
  export { chainKeyToChainLabelMap, chainLabelsToKeyMap, };
3
3
  export declare function updateData(): Promise<void>;
4
+ export declare function updateChainLabels(): Promise<void>;
4
5
  export declare const sluggifyString: (name: string) => string;
5
6
  export declare function getSluggifiedChainLabel(label: string): string;
6
7
  export declare function getChainKeyFromLabel(label: string): string;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sluggifyString = exports.chainLabelsToKeyMap = exports.chainKeyToChainLabelMap = void 0;
7
7
  exports.updateData = updateData;
8
+ exports.updateChainLabels = updateChainLabels;
8
9
  exports.getSluggifiedChainLabel = getSluggifiedChainLabel;
9
10
  exports.getChainKeyFromLabel = getChainKeyFromLabel;
10
11
  exports.getChainLabelFromKey = getChainLabelFromKey;
@@ -39,6 +40,10 @@ async function updateData() {
39
40
  continue;
40
41
  const key = getChainKeyFromLabel(label);
41
42
  data_json_1.deadChains[key] = deadFrom;
43
+ if (!deadChainsSet.has(key)) {
44
+ deadChainsSet.add(key);
45
+ deadChainsArray.push(key);
46
+ }
42
47
  }
43
48
  // Save to data.json file
44
49
  const dataFilePath = path_1.default.join(__dirname, 'data.json');
@@ -52,6 +57,24 @@ async function updateData() {
52
57
  console.error('Error updating chain data:', error);
53
58
  }
54
59
  }
60
+ // runs updateData and sanity checks that the mappings only grew
61
+ async function updateChainLabels() {
62
+ const chainKeyLabelMapCountBefore = Object.keys(data_json_1.chainKeyToChainLabelMap).length;
63
+ const chainLabelsKeyMapCountBefore = Object.keys(data_json_1.chainLabelsToKeyMap).length;
64
+ await updateData();
65
+ const chainKeyLabelMapCountAfter = Object.keys(data_json_1.chainKeyToChainLabelMap).length;
66
+ const chainLabelsKeyMapCountAfter = Object.keys(data_json_1.chainLabelsToKeyMap).length;
67
+ if (chainKeyLabelMapCountAfter > chainKeyLabelMapCountBefore) {
68
+ console.log(`Updated chainKeyToChainLabelMap: ${chainKeyLabelMapCountBefore} -> ${chainKeyLabelMapCountAfter}`);
69
+ }
70
+ if (chainLabelsKeyMapCountAfter > chainLabelsKeyMapCountBefore) {
71
+ console.log(`Updated chainLabelsToKeyMap: ${chainLabelsKeyMapCountBefore} -> ${chainLabelsKeyMapCountAfter}`);
72
+ }
73
+ if (chainKeyLabelMapCountAfter < chainKeyLabelMapCountBefore)
74
+ throw new Error('chainKeyToChainLabelMap count decreased, please investigate');
75
+ if (chainLabelsKeyMapCountAfter < chainLabelsKeyMapCountBefore)
76
+ throw new Error('chainLabelsToKeyMap count decreased, please investigate');
77
+ }
55
78
  const sluggifyString = (name) => name.toLowerCase().split(" ").join("-").split("'").join("");
56
79
  exports.sluggifyString = sluggifyString;
57
80
  function sortJSONData(jsonData) {
@@ -174,10 +174,9 @@ function sumChainTvls(chainTvls) {
174
174
  function getUniqueAddresses(addresses, chain) {
175
175
  if (!addresses.length)
176
176
  return [];
177
- const isTronAddress = chain === 'tron' && addresses[0].includes('T');
178
- const toLowerCase = !isTronAddress;
177
+ const isTronChain = chain === 'tron';
179
178
  const set = {};
180
- addresses.forEach(i => set[toLowerCase ? i.toLowerCase() : i] = true);
179
+ addresses.forEach(i => set[isTronChain && i.includes('T') ? i : i.toLowerCase()] = true);
181
180
  return Object.keys(set);
182
181
  }
183
182
  function getProviderUrl(provider) {
@@ -1,11 +1 @@
1
- export declare const isCosmosChain: (chain: string) => boolean;
2
- export declare function getCosmosBlock(block?: number | string, chain?: string): Promise<{
3
- number: number;
4
- timestamp: number;
5
- }>;
6
- export declare function getCosmosProvider(chain: string): {
7
- getBlock: (block?: number | string) => Promise<{
8
- number: number;
9
- timestamp: number;
10
- }>;
11
- };
1
+ export { isCosmosChain, getCosmosBlock, getCosmosProvider } from "../chains/cosmos";
@@ -1,68 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCosmosChain = void 0;
4
- exports.getCosmosBlock = getCosmosBlock;
5
- exports.getCosmosProvider = getCosmosProvider;
6
- const env_1 = require("./env");
7
- const common_1 = require("./common");
8
- // where to find chain info
9
- // https://proxy.atomscan.com/chains.json
10
- // https://cosmos-chain.directory/chains/cosmoshub
11
- // https://cosmos-chain.directory/chains
12
- const endPoints = {
13
- crescent: "https://mainnet.crescent.network:1317",
14
- osmosis: "https://osmosis-api.polkachu.com",
15
- cosmos: "https://cosmoshub-lcd.stakely.io",
16
- kujira: "https://kuji-api.kleomedes.network",
17
- comdex: "https://rest.comdex.one",
18
- terra: "https://terra-classic-lcd.publicnode.com",
19
- terra2: "https://terra-lcd.publicnode.com",
20
- umee: "https://umee-api.polkachu.com",
21
- orai: "https://lcd.orai.io",
22
- juno: "https://juno.api.m.stavr.tech",
23
- // cronos: "https://rest.mainnet.crypto.org", // it is also evm like kava
24
- chihuahua: "https://rest.cosmos.directory/chihuahua",
25
- stargaze: "https://rest.stargaze-apis.com",
26
- quicksilver: "https://rest.cosmos.directory/quicksilver",
27
- persistence: "https://rest.cosmos.directory/persistence",
28
- secret: "https://lcd.secret.express",
29
- // chihuahua: "https://api.chihuahua.wtf",
30
- injective: "https://sentry.lcd.injective.network:443",
31
- migaloo: "https://migaloo-api.polkachu.com",
32
- fxcore: "https://fx-rest.functionx.io",
33
- xpla: "https://dimension-lcd.xpla.dev",
34
- neutron: "https://rest-kralum.neutron-1.neutron.org",
35
- quasar: "https://quasar-api.polkachu.com",
36
- gravitybridge: "https://gravitychain.io:1317",
37
- // sei: "https://sei-api.polkachu.com",
38
- // aura: "https://lcd.aura.network", // is evm now
39
- archway: "https://api.mainnet.archway.io",
40
- sifchain: "https://sifchain-api.polkachu.com",
41
- nolus: "https://pirin-cl.nolus.network:1317",
42
- bostrom: "https://lcd.bostrom.cybernode.ai"
43
- };
44
- const ibcChains = ['terra', 'terra2', 'crescent', 'osmosis', 'kujira', 'stargaze', 'juno', 'injective', 'cosmos', 'comdex', 'umee', 'orai', 'persistence', 'fxcore', 'neutron', 'quasar', 'chihuahua', 'archway', 'migaloo', 'secret', 'xpla', 'bostrom'];
45
- const isCosmosChain = (chain) => ibcChains.includes(chain) || !!endPoints[chain];
46
- exports.isCosmosChain = isCosmosChain;
47
- async function getCosmosBlock(block = 'latest', chain = 'cosmos') {
48
- var _a;
49
- const endPoint = (0, env_1.getEnvRPC)(chain) || endPoints[chain] || 'https://rest.cosmos.directory/' + chain;
50
- try {
51
- const data = await (0, common_1.postJson)(`${endPoint}/blocks/${block}`);
52
- const { block: { header: { height, time } } } = data;
53
- return {
54
- number: Number(height),
55
- timestamp: Math.floor(Date.parse(time) / 1000),
56
- };
57
- }
58
- catch (e) {
59
- const message = `Error fetchin cosmos block -
60
- chain: ${chain}, block: ${block}, endPoint: ${endPoint}, error: ${(_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : JSON.stringify(e)}`;
61
- throw new Error(message);
62
- }
63
- }
64
- function getCosmosProvider(chain) {
65
- return {
66
- getBlock: (block = 'latest') => getCosmosBlock(block, chain)
67
- };
68
- }
3
+ exports.getCosmosProvider = exports.getCosmosBlock = exports.isCosmosChain = void 0;
4
+ // Kept for backwards compatibility, the implementation lives in ../chains/cosmos
5
+ var cosmos_1 = require("../chains/cosmos");
6
+ Object.defineProperty(exports, "isCosmosChain", { enumerable: true, get: function () { return cosmos_1.isCosmosChain; } });
7
+ Object.defineProperty(exports, "getCosmosBlock", { enumerable: true, get: function () { return cosmos_1.getCosmosBlock; } });
8
+ Object.defineProperty(exports, "getCosmosProvider", { enumerable: true, get: function () { return cosmos_1.getCosmosProvider; } });
package/build/util/env.js CHANGED
@@ -21,6 +21,7 @@ exports.whitelistedEnvConstants = [
21
21
  'R2_ENDPOINT', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'TRON_PRO_API_KEY', 'COINS_API_KEY', 'INTERNAL_API_KEY',
22
22
  'ELASTICSEARCH_CONFIG', 'GRAPH_API_KEY', 'LLAMA_INDEXER_V2_ENDPOINT', 'LLAMA_INDEXER_V2_API_KEY', 'LLAMA_INDEXER_TIMEOUT_MS',
23
23
  'LLAMA_INDEXER_V4_ENDPOINT', 'LLAMA_INDEXER_V4_API_KEY', 'LLAMA_INDEXER_PREFER_V4', 'LLAMA_INDEXER_V4_ONLY_CHAINS',
24
+ 'LLAMA_INDEXER_SQL_ENDPOINT', 'LLAMA_INDEXER_SQL_USER', 'LLAMA_INDEXER_SQL_PASSWORD',
24
25
  ];
25
26
  const isDebugLevel3 = process.env.LLAMA_SDK_DEBUG_LEVEL_3 === 'true';
26
27
  const defaultEnvValues = {
@@ -0,0 +1,6 @@
1
+ type RowKind = "logs" | "transfers" | "transactions";
2
+ /** Preserve v2 REST field types and padding; never applied to SQL results. */
3
+ export declare function normalizeV4Row(row: any, kind: RowKind): any;
4
+ /** Capture an unquoted UInt256 id before JSON.parse can round it. */
5
+ export declare function parseTransferResponse(text: string): Promise<any>;
6
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeV4Row = normalizeV4Row;
7
+ exports.parseTransferResponse = parseTransferResponse;
8
+ const stream_1 = require("stream");
9
+ const promises_1 = require("stream/promises");
10
+ const stream_json_1 = require("stream-json");
11
+ const Assembler_1 = __importDefault(require("stream-json/Assembler"));
12
+ const numericFields = {
13
+ logs: ["chain", "block_number", "log_index"],
14
+ transfers: ["chain", "block_number", "log_index", "value", "id"],
15
+ transactions: ["chain", "block_number", "transaction_index", "value", "gas", "gas_price",
16
+ "gas_used", "effective_gas_price", "max_fee_per_gas", "max_priority_fee_per_gas",
17
+ "base_fee_per_gas", "nonce", "transaction_type", "cumulative_gas_used"],
18
+ };
19
+ const addressFields = {
20
+ logs: ["source", "address"],
21
+ transfers: ["from_address", "to_address", "token", "operator"],
22
+ transactions: ["from_address", "to_address", "contract_created"],
23
+ };
24
+ const hashFields = {
25
+ logs: ["transaction_hash", "topic0", "topic1", "topic2", "topic3"],
26
+ transfers: ["transaction_hash"],
27
+ transactions: ["hash", "block_hash"],
28
+ };
29
+ function fixedHex(value, bytes) {
30
+ // Empty/absent values are not the zero address or the zero topic.
31
+ if (typeof value !== "string" || !/^0x[0-9a-f]+$/i.test(value))
32
+ return value;
33
+ const hex = value.slice(2);
34
+ return hex.length <= bytes * 2 ? `0x${hex.toLowerCase().padStart(bytes * 2, "0")}` : value;
35
+ }
36
+ /** Preserve v2 REST field types and padding; never applied to SQL results. */
37
+ function normalizeV4Row(row, kind) {
38
+ for (const key of numericFields[kind]) {
39
+ // The exact transfer id is captured for the cursor before restoring the public Number.
40
+ if (typeof row[key] === "string" && /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(row[key]))
41
+ row[key] = Number(row[key]);
42
+ }
43
+ for (const key of addressFields[kind])
44
+ if (key in row)
45
+ row[key] = fixedHex(row[key], 20);
46
+ for (const key of hashFields[kind])
47
+ if (key in row)
48
+ row[key] = fixedHex(row[key], 32);
49
+ if (kind === "logs" && row.source === undefined && row.address !== undefined)
50
+ row.source = row.address;
51
+ return row;
52
+ }
53
+ /** Capture an unquoted UInt256 id before JSON.parse can round it. */
54
+ async function parseTransferResponse(text) {
55
+ const assembler = new Assembler_1.default();
56
+ // Assembler only needs packed values, not intermediate string/number chunks.
57
+ await (0, promises_1.pipeline)(stream_1.Readable.from([text]), (0, stream_json_1.parser)({ streamValues: false }), async (tokens) => {
58
+ for await (const token of tokens) {
59
+ assembler.consume(token.name === "numberValue" && assembler.key === "id"
60
+ ? { name: "stringValue", value: token.value } : token);
61
+ }
62
+ });
63
+ return assembler.current;
64
+ }
@@ -29,7 +29,7 @@ export type IndexerGetLogsOptions = {
29
29
  processor?: (logs: any[]) => Promise<void> | void;
30
30
  maxBlockRange?: number;
31
31
  allowParseFailure?: boolean;
32
- /** Feature flag: enable client-side streaming of /logs v2 */
32
+ /** Opt in to streaming /logs instead of paginated requests. */
33
33
  clientStreaming?: boolean;
34
34
  /** Decoder type: 'viem' (faster) or 'ethers' (fallback) */
35
35
  decoderType?: "viem" | "ethers";
@@ -65,6 +65,28 @@ export type IndexerGetTokenTransfersOptions = {
65
65
  };
66
66
  export declare function getLogs(options: IndexerGetLogsOptions): Promise<any[]>;
67
67
  export declare function getTokenTransfers({ chain, fromAddressFilter, fromBlock, toBlock, all, limit, offset, target, targets, flatten, fromTimestamp, toTimestamp, debugMode, transferType, token, tokens, }: IndexerGetTokenTransfersOptions): Promise<any[]>;
68
- export declare function getTransactions({ chain, addresses, transaction_hashes, from_block, to_block, all, limit, offset, debugMode, transactionType, }: GetTransactionOptions): Promise<any>;
68
+ export declare function getTransactions({ chain, addresses, transaction_hashes, from_block, to_block, all, limit, offset, debugMode, transactionType, }: GetTransactionOptions): Promise<{
69
+ hash: any;
70
+ blockNumber: number;
71
+ transactionIndex: number;
72
+ from: any;
73
+ to: any;
74
+ value: any;
75
+ gasPrice: any;
76
+ gas: any;
77
+ input: any;
78
+ nonce: number;
79
+ data: any;
80
+ type: any;
81
+ maxFeePerGas: any;
82
+ maxPriorityFeePerGas: any;
83
+ baseFeePerGas: any;
84
+ effectiveGasPrice: any;
85
+ gasUsed: any;
86
+ cumulativeGasUsed: any;
87
+ status: number;
88
+ contractCreated: any;
89
+ timestamp: any;
90
+ }[] | null>;
69
91
  export declare function isIndexerEnabled(chain?: string): boolean;
70
92
  export declare function isIndexer2Enabled(chain?: string): boolean;